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
All Known Implementing Classes:
MicroElement

public interface IMicroElement extends IMicroNodeWithChildren, IMicroAttributeContainer<IMicroElement>
Represents a single element (=tag) of a document.
Author:
Philip Helger
  • Method Details

    • getNamespaceURI

      @Nullable String getNamespaceURI()
      Get the namespace URI of this element
      Returns:
      May be null if 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 be null or 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:
      true if this element has a specified namespace URI, false otherwise
    • hasNoNamespaceURI

      default boolean hasNoNamespaceURI()
      Check if this element has no namespace URI.
      Returns:
      true if this element has no namespace URI, false otherwise
    • 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 be null.
      Returns:
      true if this element has the specified namespace URI, false otherwise
    • getLocalName

      @Nullable String getLocalName()
      Get the local name of the element. Is the same name as returned by getTagName() but it is only present, if a namespace URI is present.
      Returns:
      May be null if 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 by getTagName() but is only present if a namespace URI is present.
      Parameters:
      sLocalName - The local name to compare against. May be null.
      Returns:
      true if 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 as getLocalName() 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 be null.
      Returns:
      true if 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 be null.
      Returns:
      true if 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 be null.
      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 be null.
      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 be null.
      sLocalName - The tag name to check. May be null.
      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 be null in 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 null but empty.
    • hasChildElements

      default boolean hasChildElements()
      Check if this element has at least one direct child element. Micro container children are also checked.
      Returns:
      true if 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 be null.
      Returns:
      true if 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 be null.
      sLocalName - The tag name to check. May be null.
      Returns:
      true if 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 be null.
      Returns:
      true if this element has at least one direct child element that matches the passed filter, false otherwise.
    • 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 null if 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 be null.
      Returns:
      null if 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:
      null if 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

      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<IMicroNode>
      Specified by:
      getClone in interface IMicroNodeWithChildren
    • filterNamespaceURI

      @Nonnull static Predicate<? super IMicroElement> filterNamespaceURI(@Nullable String sNamespaceURI)
    • filterName

      @Nonnull static Predicate<? super IMicroElement> filterName(@Nullable String sTagOrLocalName)
    • filterNamespaceURIAndName

      @Nonnull static Predicate<? super IMicroElement> filterNamespaceURIAndName(@Nullable String sNamespaceURI, @Nullable String sTagOrLocalName)