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 and Description
    --- | ---
    `static interface` | `Element.Matcher<T>`
    `protected class` | `Element.XMLIdentityHashMap<K,V>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Element.XMLIdentityHashMap<String,String>` | `attributes`
    `protected LinkedList<XMLNodeIfc>` | `children`
    `protected String` | `defxmlns`
    `protected String` | `name`
    `protected String` | `xmlns`

  - ### Constructor Summary

    Constructors
    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)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttribute(String attName, String attValue)`
    `void` | `addAttributes(Map<String,String> attrs)`
    `void` | `addCData(String argCData)`
    `void` | `addChild(XMLNodeIfc child)`
    `void` | `addChildren(List<Element> children)`
    `protected String` | `cdataToString()`
    `String` | `childrenToString()`
    `void` | `childrenToString(StringBuilder result)`
    `String` | `childrenToStringPretty()`
    `String` | `childrenToStringSecure()`
    `void` | `childrenToStringSecure(StringBuilder result)`
    `Element` | `clone()`
    `int` | `compareTo(Element elem)`
    `boolean` | `equals(Object obj)`
    `Element` | `findChild(Element.Matcher<Element> matcher)`
    `Element` | `findChild(String elementPath)` Deprecated. use `findChild(java.lang.String[])` instead.
    `Element` | `findChild(String[] elemPath)`
    `List<Element>` | `findChildren(Element.Matcher<Element> matcher)`
    `Element` | `findChildStaticStr(String[] elementPath)`
    `<R> List<R>` | `flatMapChildren(Function<Element,Collection<? extends R>> mapper)`
    `void` | `forEachChild(Consumer<Element> consumer)`
    `String` | `getAttribute(String attName)` Deprecated. use `getAttributeStaticStr(java.lang.String)` instead.
    `String` | `getAttribute(String[] elementPath, String att_name)` Deprecated. `getAttributeStaticStr(java.lang.String[], java.lang.String)` instead.
    `String` | `getAttribute(String elementPath, String att_name)` Deprecated. use `getAttributeStaticStr(java.lang.String[], java.lang.String)` instead.
    `Map<String,String>` | `getAttributes()`
    `String` | `getAttributeStaticStr(String attName)`
    `String` | `getAttributeStaticStr(String[] elementPath, String att_name)`
    `String` | `getCData()`
    `String` | `getCData(String elementPath)` Deprecated. use `getCData(java.lang.String[])` instead.
    `String` | `getCData(String[] elementPath)`
    `String` | `getCDataStaticStr(String[] elementPath)`
    `Element` | `getChild(String name)`
    `Element` | `getChild(String name, String child_xmlns)`
    `String` | `getChildAttribute(String childName, String attName)` Deprecated. use `getChildAttributeStaticStr(java.lang.String, java.lang.String)` instead.
    `String` | `getChildAttributeStaticStr(String childName, String attName)`
    `String` | `getChildCData(Element.Matcher<Element> matcher)`
    `String` | `getChildCData(String elementPath)` Deprecated. use `getCData(java.lang.String[])` instead.
    `String` | `getChildCData(String[] elementPath)`
    `String` | `getChildCDataStaticStr(String[] elementPath)`
    `List<Element>` | `getChildren()`
    `List<Element>` | `getChildren(Element.Matcher<Element> matcher)`
    `List<Element>` | `getChildren(String elementPath)` Deprecated. use `getChildren(java.lang.String[])` instead.
    `List<Element>` | `getChildren(String[] elementPath)`
    `List<Element>` | `getChildrenStaticStr(String[] elementPath)`
    `Element` | `getChildStaticStr(String name)`
    `Element` | `getChildStaticStr(String name, String child_xmlns)`
    `String` | `getName()`
    `String` | `getXMLNS()`
    `String` | `getXMLNS(String elementPath)` Deprecated. use `getXMLNS(java.lang.String[])` instead.
    `String` | `getXMLNS(String[] elementPath)`
    `String` | `getXMLNSStaticStr(String[] elementPath)`
    `int` | `hashCode()`
    `static void` | `main(String[] args)`
    `<R> R` | `map(Function<Element,? extends R> mapper)`
    `<R> List<R>` | `mapChildren(Element.Matcher<Element> matcher, Function<Element,? extends R> mapper)`
    `<R> List<R>` | `mapChildren(Function<Element,? extends R> mapper)`
    `boolean` | `matches(Element.Matcher<Element> matcher)`
    `void` | `removeAttribute(String key)`
    `boolean` | `removeChild(Element child)`
    `void` | `setAttribute(String key, String value)`
    `void` | `setAttributes(Map<String,String> newAttributes)`
    `void` | `setAttributes(String[] names, String[] values)`
    `void` | `setAttributes(StringBuilder[] names, StringBuilder[] values)`
    `void` | `setAttributeStaticStr(String[] elementPath, String att_name, String att_value)`
    `void` | `setCData(String argCData)`
    `void` | `setChildren(List<XMLNodeIfc> children)`
    `void` | `setDefXMLNS(String ns)`
    `void` | `setName(String argName)`
    `void` | `setXMLNS(String ns)`
    `String` | `toString()`
    `void` | `toString(StringBuilder result)`
    `String` | `toStringNoChildren()`
    `String` | `toStringPretty()`
    `String` | `toStringSecure()`
    `void` | `toStringSecure(StringBuilder result)`
    `Element` | `withAttribute(String attName, String attValue)`
    `Element` | `withElement(String name, Consumer<Element> consumer)`
    `Element` | `withElement(String name, String xmlns, Consumer<Element> consumer)`
    `Element` | `withElement(String name, String xmlns, String cdata)`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 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,
                         String argCData)

    - #### Element

          public Element(String argName,
                         String[] att_names,
                         String[] att_values)

    - #### Element

          public Element(String argName,
                         Element[] children,
                         String[] att_names,
                         String[] att_values)

    - #### Element

          public Element(String argName,
                         String argCData,
                         String[] att_names,
                         String[] att_values)

    - #### Element

          public Element(String argName,
                         String argCData,
                         StringBuilder[] att_names,
                         StringBuilder[] att_values)

  - ### Method Detail

    - #### main

          public static void main(String[] args)
                           throws Exception

      Throws:
        `Exception`

    - #### addAttribute

          public void addAttribute(String attName,
                                   String attValue)

    - #### addAttributes

          public void addAttributes(Map<String,String> attrs)

    - #### addCData

          public void addCData(String argCData)

    - #### addChild

          public void addChild(XMLNodeIfc child)

    - #### addChildren

          public void addChildren(List<Element> children)

    - #### 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:
        `clone` in interface `XMLNodeIfc<Element>`
      Overrides:
        `clone` in class `Object`

    - #### compareTo

          public int compareTo(Element elem)

      Specified by:
        `compareTo` in interface `Comparable<Element>`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### findChildStaticStr

          public Element findChildStaticStr(String[] elementPath)

    - #### findChild

          public Element findChild(String[] elemPath)

    - #### findChild

          @Deprecated
          public Element findChild(String elementPath)

      Deprecated. use `findChild(java.lang.String[])` instead.

    - #### 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)

    - #### forEachChild

          public void forEachChild(Consumer<Element> consumer)

    - #### getAttribute

          @Deprecated
          public String getAttribute(String attName)

      Deprecated. use `getAttributeStaticStr(java.lang.String)` instead.

    - #### getChildAttribute

          @Deprecated
          public String getChildAttribute(String childName,
                                                      String attName)

      Deprecated. use `getChildAttributeStaticStr(java.lang.String, java.lang.String)` instead.

    - #### getChildAttributeStaticStr

          public String getChildAttributeStaticStr(String childName,
                                                   String attName)

    - #### getAttributeStaticStr

          public String getAttributeStaticStr(String attName)

    - #### getAttribute

          @Deprecated
          public String getAttribute(String elementPath,
                                                 String att_name)

      Deprecated. use `getAttributeStaticStr(java.lang.String[], java.lang.String)` instead.

    - #### getAttribute

          @Deprecated
          public String getAttribute(String[] elementPath,
                                                 String att_name)

      Deprecated. `getAttributeStaticStr(java.lang.String[], java.lang.String)` instead.

    - #### getAttributeStaticStr

          public String getAttributeStaticStr(String[] elementPath,
                                              String att_name)

    - #### getAttributes

          public Map<String,String> getAttributes()

    - #### setAttributes

          public void setAttributes(Map<String,String> newAttributes)

    - #### getCData

          @Deprecated
          public String getCData(String elementPath)

      Deprecated. use `getCData(java.lang.String[])` instead.

    - #### getCData

          public String getCData(String[] elementPath)

    - #### getCDataStaticStr

          public String getCDataStaticStr(String[] elementPath)

    - #### getCData

          public String getCData()

    - #### setCData

          public void setCData(String argCData)

    - #### getChild

          public Element getChild(String name)

    - #### getChildStaticStr

          public Element getChildStaticStr(String name)

    - #### getChild

          public Element getChild(String name,
                                  String child_xmlns)

    - #### getChildStaticStr

          public Element getChildStaticStr(String name,
                                           String child_xmlns)

    - #### getChildCData

          @Deprecated
          public String getChildCData(String elementPath)

      Deprecated. use `getCData(java.lang.String[])` instead.

    - #### getChildCData

          public String getChildCData(String[] elementPath)

    - #### getChildCDataStaticStr

          public String getChildCDataStaticStr(String[] elementPath)

    - #### getChildCData

          public String getChildCData(Element.Matcher<Element> matcher)

    - #### getChildren

          public List<Element> getChildren()

    - #### setChildren

          public void setChildren(List<XMLNodeIfc> children)

    - #### getChildren

          @Deprecated
          public List<Element> getChildren(String elementPath)

      Deprecated. use `getChildren(java.lang.String[])` instead.

    - #### getChildren

          public List<Element> getChildren(String[] elementPath)

    - #### getChildrenStaticStr

          public List<Element> getChildrenStaticStr(String[] elementPath)

    - #### 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. use `getXMLNS(java.lang.String[])` instead.

    - #### getXMLNS

          public String getXMLNS(String[] elementPath)

    - #### getXMLNSStaticStr

          public String getXMLNSStaticStr(String[] elementPath)

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### map

          public <R> R map(Function<Element,? extends R> mapper)

    - #### mapChildren

          public <R> List<R> mapChildren(Function<Element,? extends R> mapper)

    - #### 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)

    - #### setAttribute

          public void setAttribute(String key,
                                   String value)

    - #### setAttributes

          public void setAttributes(StringBuilder[] names,
                                    StringBuilder[] values)

    - #### setAttributes

          public void setAttributes(String[] names,
                                    String[] values)

    - #### setDefXMLNS

          public void setDefXMLNS(String ns)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toString

          public void toString(StringBuilder result)

    - #### toStringPretty

          public String toStringPretty()

      Specified by:
        `toStringPretty` in interface `XMLNodeIfc<Element>`

    - #### toStringNoChildren

          public String toStringNoChildren()

    - #### toStringSecure

          public String toStringSecure()

      Specified by:
        `toStringSecure` in interface `XMLNodeIfc<Element>`

    - #### toStringSecure

          public void toStringSecure(StringBuilder result)

    - #### withAttribute

          public Element withAttribute(String attName,
                                       String attValue)

    - #### withElement

          public Element withElement(String name,
                                     Consumer<Element> consumer)

    - #### withElement

          public Element withElement(String name,
                                     String xmlns,
                                     String cdata)

    - #### withElement

          public Element withElement(String name,
                                     String xmlns,
                                     Consumer<Element> consumer)

    - #### cdataToString

          protected String cdataToString()

Copyright © 2004–2021 "Tigase, Inc.". All rights reserved.