net.sf.magicproject.xml
Class XmlParser.Node

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<java.lang.Object>
          extended by net.sf.magicproject.xml.XmlParser.Node
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, java.util.Collection<java.lang.Object>, java.util.List<java.lang.Object>
Enclosing class:
XmlParser

public static class XmlParser.Node
extends java.util.AbstractList<java.lang.Object>

XML Node. Represents an XML element with optional attributes and ordered content.


Field Summary
 XmlParser.Attribute[] aAttrs
          Attributes
 boolean aLastString
          Is the last object is a string.
 java.util.List<java.lang.Object> aList
          Nodes
 java.lang.String aTag
          Tag name.
 
Constructor Summary
XmlParser.Node(XmlParser.Node parent, java.lang.String tag, org.xml.sax.Attributes attrs)
          Create a new instance of this class.
 
Method Summary
 void add(int i, java.lang.Object o)
           
 void addAttribute(XmlParser.Attribute attr)
           
 void addFirstAttribute(XmlParser.Attribute attr)
           
 void clear()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.Object get(int i)
          Get the ith child node or content.
 XmlParser.Node get(java.lang.String tag)
          Get the first child node with the tag.
 java.lang.String getAttribute(java.lang.String name)
          Get an element attribute.
 java.lang.String getAttribute(java.lang.String name, java.lang.String dft)
          Get an element attribute.
 int getNbNodes()
          Get the number of non text children nodes.
 java.util.List<XmlParser.Node> getNodes(java.lang.String tag)
          Get the child nodes with the tag.
 XmlParser.Node getParent()
           
 java.lang.String getTag()
           
 int hashCode()
           
 void print(java.io.PrintWriter printer)
          Print this node using the specified printer.
 void removeAttribute(java.lang.String attributeName)
           
 void removeElement(int index)
          Removes the element at the specified position in this list (optional operation).
 void removeElement(XmlParser.Node o)
          Inserts the specified element at the specified position in this list (optional operation).
 void setElement(int index, java.lang.Object element)
          Replaces the element at the specified position in this list with the specified element (optional operation).
 int size()
          Get the number of children nodes.
 java.lang.String toString()
           
 
Methods inherited from class java.util.AbstractList
add, addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

aList

public java.util.List<java.lang.Object> aList
Nodes


aTag

public java.lang.String aTag
Tag name.


aAttrs

public XmlParser.Attribute[] aAttrs
Attributes


aLastString

public boolean aLastString
Is the last object is a string.

Constructor Detail

XmlParser.Node

public XmlParser.Node(XmlParser.Node parent,
                      java.lang.String tag,
                      org.xml.sax.Attributes attrs)
Create a new instance of this class.

Parameters:
parent - parent node.
tag - tag name.
attrs - attributes
Method Detail

addFirstAttribute

public void addFirstAttribute(XmlParser.Attribute attr)
Parameters:
attr - attribute to add.

removeAttribute

public void removeAttribute(java.lang.String attributeName)
Parameters:
attributeName - the attribute to remove.

addAttribute

public void addAttribute(XmlParser.Attribute attr)
Parameters:
attr - attribute to add.

getParent

public XmlParser.Node getParent()
Returns:
parent

getTag

public java.lang.String getTag()
Returns:
tag

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Get an element attribute.

Parameters:
name - the attribute name.
Returns:
attribute or null.

getAttribute

public java.lang.String getAttribute(java.lang.String name,
                                     java.lang.String dft)
Get an element attribute.

Parameters:
name - the attribute name.
dft - the default value.
Returns:
attribute or null.

size

public int size()
Get the number of children nodes.

Specified by:
size in interface java.util.Collection<java.lang.Object>
Specified by:
size in interface java.util.List<java.lang.Object>
Specified by:
size in class java.util.AbstractCollection<java.lang.Object>
Returns:
size

getNbNodes

public int getNbNodes()
Get the number of non text children nodes.

Returns:
the number of non text children nodes.

get

public java.lang.Object get(int i)
Get the ith child node or content.

Specified by:
get in interface java.util.List<java.lang.Object>
Specified by:
get in class java.util.AbstractList<java.lang.Object>
Parameters:
i - index of node.
Returns:
Node or String.

get

public XmlParser.Node get(java.lang.String tag)
Get the first child node with the tag.

Parameters:
tag - the tag name of node.
Returns:
Node or null.

getNodes

public java.util.List<XmlParser.Node> getNodes(java.lang.String tag)
Get the child nodes with the tag.

Parameters:
tag - the tag name of node.
Returns:
list of nodes or null.

add

public void add(int i,
                java.lang.Object o)
Specified by:
add in interface java.util.List<java.lang.Object>
Overrides:
add in class java.util.AbstractList<java.lang.Object>

removeElement

public void removeElement(XmlParser.Node o)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

This implementation always throws an UnsupportedOperationException.

Parameters:
o - element to be inserted.

removeElement

public void removeElement(int index)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters:
index - the index of the element to removed.

setElement

public void setElement(int index,
                       java.lang.Object element)
Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters:
index - index of element to replace.
element - element to be stored at the specified position.

clear

public void clear()
Specified by:
clear in interface java.util.Collection<java.lang.Object>
Specified by:
clear in interface java.util.List<java.lang.Object>
Overrides:
clear in class java.util.AbstractList<java.lang.Object>

print

public void print(java.io.PrintWriter printer)
Print this node using the specified printer.

Parameters:
printer - used printer to add this node.

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<java.lang.Object>

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Collection<java.lang.Object>
Specified by:
equals in interface java.util.List<java.lang.Object>
Overrides:
equals in class java.util.AbstractList<java.lang.Object>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<java.lang.Object>
Specified by:
hashCode in interface java.util.List<java.lang.Object>
Overrides:
hashCode in class java.util.AbstractList<java.lang.Object>


Copyright © 2003-2007 Magic-Project. All Rights Reserved.