Class Attribute
- All Implemented Interfaces:
Serializable
,Cloneable
- Version:
- $Revision: 1.56 $, $Date: 2007/11/10 05:28:58 $
- Author:
- Brett McLaughlin, Jason Hunter, Elliotte Rusty Harold, Wesley Biggs, Victor Toni
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Attribute type: the attribute value is a string.static final int
Attribute type: the attribute value is a list of entity names.static final int
Attribute type: the attribute value is the name of an entity.static final int
Attribute type: the attribute value is a name token from an enumeration.static final int
Attribute type: the attribute value is a unique identifier.static final int
Attribute type: the attribute value is a reference to a unique identifier.static final int
Attribute type: the attribute value is a list of references to unique identifiers.protected String
The local name of theAttribute
protected Namespace
The
of theNamespace
Attribute
static final int
Attribute type: the attribute value is a name token.static final int
Attribute type: the attribute value is a list of name tokens.static final int
Attribute type: the attribute value is the name of a notation.protected Element
Parent element, or null if noneprotected int
The type of theAttribute
static final int
Attribute type: the attribute has not been declared or type is unknown.protected String
The value of theAttribute
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default, no-args constructor for implementations to use if needed.This will create a newAttribute
with the specified (local) name and value, and does not place the attribute in a
.Namespace
This will create a newAttribute
with the specified (local) name, value and type, and does not place the attribute in a
.Namespace
This will create a newAttribute
with the specified (local) name, value, and type, and in the provided
.Namespace
This will create a newAttribute
with the specified (local) name and value, and in the provided
.Namespace
-
Method Summary
Modifier and TypeMethodDescriptionclone()
This will return a clone of thisAttribute
.detach()
This detaches theAttribute
from its parent, or does nothing if theAttribute
has no parent.final boolean
This tests for equality of thisAttribute
to the suppliedObject
.int
This will return the actual declared type of thisAttribute
.boolean
This gets the effective boolean value of the attribute, or throws a
if a conversion can't be performed.DataConversionException
double
This gets the value of the attribute, indouble
form, and if no conversion can occur, throws aDataConversionException
float
This gets the value of the attribute, infloat
form, and if no conversion can occur, throws aDataConversionException
int
This gets the value of the attribute, inint
form, and if no conversion can occur, throws aDataConversionException
long
This gets the value of the attribute, inlong
form, and if no conversion can occur, throws aDataConversionException
getName()
This will retrieve the local name of theAttribute
.This will return thisAttribute
's
.Namespace
This will retrieve the namespace prefix of theAttribute
.This returns the URI mapped to thisAttribute
's prefix.This will return the parent of thisAttribute
.This will retrieve the qualified name of theAttribute
.getValue()
This will return the actual textual value of thisAttribute
.final int
hashCode()
This returns the hash code for thisAttribute
.setAttributeType
(int type) This will set the type of theAttribute
.This sets the local name of theAttribute
.setNamespace
(Namespace namespace) This sets thisAttribute
's
.Namespace
protected Attribute
This will set the parent of thisAttribute
.This will set the value of theAttribute
.toString()
This returns aString
representation of theAttribute
, suitable for debugging.
-
Field Details
-
UNDECLARED_TYPE
public static final int UNDECLARED_TYPEAttribute type: the attribute has not been declared or type is unknown.- See Also:
-
CDATA_TYPE
public static final int CDATA_TYPEAttribute type: the attribute value is a string.- See Also:
-
ID_TYPE
public static final int ID_TYPEAttribute type: the attribute value is a unique identifier.- See Also:
-
IDREF_TYPE
public static final int IDREF_TYPEAttribute type: the attribute value is a reference to a unique identifier.- See Also:
-
IDREFS_TYPE
public static final int IDREFS_TYPEAttribute type: the attribute value is a list of references to unique identifiers.- See Also:
-
ENTITY_TYPE
public static final int ENTITY_TYPEAttribute type: the attribute value is the name of an entity.- See Also:
-
ENTITIES_TYPE
public static final int ENTITIES_TYPEAttribute type: the attribute value is a list of entity names.
- See Also:
-
NMTOKEN_TYPE
public static final int NMTOKEN_TYPEAttribute 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_TYPE
.- See Also:
-
NMTOKENS_TYPE
public static final int NMTOKENS_TYPEAttribute type: the attribute value is a list of name tokens.- See Also:
-
NOTATION_TYPE
public static final int NOTATION_TYPEAttribute type: the attribute value is the name of a notation.- See Also:
-
ENUMERATED_TYPE
public static final int ENUMERATED_TYPEAttribute type: the attribute value is a name token from an enumeration.- See Also:
-
name
The local name of theAttribute
-
namespace
The
of theNamespace
Attribute
-
value
The value of theAttribute
-
type
protected int typeThe type of theAttribute
-
parent
Parent element, or null if none
-
-
Constructor Details
-
Attribute
protected Attribute()Default, no-args constructor for implementations to use if needed. -
Attribute
This will create a newAttribute
with the specified (local) name and value, and in the provided
.Namespace
- Parameters:
name
-String
name ofAttribute
.value
-String
value for new attribute.namespace
-Namespace
namespace for new attribute.- Throws:
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 byVerifier.checkCharacterData(java.lang.String)
).
-
Attribute
This will create a newAttribute
with the specified (local) name, value, and type, and in the provided
.Namespace
- Parameters:
name
-String
name ofAttribute
.value
-String
value for new attribute.type
-int
type for new attribute.namespace
-Namespace
namespace for new attribute.- Throws:
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 byVerifier.checkCharacterData(java.lang.String)
) or if the given attribute type is not one of the supported types.
-
Attribute
This will create a newAttribute
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
- Parameters:
name
-String
name ofAttribute
.value
-String
value for new attribute.- Throws:
IllegalNameException
- if the given name is illegal as an attribute name.IllegalDataException
- if the given attribute value is illegal character data (as determined byVerifier.checkCharacterData(java.lang.String)
).
-
Attribute
This will create a newAttribute
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 ofAttribute
.value
-String
value for new attribute.type
-int
type for new attribute.- Throws:
IllegalNameException
- if the given name is illegal as an attribute name.IllegalDataException
- if the given attribute value is illegal character data (as determined byVerifier.checkCharacterData(java.lang.String)
) or if the given attribute type is not one of the supported types.
-
-
Method Details
-
getParent
This will return the parent of thisAttribute
. If there is no parent, then this returnsnull
.- Returns:
- parent of this
Attribute
-
getDocument
This retrieves the owning
for this Attribute, or null if not a currently a member of aDocument
.Document
- Returns:
Document
owning this Attribute, or null.
-
setParent
This will set the parent of thisAttribute
.- Parameters:
parent
-Element
to be new parent.- Returns:
- this
Attribute
modified.
-
detach
This detaches theAttribute
from its parent, or does nothing if theAttribute
has no parent.- Returns:
Attribute
- thisAttribute
modified.
-
getName
This will retrieve the local name of theAttribute
. 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()
- Returns:
String
- name of this attribute, without any namespace prefix.
-
setName
This sets the local name of theAttribute
.- Parameters:
name
- the new local name to set- Returns:
Attribute
- the attribute modified.- Throws:
IllegalNameException
- if the given name is illegal as an attribute name.
-
getQualifiedName
This will retrieve the qualified name of theAttribute
. 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()
- Returns:
String
- full name for this element.
-
getNamespacePrefix
This will retrieve the namespace prefix of theAttribute
. 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 emptyString
is returned.- Returns:
String
- namespace prefix of this attribute.
-
getNamespaceURI
This returns the URI mapped to thisAttribute
's prefix. If no mapping is found, an emptyString
is returned.- Returns:
String
- namespace URI for thisAttribute
.
-
getNamespace
This will return thisAttribute
's
.Namespace
- Returns:
Namespace
- Namespace object for thisAttribute
-
setNamespace
This sets thisAttribute
's
. If the provided namespace is null, the attribute will have no namespace. The namespace must have a prefix.Namespace
- Parameters:
namespace
- the new namespace- Returns:
Element
- the element modified.- Throws:
IllegalNameException
- if the new namespace is the default namespace. Attributes cannot be in a default namespace.
-
getValue
This will return the actual textual value of thisAttribute
. This will include all text within the quotation marks.- Returns:
String
- value for this attribute.
-
setValue
This will set the value of theAttribute
.- Parameters:
value
-String
value for the attribute.- Returns:
Attribute
- this Attribute modified.- Throws:
IllegalDataException
- if the given attribute value is illegal character data (as determined byVerifier.checkCharacterData(java.lang.String)
).
-
getAttributeType
public int getAttributeType()This will return the actual declared type of thisAttribute
.- Returns:
int
- type for this attribute.
-
setAttributeType
This will set the type of theAttribute
.- Parameters:
type
-int
type for the attribute.- Returns:
Attribute
- this Attribute modified.- Throws:
IllegalDataException
- if the given attribute type is not one of the supported types.
-
toString
This returns aString
representation of theAttribute
, suitable for debugging. -
equals
This tests for equality of thisAttribute
to the suppliedObject
. -
hashCode
public final int hashCode()This returns the hash code for thisAttribute
. -
clone
This will return a clone of thisAttribute
. -
getIntValue
This gets the value of the attribute, inint
form, and if no conversion can occur, throws aDataConversionException
- Returns:
int
value of attribute.- Throws:
DataConversionException
- when conversion fails.
-
getLongValue
This gets the value of the attribute, inlong
form, and if no conversion can occur, throws aDataConversionException
- Returns:
long
value of attribute.- Throws:
DataConversionException
- when conversion fails.
-
getFloatValue
This gets the value of the attribute, infloat
form, and if no conversion can occur, throws aDataConversionException
- Returns:
float
value of attribute.- Throws:
DataConversionException
- when conversion fails.
-
getDoubleValue
This gets the value of the attribute, indouble
form, and if no conversion can occur, throws aDataConversionException
- Returns:
double
value of attribute.- Throws:
DataConversionException
- when conversion fails.
-
getBooleanValue
This gets the effective boolean value of the attribute, or throws a
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.DataConversionException
- Returns:
boolean
value of attribute.- Throws:
DataConversionException
- when conversion fails.
-