org.apache.crimson.tree
Class AttributeSet

java.lang.Object
  extended byorg.apache.crimson.tree.AttributeSet
All Implemented Interfaces:
org.w3c.dom.NamedNodeMap, XmlWritable

final class AttributeSet
extends Object
implements org.w3c.dom.NamedNodeMap, XmlWritable

Class representing a list of XML attributes.

This couples slightly with the Sun XML parser, in that it optionally uses an extended SAX API to see if an attribute was specified in the document or was instead defaulted by attribute processing.

Author:
David Brownell

Field Summary
private  Vector list
           
private  org.w3c.dom.Element ownerElement
           
private  boolean readonly
           
 
Constructor Summary
private AttributeSet()
           
(package private) AttributeSet(AttributeSet original)
          Constructor used to implement Document.importNode().
(package private) AttributeSet(AttributeSet original, boolean deep)
           
(package private) AttributeSet(org.w3c.dom.Element ownerElement)
           
 
Method Summary
(package private) static AttributeSet createAttributeSet1(org.xml.sax.Attributes source)
          Create a DOM NamedNodeMap consisting of DOM Level 1 Attr nodes from a SAX2 Attributes object
(package private) static AttributeSet createAttributeSet2(org.xml.sax.Attributes source)
          Create a DOM NamedNodeMap consisting of DOM Level 2 Attr nodes from a SAX2 Attributes object
 int getLength()
           
 org.w3c.dom.Node getNamedItem(String name)
           
 org.w3c.dom.Node getNamedItemNS(String namespaceURI, String localName)
          DOM2:
(package private)  String getValue(String name)
           
 boolean isReadonly()
           
 org.w3c.dom.Node item(int index)
           
 org.w3c.dom.Node removeNamedItem(String name)
           
 org.w3c.dom.Node removeNamedItemNS(String namespaceURI, String localName)
          DOM2:
 org.w3c.dom.Node setNamedItem(org.w3c.dom.Node value)
          Note: this method both checks and sets the "ownerElement" of the "value" parameter.
 org.w3c.dom.Node setNamedItemNS(org.w3c.dom.Node arg)
          DOM2: Spec technically allows other types of nodes also, but this code assumes Attr nodes only
(package private)  void setOwnerElement(org.w3c.dom.Element e)
           
 void setReadonly()
           
 String toString()
          Returns a string representation of the object.
(package private)  void trimToSize()
           
 void writeChildrenXml(XmlWriteContext context)
          Does nothing; this type of node has no children.
 void writeXml(XmlWriteContext context)
          Writes out the attribute list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

readonly

private boolean readonly

list

private Vector list

ownerElement

private org.w3c.dom.Element ownerElement
Constructor Detail

AttributeSet

private AttributeSet()

AttributeSet

AttributeSet(org.w3c.dom.Element ownerElement)

AttributeSet

AttributeSet(AttributeSet original,
             boolean deep)

AttributeSet

AttributeSet(AttributeSet original)
Constructor used to implement Document.importNode(). Only "specified" Attr nodes are copied. Copy is always deep.

Method Detail

createAttributeSet2

static AttributeSet createAttributeSet2(org.xml.sax.Attributes source)
                                 throws org.w3c.dom.DOMException
Create a DOM NamedNodeMap consisting of DOM Level 2 Attr nodes from a SAX2 Attributes object

Throws:
org.w3c.dom.DOMException

createAttributeSet1

static AttributeSet createAttributeSet1(org.xml.sax.Attributes source)
                                 throws org.w3c.dom.DOMException
Create a DOM NamedNodeMap consisting of DOM Level 1 Attr nodes from a SAX2 Attributes object

Throws:
org.w3c.dom.DOMException

trimToSize

void trimToSize()

setReadonly

public void setReadonly()

isReadonly

public boolean isReadonly()

setOwnerElement

void setOwnerElement(org.w3c.dom.Element e)

getValue

String getValue(String name)

getNamedItem

public org.w3c.dom.Node getNamedItem(String name)
Specified by:
getNamedItem in interface org.w3c.dom.NamedNodeMap

getNamedItemNS

public org.w3c.dom.Node getNamedItemNS(String namespaceURI,
                                       String localName)
DOM2:

Specified by:
getNamedItemNS in interface org.w3c.dom.NamedNodeMap

getLength

public int getLength()
Specified by:
getLength in interface org.w3c.dom.NamedNodeMap

item

public org.w3c.dom.Node item(int index)
Specified by:
item in interface org.w3c.dom.NamedNodeMap

removeNamedItem

public org.w3c.dom.Node removeNamedItem(String name)
                                 throws org.w3c.dom.DOMException
Specified by:
removeNamedItem in interface org.w3c.dom.NamedNodeMap
Throws:
org.w3c.dom.DOMException

removeNamedItemNS

public org.w3c.dom.Node removeNamedItemNS(String namespaceURI,
                                          String localName)
                                   throws org.w3c.dom.DOMException
DOM2:

Specified by:
removeNamedItemNS in interface org.w3c.dom.NamedNodeMap
Throws:
org.w3c.dom.DOMException

setNamedItem

public org.w3c.dom.Node setNamedItem(org.w3c.dom.Node value)
                              throws org.w3c.dom.DOMException
Note: this method both checks and sets the "ownerElement" of the "value" parameter. So if "ownerElement" is already set, an incorrect error results. Callers should avoid setting "ownerElement".

Specified by:
setNamedItem in interface org.w3c.dom.NamedNodeMap
Throws:
org.w3c.dom.DOMException

setNamedItemNS

public org.w3c.dom.Node setNamedItemNS(org.w3c.dom.Node arg)
                                throws org.w3c.dom.DOMException
DOM2: Spec technically allows other types of nodes also, but this code assumes Attr nodes only

Specified by:
setNamedItemNS in interface org.w3c.dom.NamedNodeMap
Throws:
org.w3c.dom.DOMException

writeXml

public void writeXml(XmlWriteContext context)
              throws IOException
Writes out the attribute list. Attributes known to have been derived from the DTD are not (at this time) written out. Part of writing standalone XML is first ensuring that all attributes are flagged as being specified in the "printed" form (or else are defaulted only in the internal DTD subset).

Specified by:
writeXml in interface XmlWritable
Throws:
IOException

writeChildrenXml

public void writeChildrenXml(XmlWriteContext context)
                      throws IOException
Does nothing; this type of node has no children.

Specified by:
writeChildrenXml in interface XmlWritable
Throws:
IOException

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.