public class ElementWrapper extends Object implements Element
Constructor and Description |
---|
ElementWrapper(Element element) |
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.
|
protected String |
getChildElementValue(String elemName) |
protected String |
getChildElementValue(String elemName,
String xmlns) |
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.
|
Element |
getWrappedElement() |
String |
getXMLNS()
Get namespace of this element.
|
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.
|
protected void |
setChildElementValue(String elemName,
String value) |
protected void |
setChildElementValue(String elemName,
String xmlns,
String value) |
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.
|
String |
toString() |
public ElementWrapper(Element element)
public Element addChild(Element child) throws XMLException
addChild
in interface Element
child
- Child to add.XMLException
public Element findChild(String[] elemPath) throws XMLException
findChild
in interface Element
XMLException
public String getAsString() throws XMLException
getAsString
in interface Element
XMLException
public String getAttribute(String attName) throws XMLException
getAttribute
in interface Element
attName
- Name of attribute to fetch.XMLException
public Map<String,String> getAttributes() throws XMLException
getAttributes
in interface Element
XMLException
public void setAttributes(Map<String,String> attrs) throws XMLException
setAttributes
in interface Element
attrs
- Attributes to set.XMLException
public Element getChildAfter(Element child) throws XMLException
getChildAfter
in interface Element
child
- The child to look up.XMLException
protected String getChildElementValue(String elemName) throws XMLException
XMLException
protected String getChildElementValue(String elemName, String xmlns) throws XMLException
XMLException
public List<Element> getChildren() throws XMLException
getChildren
in interface Element
XMLException
public List<Element> getChildren(String name) throws XMLException
getChildren
in interface Element
name
- Name of the children to get.XMLException
public List<Element> getChildrenNS(String xmlns) throws XMLException
getChildrenNS
in interface Element
xmlns
- Namespace of the children to get.XMLException
public Element getChildrenNS(String name, String xmlns) throws XMLException
getChildrenNS
in interface Element
name
- Name of the children to get.xmlns
- Namespace of the children to get.XMLException
public Element getFirstChild() throws XMLException
getFirstChild
in interface Element
XMLException
public Element getFirstChild(String name) throws XMLException
getFirstChild
in interface Element
XMLException
public String getName() throws XMLException
getName
in interface Element
XMLException
public Element getNextSibling() throws XMLException
getNextSibling
in interface Element
XMLException
public Element getParent() throws XMLException
getParent
in interface Element
XMLException
public void setParent(Element parent) throws XMLException
setParent
in interface Element
parent
- The parent to set for this element.XMLException
public String getValue() throws XMLException
getValue
in interface Element
XMLException
public void setValue(String value) throws XMLException
setValue
in interface Element
value
- Value to set.XMLException
public Element getWrappedElement()
public String getXMLNS() throws XMLException
getXMLNS
in interface Element
XMLException
public void setXMLNS(String xmlns) throws XMLException
setXMLNS
in interface Element
xmlns
- Namespace to set.XMLException
public void removeAttribute(String key) throws XMLException
removeAttribute
in interface Element
key
- Name of attribute to remove.XMLException
public void removeChild(Element child) throws XMLException
removeChild
in interface Element
child
- Child element to remove.XMLException
public void setAttribute(String key, String value) throws XMLException
setAttribute
in interface Element
key
- Name of attribute to set.value
- Value of attribute to set.XMLException
protected void setChildElementValue(String elemName, String value) throws XMLException
XMLException
protected void setChildElementValue(String elemName, String xmlns, String value) throws XMLException
XMLException
Copyright © 2006–2022 Tigase. All rights reserved.