Class AbstractAttribute

java.lang.Object
com.webfirmframework.wffweb.tag.core.AbstractTagBase
com.webfirmframework.wffweb.tag.html.attribute.core.AbstractAttribute
All Implemented Interfaces:
TagBase, Serializable, Cloneable
Direct Known Subclasses:
AbstractEventAttribute, AbstractValueSetAttribute, Accept, AcceptCharset, AccessKey, Action, Align, Alt, Async, AutoFocus, AutoPlay, Border, CellPadding, CellSpacing, Charset, Checked, ColorAttribute, Cols, ColSpan, Content, ContentEditable, ContextMenu, Controls, CoOrds, CustomAttribute, DataAttribute, DateTime, Default, Defer, Dir, DirName, Disabled, Download, Draggable, Dropzone, EncType, Face, For, FormAction, FormAttribute, FormEncType, FormMethod, FormNoValidate, FormTarget, Height, Hidden, High, Href, HrefLang, HttpEquiv, Id, IsMap, Lang, List, Loop, Low, Max, MaxLength, Media, Method, Min, MinLength, Multiple, Muted, Name, NoHref, Nonce, Open, Optimum, Pattern, Placeholder, Poster, Preload, ReadOnly, Required, Rev, Reversed, Role, Rows, RowSpan, Sandbox, Scope, Selected, Shape, Size, Sizes, Sorted, SpellCheck, Src, SrcSet, Step, Style, TabIndex, Target, Title, Translate, Type, UseMap, Value, Width, Wrap

public abstract class AbstractAttribute extends AbstractTagBase
See Also:
  • Constructor Details

    • AbstractAttribute

      public AbstractAttribute()
    • AbstractAttribute

      protected AbstractAttribute(boolean nullableAttrValueMapValue)
      this constructor is only for the attribute whose value is an attribute value map, eg: style
      Parameters:
      nullableAttrValueMapValue - only
  • Method Details

    • getPrintStructure

      protected String getPrintStructure()
      Returns:
      String equalent to the html string of the tag including the child tags.
      Since:
      1.0.0
    • getPrintStructure

      protected String getPrintStructure(boolean rebuild)
    • getWffPrintStructure

      protected String getWffPrintStructure()
      gets the attribute name and value in the format of name=value.
      Eg: style=color:green;background:blue
      This reduces 2 bytes taken for ".
      Returns:
      the attribute name and value in the format of name=value. Eg: style=color:green;background:blue
      Since:
      2.0.0
    • toWffString

      public String toWffString()
      gets the attribute name and value in the format of name=value.
      Eg: style=color:green;background:blue
      This reduces 2 bytes taken for ".
      Returns:
      the attribute name and value in the format of name=value. Eg: style=color:green;background:blue;
      Since:
      2.0.0
    • beforeWffPrintStructure

      protected void beforeWffPrintStructure()
    • getBinaryStructureCompressedByIndex

      protected byte[] getBinaryStructureCompressedByIndex(boolean rebuild) throws IOException
      gives compressed by index bytes for the attribute and value. The first byte represents the attribute name index bytes length, the next bytes represent the attribute name index bytes and the remaining bytes represent attribute value without = and ".
      Parameters:
      rebuild -
      Returns:
      the compressed by index bytes.
      Throws:
      IOException
      Since:
      1.1.3
    • getBinaryStructureCompressedByIndex

      protected byte[] getBinaryStructureCompressedByIndex(boolean rebuild, Charset charset) throws IOException
      gives compressed by index bytes for the attribute and value. The first byte represents the attribute name index bytes length, the next bytes represent the attribute name index bytes and the remaining bytes represent attribute value without = and ".
      Parameters:
      rebuild -
      charset -
      Returns:
      the compressed by index bytes.
      Throws:
      IOException
      Since:
      3.0.3
    • getAttributeName

      public String getAttributeName()
      Returns:
      the attributeName set by AbstractAttribute#setAttributeName(String)
      Since:
      1.0.0
    • setAttributeName

      protected void setAttributeName(String attributeName)
      Set attribute name, eg: width, height, name, type etc..
      Parameters:
      attributeName - the attributeName to set
      Since:
      1.0.0
    • setPreIndexedAttribute

      protected void setPreIndexedAttribute(PreIndexedAttributeName preIndexedAttrName)
      NB: only for internal use. Signature of this method may be modified in future version. Sets PreIndexedAttributeName for name and index
      Parameters:
      preIndexedAttrName - PreIndexedAttributeName object
      Since:
      3.0.3
    • toHtmlString

      public String toHtmlString()
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values. rebuilds the html string if the child tags/values or attributes have been modified.
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toCompressedBytesByIndex

      public byte[] toCompressedBytesByIndex(boolean rebuild) throws IOException
      Throws:
      IOException
    • toCompressedBytesByIndex

      public byte[] toCompressedBytesByIndex(boolean rebuild, Charset charset) throws IOException
      Throws:
      IOException
    • toHtmlString

      @Deprecated public String toHtmlString(Charset charset)
      Deprecated.
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values using the given charset. rebuilds the html string if the child tags/values or attributes have been modified.
      Parameters:
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(String charset)
      Deprecated.
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values using the given charset. rebuilds the html string if the child tags/values or attributes have been modified.
      Parameters:
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8.name()
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      public String toHtmlString(boolean rebuild)
      Description copied from interface: TagBase
      rebuilds the html string of the tag including the child tags/values if parameter is true, otherwise returns the html string prebuilt and kept in the cache.
      Parameters:
      rebuild - true to rebuild & false to return previously built string.
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(boolean rebuild, Charset charset)
      Deprecated.
      Description copied from interface: TagBase
      rebuilds the html string of the tag including the child tags/values if parameter is true, otherwise returns the html string prebuilt and kept in the cache.
      Parameters:
      rebuild - true to rebuild & false to return previously built string.
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(boolean rebuild, String charset)
      Deprecated.
      Description copied from interface: TagBase
      rebuilds the html string of the tag including the child tags/values if parameter is true, otherwise returns the html string prebuilt and kept in the cache.
      Parameters:
      rebuild - true to rebuild & false to return previously built string.
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8.name()
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toString

      public String toString()
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values. rebuilds the html string if the child tags/values or attributes have been modified.
      Specified by:
      toString in interface TagBase
      Overrides:
      toString in class Object
      Returns:
      String equalent to the html string of the tag including the child tags.
    • getAttributeValueMap

      protected Map<String,String> getAttributeValueMap()
      Returns:
      the attributeValueMap
      Since:
      1.0.0
    • setAttributeValueMap

      protected void setAttributeValueMap(Map<String,String> attributeValueMap)
      Parameters:
      attributeValueMap - the attributeValueMap to set
      Since:
      1.0.0
    • addToAttributeValueMap

      protected boolean addToAttributeValueMap(String key, String value)
      adds the given key value.
      Parameters:
      key -
      value -
      Returns:
      true if it is modified
      Since:
      1.0.0
    • addAllToAttributeValueMap

      protected boolean addAllToAttributeValueMap(Map<String,String> map)
      adds all to the attribute value map.
      Parameters:
      map -
      Returns:
      true if it is modified
      Since:
      1.0.0
    • removeFromAttributeValueMap

      protected boolean removeFromAttributeValueMap(String key)
      removes the key value for the input key.
      Parameters:
      key -
      Returns:
      true if the given key (as well as value contained corresponding to it) has been removed.
      Since:
      1.0.0
    • removeFromAttributeValueMapByKeys

      protected boolean removeFromAttributeValueMapByKeys(String... keys)
      removes the key value for the input key.
      Parameters:
      keys -
      Returns:
      true if any of the given keys (as well as value contained corresponding to it) has been removed.
      Since:
      3.0.1
    • removeFromAttributeValueMap

      protected boolean removeFromAttributeValueMap(String key, String value)
      removes only if the key and value matches in the map for any particular entry.
      Parameters:
      key -
      value -
      Returns:
      true if it is modified
      Since:
      1.0.0
    • removeAllFromAttributeValueMap

      protected void removeAllFromAttributeValueMap()
    • getAttributeValue

      public String getAttributeValue()
      Returns:
      the attributeValue
      Since:
      1.0.0
    • setAttributeValue

      protected void setAttributeValue(String attributeValue)
      Parameters:
      attributeValue - the attributeValue to set
      Since:
      1.0.0
    • setAttributeValue

      protected void setAttributeValue(boolean updateClient, String attributeValue)
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      attributeValue - the attributeValue to set
      Since:
      2.1.15
    • getOwnerTag

      @Deprecated public AbstractHtml getOwnerTag()
      Deprecated.
      this method may be removed later as there could be multiple owner tags.
      Returns:
      one of the ownerTags
      Since:
      1.0.0
    • getOwnerTags

      public AbstractHtml[] getOwnerTags()
      Please know that the AbstractAttribute class doesn't prevent its consumer tags to be garbage collected. So, this is a weak method. i.e. if the consumer tags are garbage collected they will not be included in the array.
      Returns:
      the tags which are consuming this attribute as an array. If there is no owner tag then it will return an empty array instead of null.
      Since:
      2.0.0
    • setOwnerTag

      public void setOwnerTag(AbstractHtml ownerTag)
      NB:- this method is used for internal purpose, so it should not be consumed.
      Parameters:
      ownerTag - the ownerTag to set
      Since:
      1.0.0
    • unsetOwnerTag

      public boolean unsetOwnerTag(AbstractHtml ownerTag)
      NB:- this method is used for internal purpose, so it should not be consumed.
      Parameters:
      ownerTag - the ownerTag to unset
      Returns:
      true if the given ownerTag is an owner of the attribute.
      Since:
      2.0.0
    • setModified

      public void setModified(boolean modified)
      Description copied from class: AbstractTagBase
      set true whenever this object's state is modified.
      Overrides:
      setModified in class AbstractTagBase
      Parameters:
      modified - the modified to set
    • setModifiedLockless

      protected final void setModifiedLockless(boolean modified)
      Parameters:
      modified -
      Since:
      3.0.15
    • getAttributeValueSet

      protected Set<String> getAttributeValueSet()
      NB:- this is only for getting values. Use addToAttributeValueSet method for adding
      Returns:
      the attributeValueSet
      Since:
      1.0.0
    • setAttributeValueSet

      protected void setAttributeValueSet(Set<String> attributeValueSet)
      Parameters:
      attributeValueSet - the attributeValueSet to set
      Since:
      1.0.0
    • addToAttributeValueSet

      protected boolean addToAttributeValueSet(String value)
      adds to the attribute value set.
      Parameters:
      value -
      Returns:
      Since:
      1.0.0
    • addAllToAttributeValueSet

      protected void addAllToAttributeValueSet(Collection<String> values)
      adds all to the attribute value set.
      Parameters:
      values -
      Since:
      1.0.0
    • replaceAllInAttributeValueSet

      protected void replaceAllInAttributeValueSet(Collection<String> values)
      removes all and then adds all to the attribute value set.
      Parameters:
      values -
      Since:
      3.0.1
    • replaceAllInAttributeValueSet

      protected void replaceAllInAttributeValueSet(boolean updateClient, Collection<String> values)
      removes all and then adds all to the attribute value set.
      Parameters:
      updateClient - true to update client browser page
      values -
      Since:
      3.0.1
    • addAllToAttributeValueSet

      protected void addAllToAttributeValueSet(boolean updateClient, Collection<String> values)
      adds all to the attribute value set.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      values -
      Since:
      2.1.15
    • removeFromAttributeValueSet

      protected void removeFromAttributeValueSet(String value)
      removes the value from the the attribute set.
      Parameters:
      value -
      Since:
      1.0.0
    • removeAllFromAttributeValueSet

      protected void removeAllFromAttributeValueSet(Collection<String> values)
      removes the value from the the attribute set.
      Parameters:
      values -
      Since:
      1.0.0
    • removeAllFromAttributeValueSet

      protected void removeAllFromAttributeValueSet()
      clears all values from the value set.
      Since:
      1.0.0
    • beforePrintStructure

      protected void beforePrintStructure()
      invokes just before getPrintStructure(final boolean method and only if the getPrintStructure(final boolean} rebuilds the structure.
      Since:
      1.0.0
    • beforePrintStructureCompressedByIndex

      protected void beforePrintStructureCompressedByIndex()
      invokes just before getPrintStructureCompressedByIndex(final boolean method and only if the getPrintStructureCompressedByIndex(final boolean} rebuilds the structure.
      Since:
      1.0.0
    • getCharset

      public Charset getCharset()
      Returns:
      the charset
    • setCharset

      public void setCharset(Charset charset)
      Parameters:
      charset - the charset to set
    • addValueChangeListener

      public void addValueChangeListener(AttributeValueChangeListener valueChangeListener)
      adds value change lister which will be invoked when the value changed
      Parameters:
      valueChangeListener -
      Since:
      2.0.0
    • removeValueChangeListener

      public void removeValueChangeListener(AttributeValueChangeListener valueChangeListener)
      removes the corresponding value change listener
      Parameters:
      valueChangeListener -
      Since:
      2.0.0
    • getValueChangeListeners

      public Set<AttributeValueChangeListener> getValueChangeListeners()
      Returns:
      the set of value change listeners
      Since:
      2.0.0
    • lockAndGetWriteLocksWithAttrLock

      protected final Collection<Lock> lockAndGetWriteLocksWithAttrLock()
      NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time. Use it for only unlock. This method also locks this attribute as well. NB: this attribute lock is not reentrant.
      Returns:
      the set of write locks after locking
      Since:
      3.0.15
    • lockAndGetWriteLocks

      protected Collection<ReentrantReadWriteLock.WriteLock> lockAndGetWriteLocks()
      NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time. Use it for only unlock.
      Returns:
      the set of write locks after locking
    • lockAndGetReadLocksWithAttrLock

      protected final Collection<Lock> lockAndGetReadLocksWithAttrLock()
      NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time. Use it for only unlock. This method also locks this attribute as well. NB: this attribute lock is not reentrant.
      Returns:
      the set of read locks after locking
      Since:
      3.0.15
    • lockAndGetReadLocks

      protected Collection<ReentrantReadWriteLock.ReadLock> lockAndGetReadLocks()
      NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time. Use it for only unlock.
      Returns:
      the set of read locks after locking
    • getWriteLocks

      protected Collection<ReentrantReadWriteLock.WriteLock> getWriteLocks()
      NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time. So call only once and reuse it for both lock and unlock call. NB: should be unlocked in the reverse order.
      Returns:
      the set of write locks
    • getReadLocks

      protected Collection<ReentrantReadWriteLock.ReadLock> getReadLocks()
      NB: this may not return the same locks as there could be the its ownerTags change. So call only once and reuse it for both lock and unlock call. NB: should be unlocked in the reverse order.
      Returns:
      the set of read locks