@TODO(note="Make it a bit lighter.") public class Element extends Object implements XMLNodeIfc<Element>
Element
- basic document tree node implementation. Supports Java
5.0 generic feature to make it easier to extend this class and still preserve
some useful functionality. Sufficient for simple cases but probably in the
most more advanced cases should be extended with additional features. Look in
API documentation for more details and information about existing extensions.
The most important features apart from abvious tree implementation are:
toString()
implementation so it can generate valid
XML content from this element and all children.addChild(...)
, getChild(childName)
supporting
generic types.findChild(childPath)
finding child in subtree by given path
to element.getChildCData(childPath)
, getAttribute(childPath,
attName)
returning element CData from child in subtree by given
path to element.Created: Mon Oct 4 17:55:16 2004
Modifier and Type | Class and Description |
---|---|
static interface |
Element.Matcher<T> |
protected class |
Element.XMLIdentityHashMap<K,V> |
Modifier and Type | Field and Description |
---|---|
protected Element.XMLIdentityHashMap<String,String> |
attributes
Field description
|
protected LinkedList<XMLNodeIfc> |
children
Field description
|
protected String |
defxmlns
Field description
|
protected String |
name
Field description
|
protected String |
xmlns
Field description
|
Constructor and Description |
---|
Element(Element element) |
Element(String argName) |
Element(String argName,
Element[] children,
String[] att_names,
String[] att_values) |
Element(String argName,
String argCData) |
Element(String argName,
String[] att_names,
String[] att_values) |
Element(String argName,
String argCData,
String[] att_names,
String[] att_values) |
Element(String argName,
String argCData,
StringBuilder[] att_names,
StringBuilder[] att_values) |
protected Element.XMLIdentityHashMap<String,String> attributes
protected LinkedList<XMLNodeIfc> children
protected String defxmlns
protected String name
protected String xmlns
public Element(Element element)
public Element(String argName)
public Element(String argName, String argCData, StringBuilder[] att_names, StringBuilder[] att_values)
public void addCData(String argCData)
public void addChild(XMLNodeIfc child)
public String childrenToString()
public void childrenToString(StringBuilder result)
public String childrenToStringPretty()
public String childrenToStringSecure()
public void childrenToStringSecure(StringBuilder result)
public Element clone()
clone
in interface XMLNodeIfc<Element>
clone
in class Object
public int compareTo(Element elem)
compareTo
in interface Comparable<Element>
@Deprecated public Element findChild(String elementPath)
findChild(java.lang.String[])
instead.public Element findChild(Element.Matcher<Element> matcher)
public List<Element> findChildren(Element.Matcher<Element> matcher)
public <R> List<R> flatMapChildren(java.util.function.Function<Element,Collection<? extends R>> mapper)
public void forEachChild(java.util.function.Consumer<Element> consumer)
@Deprecated public String getAttribute(String attName)
getAttributeStaticStr(java.lang.String)
instead.@Deprecated public String getChildAttribute(String childName, String attName)
getChildAttributeStaticStr(java.lang.String, java.lang.String)
instead.public String getChildAttributeStaticStr(String childName, String attName)
@Deprecated public String getAttribute(String elementPath, String att_name)
getAttributeStaticStr(java.lang.String[], java.lang.String)
instead.@Deprecated public String getAttribute(String[] elementPath, String att_name)
getAttributeStaticStr(java.lang.String[], java.lang.String)
instead.@Deprecated public String getCData(String elementPath)
getCData(java.lang.String[])
instead.public String getCData()
@Deprecated public String getChildCData(String elementPath)
getCData(java.lang.String[])
instead.public String getChildCData(Element.Matcher<Element> matcher)
@Deprecated public List<Element> getChildren(String elementPath)
getChildren(java.lang.String[])
instead.public List<Element> getChildren(Element.Matcher<Element> matcher)
public String getName()
public String getXMLNS()
@Deprecated public String getXMLNS(String elementPath)
getXMLNS(java.lang.String[])
instead.public <R> R map(java.util.function.Function<Element,? extends R> mapper)
public <R> List<R> mapChildren(java.util.function.Function<Element,? extends R> mapper)
public <R> List<R> mapChildren(Element.Matcher<Element> matcher, java.util.function.Function<Element,? extends R> mapper)
public boolean matches(Element.Matcher<Element> matcher)
public void removeAttribute(String key)
public boolean removeChild(Element child)
public void setAttributeStaticStr(String[] elementPath, String att_name, String att_value)
public void setAttributes(StringBuilder[] names, StringBuilder[] values)
public void setCData(String argCData)
public void setChildren(List<XMLNodeIfc> children)
public void setDefXMLNS(String ns)
public void setName(String argName)
public void setXMLNS(String ns)
public void toString(StringBuilder result)
public String toStringPretty()
toStringPretty
in interface XMLNodeIfc<Element>
public String toStringNoChildren()
public String toStringSecure()
toStringSecure
in interface XMLNodeIfc<Element>
public void toStringSecure(StringBuilder result)
protected String cdataToString()
Copyright © 2017 "Tigase, Inc.". All rights reserved.