GXPARSE hosted by SourceForge.net Logo

ca.gorman.xml.parse.toolkit
Class AbstractAttribute

java.lang.Object
  extended by ca.gorman.xml.parse.toolkit.AbstractAttribute
All Implemented Interfaces:
Attribute
Direct Known Subclasses:
MutableAttribute

public abstract class AbstractAttribute
extends Object
implements Attribute

Abstract realization of Attribute.

This is a common base class for the parser's internal view of Attribute objects and the application programmer's external view of Attribute objects. Attributes are presented to the application programmer as immutable objects, but are treated as mutable objects inside the parser. The mutable version is created by subclassing to expose the setters.


Constructor Summary
protected AbstractAttribute()
           Create an uninitialized AbstractAttribute.
protected AbstractAttribute(Attribute attribute)
           Create an initialized AbstractAttribute.
protected AbstractAttribute(QName qName, String type)
           Create an uninitialized AbstractAttribute.
protected AbstractAttribute(QName qName, String type, String value, boolean isDeclared, boolean isSpecified)
           Create an initialized AbstractAttribute.
 
Method Summary
 boolean equals(Object obj)
           Define Attribute equality as identity of instances.
 QName getQName()
           Get QName.
 String getQuotableValue()
           Get attribute value that can be enclosed in quotes.
 String getType()
           Get attribute type.
 String getValue()
           Get attribute value.
 int hashCode()
           Returns Object.hashCode.
 boolean isDeclared()
           Ask whether the attribute was declared.
 boolean isSpecified()
           Ask whether the attribute value was provided from the input, rather than from a default value.
 AbstractAttribute newInstance(QName qName, String type, String value, boolean isDeclared, boolean isSpecified)
           Create an immutable AbstractAttribute.
protected  void setDeclared(boolean b)
           Indicate whether the attribute was declared..
protected  void setQName(QName qName)
           Set attribute name.
protected  void setSpecified(boolean b)
           Indicate whether the attribute value was provided from the input, rather than from a default value.
protected  void setType(String type)
           Set attribute type.
protected  void setValue(String value)
           Set attribute value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAttribute

protected AbstractAttribute(QName qName,
                            String type)

Create an uninitialized AbstractAttribute.


AbstractAttribute

protected AbstractAttribute(QName qName,
                            String type,
                            String value,
                            boolean isDeclared,
                            boolean isSpecified)

Create an initialized AbstractAttribute.


AbstractAttribute

protected AbstractAttribute(Attribute attribute)

Create an initialized AbstractAttribute.


AbstractAttribute

protected AbstractAttribute()

Create an uninitialized AbstractAttribute.

Method Detail

newInstance

public AbstractAttribute newInstance(QName qName,
                                     String type,
                                     String value,
                                     boolean isDeclared,
                                     boolean isSpecified)

Create an immutable AbstractAttribute.

Throws:
NullPointerException - if qName is null

getQName

public final QName getQName()
Description copied from interface: Attribute

Get QName.

This identifies the Attribute by namespace and local name.

Specified by:
getQName in interface Attribute
Returns:
QName.

setQName

protected void setQName(QName qName)

Set attribute name.

Throws:
NullPointerException - if qName is null

getType

public final String getType()
Description copied from interface: Attribute

Get attribute type.

The attribute type must be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case).

If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 Recommentation (clause 3.3.3, "Attribute-Value Normalization").

For an enumerated attribute that is not a notation, the parser should report the type as "NMTOKEN".

Specified by:
getType in interface Attribute

setType

protected void setType(String type)

Set attribute type.

Throws:
NullPointerException - if type is null

getValue

public final String getValue()
Description copied from interface: Attribute

Get attribute value.

Specified by:
getValue in interface Attribute

setValue

protected void setValue(String value)

Set attribute value.

Throws:
NullPointerException - if value is null

getQuotableValue

public final String getQuotableValue()
Description copied from interface: Attribute

Get attribute value that can be enclosed in quotes.

Specified by:
getQuotableValue in interface Attribute

isDeclared

public boolean isDeclared()
Description copied from interface: Attribute

Ask whether the attribute was declared. When using a validating parser, an attribute is valid if and only if it was declared.

Specified by:
isDeclared in interface Attribute

setDeclared

protected void setDeclared(boolean b)

Indicate whether the attribute was declared..


isSpecified

public boolean isSpecified()
Description copied from interface: Attribute

Ask whether the attribute value was provided from the input, rather than from a default value.

Specified by:
isSpecified in interface Attribute

setSpecified

protected void setSpecified(boolean b)

Indicate whether the attribute value was provided from the input, rather than from a default value.


equals

public final boolean equals(Object obj)
Description copied from interface: Attribute

Define Attribute equality as identity of instances.

Specified by:
equals in interface Attribute
Overrides:
equals in class Object

hashCode

public final int hashCode()
Description copied from interface: Attribute

Returns Object.hashCode.

Specified by:
hashCode in interface Attribute
Overrides:
hashCode in class Object

GXPARSE download

GXPARSE Generic XML Stream Parser API and supporting tools.   Release $Name: gxparse-sf-alpha-2_0 $
Copyright 2003-2004 Ian E. Gorman
Released under GNU Lesser General Public License