All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.jdom.Attribute

java.lang.Object
   |
   +----org.jdom.Attribute

public class Attribute
extends Object
implements Serializable, Cloneable

Attribute defines behavior for an XML attribute, modeled in Java. Methods allow the user to obtain the value of the attribute as well as namespace information.

Version:
$Revision: 1.40 $, $Date: 2002/03/19 04:25:37 $
Author:
Brett McLaughlin, Jason Hunter, Elliotte Rusty Harold, Wesley Biggs

Variable Index

 o CDATA_ATTRIBUTE

Attribute type: the attribute value is a string.

 o ENTITIES_ATTRIBUTE

Attribute type: the attribute value is a list of entity names.

 o ENTITY_ATTRIBUTE

Attribute type: the attribute value is the name of an entity.

 o ENUMERATED_ATTRIBUTE

Attribute type: the attribute value is a name token from an enumeration.

 o ID_ATTRIBUTE

Attribute type: the attribute value is a unique identifier.

 o IDREF_ATTRIBUTE

Attribute type: the attribute value is a reference to a unique identifier.

 o IDREFS_ATTRIBUTE

Attribute type: the attribute value is a list of references to unique identifiers.

 o name
The local name of the Attribute
 o namespace
The {
 o NMTOKEN_ATTRIBUTE

Attribute type: the attribute value is a name token.

 o NMTOKENS_ATTRIBUTE

Attribute type: the attribute value is a list of name tokens.

 o NOTATION_ATTRIBUTE

Attribute type: the attribute value is the name of a notation.

 o parent
Parent element, or null if none
 o type
The type of the Attribute
 o UNDECLARED_ATTRIBUTE

Attribute type: the attribute has not been declared or type is unknown.

 o value
The value of the Attribute

Constructor Index

 o Attribute()

Default, no-args constructor for implementations to use if needed.

 o Attribute(String, String)

This will create a new Attribute with the specified (local) name and value, and does not place the attribute in a {

 o Attribute(String, String, int)

This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a {

 o Attribute(String, String, int, Namespace)

This will create a new Attribute with the specified (local) name, value, and type, and in the provided {

 o Attribute(String, String, Namespace)

This will create a new Attribute with the specified (local) name and value, and in the provided {

Method Index

 o clone()

This will return a clone of this Attribute.

 o detach()

This detaches the Attribute from its parent, or does nothing if the Attribute has no parent.

 o equals(Object)

This tests for equality of this Attribute to the supplied Object.

 o getAttributeType()

This will return the actual declared type of this Attribute.

 o getBooleanValue()

This gets the value of the attribute, in boolean form, and if no conversion can occur, throws a {

 o getDocument()

This retrieves the owning {

 o getDoubleValue()

This gets the value of the attribute, in double form, and if no conversion can occur, throws a {

 o getFloatValue()

This gets the value of the attribute, in float form, and if no conversion can occur, throws a {

 o getIntValue()

This gets the value of the attribute, in int form, and if no conversion can occur, throws a {

 o getLongValue()

This gets the value of the attribute, in long form, and if no conversion can occur, throws a {

 o getName()

This will retrieve the local name of the Attribute.

 o getNamespace()

This will return this Attribute's {

 o getNamespacePrefix()

This will retrieve the namespace prefix of the Attribute.

 o getNamespaceURI()

This returns the URI mapped to this Attribute's prefix.

 o getParent()

This will return the parent of this Attribute.

 o getQualifiedName()

This will retrieve the qualified name of the Attribute.

 o getValue()

This will return the actual textual value of this Attribute.

 o hashCode()

This returns the hash code for this Attribute.

 o setAttributeType(int)

This will set the type of the Attribute.

 o setName(String)

This sets the local name of the Attribute.

 o setNamespace(Namespace)

This sets this Attribute's {

 o setParent(Element)

This will set the parent of this Attribute.

 o setValue(String)

This will set the value of the Attribute.

 o toString()

This returns a String representation of the Attribute, suitable for debugging.

Variables

 o UNDECLARED_ATTRIBUTE
 public static final int UNDECLARED_ATTRIBUTE

Attribute type: the attribute has not been declared or type is unknown.

See Also:
getAttributeType
 o CDATA_ATTRIBUTE
 public static final int CDATA_ATTRIBUTE

Attribute type: the attribute value is a string.

See Also:
getAttributeType
 o ID_ATTRIBUTE
 public static final int ID_ATTRIBUTE

Attribute type: the attribute value is a unique identifier.

See Also:
getAttributeType
 o IDREF_ATTRIBUTE
 public static final int IDREF_ATTRIBUTE

Attribute type: the attribute value is a reference to a unique identifier.

See Also:
getAttributeType
 o IDREFS_ATTRIBUTE
 public static final int IDREFS_ATTRIBUTE

Attribute type: the attribute value is a list of references to unique identifiers.

See Also:
getAttributeType
 o ENTITY_ATTRIBUTE
 public static final int ENTITY_ATTRIBUTE

Attribute type: the attribute value is the name of an entity.

See Also:
getAttributeType
 o ENTITIES_ATTRIBUTE
 public static final int ENTITIES_ATTRIBUTE

Attribute type: the attribute value is a list of entity names.

See Also:
getAttributeType
 o NMTOKEN_ATTRIBUTE
 public static final int NMTOKEN_ATTRIBUTE

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 {@link #ENUMERATED_ATTRIBUTE}.

See Also:
getAttributeType
 o NMTOKENS_ATTRIBUTE
 public static final int NMTOKENS_ATTRIBUTE

Attribute type: the attribute value is a list of name tokens.

See Also:
getAttributeType
 o NOTATION_ATTRIBUTE
 public static final int NOTATION_ATTRIBUTE

Attribute type: the attribute value is the name of a notation.

See Also:
getAttributeType
 o ENUMERATED_ATTRIBUTE
 public static final int ENUMERATED_ATTRIBUTE

Attribute type: the attribute value is a name token from an enumeration.

See Also:
getAttributeType
 o name
 protected String name
The local name of the Attribute

 o namespace
 protected transient Namespace namespace
The {@link Namespace} of the Attribute

 o value
 protected String value
The value of the Attribute

 o type
 protected int type
The type of the Attribute

 o parent
 protected Object parent
Parent element, or null if none

Constructors

 o Attribute
 protected Attribute()

Default, no-args constructor for implementations to use if needed.

 o Attribute
 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 {@link Namespace}.

Parameters:
name - String name of Attribute.
value - String value for new attribute.
namespace - Namespace namespace for new attribute.
 o Attribute
 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 {@link Namespace}.

Parameters:
name - String name of Attribute.
value - String value for new attribute.
type - int type for new attribute.
namespace - Namespace namespace for new attribute.
 o Attribute
 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 {@link Namespace}.

Note: This actually explicitly puts the Attribute in the "empty" Namespace ({@link Namespace#NO_NAMESPACE}).

Parameters:
name - String name of Attribute.
value - String value for new attribute.
 o Attribute
 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 {@link Namespace}.

Note: This actually explicitly puts the Attribute in the "empty" Namespace ({@link Namespace#NO_NAMESPACE}).

Parameters:
name - String name of Attribute.
value - String value for new attribute.
type - int type for new attribute.

Methods

 o getParent
 public Element getParent()

This will return the parent of this Attribute. If there is no parent, then this returns null.

Returns:
parent of this Attribute
 o getDocument
 public Document getDocument()

This retrieves the owning {@link Document} for this Attribute, or null if not a currently a member of a {@link Document}.

Returns:
Document owning this Attribute, or null.
 o setParent
 protected Attribute setParent(Element parent)

This will set the parent of this Attribute.

Parameters:
parent - Element to be new parent.
Returns:
this Attribute modified.
 o detach
 public Attribute detach()

This detaches the Attribute from its parent, or does nothing if the Attribute has no parent.

Returns:
Attribute - this Attribute modified.
 o getName
 public 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 {@link #getNamespacePrefix()} method should be used.

Returns:
String - name of this attribute, without any namespace prefix.
 o setName
 public Attribute setName(String name)

This sets the local name of the Attribute.

Returns:
Attribute - the attribute modified.
Throws: IllegalNameException
if the given name is illegal as an attribute name.
 o getQualifiedName
 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). 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 {@link #getName()} method should be used.

To obtain the namespace prefix for this attribute, the {@link #getNamespacePrefix()} method should be used.

Returns:
String - full name for this element.
 o getNamespacePrefix
 public 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 empty String is returned.

Returns:
String - namespace prefix of this attribute.
 o getNamespaceURI
 public String getNamespaceURI()

This returns the URI mapped to this Attribute's prefix. If no mapping is found, an empty String is returned.

Returns:
String - namespace URI for this Attribute.
 o getNamespace
 public Namespace getNamespace()

This will return this Attribute's {@link Namespace}.

Returns:
Namespace - Namespace object for this Attribute
 o setNamespace
 public Attribute setNamespace(Namespace namespace)

This sets this Attribute's {@link Namespace}. If the provided namespace is null, the attribute will have no namespace. The namespace must have a prefix.

Returns:
Element - the element modified.
Throws: IllegalNameException
if the new namespace is the default namespace. Attributes cannot be in a default namespace.
 o getValue
 public String getValue()

This will return the actual textual value of this Attribute. This will include all text within the quotation marks.

Returns:
String - value for this attribute.
 o setValue
 public Attribute setValue(String value)

This will set the value of the Attribute.

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 by {@link org.jdom.Verifier#checkCharacterData}).
 o getAttributeType
 public int getAttributeType()

This will return the actual declared type of this Attribute.

Returns:
int - type for this attribute.
 o setAttributeType
 public Attribute setAttributeType(int type)

This will set the type of the Attribute.

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.
 o toString
 public String toString()

This returns a String representation of the Attribute, suitable for debugging.

Returns:
String - information about the Attribute
Overrides:
toString in class Object
 o equals
 public final boolean equals(Object ob)

This tests for equality of this Attribute to the supplied Object.

Parameters:
ob - Object to compare to.
Returns:
boolean - whether the Attribute is equal to the supplied Object.
Overrides:
equals in class Object
 o hashCode
 public final int hashCode()

This returns the hash code for this Attribute.

Returns:
int - hash code.
Overrides:
hashCode in class Object
 o clone
 public Object clone()

This will return a clone of this Attribute.

Returns:
Object - clone of this Attribute.
Overrides:
clone in class Object
 o getIntValue
 public int getIntValue() throws DataConversionException

This gets the value of the attribute, in int form, and if no conversion can occur, throws a {@link DataConversionException}

Returns:
int value of attribute.
Throws: DataConversionException
when conversion fails.
 o getLongValue
 public long getLongValue() throws DataConversionException

This gets the value of the attribute, in long form, and if no conversion can occur, throws a {@link DataConversionException}

Returns:
long value of attribute.
Throws: DataConversionException
when conversion fails.
 o getFloatValue
 public float getFloatValue() throws DataConversionException

This gets the value of the attribute, in float form, and if no conversion can occur, throws a {@link DataConversionException}

Returns:
float value of attribute.
Throws: DataConversionException
when conversion fails.
 o getDoubleValue
 public double getDoubleValue() throws DataConversionException

This gets the value of the attribute, in double form, and if no conversion can occur, throws a {@link DataConversionException}

Returns:
double value of attribute.
Throws: DataConversionException
when conversion fails.
 o getBooleanValue
 public boolean getBooleanValue() throws DataConversionException

This gets the value of the attribute, in boolean form, and if no conversion can occur, throws a {@link DataConversionException}

Returns:
boolean value of attribute.
Throws: DataConversionException
when conversion fails.

All Packages  Class Hierarchy  This Package  Previous  Next  Index