Interface IMicroAttributeContainer<IMPLTYPE extends IMicroAttributeContainer<IMPLTYPE>>

  • Type Parameters:
    IMPLTYPE - implementation type
    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>, IMicroNode, Serializable
    All Known Subinterfaces:
    IMicroElement
    All Known Implementing Classes:
    MicroElement

    public interface IMicroAttributeContainer<IMPLTYPE extends IMicroAttributeContainer<IMPLTYPE>>
    extends IMicroNode
    Interface for objects having attributes. Currently this is only an element.
    Author:
    Philip Helger
    • Method Detail

      • hasAttributes

        boolean hasAttributes()
        Returns:
        true if this element has at least one attribute, false otherwise
      • hasNoAttributes

        boolean hasNoAttributes()
        Returns:
        true if this element has no attribute, false if at least one attribute is present.
      • getAttributeCount

        @Nonnegative
        int getAttributeCount()
        Returns:
        The number of assigned attributes. Always ≥ 0.
      • hasAttribute

        default boolean hasAttribute​(@Nullable
                                     String sAttrName)
        Check if this element has an attribute with the specified name.
        Parameters:
        sAttrName - The attribute name to check.
        Returns:
        true if such an attribute is present, false otherwise
      • hasAttribute

        default boolean hasAttribute​(@Nullable
                                     String sNamespaceURI,
                                     @Nullable
                                     String sAttrName)
        Check if this element has an attribute with the specified name.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - The attribute name to check.
        Returns:
        true if such an attribute is present, false otherwise
      • hasAttribute

        boolean hasAttribute​(@Nullable
                             IMicroQName aAttrName)
        Check if this element has an attribute with the specified name.
        Parameters:
        aAttrName - The qualified attribute name to check. May be null.
        Returns:
        true if such an attribute is present, false otherwise
      • getAttributeObj

        @Nullable
        default IMicroAttribute getAttributeObj​(@Nullable
                                                String sAttrName)
        Get the attribute object with the specified name.
        Parameters:
        sAttrName - The attribute locale name to query. May be null.
        Returns:
        null of no such attribute object exists.
      • getAttributeObj

        @Nullable
        default IMicroAttribute getAttributeObj​(@Nullable
                                                String sNamespaceURI,
                                                @Nullable
                                                String sAttrName)
        Get the attribute object with the specified namespace URI and local name.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - The attribute locale name to query. May be null.
        Returns:
        null of no such attribute object exists.
      • getAttributeObj

        @Nullable
        IMicroAttribute getAttributeObj​(@Nullable
                                        IMicroQName aAttrName)
        Get the attribute object with the specified qualified name.
        Parameters:
        aAttrName - The qualified attribute name to check. May be null.
        Returns:
        null of no such attribute object exists.
      • getAttributeValue

        @Nullable
        default String getAttributeValue​(@Nullable
                                         String sAttrName)
        Get the attribute value of the given attribute name. If this element has no such attribute, null is returned.
        Parameters:
        sAttrName - The attribute name to retrieve the value of.
        Returns:
        The assigned attribute value or null.
      • getAttributeValue

        @Nullable
        default String getAttributeValue​(@Nullable
                                         String sNamespaceURI,
                                         @Nullable
                                         String sAttrName)
        Get the attribute value of the given attribute name. If this element has no such attribute, null is returned.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - The attribute name to retrieve the value of.
        Returns:
        The assigned attribute value or null.
      • getAttributeValue

        @Nullable
        default String getAttributeValue​(@Nullable
                                         IMicroQName aAttrName)
        Get the attribute value of the given attribute name. If this element has no such attribute, null is returned.
        Parameters:
        aAttrName - The qualified attribute name to retrieve the value of. May be null.
        Returns:
        The assigned attribute value or null.
      • getAttributeValueWithConversion

        @Nullable
        default <DSTTYPE> DSTTYPE getAttributeValueWithConversion​(@Nullable
                                                                  String sAttrName,
                                                                  @Nonnull
                                                                  Class<DSTTYPE> aDstClass)
        Get the attribute value of the given attribute name. If this element has no such attribute, null is returned. The attribute value is converted via the TypeConverter to the desired destination class. If no such attribute is present, null is returned.
        Type Parameters:
        DSTTYPE - Destination type
        Parameters:
        sAttrName - The attribute name to retrieve the value of.
        aDstClass - The destination class.
        Returns:
        The assigned attribute value or null.
        Throws:
        ClassCastException - if the value cannot be converted
      • getAttributeValueWithConversion

        @Nullable
        default <DSTTYPE> DSTTYPE getAttributeValueWithConversion​(@Nullable
                                                                  String sNamespaceURI,
                                                                  @Nullable
                                                                  String sAttrName,
                                                                  @Nonnull
                                                                  Class<DSTTYPE> aDstClass)
        Get the attribute value of the given attribute name. If this element has no such attribute, null is returned. The attribute value is converted via the TypeConverter to the desired destination class. If no such attribute is present, null is returned.
        Type Parameters:
        DSTTYPE - Destination type
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - The attribute name to retrieve the value of.
        aDstClass - The destination class.
        Returns:
        The assigned attribute value or null.
        Throws:
        ClassCastException - if the value cannot be converted
      • getAttributeValueWithConversion

        @Nullable
        <DSTTYPE> DSTTYPE getAttributeValueWithConversion​(@Nullable
                                                          IMicroQName aAttrName,
                                                          @Nonnull
                                                          Class<DSTTYPE> aDstClass)
        Get the attribute value of the given attribute name. If this element has no such attribute, null is returned. The attribute value is converted via the TypeConverter to the desired destination class. If no such attribute is present, null is returned.
        Type Parameters:
        DSTTYPE - Destination type
        Parameters:
        aAttrName - The attribute qualified name to retrieve the value of.
        aDstClass - The destination class.
        Returns:
        The assigned attribute value or null.
        Throws:
        ClassCastException - if the value cannot be converted
      • getAttributeValueAsBool

        default boolean getAttributeValueAsBool​(@Nullable
                                                String sAttrName,
                                                boolean bDefault)
      • getAttributeValueAsBool

        default boolean getAttributeValueAsBool​(@Nullable
                                                String sNamespaceURI,
                                                @Nullable
                                                String sAttrName,
                                                boolean bDefault)
      • getAttributeValueAsBool

        default boolean getAttributeValueAsBool​(@Nullable
                                                IMicroQName aAttrName,
                                                boolean bDefault)
      • getAttributeValueAsDouble

        default double getAttributeValueAsDouble​(@Nullable
                                                 String sAttrName,
                                                 double dDefault)
      • getAttributeValueAsDouble

        default double getAttributeValueAsDouble​(@Nullable
                                                 String sNamespaceURI,
                                                 @Nullable
                                                 String sAttrName,
                                                 double dDefault)
      • getAttributeValueAsDouble

        default double getAttributeValueAsDouble​(@Nullable
                                                 IMicroQName aAttrName,
                                                 double dDefault)
      • getAttributeValueAsFloat

        default float getAttributeValueAsFloat​(@Nullable
                                               String sAttrName,
                                               float fDefault)
      • getAttributeValueAsFloat

        default float getAttributeValueAsFloat​(@Nullable
                                               IMicroQName aAttrName,
                                               float fDefault)
      • getAttributeValueAsInt

        default int getAttributeValueAsInt​(@Nullable
                                           String sAttrName,
                                           int nDefault)
      • getAttributeValueAsInt

        default int getAttributeValueAsInt​(@Nullable
                                           IMicroQName aAttrName,
                                           int nDefault)
      • getAttributeValueAsLong

        default long getAttributeValueAsLong​(@Nullable
                                             String sAttrName,
                                             long nDefault)
      • getAttributeValueAsLong

        default long getAttributeValueAsLong​(@Nullable
                                             IMicroQName aAttrName,
                                             long nDefault)
      • getAllAttributeObjs

        @Nullable
        @ReturnsMutableCopy
        com.helger.commons.collection.impl.ICommonsList<? extends IMicroAttribute> getAllAttributeObjs()
        Get a list of all attributes. Is ensured to be not null if hasAttributes() returns true.
        Returns:
        May be null.
      • getAllQAttributes

        @Nullable
        @ReturnsMutableCopy
        com.helger.commons.collection.impl.ICommonsOrderedMap<IMicroQName,​String> getAllQAttributes()
        Get a map of all fully qualified attribute names and values. Is ensured to be not null if hasAttributes() returns true.
        Returns:
        May be null.
      • getAllAttributeQNames

        @Nullable
        @ReturnsMutableCopy
        com.helger.commons.collection.impl.ICommonsOrderedSet<IMicroQName> getAllAttributeQNames()
        Get a set of all attribute names. Is ensured to be not null if hasAttributes() returns true.
        Returns:
        May be null.
      • forAllAttributes

        void forAllAttributes​(@Nonnull
                              Consumer<? super IMicroAttribute> aConsumer)
        Iterate all attribute objects.
        Parameters:
        aConsumer - The consumer. May not be null. May only perform reading operations!
      • forAllAttributes

        void forAllAttributes​(@Nonnull
                              BiConsumer<? super IMicroQName,​? super String> aConsumer)
        Iterate all attribute objects.
        Parameters:
        aConsumer - The consumer that takes the QName and the value. May not be null. May only perform reading operations!
      • forAllAttributes

        void forAllAttributes​(@Nonnull
                              com.helger.commons.functional.ITriConsumer<? super String,​? super String,​? super String> aConsumer)
        Iterate all attribute objects.
        Parameters:
        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!
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      @Nullable
                                      String sAttrValue)
        Set an attribute value of this element.
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        sAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      @Nullable
                                      String sAttrValue)
        Set an attribute value of this element.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        sAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttribute

        @Nonnull
        IMPLTYPE setAttribute​(@Nonnull
                              IMicroQName aAttrName,
                              @Nullable
                              String sAttrValue)
        Set an attribute value of this element.
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        sAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      @Nonnull
                                      IHasAttributeValue aAttrValueProvider)
        Set an attribute value of this element.
        Parameters:
        sAttrName - 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)
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      @Nonnull
                                      IHasAttributeValue aAttrValueProvider)
        Set an attribute value of this element.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - 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)
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      IMicroQName aAttrName,
                                      @Nonnull
                                      IHasAttributeValue aAttrValueProvider)
        Set an attribute value of this element.
        Parameters:
        aAttrName - Qualified 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)
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      boolean bAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sAttrName, Boolean.toString (nValue)). That means, that the serialized value of the attribute is either true or false. If you need something else (like "yes" or "no") don't use this method.
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        bAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      boolean bAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sNamespaceURI, sAttrName, Boolean.toString (nValue)) . That means, that the serialized value of the attribute is either true or false. If you need something else (like "yes" or "no") don't use this method.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        bAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      IMicroQName aAttrName,
                                      boolean bAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(aAttrName, Boolean.toString (nValue)). That means, that the serialized value of the attribute is either true or false. If you need something else (like "yes" or "no") don't use this method.
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        bAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      double dAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sAttrName, Double.toString (nValue)).
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        dAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      double dAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sNamespaceURI, sAttrName, Double.toString (nValue)) .
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        dAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      IMicroQName aAttrName,
                                      double dAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(aAttrName, Double.toString (nValue)).
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        dAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      float fAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sAttrName, Float.toString (nValue)).
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        fAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      float fAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sNamespaceURI, sAttrName, Float.toString (nValue)) .
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        fAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      IMicroQName aAttrName,
                                      float fAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(aAttrName, Float.toString (nValue)).
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        fAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      int nAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sAttrName, Integer.toString (nValue)).
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        nAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      int nAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(sNamespaceURI, sAttrName, Integer.toString (nValue)) .
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        nAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      IMicroQName aAttrName,
                                      int nAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(aAttrName, Integer.toString (nValue)).
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        nAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      String sAttrName,
                                      long nAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(name, Long.toString (nValue)).
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        nAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nullable
                                      String sNamespaceURI,
                                      @Nonnull
                                      String sAttrName,
                                      long nAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(name, Long.toString (nValue)).
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        nAttrValue - The new value to be set.
        Returns:
        this
      • setAttribute

        @Nonnull
        default IMPLTYPE setAttribute​(@Nonnull
                                      IMicroQName aAttrName,
                                      long nAttrValue)
        Set an attribute value of this element. This is a shortcut for setAttribute(name, Long.toString (nValue)).
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        nAttrValue - The new value to be set.
        Returns:
        this
      • setAttributeWithConversion

        @Nonnull
        default IMPLTYPE setAttributeWithConversion​(@Nonnull
                                                    String sAttrName,
                                                    @Nullable
                                                    Object aAttrValue)
        Set an attribute value of this element. If the type of the value is not String, the TypeConverter is invoked to convert it to a String object.
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        aAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttributeWithConversion

        @Deprecated
        @Nonnull
        @DevelopersNote("No need for setAttributeWithConversion - setAttribute is enough")
        default IMPLTYPE setAttributeWithConversion​(@Nonnull
                                                    String sAttrName,
                                                    @Nullable
                                                    String sAttrValue)
        Deprecated.
        Set an attribute value of this element.
        Parameters:
        sAttrName - Name of the attribute. May neither be null nor empty.
        sAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttributeWithConversion

        @Nonnull
        default IMPLTYPE setAttributeWithConversion​(@Nullable
                                                    String sNamespaceURI,
                                                    @Nonnull
                                                    String sAttrName,
                                                    @Nullable
                                                    Object aAttrValue)
        Set an attribute value of this element. If the type of the value is not String, the TypeConverter is invoked to convert it to a String object.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        aAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttributeWithConversion

        @Deprecated
        @Nonnull
        @DevelopersNote("No need for setAttributeWithConversion - setAttribute is enough")
        default IMPLTYPE setAttributeWithConversion​(@Nullable
                                                    String sNamespaceURI,
                                                    @Nonnull
                                                    String sAttrName,
                                                    @Nullable
                                                    String sAttrValue)
        Deprecated.
        Set an attribute value of this element.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - Name of the attribute. May neither be null nor empty.
        sAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttributeWithConversion

        @Nonnull
        default IMPLTYPE setAttributeWithConversion​(@Nonnull
                                                    IMicroQName aAttrName,
                                                    @Nullable
                                                    Object aAttrValue)
        Set an attribute value of this element. If the type of the value is not String, the TypeConverter is invoked to convert it to a String object.
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        aAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • setAttributeWithConversion

        @Deprecated
        @Nonnull
        @DevelopersNote("No need for setAttributeWithConversion - setAttribute is enough")
        default IMPLTYPE setAttributeWithConversion​(@Nonnull
                                                    IMicroQName aAttrName,
                                                    @Nullable
                                                    String sAttrValue)
        Deprecated.
        Set an attribute value of this element.
        Parameters:
        aAttrName - Qualified name of the attribute. May neither be null nor empty.
        sAttrValue - If the value is null the attribute is removed (if present)
        Returns:
        this
      • removeAttribute

        @Nonnull
        default com.helger.commons.state.EChange removeAttribute​(@Nullable
                                                                 String sAttrName)
        Remove the attribute with the given name.
        Parameters:
        sAttrName - The name of the attribute to be removed. May be null.
        Returns:
        EChange.CHANGED if the attribute was removed, EChange.UNCHANGED if no such attribute exists at this element.
      • removeAttribute

        @Nonnull
        default com.helger.commons.state.EChange removeAttribute​(@Nullable
                                                                 String sNamespaceURI,
                                                                 @Nullable
                                                                 String sAttrName)
        Remove the attribute with the given name.
        Parameters:
        sNamespaceURI - Namespace URI to use. May be null.
        sAttrName - The name of the attribute to be removed. May be null.
        Returns:
        EChange.CHANGED if the attribute was removed, EChange.UNCHANGED if no such attribute exists at this element.
      • removeAttribute

        @Nonnull
        com.helger.commons.state.EChange removeAttribute​(@Nullable
                                                         IMicroQName aAttrName)
        Remove the attribute with the given name.
        Parameters:
        aAttrName - The qualified name of the attribute to be removed. May be null.
        Returns:
        EChange.CHANGED if the attribute was removed, EChange.UNCHANGED if no such attribute exists at this element.
      • removeAllAttributes

        @Nonnull
        com.helger.commons.state.EChange removeAllAttributes()
        Remove all attributes from this element
        Returns:
        EChange.