tigase.jaxmpp.core.client.xml

## Class DefaultElement

- java.lang.Object
- - tigase.jaxmpp.core.client.xml.DefaultElement

- All Implemented Interfaces:
    Element
  Direct Known Subclasses:
    ParcelableElement

      public class DefaultElement
      extends Object
      implements Element

  Default implementation of XML Element object. This class should be used every time when new XML Element is created.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DefaultElement(String name)`
    `protected` | `DefaultElement(String name, String value, String xmlns)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Element` | `addChild(Element child)` Add child element to tree and return the added element.
    `boolean` | `equals(Object obj)`
    `Element` | `findChild(String[] elemPath)`
    `String` | `getAsString()` Get this element as XML string.
    `String` | `getAttribute(String attName)` Get attribute by name.
    `Map<String,String>` | `getAttributes()` Get all attributes as a Map.
    `Element` | `getChildAfter(Element child)` Gets the first child after specified child in children list.
    `List<Element>` | `getChildren()` Get all children of the element.
    `List<Element>` | `getChildren(String name)` Get children by name.
    `List<Element>` | `getChildrenNS(String xmlns)` Get children by namespace.
    `Element` | `getChildrenNS(String name, String xmlns)` Get children by namespace.
    `Element` | `getFirstChild()` Get the first child element of this element.
    `Element` | `getFirstChild(String name)`
    `String` | `getName()` Get name of this element.
    `Element` | `getNextSibling()` Get next sibling to this element or null if no parent or no more siblings exist.
    `Element` | `getParent()` Get parent element of this element.
    `String` | `getValue()` Get element value.
    `String` | `getXMLNS()` Get namespace of this element. traverses up to find actual namespace.
    `int` | `hashCode()`
    `void` | `removeAttribute(String key)` Remove attribute from element.
    `void` | `removeChild(Element child)` Remove child from element.
    `void` | `setAttribute(String key, String value)` Set value of attribute.
    `void` | `setAttributes(Map<String,String> attrs)` Set a number of attributes.
    `void` | `setParent(Element parent)` Set element parent.
    `void` | `setValue(String value)` Set value of this element.
    `void` | `setXMLNS(String xmlns)` Change the namespace of this element.

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

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultElement

          protected DefaultElement(String name)

    - #### DefaultElement

          protected DefaultElement(String name,
                                   String value,
                                   String xmlns)

  - ### Method Detail

    - #### addChild

          public Element addChild(Element child)
                           throws XMLException

      Description copied from interface: `Element`
      Add child element to tree and return the added element.
      Specified by:
        `addChild` in interface `Element`
      Parameters:
        `child` - Child to add.
      Returns:
        Added child element.
      Throws:
        `XMLException`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### findChild

          public Element findChild(String[] elemPath)
                            throws XMLException

      Specified by:
        `findChild` in interface `Element`
      Throws:
        `XMLException`

    - #### getAsString

          public String getAsString()
                             throws XMLException

      Description copied from interface: `Element`
      Get this element as XML string.
      Specified by:
        `getAsString` in interface `Element`
      Returns:
        The normalized XML describing this element.
      Throws:
        `XMLException`

    - #### getAttribute

          public String getAttribute(String attName)
                              throws XMLException

      Description copied from interface: `Element`
      Get attribute by name.
      Specified by:
        `getAttribute` in interface `Element`
      Parameters:
        `attName` - Name of attribute to fetch.
      Returns:
        Attribute value or null if no such element exist.
      Throws:
        `XMLException`

    - #### getAttributes

          public Map<String,String> getAttributes()
                                           throws XMLException

      Description copied from interface: `Element`
      Get all attributes as a Map.
      Specified by:
        `getAttributes` in interface `Element`
      Returns:
        Element's attributes.
      Throws:
        `XMLException`

    - #### getChildAfter

          public Element getChildAfter(Element child)
                                throws XMLException

      Description copied from interface: `Element`
      Gets the first child after specified child in children list. Only to be used internally.
      Specified by:
        `getChildAfter` in interface `Element`
      Parameters:
        `child` - The child to look up.
      Returns:
        The child after specific child.
      Throws:
        `XMLException`

    - #### getChildren

          public List<Element> getChildren()
                                    throws XMLException

      Description copied from interface: `Element`
      Get all children of the element.
      Specified by:
        `getChildren` in interface `Element`
      Returns:
        A list containing all child elements.
      Throws:
        `XMLException`

    - #### getChildren

          public List<Element> getChildren(String name)
                                    throws XMLException

      Description copied from interface: `Element`
      Get children by name.
      Specified by:
        `getChildren` in interface `Element`
      Parameters:
        `name` - Name of the children to get.
      Returns:
        A list of the Element with the given name.
      Throws:
        `XMLException`

    - #### getChildrenNS

          public List<Element> getChildrenNS(String xmlns)
                                      throws XMLException

      Description copied from interface: `Element`
      Get children by namespace.
      Specified by:
        `getChildrenNS` in interface `Element`
      Parameters:
        `xmlns` - Namespace of the children to get.
      Returns:
        A list of children with the given namespace.
      Throws:
        `XMLException`

    - #### getChildrenNS

          public Element getChildrenNS(String name,
                                       String xmlns)
                                throws XMLException

      Description copied from interface: `Element`
      Get children by namespace.
      Specified by:
        `getChildrenNS` in interface `Element`
      Parameters:
        `name` - Name of the children to get.
        `xmlns` - Namespace of the children to get.
      Returns:
        A list of Elements with the given name and namespace.
      Throws:
        `XMLException`

    - #### getFirstChild

          public Element getFirstChild()
                                throws XMLException

      Description copied from interface: `Element`
      Get the first child element of this element.
      Specified by:
        `getFirstChild` in interface `Element`
      Returns:
        First child element or null if no children.
      Throws:
        `XMLException`

    - #### getFirstChild

          public Element getFirstChild(String name)
                                throws XMLException

      Specified by:
        `getFirstChild` in interface `Element`
      Throws:
        `XMLException`

    - #### getName

          public String getName()
                         throws XMLException

      Description copied from interface: `Element`
      Get name of this element.
      Specified by:
        `getName` in interface `Element`
      Returns:
        Name of the element.
      Throws:
        `XMLException`

    - #### getNextSibling

          public Element getNextSibling()
                                 throws XMLException

      Description copied from interface: `Element`
      Get next sibling to this element or null if no parent or no more siblings exist.
      Specified by:
        `getNextSibling` in interface `Element`
      Returns:
        Next sibling element.
      Throws:
        `XMLException`

    - #### getParent

          public Element getParent()
                            throws XMLException

      Description copied from interface: `Element`
      Get parent element of this element. Or null if no parent exist.
      Specified by:
        `getParent` in interface `Element`
      Returns:
        Parent element.
      Throws:
        `XMLException`

    - #### getValue

          public String getValue()
                          throws XMLException

      Description copied from interface: `Element`
      Get element value.
      Specified by:
        `getValue` in interface `Element`
      Returns:
        Concatenated string value of element or null if none.
      Throws:
        `XMLException`

    - #### getXMLNS

          public String getXMLNS()
                          throws XMLException

      Description copied from interface: `Element`
      Get namespace of this element. traverses up to find actual namespace.
      Specified by:
        `getXMLNS` in interface `Element`
      Returns:
        Namespace of this element.
      Throws:
        `XMLException`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### removeAttribute

          public void removeAttribute(String key)
                               throws XMLException

      Description copied from interface: `Element`
      Remove attribute from element.
      Specified by:
        `removeAttribute` in interface `Element`
      Parameters:
        `key` - Name of attribute to remove.
      Throws:
        `XMLException`

    - #### removeChild

          public void removeChild(Element child)
                           throws XMLException

      Description copied from interface: `Element`
      Remove child from element.
      Specified by:
        `removeChild` in interface `Element`
      Parameters:
        `child` - Child element to remove.
      Throws:
        `XMLException`

    - #### setAttribute

          public void setAttribute(String key,
                                   String value)
                            throws XMLException

      Description copied from interface: `Element`
      Set value of attribute. Add attribute if it does not exist.
      Specified by:
        `setAttribute` in interface `Element`
      Parameters:
        `key` - Name of attribute to set.
        `value` - Value of attribute to set.
      Throws:
        `XMLException`

    - #### setAttributes

          public void setAttributes(Map<String,String> attrs)
                             throws XMLException

      Description copied from interface: `Element`
      Set a number of attributes. Add the ones which does not exist.
      Specified by:
        `setAttributes` in interface `Element`
      Parameters:
        `attrs` - Attributes to set.
      Throws:
        `XMLException`

    - #### setParent

          public void setParent(Element parent)
                         throws XMLException

      Description copied from interface: `Element`
      Set element parent. Only to be used internally.
      Specified by:
        `setParent` in interface `Element`
      Parameters:
        `parent` - The parent to set for this element.
      Throws:
        `XMLException`

    - #### setValue

          public void setValue(String value)
                        throws XMLException

      Description copied from interface: `Element`
      Set value of this element.
      Specified by:
        `setValue` in interface `Element`
      Parameters:
        `value` - Value to set.
      Throws:
        `XMLException`

    - #### setXMLNS

          public void setXMLNS(String xmlns)
                        throws XMLException

      Description copied from interface: `Element`
      Change the namespace of this element.
      Specified by:
        `setXMLNS` in interface `Element`
      Parameters:
        `xmlns` - Namespace to set.
      Throws:
        `XMLException`

Copyright © 2006–2017 Tigase. All rights reserved.