JDOM 1.0 | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.jdom.Attribute
public class Attribute
extends java.lang.Object
implements Serializable, Cloneable
Field Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
protected String |
|
protected Namespace | |
protected Object |
|
protected int |
|
protected String |
|
Constructor Summary | |
| |
Method Summary | |
Object |
|
Attribute |
|
boolean |
|
int |
|
boolean |
|
Document |
|
double |
|
float |
|
int |
|
long |
|
String |
|
Namespace |
|
String |
|
String |
|
Element |
|
String |
|
String |
|
int |
|
Attribute |
|
Attribute |
|
Attribute |
|
protected Attribute | |
Attribute |
|
String |
|
public static final int CDATA_TYPE
Attribute type: the attribute value is a string.
- Field Value:
- 1
- See Also:
getAttributeType()
public static final int ENTITIES_TYPE
Attribute type: the attribute value is a list of entity names.
- Field Value:
- 6
- See Also:
getAttributeType()
public static final int ENTITY_TYPE
Attribute type: the attribute value is the name of an entity.
- Field Value:
- 5
- See Also:
getAttributeType()
public static final int ENUMERATED_TYPE
Attribute type: the attribute value is a name token from an enumeration.
- Field Value:
- 10
- See Also:
getAttributeType()
public static final int IDREFS_TYPE
Attribute type: the attribute value is a list of references to unique identifiers.
- Field Value:
- 4
- See Also:
getAttributeType()
public static final int IDREF_TYPE
Attribute type: the attribute value is a reference to a unique identifier.
- Field Value:
- 3
- See Also:
getAttributeType()
public static final int ID_TYPE
Attribute type: the attribute value is a unique identifier.
- Field Value:
- 2
- See Also:
getAttributeType()
public static final int NMTOKENS_TYPE
Attribute type: the attribute value is a list of name tokens.
- Field Value:
- 8
- See Also:
getAttributeType()
public static final 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. But the major parsers (Xerces and Crimson) provide specific values that permit to recognize them asENUMERATED_TYPE
.
- Field Value:
- 7
- See Also:
getAttributeType()
public static final int NOTATION_TYPE
Attribute type: the attribute value is the name of a notation.
- Field Value:
- 9
- See Also:
getAttributeType()
public static final int UNDECLARED_TYPE
Attribute type: the attribute has not been declared or type is unknown.
- Field Value:
- 0
- See Also:
getAttributeType()
protected String name
The local name of theAttribute
protected Object parent
Parent element, or null if none
protected int type
The type of theAttribute
protected String value
The value of theAttribute
protected Attribute()
Default, no-args constructor for implementations to use if needed.
public Attribute(String name, String value)
This will create a newAttribute
with the specified (local) name and value, and does not place the attribute in a. Note: This actually explicitly puts the
Namespace
Attribute
in the "empty"Namespace
().
Namespace.NO_NAMESPACE
- Parameters:
name
-String
name ofAttribute
.value
-String
value for new attribute.
public Attribute(String name, String value, int type)
This will create a newAttribute
with the specified (local) name, value and type, and does not place the attribute in a. Note: This actually explicitly puts the
Namespace
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.
public Attribute(String name, String value, int type, Namespace namespace)
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.
public Attribute(String name, String value, Namespace namespace)
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.
public Object clone()
This will return a clone of thisAttribute
.
- Returns:
Object
- clone of thisAttribute
.
public Attribute detach()
This detaches theAttribute
from its parent, or does nothing if theAttribute
has no parent.
- Returns:
Attribute
- thisAttribute
modified.
public final boolean equals(Object ob)
This tests for equality of thisAttribute
to the suppliedObject
.
- Parameters:
ob
-Object
to compare to.
- Returns:
boolean
- whether theAttribute
is equal to the suppliedObject
.
public int getAttributeType()
This will return the actual declared type of thisAttribute
.
- Returns:
int
- type for this attribute.
public boolean getBooleanValue() throws DataConversionException
This gets the effective boolean value of the attribute, or throws aif 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.
public Document getDocument()
This retrieves the owningfor this Attribute, or null if not a currently a member of a
Document
.
Document
- Returns:
Document
owning this Attribute, or null.
public double getDoubleValue() throws DataConversionException
This gets the value of the attribute, indouble
form, and if no conversion can occur, throws a
DataConversionException
- Returns:
double
value of attribute.
- Throws:
DataConversionException
- when conversion fails.
public float getFloatValue() throws DataConversionException
This gets the value of the attribute, infloat
form, and if no conversion can occur, throws a
DataConversionException
- Returns:
float
value of attribute.
- Throws:
DataConversionException
- when conversion fails.
public int getIntValue() throws DataConversionException
This gets the value of the attribute, inint
form, and if no conversion can occur, throws a
DataConversionException
- Returns:
int
value of attribute.
- Throws:
DataConversionException
- when conversion fails.
public long getLongValue() throws DataConversionException
This gets the value of the attribute, inlong
form, and if no conversion can occur, throws a
DataConversionException
- Returns:
long
value of attribute.
- Throws:
DataConversionException
- when conversion fails.
public String 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, themethod should be used.
getNamespacePrefix()
- Returns:
String
- name of this attribute, without any namespace prefix.
public Namespace getNamespace()
This will return thisAttribute
's.
Namespace
- Returns:
Namespace
- Namespace object for thisAttribute
public String 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.
public String 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
.
public Element getParent()
This will return the parent of thisAttribute
. If there is no parent, then this returnsnull
.
- Returns:
- parent of this
Attribute
public String 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, themethod should be used. To obtain the namespace prefix for this attribute, the
getName()
method should be used.
getNamespacePrefix()
- Returns:
String
- full name for this element.
public String 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.
public final int hashCode()
This returns the hash code for thisAttribute
.
- Returns:
int
- hash code.
public Attribute setAttributeType(int type)
This will set the type of theAttribute
.
- Parameters:
type
-int
type for the attribute.
- Returns:
Attribute
- this Attribute modified.
public Attribute setName(String name)
This sets the local name of theAttribute
.
- Parameters:
name
- the new local name to set
- Returns:
Attribute
- the attribute modified.
public Attribute setNamespace(Namespace namespace)
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.
protected Attribute setParent(Element parent)
This will set the parent of thisAttribute
.
- Parameters:
parent
-Element
to be new parent.
- Returns:
- this
Attribute
modified.
public Attribute setValue(String value)
This will set the value of theAttribute
.
- Parameters:
value
-String
value for the attribute.
- Returns:
Attribute
- this Attribute modified.
public String toString()
This returns aString
representation of theAttribute
, suitable for debugging.
- Returns:
String
- information about theAttribute