|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pf.six.Element
Each element represents one tag occurrence in a XML stream. The element's name corresponds to the XML tag name.
| Field Summary | |
static Element[] |
EMPTY_ARRAY
|
| Constructor Summary | |
Element()
Initialize the new instance with default values. |
|
Element(java.lang.String tagName)
Initialize the new instance with the given name. |
|
Element(java.lang.String tagName,
java.lang.String text)
Initialize the new instance with the given name and text. |
|
| Method Summary | |
void |
addChild(Element childElement)
Adds the given element as a child to the receiver |
Element |
copy()
Returns a copy of the element with all child elements copied as well. |
Element |
deepCopy()
Returns a deep copy of the element. |
Element[] |
find(java.lang.String tagName)
Returns all sub elements with the given tag name plus this element, if it's name is equal to the given tagName. |
Element[] |
find(java.lang.String tagName,
java.util.Map attributes)
Returns all sub elements with the given tag name and the specified attribute values plus this element if it matches the tagName and attributes. |
Element[] |
findChildren(java.lang.String tagName)
Returns all children with the given tag name. |
Element[] |
findChildren(java.lang.String tagName,
java.util.Map attributes)
Returns all children with the given tag name and the specified attribute values. |
Element[] |
findSubElements(java.lang.String tagName)
Returns all sub elements with the given tag name. |
Element[] |
findSubElements(java.lang.String tagName,
java.util.Map attributes)
Returns all sub elements with the given tag name and the specified attribute values. |
java.lang.String |
getAttribute(java.lang.String attrName)
Returns the value of the attribute with the given name. |
java.lang.String[] |
getAttributeLocalNames()
Returns the names of all attributes assigned to this element. |
java.lang.String[] |
getAttributeNames()
Returns the names of all attributes assigned to this element. |
java.util.Map |
getAttributes()
Returns all attributes of this element. |
Element[] |
getChildren()
Returns all child elements. |
int |
getChildrenCount()
Returns the number of child elements. |
Element |
getFirstChild()
Returns the first child element or null if there is no child element. |
java.lang.String |
getLocalName()
Returns the local name of this element. |
java.lang.String |
getName()
Returns the name of the element. |
java.lang.String |
getNamePrefix()
|
java.util.Map |
getNamespaceDeclarations()
Returns a map with the names of namespaces as keys and the corresponding namespace URIs as values. |
java.lang.String |
getText()
Returns the elements textual content which corresponds to the XML tag's PCDATA. |
boolean |
hasAttribute(java.lang.String attrName)
Returns true if the element has an attribue with the given name. |
boolean |
hasAttributes()
Returns true if the element has any attribue. |
boolean |
hasChildren()
Returns true if the element contains any child element. |
boolean |
hasText()
Returns true if the element has any text. |
boolean |
insertChildAfter(Element oldChild,
Element newChild)
Inserts the given newChild after the specified old child. |
boolean |
insertChildBefore(Element oldChild,
Element newChild)
Inserts the given newChild before the specified old child. |
void |
removeAllChildren()
Removes all children of this element |
void |
removeAttribute(java.lang.String attrName)
Removes the attribute with the specified name from the element's attribute list. |
boolean |
removeChild(Element childElement)
Removes the given child from this element. |
void |
removeText()
Removes the element's text content. |
boolean |
replaceChild(Element oldChild,
Element newChild)
Replaces the given oldChild by the given newChild. |
void |
setAttribute(java.lang.String attrName,
java.lang.String value)
Sets the value of the attribute with the given name. |
void |
setName(java.lang.String newName)
Set the element's name which corresponds to its XML tag name. |
void |
setText(java.lang.String newText)
Set the element's text. |
Element |
shallowCopy()
Returns a shallow copy of the element, that is a new element with the same name, same attributes and same text but without children. |
static Element[] |
toArray(java.util.Collection elementCollection)
Returns an Element array that contains all Element objects of the given collection. |
static java.util.List |
toList(Element[] elements)
Returns an ArrayList that contains all elements of the given array. |
java.lang.String |
toString()
Returns the element's name as a XML tag. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Element[] EMPTY_ARRAY
| Constructor Detail |
public Element()
public Element(java.lang.String tagName)
tagName - The name of the new element
public Element(java.lang.String tagName,
java.lang.String text)
tagName - The name of the new elementtext - The text content of the new element| Method Detail |
public static Element[] toArray(java.util.Collection elementCollection)
elementCollection - The collection to be converted to an array.
java.lang.ClassCastException - If any object in the given collection is not an Element.public static java.util.List toList(Element[] elements)
elements - The array to convert to a listpublic java.lang.String getName()
public void setName(java.lang.String newName)
newName - Any valid XML tag namepublic java.lang.String getLocalName()
public java.lang.String getNamePrefix()
public java.lang.String getText()
public void setText(java.lang.String newText)
newText - Any valid XML character data compliant to the desired encodingpublic java.lang.String getAttribute(java.lang.String attrName)
attrName - The name of the attribute including a namespace prefix if applicable
public void setAttribute(java.lang.String attrName,
java.lang.String value)
attrName - The name of the attribute including a namespace prefix if applicablevalue - The value to assign to this attributepublic void removeAttribute(java.lang.String attrName)
attrName - The name of the attribute to remove (including namespace prefix)public java.util.Map getAttributes()
public java.lang.String[] getAttributeNames()
public java.lang.String[] getAttributeLocalNames()
public int getChildrenCount()
public Element[] getChildren()
public Element getFirstChild()
public boolean hasChildren()
public boolean removeChild(Element childElement)
childElement - The child element to be removed
public void removeAllChildren()
public void removeText()
public boolean hasText()
public boolean hasAttributes()
public boolean hasAttribute(java.lang.String attrName)
public java.lang.String toString()
public void addChild(Element childElement)
childElement - The element to add
public boolean insertChildAfter(Element oldChild,
Element newChild)
public boolean insertChildBefore(Element oldChild,
Element newChild)
public boolean replaceChild(Element oldChild,
Element newChild)
public Element[] find(java.lang.String tagName)
public Element[] find(java.lang.String tagName,
java.util.Map attributes)
public Element[] findSubElements(java.lang.String tagName)
public Element[] findSubElements(java.lang.String tagName,
java.util.Map attributes)
public Element[] findChildren(java.lang.String tagName)
public Element[] findChildren(java.lang.String tagName,
java.util.Map attributes)
public Element shallowCopy()
public Element deepCopy()
public Element copy()
deepCopy()public java.util.Map getNamespaceDeclarations()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||