Package com.helger.xml.microdom
Interface IMicroElement
-
- All Superinterfaces:
com.helger.commons.lang.ICloneable<IMicroNode>,com.helger.commons.hierarchy.IHasChildren<IMicroNode>,com.helger.commons.hierarchy.IHasChildrenRecursive<IMicroNode>,com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>,com.helger.commons.hierarchy.IHasParent<IMicroNode>,IMicroAttributeContainer<IMicroElement>,IMicroNode,IMicroNodeWithChildren,Serializable
- All Known Implementing Classes:
MicroElement
public interface IMicroElement extends IMicroNodeWithChildren, IMicroAttributeContainer<IMicroElement>
Represents a single element (=tag) of a document.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancontainsAnyChildElement(Predicate<? super IMicroElement> aFilter)Check if this element has at least one direct child element that matches the provided filter.static com.helger.commons.functional.IPredicate<? super IMicroElement>filterName(String sTagOrLocalName)static com.helger.commons.functional.IPredicate<? super IMicroElement>filterNamespaceURI(String sNamespaceURI)static com.helger.commons.functional.IPredicate<? super IMicroElement>filterNamespaceURIAndName(String sNamespaceURI, String sTagOrLocalName)default voidforAllChildElements(Consumer<? super IMicroElement> aConsumer)voidforAllChildElements(Predicate<? super IMicroElement> aFilter, Consumer<? super IMicroElement> aConsumer)default com.helger.commons.state.EContinueforAllChildElementsBreakable(Function<? super IMicroElement,com.helger.commons.state.EContinue> aConsumer)com.helger.commons.state.EContinueforAllChildElementsBreakable(Predicate<? super IMicroElement> aFilter, Function<? super IMicroElement,com.helger.commons.state.EContinue> aConsumer)default com.helger.commons.collection.impl.ICommonsList<IMicroElement>getAllChildElements()Get a list of all direct child elements.default com.helger.commons.collection.impl.ICommonsList<IMicroElement>getAllChildElements(String sTagName)Get a list of all direct child elements having the specified tag name.default com.helger.commons.collection.impl.ICommonsList<IMicroElement>getAllChildElements(String sNamespaceURI, String sLocalName)Get a list of all direct child elements having the specified namespace and the specified tag name.default com.helger.commons.collection.impl.ICommonsList<IMicroElement>getAllChildElements(Predicate<? super IMicroElement> aFilter)Get a list of all direct child elements matching the provided filter.com.helger.commons.collection.impl.ICommonsList<IMicroElement>getAllChildElementsRecursive()Recursively get all child elements.default intgetChildElementCount()Get the number of all direct child elements.default intgetChildElementCount(Predicate<? super IMicroElement> aFilter)Get the number of direct child elements that match the provided filter.IMicroElementgetClone()default IMicroElementgetFirstChildElement()Get the first child element of this element.default IMicroElementgetFirstChildElement(String sTagName)Get the first child element with the given tag name.default IMicroElementgetFirstChildElement(String sNamespaceURI, String sLocalName)Get the first child element with the given tag name and the given namespace.IMicroElementgetFirstChildElement(Predicate<? super IMicroElement> aFilter)StringgetLocalName()Get the local name of the element.StringgetNamespaceURI()Get the namespace URI of this elementStringgetTagName()Get the name of the tag.default booleanhasChildElements()Check if this element has at least one direct child element.default booleanhasChildElements(String sTagName)Check if this element has at least one direct child element with the specified tag name.default booleanhasChildElements(String sNamespaceURI, String sLocalName)Check if this element has at least one direct child element with the specified namespace URI and tag name.default booleanhasLocalName(String sLocalName)Check if this element has the provided local name.default booleanhasNamespaceURI()Check if this element has a specified namespace URI.default booleanhasNamespaceURI(String sNamespaceURI)Check if this element has the specified namespace URI.default booleanhasNoNamespaceURI()Check if this element has no namespace URI.default booleanhasTagName(String sTagName)Check if this element has the provided tag name.default booleanhasTagNameIgnoreCase(String sTagName)Check if this element has the provided tag name but ignoring case.com.helger.commons.state.EChangesetNamespaceURI(String sNamespaceURI)Set a new namespace URI for this element.-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildren
forAllChildren, forAllChildren, forAllChildrenBreakable, forAllChildrenMapped, getChildCount, getChildren, hasChildren, hasNoChildren
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildrenRecursive
forAllChildrenRecursive, forAllChildrenRecursive
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildrenSorted
findFirstChild, findFirstChildMapped, getChildAtIndex
-
Methods inherited from interface com.helger.xml.microdom.IMicroAttributeContainer
forAllAttributes, forAllAttributes, forAllAttributes, getAllAttributeObjs, getAllAttributeQNames, getAllQAttributes, getAttributeCount, getAttributeObj, getAttributeObj, getAttributeObj, getAttributeObjs, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValueAsBool, getAttributeValueAsBool, getAttributeValueAsBool, getAttributeValueAsDouble, getAttributeValueAsDouble, getAttributeValueAsDouble, getAttributeValueAsFloat, getAttributeValueAsFloat, getAttributeValueAsFloat, getAttributeValueAsInt, getAttributeValueAsInt, getAttributeValueAsInt, getAttributeValueAsLong, getAttributeValueAsLong, getAttributeValueAsLong, getAttributeValueWithConversion, getAttributeValueWithConversion, getAttributeValueWithConversion, hasAttribute, hasAttribute, hasAttribute, hasAttributes, hasNoAttributes, removeAllAttributes, removeAttribute, removeAttribute, removeAttribute, setAttribute, 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, setAttributeWithConversion
-
Methods inherited from interface com.helger.xml.microdom.IMicroNode
appendCDATA, 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, getNodeName, getNodeValue, getParent, getParentElementWithName, getParentElementWithName, getPreviousSibling, getType, hasParent, insertAfter, insertAtIndex, insertBefore, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isEqualContent, isProcessingInstruction, isText, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, replaceChild, unregisterEventTarget
-
Methods inherited from interface com.helger.xml.microdom.IMicroNodeWithChildren
getTextContent, getTextContentTrimmed, getTextContentWithConversion
-
-
-
-
Method Detail
-
getNamespaceURI
@Nullable String getNamespaceURI()
Get the namespace URI of this element- Returns:
- May be
nullif this element has no namespace URI.
-
setNamespaceURI
@Nonnull com.helger.commons.state.EChange setNamespaceURI(@Nullable String sNamespaceURI)
Set a new namespace URI for this element.- Parameters:
sNamespaceURI- The namespace URI to be set. May benullor empty to indicate that the namespace should be removed.- Returns:
EChange
-
hasNamespaceURI
default boolean hasNamespaceURI()
Check if this element has a specified namespace URI.- Returns:
trueif this element has a specified namespace URI,falseotherwise
-
hasNoNamespaceURI
default boolean hasNoNamespaceURI()
Check if this element has no namespace URI.- Returns:
trueif this element has no namespace URI,falseotherwise
-
hasNamespaceURI
default boolean hasNamespaceURI(@Nullable String sNamespaceURI)
Check if this element has the specified namespace URI.- Parameters:
sNamespaceURI- The namespace URI to check. May not benull.- Returns:
trueif this element has the specified namespace URI,falseotherwise
-
getLocalName
@Nullable String getLocalName()
Get the local name of the element. Is the same name as returned bygetTagName()but it is only present, if a namespace URI is present.- Returns:
- May be
nullif no namespace is present.
-
hasLocalName
default boolean hasLocalName(@Nullable String sLocalName)
Check if this element has the provided local name. The local name is the same name as returned bygetTagName()but is only present if a namespace URI is present.- Parameters:
sLocalName- The local name to compare against. May benull.- Returns:
trueif local name and the passed name match.
-
getTagName
@Nonnull String getTagName()
Get the name of the tag. It never contains XML schema prefixes or the like. Is the same asgetLocalName()if a namespace URI is present.- Returns:
- May not be
null.
-
hasTagName
default boolean hasTagName(@Nullable String sTagName)
Check if this element has the provided tag name.- Parameters:
sTagName- The tag name to compare against. May benull.- Returns:
trueif tag name and the passed name match.
-
hasTagNameIgnoreCase
default boolean hasTagNameIgnoreCase(@Nullable String sTagName)
Check if this element has the provided tag name but ignoring case.- Parameters:
sTagName- The tag name to compare against. May benull.- Returns:
trueif tag name and the passed name match case insensitive.
-
getChildElementCount
@Nonnegative default int getChildElementCount()
Get the number of all direct child elements.- Returns:
- The number of all direct child elements. Always ≥ 0.
-
getChildElementCount
@Nonnegative default int getChildElementCount(@Nullable Predicate<? super IMicroElement> aFilter)
Get the number of direct child elements that match the provided filter.- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
- The number of all direct child elements that match the provided filter. Always ≥ 0.
-
getAllChildElements
@Nonnull @ReturnsMutableCopy default com.helger.commons.collection.impl.ICommonsList<IMicroElement> getAllChildElements()
Get a list of all direct child elements. Text nodes and other other child nodes are not returned with this call. Micro container children are inlined.- Returns:
- Never be
null.
-
getAllChildElements
@Nonnull @ReturnsMutableCopy default com.helger.commons.collection.impl.ICommonsList<IMicroElement> getAllChildElements(@Nullable String sTagName)
Get a list of all direct child elements having the specified tag name. Micro container children are inlined.- Parameters:
sTagName- The tag name to check. May benull.- Returns:
- Never be
null.
-
getAllChildElements
@Nonnull @ReturnsMutableCopy default com.helger.commons.collection.impl.ICommonsList<IMicroElement> getAllChildElements(@Nullable String sNamespaceURI, @Nullable String sLocalName)
Get a list of all direct child elements having the specified namespace and the specified tag name. Micro container children are inlined.- Parameters:
sNamespaceURI- The namespace URI to check. May benull.sLocalName- The tag name to check. May benull.- Returns:
- Never be
null.
-
getAllChildElements
@Nonnull @ReturnsMutableCopy default com.helger.commons.collection.impl.ICommonsList<IMicroElement> getAllChildElements(@Nullable Predicate<? super IMicroElement> aFilter)
Get a list of all direct child elements matching the provided filter. Micro container children are inlined.- Parameters:
aFilter- The filter to be applied. May benullin which all direct child elements are returned.- Returns:
- A new list and never
null.
-
getAllChildElementsRecursive
@Nonnull @ReturnsMutableCopy com.helger.commons.collection.impl.ICommonsList<IMicroElement> getAllChildElementsRecursive()
Recursively get all child elements. Micro container children are inlined.- Returns:
- A list containing all recursively contained elements. May not be
nullbut empty.
-
hasChildElements
default boolean hasChildElements()
Check if this element has at least one direct child element. Micro container children are also checked.- Returns:
trueif this element has at least one child element
-
hasChildElements
default boolean hasChildElements(@Nullable String sTagName)
Check if this element has at least one direct child element with the specified tag name. Micro container children are also checked.- Parameters:
sTagName- The tag name to check. May benull.- Returns:
trueif this element has at least one child element with the specified tag name
-
hasChildElements
default boolean hasChildElements(@Nullable String sNamespaceURI, @Nullable String sLocalName)
Check if this element has at least one direct child element with the specified namespace URI and tag name. Micro container children are also checked.- Parameters:
sNamespaceURI- The namespace URI to check. May benull.sLocalName- The tag name to check. May benull.- Returns:
trueif this element has at least one child element with the specified namespace URI and tag name
-
containsAnyChildElement
boolean containsAnyChildElement(@Nullable Predicate<? super IMicroElement> aFilter)
Check if this element has at least one direct child element that matches the provided filter. Micro container children are also checked.- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
trueif this element has at least one direct child element that matches the passed filter,falseotherwise.
-
getFirstChildElement
@Nullable default IMicroElement getFirstChildElement()
Get the first child element of this element. Micro container children are also checked.- Returns:
- The first child element or
nullif this element has no child element.
-
getFirstChildElement
@Nullable default IMicroElement getFirstChildElement(@Nullable String sTagName)
Get the first child element with the given tag name. Micro container children are also checked.- Parameters:
sTagName- The tag name of the element to search. May benull.- Returns:
nullif no such child element is present
-
getFirstChildElement
@Nullable default IMicroElement getFirstChildElement(@Nullable String sNamespaceURI, @Nullable String sLocalName)
Get the first child element with the given tag name and the given namespace. Micro container children are also checked.- Parameters:
sNamespaceURI- The namespace URL to search.sLocalName- The tag name of the element to search.- Returns:
nullif no such child element is present
-
getFirstChildElement
@Nullable IMicroElement getFirstChildElement(@Nullable Predicate<? super IMicroElement> aFilter)
-
forAllChildElements
default void forAllChildElements(@Nonnull Consumer<? super IMicroElement> aConsumer)
-
forAllChildElements
void forAllChildElements(@Nullable Predicate<? super IMicroElement> aFilter, @Nonnull Consumer<? super IMicroElement> aConsumer)
-
forAllChildElementsBreakable
@Nonnull default com.helger.commons.state.EContinue forAllChildElementsBreakable(@Nonnull Function<? super IMicroElement,com.helger.commons.state.EContinue> aConsumer)
-
forAllChildElementsBreakable
@Nonnull com.helger.commons.state.EContinue forAllChildElementsBreakable(@Nullable Predicate<? super IMicroElement> aFilter, @Nonnull Function<? super IMicroElement,com.helger.commons.state.EContinue> aConsumer)
-
getClone
@Nonnull IMicroElement getClone()
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<IMicroNode>- Specified by:
getClonein interfaceIMicroNodeWithChildren
-
filterNamespaceURI
@Nonnull static com.helger.commons.functional.IPredicate<? super IMicroElement> filterNamespaceURI(@Nullable String sNamespaceURI)
-
filterName
@Nonnull static com.helger.commons.functional.IPredicate<? super IMicroElement> filterName(@Nullable String sTagOrLocalName)
-
-