Main Page   Packages   Namespace List   Class Hierarchy   Compound List   Compound Members  

Attribute Class Reference

List of all members.

Public Methods

 Attribute (String name, String value, Namespace namespace)
 Attribute (String name, String value, int type, Namespace namespace)
 Attribute (String name, String value)
 Attribute (String name, String value, int type)
Element getParent ()
Document getDocument ()
Attribute detach ()
String getName ()
Attribute setName (String name)
String getQualifiedName ()
String getNamespacePrefix ()
String getNamespaceURI ()
Namespace getNamespace ()
Attribute setNamespace (Namespace namespace)
String getValue ()
Attribute setValue (String value)
int getAttributeType ()
Attribute setAttributeType (int type)
String toString ()
final boolean equals (Object ob)
final int hashCode ()
Object clone ()
int getIntValue () throws DataConversionException
long getLongValue () throws DataConversionException
float getFloatValue () throws DataConversionException
double getDoubleValue () throws DataConversionException
boolean getBooleanValue () throws DataConversionException

Static Public Attributes

final int UNDECLARED_ATTRIBUTE = 0
final int CDATA_ATTRIBUTE = 1
final int ID_ATTRIBUTE = 2
final int IDREF_ATTRIBUTE = 3
final int IDREFS_ATTRIBUTE = 4
final int ENTITY_ATTRIBUTE = 5
final int ENTITIES_ATTRIBUTE = 6
final int NMTOKEN_ATTRIBUTE = 7
final int NMTOKENS_ATTRIBUTE = 8
final int NOTATION_ATTRIBUTE = 9
final int ENUMERATED_ATTRIBUTE = 10

Protected Methods

 Attribute ()
Attribute setParent (Element parent)

Protected Attributes

String name
String value
int type = UNDECLARED_ATTRIBUTE
Element parent

Detailed Description

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.

Author:
Brett McLaughlin , Jason Hunter , Elliotte Rusty Harold , Wesley Biggs
Version:
Revision:
1.37
,
Date:
2002/02/08 02:49:41


Constructor & Destructor Documentation

Attribute::Attribute   [inline, protected]
 

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

Attribute::Attribute String    name,
String    value,
Namespace    namespace
[inline]
 

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

Parameters:
name  String name of Attribute.
value  String value for new attribute.
namespace  Namespace namespace for new attribute.

Attribute::Attribute String    name,
String    value,
int    type,
Namespace    namespace
[inline]
 

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.
value  String value for new attribute.
type  int type for new attribute.
namespace  Namespace namespace for new attribute.

Attribute::Attribute String    name,
String    value
[inline]
 

This will create a new 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).

Parameters:
name  String name of Attribute.
value  String value for new attribute.

Attribute::Attribute String    name,
String    value,
int    type
[inline]
 

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.
value  String value for new attribute.
type  int type for new attribute.


Member Function Documentation

Object Attribute::clone   [inline]
 

This will return a clone of this Attribute.

Returns:
Object - clone of this Attribute.

Attribute Attribute::detach   [inline]
 

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

Returns:
Attribute - this Attribute modified.

final boolean Attribute::equals Object    ob [inline]
 

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.

int Attribute::getAttributeType   [inline]
 

This will return the actual declared type of this Attribute.

Returns:
int - type for this attribute.

boolean Attribute::getBooleanValue   [inline]
 

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

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

Document Attribute::getDocument   [inline]
 

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

Returns:
Document owning this Attribute, or null.

double Attribute::getDoubleValue   [inline]
 

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

Returns:
double value of attribute.
Exceptions:
DataConversionException  when conversion fails.

float Attribute::getFloatValue   [inline]
 

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

Returns:
float value of attribute.
Exceptions:
DataConversionException  when conversion fails.

int Attribute::getIntValue   [inline]
 

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

Returns:
int value of attribute.
Exceptions:
DataConversionException  when conversion fails.

long Attribute::getLongValue   [inline]
 

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

Returns:
long value of attribute.
Exceptions:
DataConversionException  when conversion fails.

String Attribute::getName   [inline]
 

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 getNamespacePrefix method should be used.

Returns:
String - name of this attribute, without any namespace prefix.

Namespace Attribute::getNamespace   [inline]
 

This will return this Attribute's Namespace.

Returns:
Namespace - Namespace object for this Attribute

String Attribute::getNamespacePrefix   [inline]
 

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.

String Attribute::getNamespaceURI   [inline]
 

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.

Element Attribute::getParent   [inline]
 

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

Returns:
parent of this Attribute

String Attribute::getQualifiedName   [inline]
 

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 getName method should be used.

To obtain the namespace prefix for this attribute, the getNamespacePrefix method should be used.

Returns:
String - full name for this element.

String Attribute::getValue   [inline]
 

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.

final int Attribute::hashCode   [inline]
 

This returns the hash code for this Attribute.

Returns:
int - hash code.

Attribute Attribute::setAttributeType int    type [inline]
 

This will set the type of the Attribute.

Parameters:
type  int type for the attribute.
Returns:
Attribute - this Attribute modified.
Exceptions:
IllegalDataException  if the given attribute type is not one of the supported types.

Attribute Attribute::setName String    name [inline]
 

This sets the local name of the Attribute.

Returns:
Attribute - the attribute modified.
Exceptions:
IllegalNameException  if the given name is invalid as an attribute name.

Attribute Attribute::setNamespace Namespace    namespace [inline]
 

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

Returns:
Element - the element modified.
Exceptions:
IllegalNameException  if the new namespace is the default namespace. Attributes cannot be in a default namespace.

Attribute Attribute::setParent Element    parent [inline, protected]
 

This will set the parent of this Comment.

Parameters:
parent  Element to be new parent.
Returns:
this Comment modified.

Attribute Attribute::setValue String    value [inline]
 

This will set the value of the Attribute.

Parameters:
value  String value for the attribute.
Returns:
Attribute - this Attribute modified.
Exceptions:
IllegalDataException  if the given attribute value is illegal character data (as determined by Verifier::checkCharacterData).

String Attribute::toString   [inline]
 

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

Returns:
String - information about the Attribute


Member Data Documentation

final int Attribute::CDATA_ATTRIBUTE = 1 [static]
 

Attribute type: the attribute value is a string.

See also:
getAttributeType

final int Attribute::ENTITIES_ATTRIBUTE = 6 [static]
 

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

See also:
getAttributeType

final int Attribute::ENTITY_ATTRIBUTE = 5 [static]
 

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

See also:
getAttributeType

final int Attribute::ENUMERATED_ATTRIBUTE = 10 [static]
 

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

See also:
getAttributeType

final int Attribute::ID_ATTRIBUTE = 2 [static]
 

Attribute type: the attribute value is a unique identifier.

See also:
getAttributeType

final int Attribute::IDREF_ATTRIBUTE = 3 [static]
 

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

See also:
getAttributeType

final int Attribute::IDREFS_ATTRIBUTE = 4 [static]
 

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

See also:
getAttributeType

String Attribute::name [protected]
 

The local name of the Attribute

final int Attribute::NMTOKEN_ATTRIBUTE = 7 [static]
 

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_ATTRIBUTE.

See also:
getAttributeType

final int Attribute::NMTOKENS_ATTRIBUTE = 8 [static]
 

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

See also:
getAttributeType

final int Attribute::NOTATION_ATTRIBUTE = 9 [static]
 

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

See also:
getAttributeType

Element Attribute::parent [protected]
 

Parent element, or null if none

int Attribute::type = UNDECLARED_ATTRIBUTE [protected]
 

The type of the Attribute

final int Attribute::UNDECLARED_ATTRIBUTE = 0 [static]
 

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

See also:
getAttributeType

String Attribute::value [protected]
 

The value of the Attribute


The documentation for this class was generated from the following file:
Generated on Sat Mar 30 18:53:02 2002 for JDOM by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001