public final class MicroElement extends AbstractMicroNodeWithChildren implements IMicroElement
IMicroElement interface.| Constructor and Description |
|---|
MicroElement(IHasElementName aElementNameProvider) |
MicroElement(String sTagName) |
MicroElement(String sNamespaceURI,
IHasElementName aElementNameProvider) |
MicroElement(String sNamespaceURI,
String sTagName) |
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
getAllAttributeNames()
Get a set of all attribute names.
|
Map<String,String> |
getAllAttributes()
Get a map of all attribute names and values.
|
List<String> |
getAllAttributeValues()
Get a set of all attribute values.
|
List<IMicroElement> |
getAllChildElements()
Get a list of all direct child elements.
|
List<IMicroElement> |
getAllChildElements(IHasElementName aElementNameProvider)
Get a list of all direct child elements having the specified tag name.
|
List<IMicroElement> |
getAllChildElements(String sTagName)
Get a list of all direct child elements having the specified tag name.
|
List<IMicroElement> |
getAllChildElements(String sNamespaceURI,
IHasElementName aElementNameProvider)
Get a list of all direct child elements having the specified namespace and
the specified tag name.
|
List<IMicroElement> |
getAllChildElements(String sNamespaceURI,
String sLocalName)
Get a list of all direct child elements having the specified namespace and
the specified tag name.
|
List<IMicroElement> |
getAllChildElementsRecursive()
Recursively get all child elements.
|
String |
getAttribute(String sAttrName)
Get the attribute value of the given attribute name.
|
int |
getAttributeCount() |
<DSTTYPE> DSTTYPE |
getAttributeWithConversion(String sAttrName,
Class<DSTTYPE> aDstClass)
Get the attribute value of the given attribute name.
|
int |
getChildElementCount() |
IMicroElement |
getClone() |
IMicroElement |
getFirstChildElement()
Get the first child element of this element.
|
IMicroElement |
getFirstChildElement(IHasElementName aElementNameProvider)
Get the first child element with the given tag name.
|
IMicroElement |
getFirstChildElement(String sTagName)
Get the first child element with the given tag name.
|
IMicroElement |
getFirstChildElement(String sNamespaceURI,
IHasElementName aElementNameProvider)
Get the first child element with the given tag name and the given
namespace.
|
IMicroElement |
getFirstChildElement(String sNamespaceURI,
String sLocalName)
Get the first child element with the given tag name and the given
namespace.
|
String |
getLocalName()
Get the local name of the element.
|
String |
getNamespaceURI()
Get the namespace URI of this element
|
String |
getNodeName() |
String |
getTagName()
Get the name of the tag.
|
EMicroNodeType |
getType() |
boolean |
hasAttribute(String sAttrName)
Check if this element has an attribute with the specified name.
|
boolean |
hasAttributes() |
boolean |
hasChildElements()
Check if this element has at least one child element.
|
boolean |
hasChildElements(IHasElementName aElementNameProvider)
Check if this element has at least one child element with the specified tag
name.
|
boolean |
hasChildElements(String sTagName)
Check if this element has at least one child element with the specified tag
name.
|
boolean |
hasChildElements(String sNamespaceURI,
IHasElementName aElementNameProvider)
Check if this element has at least one child element with the specified
namespace URI and tag name.
|
boolean |
hasChildElements(String sNamespaceURI,
String sLocalName)
Check if this element has at least one child element with the specified
namespace URI and tag name.
|
boolean |
hasNamespaceURI()
Check if this element has a specified namespace URI.
|
boolean |
hasNamespaceURI(String sNamespaceURI)
Check if this element has the specified namespace URI.
|
boolean |
hasNoNamespaceURI()
Check if this element has no namespace URI.
|
boolean |
isEqualContent(IMicroNode o)
As instances of this class may not implement equals/hashCode we need a way
to determine, if 2 nodes are equal by content.
|
EChange |
removeAllAttributes()
Remove all attributes from this element
|
EChange |
removeAttribute(String sAttrName)
Remove the attribute with the given name.
|
MicroElement |
setAttribute(String sAttrName,
IHasAttributeValue aAttrValueProvider)
Set an attribute value of this element.
|
IMicroElement |
setAttribute(String sAttrName,
int nAttrValue)
Set an attribute value of this element.
|
IMicroElement |
setAttribute(String sAttrName,
long nAttrValue)
Set an attribute value of this element.
|
MicroElement |
setAttribute(String sAttrName,
String sAttrValue)
Set an attribute value of this element.
|
IMicroElement |
setAttributeWithConversion(String sAttrName,
Object aAttrValue)
Set an attribute value of this element.
|
EChange |
setNamespaceURI(String sNamespaceURI)
Set a new namespace URI for this element.
|
String |
toString() |
getAllChildrenRecursive, getChildAtIndex, getChildCount, getChildren, getFirstChild, getLastChild, getTextContent, getTextContentTrimmed, getTextContentWithConversion, hasChildren, onAppendChild, onInsertAfter, onInsertAtIndex, onInsertBefore, onRemoveAllChildren, onRemoveChild, onRemoveChildAtIndexappendCDATA, appendCDATA, appendCDATA, appendCDATAWithConversion, appendChild, appendComment, appendComment, appendComment, appendCommentWithConversion, appendContainer, appendElement, appendElement, appendElement, appendElement, appendEntityReference, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendProcessingInstruction, appendText, appendText, appendText, appendTextWithConversion, detachFromParent, getNextSibling, getNodeValue, getParent, getParentElementWithName, getParentElementWithName, getPreviousSibling, hasParent, insertAfter, insertAtIndex, insertBefore, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isProcessingInstruction, isText, onEvent, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, replaceChild, unregisterEventTargetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTextContent, getTextContentTrimmed, getTextContentWithConversionappendCDATA, appendCDATA, appendCDATA, appendCDATAWithConversion, appendChild, appendComment, appendComment, appendComment, appendCommentWithConversion, appendContainer, appendElement, appendElement, appendElement, appendElement, appendEntityReference, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendProcessingInstruction, appendText, appendText, appendText, appendTextWithConversion, detachFromParent, getAllChildrenRecursive, getChildren, getFirstChild, getLastChild, getNextSibling, getNodeValue, getParent, getParentElementWithName, getParentElementWithName, getPreviousSibling, hasChildren, hasParent, insertAfter, insertAtIndex, insertBefore, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isProcessingInstruction, isText, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, replaceChild, unregisterEventTargetgetChildAtIndexgetChildCountpublic MicroElement(@Nonnull IHasElementName aElementNameProvider)
public MicroElement(@Nullable String sNamespaceURI, @Nonnull IHasElementName aElementNameProvider)
@Nonnull public EMicroNodeType getType()
getType in interface IMicroNodenull.@Nonnull @Nonempty public String getNodeName()
getNodeName in interface IMicroNodepublic boolean hasAttributes()
hasAttributes in interface IMicroElementtrue if this element has at least one attribute,
false otherwise@Nonnegative public int getAttributeCount()
getAttributeCount in interface IMicroElement@Nullable @ReturnsMutableCopy public Map<String,String> getAllAttributes()
IMicroElementnull if IMicroElement.hasAttributes() returns true.getAllAttributes in interface IMicroElementnull.@Nullable @ReturnsMutableCopy public Set<String> getAllAttributeNames()
IMicroElementnull if
IMicroElement.hasAttributes() returns true.getAllAttributeNames in interface IMicroElementnull.@Nullable @ReturnsMutableCopy public List<String> getAllAttributeValues()
IMicroElementnull
if IMicroElement.hasAttributes() returns true.getAllAttributeValues in interface IMicroElementnull.@Nullable public String getAttribute(@Nullable String sAttrName)
IMicroElementnull is returned.getAttribute in interface IMicroElementsAttrName - The attribute name to retrieve the value of.null.@Nullable public <DSTTYPE> DSTTYPE getAttributeWithConversion(@Nullable String sAttrName, @Nonnull Class<DSTTYPE> aDstClass)
IMicroElementnull is returned. The attribute value is
converted via the TypeConverter to
the desired destination class. If no such attribute is present,
null is returned.getAttributeWithConversion in interface IMicroElementsAttrName - The attribute name to retrieve the value of.aDstClass - The destination class.null.public boolean hasAttribute(@Nullable String sAttrName)
IMicroElementhasAttribute in interface IMicroElementsAttrName - The attribute name to retrieve the value of.true if such an attribute is present,
false otherwise@Nonnull public EChange removeAttribute(@Nullable String sAttrName)
IMicroElementremoveAttribute in interface IMicroElementsAttrName - The name of the attribute to be removed. May be null.EChange.CHANGED if the attribute was removed,
EChange.UNCHANGED if no such attribute exists at this
element.@Nonnull public MicroElement setAttribute(@Nonnull@Nonempty String sAttrName, @Nullable String sAttrValue)
IMicroElementsetAttribute in interface IMicroElementsAttrName - Name of the attribute. May neither be null nor empty.sAttrValue - If the value is null the attribute is removed (if
present)@Nonnull public MicroElement setAttribute(@Nonnull String sAttrName, @Nonnull IHasAttributeValue aAttrValueProvider)
IMicroElementsetAttribute in interface IMicroElementsAttrName - Name of the attribute. May neither be null nor empty.aAttrValueProvider - The attribute value provider. May not be null. If the
contained attribute value is null the attribute is
removed (if present)@Nonnull public IMicroElement setAttribute(@Nonnull String sAttrName, int nAttrValue)
IMicroElementsetAttribute(name, Integer.toString (nValue)).setAttribute in interface IMicroElementsAttrName - Name of the attribute. May neither be null nor empty.nAttrValue - The new value to be set.@Nonnull public IMicroElement setAttribute(@Nonnull String sAttrName, long nAttrValue)
IMicroElementsetAttribute(name, Long.toString (nValue)).setAttribute in interface IMicroElementsAttrName - Name of the attribute. May neither be null nor empty.nAttrValue - The new value to be set.@Nonnull public IMicroElement setAttributeWithConversion(@Nonnull String sAttrName, @Nullable Object aAttrValue)
IMicroElementString, the TypeConverter is
invoked to convert it to a String object.setAttributeWithConversion in interface IMicroElementsAttrName - Name of the attribute. May neither be null nor empty.aAttrValue - If the value is null the attribute is removed (if
present)@Nonnull public EChange removeAllAttributes()
IMicroElementremoveAllAttributes in interface IMicroElementEChange.@Nullable public String getNamespaceURI()
IMicroElementgetNamespaceURI in interface IMicroElementnull if this element has no namespace URI.@Nonnull public EChange setNamespaceURI(@Nullable String sNamespaceURI)
IMicroElementsetNamespaceURI in interface IMicroElementsNamespaceURI - The namespace URI to be set. May be null or empty to
indicate that the namespace should be removed.EChangepublic boolean hasNamespaceURI()
IMicroElementhasNamespaceURI in interface IMicroElementtrue if this element has a specified namespace URI,
false otherwisepublic boolean hasNoNamespaceURI()
IMicroElementhasNoNamespaceURI in interface IMicroElementtrue if this element has no namespace URI,
false otherwisepublic boolean hasNamespaceURI(@Nullable String sNamespaceURI)
IMicroElementhasNamespaceURI in interface IMicroElementsNamespaceURI - The namespace URI to check. May not be null.true if this element has the specified namespace URI,
false otherwise@Nullable public String getLocalName()
IMicroElementIMicroElement.getTagName() but it is only present, if a namespace URI is
present.getLocalName in interface IMicroElementnull if no namespace is present.@Nonnull public String getTagName()
IMicroElementIMicroElement.getLocalName() if a namespace URI is present.getTagName in interface IMicroElementnull.@Nonnegative public int getChildElementCount()
getChildElementCount in interface IMicroElement@Nonnull @ReturnsMutableCopy public List<IMicroElement> getAllChildElements()
IMicroElementgetAllChildElements in interface IMicroElementnull.@Nonnull @ReturnsMutableCopy public List<IMicroElement> getAllChildElements(@Nullable String sTagName)
IMicroElementgetAllChildElements in interface IMicroElementsTagName - The tag name to check. May be null.null.@Nonnull @ReturnsMutableCopy public List<IMicroElement> getAllChildElements(@Nullable String sNamespaceURI, @Nullable String sLocalName)
IMicroElementgetAllChildElements in interface IMicroElementsNamespaceURI - The namespace URI to check. May be null.sLocalName - The tag name to check. May be null.null.@Nonnull @ReturnsMutableCopy public List<IMicroElement> getAllChildElements(@Nonnull IHasElementName aElementNameProvider)
IMicroElementgetAllChildElements in interface IMicroElementaElementNameProvider - Element name provider. May not be null.null.@Nonnull @ReturnsMutableCopy public List<IMicroElement> getAllChildElements(@Nullable String sNamespaceURI, @Nonnull IHasElementName aElementNameProvider)
IMicroElementgetAllChildElements in interface IMicroElementsNamespaceURI - The namespace URI to check. May be null.aElementNameProvider - Element name provider. May not be null.null.@Nonnull @ReturnsMutableCopy public List<IMicroElement> getAllChildElementsRecursive()
IMicroElementgetAllChildElementsRecursive in interface IMicroElementnull but empty.public boolean hasChildElements()
IMicroElementhasChildElements in interface IMicroElementtrue if this element has at least one child elementpublic boolean hasChildElements(@Nullable String sTagName)
IMicroElementhasChildElements in interface IMicroElementsTagName - The tag name to check. May be null.true if this element has at least one child element
with the specified tag namepublic boolean hasChildElements(@Nullable String sNamespaceURI, @Nullable String sLocalName)
IMicroElementhasChildElements in interface IMicroElementsNamespaceURI - The namespace URI to check. May be null.sLocalName - The tag name to check. May be null.true if this element has at least one child element
with the specified namespace URI and tag namepublic boolean hasChildElements(@Nonnull IHasElementName aElementNameProvider)
IMicroElementhasChildElements in interface IMicroElementaElementNameProvider - Element name provider. May not be null.true if this element has at least one child element
with the specified tag namepublic boolean hasChildElements(@Nullable String sNamespaceURI, @Nonnull IHasElementName aElementNameProvider)
IMicroElementhasChildElements in interface IMicroElementsNamespaceURI - The namespace URI to check. May be null.aElementNameProvider - Element name provider. May not be null.true if this element has at least one child element
with the specified namespace URI and tag name@Nullable public IMicroElement getFirstChildElement()
IMicroElementgetFirstChildElement in interface IMicroElementnull if this element has no
child element.@Nullable public IMicroElement getFirstChildElement(@Nullable String sTagName)
IMicroElementgetFirstChildElement in interface IMicroElementsTagName - The tag name of the element to search. May be null.null if no such child element is present@Nullable public IMicroElement getFirstChildElement(@Nullable String sNamespaceURI, @Nullable String sLocalName)
IMicroElementgetFirstChildElement in interface IMicroElementsNamespaceURI - The namespace URL to search.sLocalName - The tag name of the element to search.null if no such child element is present@Nullable public IMicroElement getFirstChildElement(@Nonnull IHasElementName aElementNameProvider)
IMicroElementgetFirstChildElement in interface IMicroElementaElementNameProvider - Element name provider. May not be null.null if no such child element is present@Nullable public IMicroElement getFirstChildElement(@Nullable String sNamespaceURI, @Nonnull IHasElementName aElementNameProvider)
IMicroElementgetFirstChildElement in interface IMicroElementsNamespaceURI - The namespace URL to search.aElementNameProvider - Element name provider. May not be null.null if no such child element is present@Nonnull public IMicroElement getClone()
IMicroElementgetClone in interface ICloneable<IMicroNode>getClone in interface IMicroElementgetClone in interface IMicroNodeWithChildrenpublic boolean isEqualContent(@Nullable IMicroNode o)
IMicroNodeisEqualContent in interface IMicroNodeisEqualContent in class AbstractMicroNodeWithChildreno - The node to compare to this.true if the nodes are of the same type and the same
content, false otherwise.public String toString()
toString in class AbstractMicroNodeWithChildrenCopyright © 2006–2014 phloc systems. All rights reserved.