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 ClassesModifier and TypeClassDescriptionstatic interfaceprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Element.XMLIdentityHashMap<String, String> protected LinkedList<XMLNodeIfc> protected Stringprotected Stringprotected String -
Constructor Summary
ConstructorsConstructorDescriptionElement(String argName, String argCData, StringBuilder[] att_names, StringBuilder[] att_values) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String attName, String attValue) voidaddAttributes(Map<String, String> attrs) voidvoidaddChild(XMLNodeIfc child) voidaddChildren(List<Element> children) protected StringvoidchildrenToString(StringBuilder result) voidchildrenToStringSecure(StringBuilder result) clone()intbooleanDeprecated.findChild(Element.Matcher<Element> matcher) findChildren(Element.Matcher<Element> matcher) findChildStaticStr(String[] elementPath) <R> List<R> flatMapChildren(Function<Element, Collection<? extends R>> mapper) voidforEachChild(Consumer<Element> consumer) getAttribute(String attName) Deprecated.usegetAttributeStaticStr(java.lang.String)instead.getAttribute(String[] elementPath, String att_name) Deprecated.getAttribute(String elementPath, String att_name) Deprecated.getAttributeStaticStr(String attName) getAttributeStaticStr(String[] elementPath, String att_name) getCData()Deprecated.usegetCData(java.lang.String[])instead.getCDataStaticStr(String[] elementPath) getChildAttribute(String childName, String attName) Deprecated.getChildAttributeStaticStr(String childName, String attName) getChildCData(String elementPath) Deprecated.usegetCData(java.lang.String[])instead.getChildCData(String[] elementPath) getChildCData(Element.Matcher<Element> matcher) getChildCDataStaticStr(String[] elementPath) getChildren(String elementPath) Deprecated.usegetChildren(java.lang.String[])instead.getChildren(String[] elementPath) getChildren(Element.Matcher<Element> matcher) getChildrenStaticStr(String[] elementPath) getChildStaticStr(String name) getChildStaticStr(String name, String child_xmlns) getName()getXMLNS()Deprecated.usegetXMLNS(java.lang.String[])instead.getXMLNSStaticStr(String[] elementPath) inthashCode()static void<R> R<R> List<R> mapChildren(Function<Element, ? extends R> mapper) <R> List<R> mapChildren(Element.Matcher<Element> matcher, Function<Element, ? extends R> mapper) booleanmatches(Element.Matcher<Element> matcher) voidremoveAttribute(String key) booleanremoveChild(Element child) voidsetAttribute(String key, String value) voidsetAttributes(String[] names, String[] values) voidsetAttributes(StringBuilder[] names, StringBuilder[] values) voidsetAttributes(Map<String, String> newAttributes) voidsetAttributeStaticStr(String[] elementPath, String att_name, String att_value) voidvoidsetChildren(List<XMLNodeIfc> children) voidsetDefXMLNS(String ns) voidvoidtoString()voidtoString(StringBuilder result) voidtoStringSecure(StringBuilder result) withAttribute(String attName, String attValue) withElement(String name, String xmlns, String cdata) withElement(String name, String xmlns, Consumer<Element> consumer) withElement(String name, Consumer<Element> consumer)
-
Field Details
-
attributes
-
children
-
defxmlns
-
name
-
xmlns
-
-
Constructor Details
-
Element
-
Element
-
Element
-
Element
-
Element
-
Element
-
Element
public Element(String argName, String argCData, StringBuilder[] att_names, StringBuilder[] att_values)
-
-
Method Details
-
main
- Throws:
Exception
-
addAttribute
-
addAttributes
-
addCData
-
addChild
-
addChildren
-
childrenToString
-
childrenToString
-
childrenToStringPretty
-
childrenToStringSecure
-
childrenToStringSecure
-
clone
- Specified by:
clonein interfaceXMLNodeIfc<Element>- Overrides:
clonein classObject
-
compareTo
- Specified by:
compareToin interfaceComparable<Element>
-
equals
-
findChildStaticStr
-
findChild
-
findChild
Deprecated.usefindChild(java.lang.String[])instead. -
findChild
-
findChildren
-
flatMapChildren
-
forEachChild
-
getAttribute
Deprecated.usegetAttributeStaticStr(java.lang.String)instead. -
getChildAttribute
Deprecated. -
getChildAttributeStaticStr
-
getAttributeStaticStr
-
getAttribute
Deprecated. -
getAttribute
Deprecated. -
getAttributeStaticStr
-
getAttributes
-
setAttributes
-
getCData
Deprecated.usegetCData(java.lang.String[])instead. -
getCData
-
getCDataStaticStr
-
getCData
-
setCData
-
getChild
-
getChildStaticStr
-
getChild
-
getChildStaticStr
-
getChildCData
Deprecated.usegetCData(java.lang.String[])instead. -
getChildCData
-
getChildCDataStaticStr
-
getChildCData
-
getChildren
-
setChildren
-
getChildren
Deprecated.usegetChildren(java.lang.String[])instead. -
getChildren
-
getChildrenStaticStr
-
getChildren
-
getName
-
setName
-
getXMLNS
-
setXMLNS
-
getXMLNS
Deprecated.usegetXMLNS(java.lang.String[])instead. -
getXMLNS
-
getXMLNSStaticStr
-
hashCode
public int hashCode() -
map
-
mapChildren
-
mapChildren
public <R> List<R> mapChildren(Element.Matcher<Element> matcher, Function<Element, ? extends R> mapper) -
matches
-
removeAttribute
-
removeChild
-
setAttributeStaticStr
-
setAttribute
-
setAttributes
-
setAttributes
-
setDefXMLNS
-
toString
-
toString
-
toStringPretty
- Specified by:
toStringPrettyin interfaceXMLNodeIfc<Element>
-
toStringNoChildren
-
toStringSecure
- Specified by:
toStringSecurein interfaceXMLNodeIfc<Element>
-
toStringSecure
-
withAttribute
-
withElement
-
withElement
-
withElement
-
cdataToString
-
findChild(java.lang.String[])instead.