org.attoparser.markup.dom
Class Element

Object
  extended by org.attoparser.markup.dom.Node
      extended by org.attoparser.markup.dom.Element
All Implemented Interfaces:
Serializable

public final class Element
extends Node

Base abstract class for all nodes in a attoDOM tree which have children.

Since:
1.0
Author:
Daniel Fernández
See Also:
Serialized Form

Constructor Summary
Element(String name, boolean standalone)
           
Element(String name, boolean standalone, int line, int col)
           
 
Method Summary
 void addAttribute(String attributeName, String attributeValue)
           
 void addAttributes(Map<String,String> newAttributes)
           
 void addChild(Node newChild)
           
 void clearAttributes()
           
 void clearChildren()
           Clears all children from this node.
 Map<String,String> getAttributeMap()
           Returns a map with all the names and values of the element attributes.
 String getAttributeValue(String attributeName)
           Returns the value of an attribute from its attribute name.
 String getAttributeValueIgnoreCase(String attributeName)
           Returns the value of an attribute from its attribute name, ignoring case in attribute name.
 List<Node> getChildren()
           Returns the children of this node.
 List<Element> getElementChildren()
           Returns only the Element children of this node, discarding children of any other types.
 Node getFirstChild()
           Returns the first child of this node.
 Element getFirstElementChild()
           Returns the first child of type Element.
 String getName()
           
 boolean hasAttribute(String attributeName)
           Returns whether an attribute exists in the element or not.
 boolean hasAttributeIgnoreCase(String attributeName)
           Returns whether an attribute exists in the element or not, ignoring case differences.
 boolean hasAttributes()
           Returns whether this element has any attributes or not.
 boolean hasChildren()
           Returns whether this node has any children.
 void insertChild(int index, Node newChild)
           
 void insertChildAfter(Node after, Node newChild)
           
 void insertChildBefore(Node before, Node newChild)
           
 boolean isStandalone()
           
 int numAttributes()
           Returns the number of attributes contained in this element.
 int numChildren()
           Returns the number of children in this node.
 void removeAttribute(String attributeName)
           
 void removeAttributeIgnoreCase(String attributeName)
           
 void removeChild(Node child)
           
 void setName(String name)
           
 void setStandalone(boolean standalone)
           
 void visit(AttoDOMVisitor visitor)
           
 
Methods inherited from class org.attoparser.markup.dom.Node
getCol, getLine, getParent, hasParent
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Element

public Element(String name,
               boolean standalone,
               int line,
               int col)

Element

public Element(String name,
               boolean standalone)
Method Detail

getName

public String getName()

setName

public void setName(String name)

isStandalone

public boolean isStandalone()

setStandalone

public void setStandalone(boolean standalone)

hasChildren

public final boolean hasChildren()

Returns whether this node has any children.

Returns:
true if the node as any children, false if not.

numChildren

public final int numChildren()

Returns the number of children in this node.

Returns:
the number of children.

getChildren

public final List<Node> getChildren()

Returns the children of this node. The returned list is immutable.

Returns:
the list of children.

clearChildren

public final void clearChildren()

Clears all children from this node.


getElementChildren

public final List<Element> getElementChildren()

Returns only the Element children of this node, discarding children of any other types. The returned list is immutable.

Returns:
the list of Element children.

getFirstChild

public final Node getFirstChild()

Returns the first child of this node.

Returns:
the first child, or null if there are no children.

getFirstElementChild

public final Element getFirstElementChild()

Returns the first child of type Element.

Returns:
the first Element child, or null if there are no children or there are but none is an Element.

addChild

public void addChild(Node newChild)

insertChild

public void insertChild(int index,
                        Node newChild)

insertChildBefore

public void insertChildBefore(Node before,
                              Node newChild)

insertChildAfter

public void insertChildAfter(Node after,
                             Node newChild)

removeChild

public void removeChild(Node child)

hasAttributes

public boolean hasAttributes()

Returns whether this element has any attributes or not.

Returns:
true if this element has attributes, false if not.

numAttributes

public int numAttributes()

Returns the number of attributes contained in this element.

Returns:
the number of attributes.

hasAttribute

public boolean hasAttribute(String attributeName)

Returns whether an attribute exists in the element or not.

Parameters:
attributeName - the name of the attribute to be checked.
Returns:
true if the attribute exists, false if not.

hasAttributeIgnoreCase

public boolean hasAttributeIgnoreCase(String attributeName)

Returns whether an attribute exists in the element or not, ignoring case differences.

Parameters:
attributeName - the name of the attribute to be checked.
Returns:
true if the attribute exists, false if not.

getAttributeValue

public String getAttributeValue(String attributeName)

Returns the value of an attribute from its attribute name.

Parameters:
attributeName - the attribute name.
Returns:
the value of the attribute.

getAttributeValueIgnoreCase

public String getAttributeValueIgnoreCase(String attributeName)

Returns the value of an attribute from its attribute name, ignoring case in attribute name.

Parameters:
attributeName - the attribute name.
Returns:
the value of the attribute.

getAttributeMap

public Map<String,String> getAttributeMap()

Returns a map with all the names and values of the element attributes.

The map object returned by this method is immutable.

Returns:
the map of all current attributes in the element.

addAttribute

public void addAttribute(String attributeName,
                         String attributeValue)

addAttributes

public void addAttributes(Map<String,String> newAttributes)

clearAttributes

public void clearAttributes()

removeAttribute

public void removeAttribute(String attributeName)

removeAttributeIgnoreCase

public void removeAttributeIgnoreCase(String attributeName)

visit

public final void visit(AttoDOMVisitor visitor)
                 throws AttoDOMVisitorException
Specified by:
visit in class Node
Throws:
AttoDOMVisitorException


Copyright © 2012 The ATTOPARSER team. All Rights Reserved.