Package org.eclipse.jetty.xml
Class XmlParser.Node
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<java.lang.Object>
-
- org.eclipse.jetty.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
Fields Modifier and Type Field Description private XmlParser.Attribute[]
_attrs
private boolean
_lastString
private java.util.ArrayList<java.lang.Object>
_list
(package private) XmlParser.Node
_parent
private java.lang.String
_path
private java.lang.String
_tag
-
Constructor Summary
Constructors Constructor Description Node(XmlParser.Node parent, java.lang.String tag, org.xml.sax.Attributes attrs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int i, java.lang.Object o)
void
clear()
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.XmlParser.Attribute[]
getAttributes()
Get an array of element attributes.XmlParser.Node
getParent()
java.lang.String
getPath()
java.lang.String
getString(java.lang.String tag, boolean tags, boolean trim)
Get a tag as a string.java.lang.String
getTag()
java.util.Iterator<XmlParser.Node>
iterator(java.lang.String tag)
Iterator over named child nodes.int
size()
Get the number of children nodes.java.lang.String
toString()
java.lang.String
toString(boolean tag)
Convert to a string.java.lang.String
toString(boolean tag, boolean trim)
Convert to a string.private void
toString(java.lang.StringBuilder buf, boolean tag)
-
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
_parent
XmlParser.Node _parent
-
_list
private java.util.ArrayList<java.lang.Object> _list
-
_tag
private java.lang.String _tag
-
_attrs
private XmlParser.Attribute[] _attrs
-
_lastString
private boolean _lastString
-
_path
private java.lang.String _path
-
-
Constructor Detail
-
Node
Node(XmlParser.Node parent, java.lang.String tag, org.xml.sax.Attributes attrs)
-
-
Method Detail
-
getParent
public XmlParser.Node getParent()
-
getTag
public java.lang.String getTag()
-
getPath
public java.lang.String getPath()
-
getAttributes
public XmlParser.Attribute[] getAttributes()
Get an array of element attributes.- Returns:
- the attributes
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Get an element attribute.- Parameters:
name
- the name of the attribute- 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 name of the elementdft
- the default value- Returns:
- attribute or null.
-
size
public int size()
Get the number of children nodes.- Specified by:
size
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
size
in interfacejava.util.List<java.lang.Object>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Object>
-
get
public java.lang.Object get(int i)
Get the ith child node or content.- Specified by:
get
in interfacejava.util.List<java.lang.Object>
- Specified by:
get
in classjava.util.AbstractList<java.lang.Object>
- Returns:
- Node or String.
-
get
public XmlParser.Node get(java.lang.String tag)
Get the first child node with the tag.- Parameters:
tag
- the name of the tag- Returns:
- Node or null.
-
add
public void add(int i, java.lang.Object o)
- Specified by:
add
in interfacejava.util.List<java.lang.Object>
- Overrides:
add
in classjava.util.AbstractList<java.lang.Object>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<java.lang.Object>
- Specified by:
clear
in interfacejava.util.List<java.lang.Object>
- Overrides:
clear
in classjava.util.AbstractList<java.lang.Object>
-
getString
public java.lang.String getString(java.lang.String tag, boolean tags, boolean trim)
Get a tag as a string.- Parameters:
tag
- The tag to gettags
- IF true, tags are included in the value.trim
- If true, trim the value.- Returns:
- results of get(tag).toString(tags).
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<java.lang.Object>
-
toString
public java.lang.String toString(boolean tag)
Convert to a string.- Parameters:
tag
- If false, only _content is shown.- Returns:
- the string value
-
toString
public java.lang.String toString(boolean tag, boolean trim)
Convert to a string.- Parameters:
tag
- If false, only _content is shown.trim
- true to trim the content- Returns:
- the trimmed content
-
toString
private void toString(java.lang.StringBuilder buf, boolean tag)
-
iterator
public java.util.Iterator<XmlParser.Node> iterator(java.lang.String tag)
Iterator over named child nodes.- Parameters:
tag
- The tag of the nodes.- Returns:
- Iterator over all child nodes with the specified tag.
-
-