public final class MicroElement extends AbstractMicroNodeWithChildren implements IMicroElement
IMicroElement interface.| Constructor and Description |
|---|
MicroElement(String sTagName) |
MicroElement(String sNamespaceURI,
String sTagName) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsAnyChildElement(Predicate<? super IMicroElement> aFilter)
Check if this element has at least one direct child element that matches
the provided filter.
|
void |
forAllAttributes(BiConsumer<? super IMicroQName,? super String> aConsumer)
Iterate all attribute objects.
|
void |
forAllAttributes(Consumer<? super IMicroAttribute> aConsumer)
Iterate all attribute objects.
|
void |
forAllAttributes(com.helger.commons.functional.ITriConsumer<? super String,? super String,? super String> aConsumer)
Iterate all attribute objects.
|
void |
forAllChildElements(Predicate<? super IMicroElement> aFilter,
Consumer<? super IMicroElement> aConsumer) |
com.helger.commons.state.EContinue |
forAllChildElementsBreakable(Predicate<? super IMicroElement> aFilter,
Function<? super IMicroElement,com.helger.commons.state.EContinue> aConsumer) |
com.helger.commons.collection.impl.ICommonsList<MicroAttribute> |
getAllAttributeObjs()
Get a list of all attributes.
|
com.helger.commons.collection.impl.ICommonsOrderedSet<IMicroQName> |
getAllAttributeQNames()
Get a set of all attribute names.
|
com.helger.commons.collection.impl.ICommonsList<IMicroElement> |
getAllChildElementsRecursive()
Recursively get all child elements.
|
com.helger.commons.collection.impl.ICommonsOrderedMap<IMicroQName,String> |
getAllQAttributes()
Get a map of all fully qualified attribute names and values.
|
int |
getAttributeCount() |
MicroAttribute |
getAttributeObj(IMicroQName aQName)
Get the attribute object with the specified qualified name.
|
Iterable<MicroAttribute> |
getAttributeObjs()
Get a iterable objects of all attributes.
|
<DSTTYPE> DSTTYPE |
getAttributeValueWithConversion(IMicroQName aAttrName,
Class<DSTTYPE> aDstClass)
Get the attribute value of the given attribute name.
|
IMicroElement |
getClone() |
IMicroElement |
getFirstChildElement(Predicate<? super IMicroElement> aFilter) |
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(IMicroQName aAttrName)
Check if this element has an attribute with the specified name.
|
boolean |
hasAttributes() |
boolean |
hasNoAttributes() |
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.
|
com.helger.commons.state.EChange |
removeAllAttributes()
Remove all attributes from this element
|
com.helger.commons.state.EChange |
removeAttribute(IMicroQName aAttrName)
Remove the attribute with the given name.
|
MicroElement |
setAttribute(IMicroQName aAttrName,
String sAttrValue)
Set an attribute value of this element.
|
com.helger.commons.state.EChange |
setNamespaceURI(String sNamespaceURI)
Set a new namespace URI for this element.
|
String |
toString() |
containsAnyChild, directGetAllChildren, findFirstChild, findFirstChildMapped, forAllChildren, forAllChildren, forAllChildrenBreakable, forAllChildrenMapped, getAllChildren, getChildAtIndex, getChildCount, getChildren, getFirstChild, getLastChild, getTextContent, getTextContentWithConversion, hasChildren, onAppendChild, onInsertAfter, onInsertAtIndex, onInsertBefore, onRemoveAllChildren, onRemoveChild, onRemoveChildAtIndexappendChild, detachFromParent, findParentElement, getAllEventTargets, getAllEventTargets, getNextSibling, getParent, getPreviousSibling, hasParent, insertAfter, insertAtIndex, insertBefore, internalResetParentNode, internalSetParentNode, internalTriggerEvent, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isProcessingInstruction, isText, onEvent, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, unregisterEventTargetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfilterName, filterNamespaceURI, filterNamespaceURIAndName, forAllChildElements, forAllChildElementsBreakable, getAllChildElements, getAllChildElements, getAllChildElements, getAllChildElements, getChildElementCount, getChildElementCount, getFirstChildElement, getFirstChildElement, getFirstChildElement, hasChildElements, hasChildElements, hasChildElements, hasLocalName, hasNamespaceURI, hasNamespaceURI, hasNoNamespaceURI, hasTagName, hasTagNameIgnoreCasegetTextContent, getTextContentTrimmed, getTextContentWithConversiongetAttributeObj, getAttributeObj, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValueAsBool, getAttributeValueAsBool, getAttributeValueAsBool, getAttributeValueAsDouble, getAttributeValueAsDouble, getAttributeValueAsDouble, getAttributeValueAsFloat, getAttributeValueAsFloat, getAttributeValueAsFloat, getAttributeValueAsInt, getAttributeValueAsInt, getAttributeValueAsInt, getAttributeValueAsLong, getAttributeValueAsLong, getAttributeValueAsLong, getAttributeValueWithConversion, getAttributeValueWithConversion, hasAttribute, hasAttribute, removeAttribute, removeAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeWithConversion, setAttributeWithConversion, setAttributeWithConversion, setAttributeWithConversion, setAttributeWithConversion, setAttributeWithConversionappendCDATA, appendCDATA, appendCDATA, appendCDATAWithConversion, appendChild, appendChildren, appendChildren, appendComment, appendComment, appendComment, appendCommentWithConversion, appendContainer, appendElement, appendElement, appendEntityReference, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendProcessingInstruction, appendText, appendText, appendText, appendTextWithConversion, containsAnyChild, detachFromParent, findParentElement, getAllChildren, getAllChildrenRecursive, getAllEventTargets, getAllEventTargets, getFirstChild, getLastChild, getNextSibling, getNodeValue, getParent, getParentElementWithName, getParentElementWithName, getPreviousSibling, hasParent, insertAfter, insertAtIndex, insertBefore, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isProcessingInstruction, isText, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, replaceChild, unregisterEventTargetfindFirstChild, findFirstChildMapped, getChildAtIndex@Nonnull public EMicroNodeType getType()
getType in interface IMicroNodenull.@Nonnull @Nonempty public String getNodeName()
getNodeName in interface IMicroNodeIMicroElement nodes this is the same as the tag name.public boolean hasAttributes()
hasAttributes in interface IMicroAttributeContainer<IMicroElement>true if this element has at least one attribute,
false otherwisepublic boolean hasNoAttributes()
hasNoAttributes in interface IMicroAttributeContainer<IMicroElement>true if this element has no attribute,
false if at least one attribute is present.@Nonnegative public int getAttributeCount()
getAttributeCount in interface IMicroAttributeContainer<IMicroElement>@Nullable @ReturnsImmutableObject public Iterable<MicroAttribute> getAttributeObjs()
IMicroAttributeContainernull if IMicroAttributeContainer.hasAttributes() returns true.getAttributeObjs in interface IMicroAttributeContainer<IMicroElement>null.@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MicroAttribute> getAllAttributeObjs()
IMicroAttributeContainernull if
IMicroAttributeContainer.hasAttributes() returns true.getAllAttributeObjs in interface IMicroAttributeContainer<IMicroElement>null.@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedMap<IMicroQName,String> getAllQAttributes()
IMicroAttributeContainernull if IMicroAttributeContainer.hasAttributes() returns
true.getAllQAttributes in interface IMicroAttributeContainer<IMicroElement>null.@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<IMicroQName> getAllAttributeQNames()
IMicroAttributeContainernull if
IMicroAttributeContainer.hasAttributes() returns true.getAllAttributeQNames in interface IMicroAttributeContainer<IMicroElement>null.public void forAllAttributes(@Nonnull Consumer<? super IMicroAttribute> aConsumer)
IMicroAttributeContainerforAllAttributes in interface IMicroAttributeContainer<IMicroElement>aConsumer - The consumer. May not be null. May only perform reading
operations!public void forAllAttributes(@Nonnull BiConsumer<? super IMicroQName,? super String> aConsumer)
IMicroAttributeContainerforAllAttributes in interface IMicroAttributeContainer<IMicroElement>aConsumer - The consumer that takes the QName and the value. May not be
null. May only perform reading operations!public void forAllAttributes(@Nonnull com.helger.commons.functional.ITriConsumer<? super String,? super String,? super String> aConsumer)
IMicroAttributeContainerforAllAttributes in interface IMicroAttributeContainer<IMicroElement>aConsumer - The consumer that takes the namespace URI, the attribute local name
and the attribute value. May not be null. May only
perform reading operations!@Nullable public MicroAttribute getAttributeObj(@Nullable IMicroQName aQName)
IMicroAttributeContainergetAttributeObj in interface IMicroAttributeContainer<IMicroElement>aQName - The qualified attribute name to check. May be null.null of no such attribute object exists.@Nullable public <DSTTYPE> DSTTYPE getAttributeValueWithConversion(@Nullable IMicroQName aAttrName, @Nonnull Class<DSTTYPE> aDstClass)
IMicroAttributeContainernull is returned. The attribute value is
converted via the TypeConverter to
the desired destination class. If no such attribute is present,
null is returned.getAttributeValueWithConversion in interface IMicroAttributeContainer<IMicroElement>DSTTYPE - Destination typeaAttrName - The attribute qualified name to retrieve the value of.aDstClass - The destination class.null.public boolean hasAttribute(@Nullable IMicroQName aAttrName)
IMicroAttributeContainerhasAttribute in interface IMicroAttributeContainer<IMicroElement>aAttrName - The qualified attribute name to check. May be null.true if such an attribute is present,
false otherwise@Nonnull public com.helger.commons.state.EChange removeAttribute(@Nullable IMicroQName aAttrName)
IMicroAttributeContainerremoveAttribute in interface IMicroAttributeContainer<IMicroElement>aAttrName - The qualified 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 IMicroQName aAttrName, @Nullable String sAttrValue)
IMicroAttributeContainersetAttribute in interface IMicroAttributeContainer<IMicroElement>aAttrName - Qualified name of the attribute. May neither be null
nor empty.sAttrValue - If the value is null the attribute is removed (if
present)@Nonnull public com.helger.commons.state.EChange removeAllAttributes()
IMicroAttributeContainerremoveAllAttributes in interface IMicroAttributeContainer<IMicroElement>EChange.@Nullable public String getNamespaceURI()
IMicroElementgetNamespaceURI in interface IMicroElementnull if this element has no namespace URI.@Nonnull public com.helger.commons.state.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.EChange@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.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<IMicroElement> getAllChildElementsRecursive()
IMicroElementgetAllChildElementsRecursive in interface IMicroElementnull but empty.public boolean containsAnyChildElement(@Nullable Predicate<? super IMicroElement> aFilter)
IMicroElementcontainsAnyChildElement in interface IMicroElementaFilter - The filter to be applied. May be null.true if this element has at least one direct child
element that matches the passed filter, false
otherwise.@Nullable public IMicroElement getFirstChildElement(@Nullable Predicate<? super IMicroElement> aFilter)
getFirstChildElement in interface IMicroElementpublic void forAllChildElements(@Nullable Predicate<? super IMicroElement> aFilter, @Nonnull Consumer<? super IMicroElement> aConsumer)
forAllChildElements in interface IMicroElement@Nonnull public com.helger.commons.state.EContinue forAllChildElementsBreakable(@Nullable Predicate<? super IMicroElement> aFilter, @Nonnull Function<? super IMicroElement,com.helger.commons.state.EContinue> aConsumer)
forAllChildElementsBreakable in interface IMicroElement@Nonnull public IMicroElement getClone()
IMicroElementgetClone in interface com.helger.commons.lang.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 © 2014–2023 Philip Helger. All rights reserved.