net.sf.vex.dom
Class Element

java.lang.Object
  |
  +--net.sf.vex.dom.Node
        |
        +--net.sf.vex.dom.Element
Direct Known Subclasses:
PseudoElement, RootElement

public class Element
extends Node

Element represents a tag in an XML document. Methods are available for managing the element's attributes and children.


Nested Class Summary
 class Element.AttributeChangeEdit
          Represents an insertion of text into the document.
 
Constructor Summary
Element(java.lang.String name)
          Class constructor.
 
Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of an attribute given its name.
 java.lang.String[] getAttributeNames()
          Returns an array of names of the attributes in the element.
 Element[] getChildElements()
          Returns an array of the elements children.
 java.util.Iterator getChildIterator()
          Returns an iterator over the children.
 Node[] getChildNodes()
          Returns an array of nodes representing the content of this element.
 Document getDocument()
           
 java.lang.String getName()
          Returns the name of the element.
 Element getParent()
          Returns the parent of this element, or null if this is the root element.
 boolean isEmpty()
          Returns true if the element has no content.
 javax.swing.undo.UndoableEdit removeAttribute(java.lang.String name)
          Removes the given attribute from the array.
 javax.swing.undo.UndoableEdit setAttribute(java.lang.String name, java.lang.String value)
          Sets the value of an attribute for this element.
 void setParent(Element parent)
          Sets the parent of this element.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.vex.dom.Node
getContent, getEndOffset, getEndPosition, getStartOffset, getStartPosition, getText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element(java.lang.String name)
Class constructor.

Parameters:
name - element name
Method Detail

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns the value of an attribute given its name. If no such attribute exists, returns null.

Parameters:
name - Name of the attribute.

getAttributeNames

public java.lang.String[] getAttributeNames()
Returns an array of names of the attributes in the element.


getChildIterator

public java.util.Iterator getChildIterator()
Returns an iterator over the children. Used by Document.delete to safely delete children.


getChildElements

public Element[] getChildElements()
Returns an array of the elements children.


getChildNodes

public Node[] getChildNodes()
Returns an array of nodes representing the content of this element. The array includes child elements and runs of text returned as Text objects.


getDocument

public Document getDocument()
Returns:
The document to which this element belongs. Returns null if this element is part of a document fragment.

getName

public java.lang.String getName()
Returns the name of the element.


getParent

public Element getParent()
Returns the parent of this element, or null if this is the root element.


isEmpty

public boolean isEmpty()
Returns true if the element has no content.


removeAttribute

public javax.swing.undo.UndoableEdit removeAttribute(java.lang.String name)
                                              throws DocumentValidationException
Removes the given attribute from the array.

Parameters:
name - name of the attribute to remove.
DocumentValidationException

setAttribute

public javax.swing.undo.UndoableEdit setAttribute(java.lang.String name,
                                                  java.lang.String value)
                                           throws DocumentValidationException
Sets the value of an attribute for this element.

Parameters:
name - Name of the attribute to be set.
value - New value for the attribute. If null, this call has the same effect as removeAttribute(name).
DocumentValidationException

setParent

public void setParent(Element parent)
Sets the parent of this element.

Parameters:
parent - Parent element.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object