|
|||||||||
| Home >> All >> org >> [ jdom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jdom
Class Attribute

java.lang.Objectorg.jdom.Attribute
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class Attribute
- extends java.lang.Object
- implements java.io.Serializable, java.lang.Cloneable
- extends java.lang.Object
An XML attribute. Methods allow the user to obtain the value of the attribute as well as namespace and type information.
- Version:
- $Revision: 1.52 $, $Date: 2004/03/01 23:58:28 $
| Field Summary | |
static int |
CDATA_TYPE
Attribute type: the attribute value is a string. |
private static java.lang.String |
CVS_ID
|
static int |
ENTITIES_TYPE
Attribute type: the attribute value is a list of entity names. |
static int |
ENTITY_TYPE
Attribute type: the attribute value is the name of an entity. |
static int |
ENUMERATED_TYPE
Attribute type: the attribute value is a name token from an enumeration. |
static int |
ID_TYPE
Attribute type: the attribute value is a unique identifier. |
static int |
IDREF_TYPE
Attribute type: the attribute value is a reference to a unique identifier. |
static int |
IDREFS_TYPE
Attribute type: the attribute value is a list of references to unique identifiers. |
protected java.lang.String |
name
The local name of the Attribute |
protected Namespace |
namespace
The Namespace of the Attribute |
static int |
NMTOKEN_TYPE
Attribute type: the attribute value is a name token. |
static int |
NMTOKENS_TYPE
Attribute type: the attribute value is a list of name tokens. |
static int |
NOTATION_TYPE
Attribute type: the attribute value is the name of a notation. |
protected java.lang.Object |
parent
Parent element, or null if none |
protected int |
type
The type of the Attribute |
static int |
UNDECLARED_TYPE
Attribute type: the attribute has not been declared or type is unknown. |
protected java.lang.String |
value
The value of the Attribute |
| Constructor Summary | |
protected |
Attribute()
Default, no-args constructor for implementations to use if needed. |
|
Attribute(java.lang.String name,
java.lang.String value)
This will create a new Attribute with the
specified (local) name and value, and does not place
the attribute in a Namespace. |
|
Attribute(java.lang.String name,
java.lang.String value,
int type)
This will create a new Attribute with the
specified (local) name, value and type, and does not place
the attribute in a Namespace. |
|
Attribute(java.lang.String name,
java.lang.String value,
int type,
Namespace namespace)
This will create a new Attribute with the
specified (local) name, value, and type, and in the provided
Namespace. |
|
Attribute(java.lang.String name,
java.lang.String value,
Namespace namespace)
This will create a new Attribute with the
specified (local) name and value, and in the provided
Namespace. |
| Method Summary | |
java.lang.Object |
clone()
This will return a clone of this Attribute. |
Attribute |
detach()
This detaches the Attribute from its parent, or does
nothing if the Attribute has no parent. |
boolean |
equals(java.lang.Object ob)
This tests for equality of this Attribute to the supplied
Object. |
int |
getAttributeType()
This will return the actual declared type of this Attribute. |
boolean |
getBooleanValue()
This gets the effective boolean value of the attribute, or throws a DataConversionException if a conversion can't be
performed. |
Document |
getDocument()
This retrieves the owning Document for
this Attribute, or null if not a currently a member of a
Document. |
double |
getDoubleValue()
This gets the value of the attribute, in double form, and if no conversion
can occur, throws a
DataConversionException |
float |
getFloatValue()
This gets the value of the attribute, in float form, and if no conversion
can occur, throws a
DataConversionException |
int |
getIntValue()
This gets the value of the attribute, in int form, and if no conversion
can occur, throws a
DataConversionException |
long |
getLongValue()
This gets the value of the attribute, in long form, and if no conversion
can occur, throws a
DataConversionException |
java.lang.String |
getName()
This will retrieve the local name of the Attribute. |
Namespace |
getNamespace()
This will return this Attribute's
Namespace. |
java.lang.String |
getNamespacePrefix()
This will retrieve the namespace prefix of the Attribute. |
java.lang.String |
getNamespaceURI()
This returns the URI mapped to this Attribute's
prefix. |
Element |
getParent()
This will return the parent of this Attribute. |
java.lang.String |
getQualifiedName()
This will retrieve the qualified name of the Attribute. |
java.lang.String |
getValue()
This will return the actual textual value of this Attribute. |
int |
hashCode()
This returns the hash code for this Attribute. |
private void |
readObject(java.io.ObjectInputStream in)
|
Attribute |
setAttributeType(int type)
This will set the type of the Attribute. |
Attribute |
setName(java.lang.String name)
This sets the local name of the Attribute. |
Attribute |
setNamespace(Namespace namespace)
This sets this Attribute's Namespace. |
protected Attribute |
setParent(Element parent)
This will set the parent of this Attribute. |
Attribute |
setValue(java.lang.String value)
This will set the value of the Attribute. |
java.lang.String |
toString()
This returns a String representation of the
Attribute, suitable for debugging. |
private void |
writeObject(java.io.ObjectOutputStream out)
|
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
CVS_ID
private static final java.lang.String CVS_ID
- See Also:
- Constant Field Values
UNDECLARED_TYPE
public static final int UNDECLARED_TYPE
- Attribute type: the attribute has not been declared or type
is unknown.
- See Also:
getAttributeType()55 , Constant Field Values
CDATA_TYPE
public static final int CDATA_TYPE
- Attribute type: the attribute value is a string.
- See Also:
getAttributeType()55 , Constant Field Values
ID_TYPE
public static final int ID_TYPE
- Attribute type: the attribute value is a unique identifier.
- See Also:
getAttributeType()55 , Constant Field Values
IDREF_TYPE
public static final int IDREF_TYPE
- Attribute type: the attribute value is a reference to a
unique identifier.
- See Also:
getAttributeType()55 , Constant Field Values
IDREFS_TYPE
public static final int IDREFS_TYPE
- Attribute type: the attribute value is a list of references to
unique identifiers.
- See Also:
getAttributeType()55 , Constant Field Values
ENTITY_TYPE
public static final int ENTITY_TYPE
- Attribute type: the attribute value is the name of an entity.
- See Also:
getAttributeType()55 , Constant Field Values
ENTITIES_TYPE
public static final int ENTITIES_TYPE
Attribute type: the attribute value is a list of entity names.
- See Also:
getAttributeType()55 , Constant Field Values
NMTOKEN_TYPE
public static final int NMTOKEN_TYPE
- Attribute type: the attribute value is a name token.
According to SAX 2.0 specification, attributes of enumerated types should be reported as "NMTOKEN" by SAX parsers. But the major parsers (Xerces and Crimson) provide specific values that permit to recognize them as
ENUMERATED_TYPE55 .- See Also:
getAttributeType()55 , Constant Field Values
NMTOKENS_TYPE
public static final int NMTOKENS_TYPE
- Attribute type: the attribute value is a list of name tokens.
- See Also:
getAttributeType()55 , Constant Field Values
NOTATION_TYPE
public static final int NOTATION_TYPE
- Attribute type: the attribute value is the name of a notation.
- See Also:
getAttributeType()55 , Constant Field Values
ENUMERATED_TYPE
public static final int ENUMERATED_TYPE
- Attribute type: the attribute value is a name token from an
enumeration.
- See Also:
getAttributeType()55 , Constant Field Values
name
protected java.lang.String name
- The local name of the
Attribute
namespace
protected transient Namespace namespace
- The
Namespaceof theAttribute
value
protected java.lang.String value
- The value of the
Attribute
type
protected int type
- The type of the
Attribute
parent
protected java.lang.Object parent
- Parent element, or null if none
| Constructor Detail |
Attribute
protected Attribute()
- Default, no-args constructor for implementations to use if needed.
Attribute
public Attribute(java.lang.String name, java.lang.String value, Namespace namespace)
- This will create a new
Attributewith the specified (local) name and value, and in the providedNamespace.
Attribute
public Attribute(java.lang.String name, java.lang.String value, int type, Namespace namespace)
- This will create a new
Attributewith the specified (local) name, value, and type, and in the providedNamespace.
Attribute
public Attribute(java.lang.String name, java.lang.String value)
- This will create a new
Attributewith the specified (local) name and value, and does not place the attribute in aNamespace.Note: This actually explicitly puts the
Attributein the "empty"Namespace().Namespace.NO_NAMESPACE55
Attribute
public Attribute(java.lang.String name, java.lang.String value, int type)
- This will create a new
Attributewith the specified (local) name, value and type, and does not place the attribute in aNamespace.Note: This actually explicitly puts the
Attributein the "empty"Namespace().Namespace.NO_NAMESPACE55
| Method Detail |
getParent
public Element getParent()
- This will return the parent of this
Attribute. If there is no parent, then this returnsnull.
getDocument
public Document getDocument()
- This retrieves the owning
Documentfor this Attribute, or null if not a currently a member of aDocument.
setParent
protected Attribute setParent(Element parent)
- This will set the parent of this
Attribute.
detach
public Attribute detach()
- This detaches the
Attributefrom its parent, or does nothing if theAttributehas no parent.
getName
public java.lang.String getName()
- This will retrieve the local name of the
Attribute. For any XML attribute which appears as[namespacePrefix]:[attributeName], the local name of the attribute would be[attributeName]. When the attribute has no namespace, the local name is simply the attribute name.To obtain the namespace prefix for this attribute, the
method should be used.getNamespacePrefix()55
setName
public Attribute setName(java.lang.String name)
- This sets the local name of the
Attribute.
getQualifiedName
public java.lang.String getQualifiedName()
- This will retrieve the qualified name of the
Attribute. For any XML attribute whose name is[namespacePrefix]:[elementName], the qualified name of the attribute would be everything (both namespace prefix and element name). When the attribute has no namespace, the qualified name is simply the attribute's local name.To obtain the local name of the attribute, the
method should be used.getName()55To obtain the namespace prefix for this attribute, the
method should be used.getNamespacePrefix()55
getNamespacePrefix
public java.lang.String getNamespacePrefix()
- This will retrieve the namespace prefix of the
Attribute. For any XML attribute which appears as[namespacePrefix]:[attributeName], the namespace prefix of the attribute would be[namespacePrefix]. When the attribute has no namespace, an emptyStringis returned.
getNamespaceURI
public java.lang.String getNamespaceURI()
- This returns the URI mapped to this
Attribute's prefix. If no mapping is found, an emptyStringis returned.
getNamespace
public Namespace getNamespace()
- This will return this
Attribute'sNamespace.
setNamespace
public Attribute setNamespace(Namespace namespace)
- This sets this
Attribute'sNamespace. If the provided namespace is null, the attribute will have no namespace. The namespace must have a prefix.
getValue
public java.lang.String getValue()
- This will return the actual textual value of this
Attribute. This will include all text within the quotation marks.
setValue
public Attribute setValue(java.lang.String value)
- This will set the value of the
Attribute.
getAttributeType
public int getAttributeType()
- This will return the actual declared type of this
Attribute.
setAttributeType
public Attribute setAttributeType(int type)
- This will set the type of the
Attribute.
toString
public java.lang.String toString()
- This returns a
Stringrepresentation of theAttribute, suitable for debugging.
equals
public final boolean equals(java.lang.Object ob)
- This tests for equality of this
Attributeto the suppliedObject.
hashCode
public final int hashCode()
- This returns the hash code for this
Attribute.
clone
public java.lang.Object clone()
- This will return a clone of this
Attribute.
getIntValue
public int getIntValue()
throws DataConversionException
- This gets the value of the attribute, in
intform, and if no conversion can occur, throws aDataConversionException
getLongValue
public long getLongValue()
throws DataConversionException
- This gets the value of the attribute, in
longform, and if no conversion can occur, throws aDataConversionException
getFloatValue
public float getFloatValue()
throws DataConversionException
- This gets the value of the attribute, in
floatform, and if no conversion can occur, throws aDataConversionException
getDoubleValue
public double getDoubleValue()
throws DataConversionException
- This gets the value of the attribute, in
doubleform, and if no conversion can occur, throws aDataConversionException
getBooleanValue
public boolean getBooleanValue()
throws DataConversionException
- This gets the effective boolean value of the attribute, or throws a
DataConversionExceptionif a conversion can't be performed. True values are: "true", "on", "1", and "yes". False values are: "false", "off", "0", and "no". Values are trimmed before comparison. Values other than those listed here throw the exception.
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
|
|||||||||
| Home >> All >> org >> [ jdom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.jdom.Attribute