| java.lang.Object org.jdom.Attribute
Attribute | public class Attribute implements Serializable,Cloneable(Code) | | An XML attribute. Methods allow the user to obtain the value of the attribute
as well as namespace and type information.
version: $Revision: 1.1 $, $Date: 2005/04/27 09:32:37 $ author: Brett McLaughlin author: Jason Hunter author: Elliotte Rusty Harold author: Wesley Biggs |
Field Summary | |
final public static int | CDATA_TYPE Attribute type: the attribute value is a string. | final public static int | ENTITIES_TYPE
Attribute type: the attribute value is a list of entity names. | final public static int | ENTITY_TYPE Attribute type: the attribute value is the name of an entity. | final public static int | ENUMERATED_TYPE Attribute type: the attribute value is a name token from an
enumeration. | final public static int | IDREFS_TYPE Attribute type: the attribute value is a list of references to
unique identifiers. | final public static int | IDREF_TYPE Attribute type: the attribute value is a reference to a
unique identifier. | final public static int | ID_TYPE Attribute type: the attribute value is a unique identifier. | final public static int | NMTOKENS_TYPE Attribute type: the attribute value is a list of name tokens. | final public static 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. | final public static int | NOTATION_TYPE Attribute type: the attribute value is the name of a notation. | final public static int | UNDECLARED_TYPE Attribute type: the attribute has not been declared or type
is unknown. | protected String | name | protected transient Namespace | namespace | protected Object | parent | protected int | type | protected String | value |
Constructor Summary | |
protected | Attribute() Default, no-args constructor for implementations to use if needed. | public | Attribute(String name, String value, Namespace namespace) This will create a new Attribute with the
specified (local) name and value, and in the provided
Namespace .
Parameters: name - String name of Attribute . Parameters: value - String value for new attribute. Parameters: namespace - Namespace namespace for new attribute. throws: IllegalNameException - if the given name is illegal as anattribute name or if if the new namespace is the defaultnamespace. | public | Attribute(String name, 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 .
Parameters: name - String name of Attribute . Parameters: value - String value for new attribute. Parameters: type - int type for new attribute. Parameters: namespace - Namespace namespace for new attribute. throws: IllegalNameException - if the given name is illegal as anattribute name or if if the new namespace is the defaultnamespace. | public | Attribute(String name, String value) This will create a new Attribute with the
specified (local) name and value, and does not place
the attribute in a
Namespace . | public | Attribute(String name, 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 . |
Method Summary | |
public Object | clone() This will return a clone of this Attribute . | public Attribute | detach() This detaches the Attribute from its parent, or does
nothing if the Attribute has no parent. | final public boolean | equals(Object ob) This tests for equality of this Attribute to the supplied
Object .
Parameters: ob - Object to compare to. | public int | getAttributeType() This will return the actual declared type of this
Attribute . | public boolean | getBooleanValue() This gets the effective boolean value of the attribute, or throws a
DataConversionException if a conversion can't be
performed. | public Document | getDocument() This retrieves the owning
Document for
this Attribute, or null if not a currently a member of a
Document . | public double | getDoubleValue() | public float | getFloatValue() | public int | getIntValue() | public long | getLongValue() | public String | getName() This will retrieve the local name of the
Attribute . | public Namespace | getNamespace() This will return this Attribute 's
Namespace . | public String | getNamespacePrefix() This will retrieve the namespace prefix of the
Attribute . | public String | getNamespaceURI() This returns the URI mapped to this Attribute 's
prefix. | public Element | getParent() This will return the parent of this Attribute . | public 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). | public String | getValue() This will return the actual textual value of this
Attribute . | final public int | hashCode() This returns the hash code for this Attribute . | public Attribute | setAttributeType(int type) This will set the type of the Attribute .
Parameters: type - int type for the attribute. | public Attribute | setName(String name) This sets the local name of the Attribute . | public Attribute | setNamespace(Namespace namespace) This sets this Attribute 's
Namespace .
If the provided namespace is null, the attribute will have no namespace.
The namespace must have a prefix.
Parameters: namespace - the new namespace Element - the element modified. throws: IllegalNameException - if the new namespace is the defaultnamespace. | protected Attribute | setParent(Element parent) This will set the parent of this Attribute .
Parameters: parent - Element to be new parent. | public Attribute | setValue(String value) This will set the value of the Attribute .
Parameters: value - String value for the attribute. | public String | toString() This returns a String representation of the
Attribute , suitable for debugging. |
ENUMERATED_TYPE | final public static int ENUMERATED_TYPE(Code) | | Attribute type: the attribute value is a name token from an
enumeration.
See Also: Attribute.getAttributeType |
IDREFS_TYPE | final public static int IDREFS_TYPE(Code) | | Attribute type: the attribute value is a list of references to
unique identifiers.
See Also: Attribute.getAttributeType |
IDREF_TYPE | final public static int IDREF_TYPE(Code) | | Attribute type: the attribute value is a reference to a
unique identifier.
See Also: Attribute.getAttributeType |
NMTOKEN_TYPE | final public static int NMTOKEN_TYPE(Code) | | 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
Attribute.ENUMERATED_TYPE .
See Also: Attribute.getAttributeType |
UNDECLARED_TYPE | final public static int UNDECLARED_TYPE(Code) | | Attribute type: the attribute has not been declared or type
is unknown.
See Also: Attribute.getAttributeType |
name | protected String name(Code) | | The local name of the Attribute
|
parent | protected Object parent(Code) | | Parent element, or null if none
|
type | protected int type(Code) | | The type of the Attribute
|
value | protected String value(Code) | | The value of the Attribute
|
Attribute | protected Attribute()(Code) | | Default, no-args constructor for implementations to use if needed.
|
Attribute | public Attribute(String name, String value, Namespace namespace)(Code) | | This will create a new Attribute with the
specified (local) name and value, and in the provided
Namespace .
Parameters: name - String name of Attribute . Parameters: value - String value for new attribute. Parameters: namespace - Namespace namespace for new attribute. throws: IllegalNameException - if the given name is illegal as anattribute name or if if the new namespace is the defaultnamespace. Attributes cannot be in a default namespace. throws: IllegalDataException - if the given attribute value isillegal character data (as determined byorg.jdom.Verifier.checkCharacterData). |
Attribute | public Attribute(String name, String value, int type, Namespace namespace)(Code) | | This will create a new Attribute with the
specified (local) name, value, and type, and in the provided
Namespace .
Parameters: name - String name of Attribute . Parameters: value - String value for new attribute. Parameters: type - int type for new attribute. Parameters: namespace - Namespace namespace for new attribute. throws: IllegalNameException - if the given name is illegal as anattribute name or if if the new namespace is the defaultnamespace. Attributes cannot be in a default namespace. throws: IllegalDataException - if the given attribute value isillegal character data (as determined byorg.jdom.Verifier.checkCharacterData) orif the given attribute type is not one of thesupported types. |
Attribute | public Attribute(String name, String value, int type)(Code) | | This will create a new Attribute with the
specified (local) name, value and type, and does not place
the attribute in a
Namespace .
Note: This actually explicitly puts the
Attribute in the "empty" Namespace
(
Namespace.NO_NAMESPACE ).
Parameters: name - String name of Attribute . Parameters: value - String value for new attribute. Parameters: type - int type for new attribute. throws: IllegalNameException - if the given name is illegal as anattribute name. throws: IllegalDataException - if the given attribute value isillegal character data (as determined byorg.jdom.Verifier.checkCharacterData) orif the given attribute type is not one of thesupported types. |
clone | public Object clone()(Code) | | This will return a clone of this Attribute .
Object - clone of this Attribute . |
detach | public Attribute detach()(Code) | | This detaches the Attribute from its parent, or does
nothing if the Attribute has no parent.
Attribute - this Attribute modified. |
equals | final public boolean equals(Object ob)(Code) | | This tests for equality of this Attribute to the supplied
Object .
Parameters: ob - Object to compare to. boolean - whether the Attribute isequal to the supplied Object . |
getAttributeType | public int getAttributeType()(Code) | | This will return the actual declared type of this
Attribute .
int - type for this attribute. |
getBooleanValue | public boolean getBooleanValue() throws DataConversionException(Code) | | This gets the effective boolean value of the attribute, or throws a
DataConversionException if 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.
boolean value of attribute. throws: DataConversionException - when conversion fails. |
getDocument | public Document getDocument()(Code) | | This retrieves the owning
Document for
this Attribute, or null if not a currently a member of a
Document .
Document owning this Attribute, or null. |
getName | public String getName()(Code) | | 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
Attribute.getNamespacePrefix()
method should be used.
String - name of this attribute,without any namespace prefix. |
getNamespace | public Namespace getNamespace()(Code) | | This will return this Attribute 's
Namespace .
Namespace - Namespace object for this Attribute |
getNamespacePrefix | public String getNamespacePrefix()(Code) | | 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 empty String is returned.
String - namespace prefix of thisattribute. |
getNamespaceURI | public String getNamespaceURI()(Code) | | This returns the URI mapped to this Attribute 's
prefix. If no mapping is found, an empty String is
returned.
String - namespace URI for this Attribute . |
getParent | public Element getParent()(Code) | | This will return the parent of this Attribute .
If there is no parent, then this returns null .
parent of this Attribute |
getQualifiedName | public String getQualifiedName()(Code) | | 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
Attribute.getName() method should be used.
To obtain the namespace prefix for this attribute,
the
Attribute.getNamespacePrefix()
method should be used.
String - full name for this element. |
getValue | public String getValue()(Code) | | This will return the actual textual value of this
Attribute . This will include all text
within the quotation marks.
String - value for this attribute. |
hashCode | final public int hashCode()(Code) | | This returns the hash code for this Attribute .
int - hash code. |
setAttributeType | public Attribute setAttributeType(int type)(Code) | | This will set the type of the Attribute .
Parameters: type - int type for the attribute. Attribute - this Attribute modified. throws: IllegalDataException - if the given attribute type isnot one of the supported types. |
setName | public Attribute setName(String name)(Code) | | This sets the local name of the Attribute .
Parameters: name - the new local name to set Attribute - the attribute modified. throws: IllegalNameException - if the given name is illegal as anattribute name. |
setNamespace | public Attribute setNamespace(Namespace namespace)(Code) | | This sets this Attribute 's
Namespace .
If the provided namespace is null, the attribute will have no namespace.
The namespace must have a prefix.
Parameters: namespace - the new namespace Element - the element modified. throws: IllegalNameException - if the new namespace is the defaultnamespace. Attributes cannot be in a default namespace. |
setParent | protected Attribute setParent(Element parent)(Code) | | This will set the parent of this Attribute .
Parameters: parent - Element to be new parent. this Attribute modified. |
toString | public String toString()(Code) | | This returns a String representation of the
Attribute , suitable for debugging.
String - information about theAttribute |
|
|