Package tigase.xml
Class Element
- java.lang.Object
-
- tigase.xml.Element
-
- All Implemented Interfaces:
Cloneable,Comparable<Element>,XMLNodeIfc<Element>
- Direct Known Subclasses:
DBElement
@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
- Version:
- $Rev$
- Author:
- Artur Hefczyc
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceElement.Matcher<T>protected classElement.XMLIdentityHashMap<K,V>
-
Field Summary
Fields Modifier and Type Field Description protected Element.XMLIdentityHashMap<String,String>attributesprotected LinkedList<XMLNodeIfc>childrenprotected Stringdefxmlnsprotected Stringnameprotected Stringxmlns
-
Constructor Summary
Constructors Constructor Description Element(String argName)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)Element(String argName, Element[] children, String[] att_names, String[] att_values)Element(Element element)
-
Method Summary
-
-
-
Field Detail
-
attributes
protected Element.XMLIdentityHashMap<String,String> attributes
-
children
protected LinkedList<XMLNodeIfc> children
-
defxmlns
protected String defxmlns
-
name
protected String name
-
xmlns
protected String xmlns
-
-
Constructor Detail
-
Element
public Element(Element element)
-
Element
public Element(String argName)
-
Element
public Element(String argName, Element[] children, String[] att_names, String[] att_values)
-
Element
public Element(String argName, String argCData, StringBuilder[] att_names, StringBuilder[] att_values)
-
-
Method Detail
-
addCData
public void addCData(String argCData)
-
addChild
public void addChild(XMLNodeIfc child)
-
childrenToString
public String childrenToString()
-
childrenToString
public void childrenToString(StringBuilder result)
-
childrenToStringPretty
public String childrenToStringPretty()
-
childrenToStringSecure
public String childrenToStringSecure()
-
childrenToStringSecure
public void childrenToStringSecure(StringBuilder result)
-
clone
public Element clone()
- Specified by:
clonein interfaceXMLNodeIfc<Element>- Overrides:
clonein classObject
-
compareTo
public int compareTo(Element elem)
- Specified by:
compareToin interfaceComparable<Element>
-
findChild
@Deprecated public Element findChild(String elementPath)
Deprecated.usefindChild(java.lang.String[])instead.- Parameters:
elementPath-- Returns:
- an Element
-
findChild
public Element findChild(Element.Matcher<Element> matcher)
-
findChildren
public List<Element> findChildren(Element.Matcher<Element> matcher)
-
flatMapChildren
public <R> List<R> flatMapChildren(Function<Element,Collection<? extends R>> mapper)
-
getAttribute
@Deprecated public String getAttribute(String attName)
Deprecated.usegetAttributeStaticStr(java.lang.String)instead.
-
getChildAttribute
@Deprecated public String getChildAttribute(String childName, String attName)
Deprecated.
-
getChildAttributeStaticStr
public String getChildAttributeStaticStr(String childName, String attName)
-
getAttribute
@Deprecated public String getAttribute(String elementPath, String att_name)
Deprecated.
-
getAttribute
@Deprecated public String getAttribute(String[] elementPath, String att_name)
Deprecated.
-
getCData
@Deprecated public String getCData(String elementPath)
Deprecated.usegetCData(java.lang.String[])instead.
-
getCData
public String getCData()
-
setCData
public void setCData(String argCData)
-
getChildCData
@Deprecated public String getChildCData(String elementPath)
Deprecated.usegetCData(java.lang.String[])instead.
-
getChildCData
public String getChildCData(Element.Matcher<Element> matcher)
-
setChildren
public void setChildren(List<XMLNodeIfc> children)
-
getChildren
@Deprecated public List<Element> getChildren(String elementPath)
Deprecated.usegetChildren(java.lang.String[])instead.
-
getChildren
public List<Element> getChildren(Element.Matcher<Element> matcher)
-
getName
public String getName()
-
setName
public void setName(String argName)
-
getXMLNS
public String getXMLNS()
-
setXMLNS
public void setXMLNS(String ns)
-
getXMLNS
@Deprecated public String getXMLNS(String elementPath)
Deprecated.usegetXMLNS(java.lang.String[])instead.
-
mapChildren
public <R> List<R> mapChildren(Element.Matcher<Element> matcher, Function<Element,? extends R> mapper)
-
matches
public boolean matches(Element.Matcher<Element> matcher)
-
removeAttribute
public void removeAttribute(String key)
-
removeChild
public boolean removeChild(Element child)
-
setAttributeStaticStr
public void setAttributeStaticStr(String[] elementPath, String att_name, String att_value)
-
setAttributes
public void setAttributes(StringBuilder[] names, StringBuilder[] values)
-
setDefXMLNS
public void setDefXMLNS(String ns)
-
toString
public void toString(StringBuilder result)
-
toStringPretty
public String toStringPretty()
- Specified by:
toStringPrettyin interfaceXMLNodeIfc<Element>
-
toStringNoChildren
public String toStringNoChildren()
-
toStringSecure
public String toStringSecure()
- Specified by:
toStringSecurein interfaceXMLNodeIfc<Element>
-
toStringSecure
public void toStringSecure(StringBuilder result)
-
cdataToString
protected String cdataToString()
-
-