Class XmlElementAdapter

    • Constructor Detail

      • XmlElementAdapter

        public XmlElementAdapter​(XmlElement target)
    • Method Detail

      • getRoot

        public XmlContainer getRoot()
        Description copied from interface: XmlElement
        Get top most container that is either XmlDocument or XmlElement (may be event this element!!!)
        Specified by:
        getRoot in interface XmlElement
      • getParent

        public XmlContainer getParent()
        Description copied from interface: XmlElement
        XML Infoset [parent] property. If current element is not child of containing parent XmlElement or XmlDocument then builder exception will be thrown
        Specified by:
        getParent in interface XmlContained
        Specified by:
        getParent in interface XmlElement
      • attribute

        public XmlAttribute attribute​(String attributeName)
        Description copied from interface: XmlElement
        Find attribute that matches given name or namespace Returns null if not found. Will match only attribute that have no namesapce.
        Specified by:
        attribute in interface XmlElement
      • attribute

        public XmlAttribute attribute​(XmlNamespace attributeNamespaceName,
                                      String attributeName)
        Description copied from interface: XmlElement
        Find attribute that matches given name or namespace Returns null if not found. NOTE: if namespace is null in this case it will match only attributes that have no namespace.
        Specified by:
        attribute in interface XmlElement
      • findAttribute

        public XmlAttribute findAttribute​(String attributeNamespaceName,
                                          String attributeName)
        Description copied from interface: XmlElement
        Find attribute that matches given name or namespace Returns null if not found. NOTE: if namespace is null in this case it will match only attributes that has no namespace.
        Specified by:
        findAttribute in interface XmlElement
      • attributes

        public Iterator attributes()
        Description copied from interface: XmlElement
        Return Iterator - null is never returned if there is no children then iteraotr over empty collection is returned
        Specified by:
        attributes in interface XmlElement
      • removeAllChildren

        public void removeAllChildren()
        Description copied from interface: XmlElement
        Removes all children - every child that was implementing XmlNode will have set parent to null.
        Specified by:
        removeAllChildren in interface XmlElement
      • addAttribute

        public XmlAttribute addAttribute​(String attributeType,
                                         String attributePrefix,
                                         String attributeNamespace,
                                         String attributeName,
                                         String attributeValue,
                                         boolean specified)
        Description copied from interface: XmlElement
        Method addAttribute
        Specified by:
        addAttribute in interface XmlElement
        Parameters:
        attributeType - a String
        attributePrefix - a String
        attributeNamespace - a String
        attributeName - a String
        attributeValue - a String
        specified - a boolean
        Returns:
        a XmlAttribute
      • getAttributeValue

        public String getAttributeValue​(String attributeNamespaceName,
                                        String attributeName)
        Description copied from interface: XmlElement
        Method getAttributeValue
        Specified by:
        getAttributeValue in interface XmlElement
        attributeName - a String
        Returns:
        a String
      • getNamespaceName

        public String getNamespaceName()
        Description copied from interface: XmlElement
        Return namespace name (XML Infoset [namespace name]property or null if element has no namespace
        Specified by:
        getNamespaceName in interface XmlElement
      • ensureChildrenCapacity

        public void ensureChildrenCapacity​(int minCapacity)
        Description copied from interface: XmlElement
        Method ensureChildrenCapacity
        Specified by:
        ensureChildrenCapacity in interface XmlElement
        Parameters:
        minCapacity - an int
      • namespaces

        public Iterator namespaces()
        Description copied from interface: XmlElement
        Return Iterator - null is never returned if there is no children then iteraotr over empty collection is returned
        Specified by:
        namespaces in interface XmlElement
      • getNamespace

        public XmlNamespace getNamespace()
        Description copied from interface: XmlElement
        Return namespace of current element (XML Infoset [namespace name] and [prefix] properties combined) null is only returned if element was created without namespace
        Specified by:
        getNamespace in interface XmlElement
      • getBaseUri

        public String getBaseUri()
        Description copied from interface: XmlElement
        XML Infoset [base URI] property
        Specified by:
        getBaseUri in interface XmlElement
        Returns:
        a String
      • declareNamespace

        public XmlNamespace declareNamespace​(String prefix,
                                             String namespaceName)
        Description copied from interface: XmlElement
        Create new namespace with prefix and namespace name (both must be not null) and add it to current element.
        Specified by:
        declareNamespace in interface XmlElement
      • hasAttributes

        public boolean hasAttributes()
        Description copied from interface: XmlElement
        Method hasAttributes
        Specified by:
        hasAttributes in interface XmlElement
        Returns:
        a boolean
      • addAttribute

        public XmlAttribute addAttribute​(String type,
                                         XmlNamespace namespace,
                                         String name,
                                         String value,
                                         boolean specified)
        Description copied from interface: XmlElement
        Method addAttribute
        Specified by:
        addAttribute in interface XmlElement
        Parameters:
        type - a String
        namespace - a XmlNamespace
        name - a String
        value - a String
        specified - a boolean
        Returns:
        a XmlAttribute
      • hasNamespaceDeclarations

        public boolean hasNamespaceDeclarations()
        Description copied from interface: XmlElement
        Method hasNamespaceDeclarations
        Specified by:
        hasNamespaceDeclarations in interface XmlElement
        Returns:
        a boolean
      • lookupNamespaceByName

        public XmlNamespace lookupNamespaceByName​(String namespaceName)
        Description copied from interface: XmlElement
        Find namespace (will have non empty prefix) corresponding to namespace name checking first current elemen and if not found continue in parent (if element has parent). and so on.
        Specified by:
        lookupNamespaceByName in interface XmlElement
      • lookupNamespaceByPrefix

        public XmlNamespace lookupNamespaceByPrefix​(String namespacePrefix)
        Description copied from interface: XmlElement
        Find namespace (will have non empty prefix) corresponding to namespace prefix checking first current elemen and if not found continue in parent (if element has parent) and so on.
        Specified by:
        lookupNamespaceByPrefix in interface XmlElement
      • setBaseUri

        public void setBaseUri​(String baseUri)
        Description copied from interface: XmlElement
        XML Infoset [base URI] property
        Specified by:
        setBaseUri in interface XmlElement
        Parameters:
        baseUri - a String
      • setNamespace

        public void setNamespace​(XmlNamespace namespace)
        Description copied from interface: XmlElement
        Set namespace ot use for theis element. Note: namespace prefix is always ignored.
        Specified by:
        setNamespace in interface XmlElement
      • ensureNamespaceDeclarationsCapacity

        public void ensureNamespaceDeclarationsCapacity​(int minCapacity)
        Description copied from interface: XmlElement
        Method ensureNamespaceDeclarationsCapacity
        Specified by:
        ensureNamespaceDeclarationsCapacity in interface XmlElement
        Parameters:
        minCapacity - an int
      • getName

        public String getName()
        Description copied from interface: XmlElement
        XML Infoset [local name] property.
        Specified by:
        getName in interface XmlElement
        Returns:
        a String
      • setName

        public void setName​(String name)
        Description copied from interface: XmlElement
        XML Infoset [local name] property.
        Specified by:
        setName in interface XmlElement
        Parameters:
        name - a String
      • ensureAttributeCapacity

        public void ensureAttributeCapacity​(int minCapacity)
        Description copied from interface: XmlElement
        Method ensureAttributeCapacity
        Specified by:
        ensureAttributeCapacity in interface XmlElement
        Parameters:
        minCapacity - an int
      • addAttribute

        public XmlAttribute addAttribute​(XmlAttribute attributeValueToAdd)
        Description copied from interface: XmlElement
        Add attribute (adds it to the XML Infoset [namespace attributes] set) Attribute mist
        Specified by:
        addAttribute in interface XmlElement
        Parameters:
        attributeValueToAdd - a XmlAttribute
        Returns:
        a XmlAttribute
      • element

        public XmlElement element​(int position)
        Description copied from interface: XmlElement
        return element at poition (0..count-1) or IndexOutOfBoundsException if positon incorrect
        Specified by:
        element in interface XmlElement
      • element

        public XmlElement element​(XmlNamespace n,
                                  String name,
                                  boolean create)
        Description copied from interface: XmlElement
        find first element with name and namespace (if namespace is null it is ignored in search) if no matching element is found then new element is created, appended to children, and returned
        Specified by:
        element in interface XmlElement
      • addElement

        public XmlElement addElement​(XmlElement child)
        Description copied from interface: XmlElement
        NOTE: the child element must unattached to be added (it is atttached if it is XmlContainer of recognized type and getParent() != null)
        Specified by:
        addElement in interface XmlElement
      • addElement

        public XmlElement addElement​(int pos,
                                     XmlElement child)
        Description copied from interface: XmlElement
        Method addElement
        Specified by:
        addElement in interface XmlElement
        Parameters:
        pos - an int (starting from 0)
        child - a XmlElement
        Returns:
        a XmlElement
      • addChild

        public void addChild​(Object child)
        Description copied from interface: XmlElement
        NOTE: =child added is _not_ checked if it XmlContainer, caller must manually fix parent in child by calling setParent() !!!!
        Specified by:
        addChild in interface XmlElement
      • removeChild

        public void removeChild​(Object child)
        Description copied from interface: XmlElement
        Method removeChild
        Specified by:
        removeChild in interface XmlElement
        Parameters:
        child - an Object
      • children

        public Iterator children()
        Description copied from interface: XmlElement
        Return Iterator - null is never returned if there is no children then iteraotr over empty collection is returned
        Specified by:
        children in interface XmlElement
        • requiredElementContent

          public Iterable requiredElementContent()
          Description copied from interface: XmlElement
          Return Iterator - that represents all XmlElement content. When used exception will be thrown if non white space children are found (as expected no mixed content!).
          Specified by:
          requiredElementContent in interface XmlElement
        • requiredTextContent

          public String requiredTextContent()
          Description copied from interface: XmlElement
          return children content as text - if there are any no text children throw exception
          Specified by:
          requiredTextContent in interface XmlElement
        • hasChild

          public boolean hasChild​(Object child)
          Description copied from interface: XmlElement
          Method hasChild
          Specified by:
          hasChild in interface XmlElement
          Parameters:
          child - an Object
          Returns:
          a boolean
        • newElement

          public XmlElement newElement​(String namespaceName,
                                       String name)
          Description copied from interface: XmlElement
          Method newElement
          Specified by:
          newElement in interface XmlElement
          Parameters:
          namespaceName - a String
          name - a String
          Returns:
          a XmlElement
        • hasChildren

          public boolean hasChildren()
          Description copied from interface: XmlElement
          Method hasChildren
          Specified by:
          hasChildren in interface XmlElement
          Returns:
          a boolean
        • addChild

          public void addChild​(int pos,
                               Object child)
          Description copied from interface: XmlElement
          Method addChild
          Specified by:
          addChild in interface XmlElement
          Parameters:
          pos - an int (starting from 0)
          child - an Object
        • replaceChild

          public void replaceChild​(Object newChild,
                                   Object oldChild)
          Description copied from interface: XmlElement
          Method replaceChild
          Specified by:
          replaceChild in interface XmlElement
          Parameters:
          newChild - an Object
          oldChild - an Object
        • replaceChildrenWithText

          public void replaceChildrenWithText​(String textContent)
          Description copied from interface: XmlElement
          Remove all children and then add this text as only child.
          Specified by:
          replaceChildrenWithText in interface XmlElement