public class Attribute extends Object implements Serializable, Cloneable
| Modifier and Type | Field and Description |
|---|---|
static int |
CDATA_TYPE
Attribute type: the attribute value is a string.
|
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 String |
name
The local name of the
Attribute |
protected Namespace |
namespace
The
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 Element |
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 String |
value
The value of the
Attribute |
| Modifier | Constructor and Description |
|---|---|
protected |
Attribute()
Default, no-args constructor for implementations to use if needed.
|
|
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 . |
|
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 . |
|
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
. |
|
Attribute(String name,
String value,
Namespace namespace)
This will create a new
Attribute with the
specified (local) name and value, and in the provided
. |
| Modifier and Type | Method and Description |
|---|---|
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(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
if a conversion can't be
performed. |
Document |
getDocument()
|
double |
getDoubleValue()
This gets the value of the attribute, in
double form, and if no conversion
can occur, throws a
|
float |
getFloatValue()
This gets the value of the attribute, in
float form, and if no conversion
can occur, throws a
|
int |
getIntValue()
This gets the value of the attribute, in
int form, and if no conversion
can occur, throws a
|
long |
getLongValue()
This gets the value of the attribute, in
long form, and if no conversion
can occur, throws a
|
String |
getName()
This will retrieve the local name of the
Attribute. |
Namespace |
getNamespace()
This will return this
Attribute's
. |
String |
getNamespacePrefix()
This will retrieve the namespace prefix of the
Attribute. |
String |
getNamespaceURI()
This returns the URI mapped to this
Attribute's
prefix. |
Element |
getParent()
This will return the parent of this
Attribute. |
String |
getQualifiedName()
This will retrieve the qualified name of the
Attribute. |
String |
getValue()
This will return the actual textual value of this
Attribute. |
int |
hashCode()
This returns the hash code for this
Attribute. |
Attribute |
setAttributeType(int type)
This will set the type of the
Attribute. |
Attribute |
setName(String name)
This sets the local name of the
Attribute. |
Attribute |
setNamespace(Namespace namespace)
This sets this
Attribute's . |
protected Attribute |
setParent(Element parent)
This will set the parent of this
Attribute. |
Attribute |
setValue(String value)
This will set the value of the
Attribute. |
String |
toString()
This returns a
String representation of the
Attribute, suitable for debugging. |
public static final int UNDECLARED_TYPE
getAttributeType(),
Constant Field Valuespublic static final int CDATA_TYPE
getAttributeType(),
Constant Field Valuespublic static final int ID_TYPE
getAttributeType(),
Constant Field Valuespublic static final int IDREF_TYPE
getAttributeType(),
Constant Field Valuespublic static final int IDREFS_TYPE
getAttributeType(),
Constant Field Valuespublic static final int ENTITY_TYPE
getAttributeType(),
Constant Field Valuespublic static final int ENTITIES_TYPE
Attribute type: the attribute value is a list of entity names.
getAttributeType(),
Constant Field Valuespublic static final int NMTOKEN_TYPE
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_TYPE.
getAttributeType(),
Constant Field Valuespublic static final int NMTOKENS_TYPE
getAttributeType(),
Constant Field Valuespublic static final int NOTATION_TYPE
getAttributeType(),
Constant Field Valuespublic static final int ENUMERATED_TYPE
getAttributeType(),
Constant Field Valuesprotected String name
Attributeprotected String value
Attributeprotected int type
Attributeprotected Element parent
protected Attribute()
public Attribute(String name, String value, Namespace namespace)
Attribute with the
specified (local) name and value, and in the provided
Namespace.name - String name of Attribute.value - String value for new attribute.namespace - Namespace namespace for new attribute.IllegalNameException - if the given name is illegal as an
attribute name or if if the new namespace is the default
namespace. Attributes cannot be in a default namespace.IllegalDataException - if the given attribute value is
illegal character data (as determined by
Verifier.checkCharacterData(java.lang.String)).public Attribute(String name, String value, int type, Namespace namespace)
Attribute with the
specified (local) name, value, and type, and in the provided
Namespace.name - String name of Attribute.value - String value for new attribute.type - int type for new attribute.namespace - Namespace namespace for new attribute.IllegalNameException - if the given name is illegal as an
attribute name or if if the new namespace is the default
namespace. Attributes cannot be in a default namespace.IllegalDataException - if the given attribute value is
illegal character data (as determined by
Verifier.checkCharacterData(java.lang.String)) or
if the given attribute type is not one of the
supported types.public Attribute(String name, String value)
Attribute with the
specified (local) name and value, and does not place
the attribute in a Namespace.
Note: This actually explicitly puts the
Attribute in the "empty" Namespace
().Namespace.NO_NAMESPACE
name - String name of Attribute.value - String value for new attribute.IllegalNameException - if the given name is illegal as an
attribute name.IllegalDataException - if the given attribute value is
illegal character data (as determined by
Verifier.checkCharacterData(java.lang.String)).public Attribute(String name, String value, int type)
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
name - String name of Attribute.value - String value for new attribute.type - int type for new attribute.IllegalNameException - if the given name is illegal as an
attribute name.IllegalDataException - if the given attribute value is
illegal character data (as determined by
Verifier.checkCharacterData(java.lang.String)) or
if the given attribute type is not one of the
supported types.public Element getParent()
Attribute.
If there is no parent, then this returns null.Attributepublic Document getDocument()
Document for
this Attribute, or null if not a currently a member of a
Document.Document owning this Attribute, or null.protected Attribute setParent(Element parent)
Attribute.parent - Element to be new parent.Attribute modified.public Attribute detach()
Attribute from its parent, or does
nothing if the Attribute has no parent.Attribute - this Attribute modified.public String getName()
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()
String - name of this attribute,
without any namespace prefix.public Attribute setName(String name)
Attribute.name - the new local name to setAttribute - the attribute modified.IllegalNameException - if the given name is illegal as an
attribute name.public String getQualifiedName()
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()
To obtain the namespace prefix for this attribute,
the
method should be used.getNamespacePrefix()
String - full name for this element.public String getNamespacePrefix()
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 this
attribute.public String getNamespaceURI()
Attribute's
prefix. If no mapping is found, an empty String is
returned.String - namespace URI for this Attribute.public Namespace getNamespace()
Attribute's
Namespace.Namespace - Namespace object for this Attributepublic Attribute setNamespace(Namespace namespace)
Attribute's Namespace.
If the provided namespace is null, the attribute will have no namespace.
The namespace must have a prefix.namespace - the new namespaceElement - the element modified.IllegalNameException - if the new namespace is the default
namespace. Attributes cannot be in a default namespace.public String getValue()
Attribute. This will include all text
within the quotation marks.String - value for this attribute.public Attribute setValue(String value)
Attribute.value - String value for the attribute.Attribute - this Attribute modified.IllegalDataException - if the given attribute value is
illegal character data (as determined by
Verifier.checkCharacterData(java.lang.String)).public int getAttributeType()
Attribute.int - type for this attribute.public Attribute setAttributeType(int type)
Attribute.type - int type for the attribute.Attribute - this Attribute modified.IllegalDataException - if the given attribute type is
not one of the supported types.public String toString()
String representation of the
Attribute, suitable for debugging.public final boolean equals(Object ob)
Attribute to the supplied
Object.public final int hashCode()
Attribute.public Object clone()
Attribute.public int getIntValue()
throws DataConversionException
int form, and if no conversion
can occur, throws a
DataConversionExceptionint value of attribute.DataConversionException - when conversion fails.public long getLongValue()
throws DataConversionException
long form, and if no conversion
can occur, throws a
DataConversionExceptionlong value of attribute.DataConversionException - when conversion fails.public float getFloatValue()
throws DataConversionException
float form, and if no conversion
can occur, throws a
DataConversionExceptionfloat value of attribute.DataConversionException - when conversion fails.public double getDoubleValue()
throws DataConversionException
double form, and if no conversion
can occur, throws a
DataConversionExceptiondouble value of attribute.DataConversionException - when conversion fails.public boolean getBooleanValue()
throws DataConversionException
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.DataConversionException - when conversion fails.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.