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
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractAttribute
(boolean nullableAttrValueMapValue) this constructor is only for the attribute whose value is an attribute value map, eg: style -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
adds all to the attribute value map.protected void
addAllToAttributeValueSet
(boolean updateClient, Collection<String> values) adds all to the attribute value set.protected void
addAllToAttributeValueSet
(Collection<String> values) adds all to the attribute value set.protected boolean
addToAttributeValueMap
(String key, String value) adds the given key value.protected boolean
addToAttributeValueSet
(String value) adds to the attribute value set.void
addValueChangeListener
(AttributeValueChangeListener valueChangeListener) adds value change lister which will be invoked when the value changedprotected void
invokes just beforegetPrintStructure(final boolean
method and only if the getPrintStructure(final boolean} rebuilds the structure.protected void
invokes just beforegetPrintStructureCompressedByIndex(final boolean
method and only if the getPrintStructureCompressedByIndex(final boolean} rebuilds the structure.protected void
NB:- this is only for getting values.protected byte[]
getBinaryStructureCompressedByIndex
(boolean rebuild) gives compressed by index bytes for the attribute and value.protected byte[]
getBinaryStructureCompressedByIndex
(boolean rebuild, Charset charset) gives compressed by index bytes for the attribute and value.Deprecated.this method may be removed later as there could be multiple owner tags.Please know that the AbstractAttribute class doesn't prevent its consumer tags to be garbage collected.protected String
protected String
getPrintStructure
(boolean rebuild) protected Collection<ReentrantReadWriteLock.ReadLock>
NB: this may not return the same locks as there could be the its ownerTags change.protected String
gets the attribute name and value in the format of name=value.protected Collection<ReentrantReadWriteLock.WriteLock>
NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time.protected Collection<ReentrantReadWriteLock.ReadLock>
NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time.protected final Collection<Lock>
NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time.protected Collection<ReentrantReadWriteLock.WriteLock>
NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time.protected final Collection<Lock>
NB: this may not return the same locks as the ownerTags of this attribute may be changed at any time.protected void
protected void
clears all values from the value set.protected void
removes the value from the the attribute set.protected boolean
removes the key value for the input key.protected boolean
removeFromAttributeValueMap
(String key, String value) removes only if the key and value matches in the map for any particular entry.protected boolean
removeFromAttributeValueMapByKeys
(String... keys) removes the key value for the input key.protected void
removes the value from the the attribute set.void
removeValueChangeListener
(AttributeValueChangeListener valueChangeListener) removes the corresponding value change listenerprotected void
replaceAllInAttributeValueSet
(boolean updateClient, Collection<String> values) removes all and then adds all to the attribute value set.protected void
removes all and then adds all to the attribute value set.protected void
setAttributeName
(String attributeName) Set attribute name, eg: width, height, name, type etc..protected void
setAttributeValue
(boolean updateClient, String attributeValue) protected void
setAttributeValue
(String attributeValue) protected void
setAttributeValueMap
(Map<String, String> attributeValueMap) protected void
setAttributeValueSet
(Set<String> attributeValueSet) void
setCharset
(Charset charset) void
setModified
(boolean modified) set true whenever this object's state is modified.protected final void
setModifiedLockless
(boolean modified) void
setOwnerTag
(AbstractHtml ownerTag) NB:- this method is used for internal purpose, so it should not be consumed.protected void
setPreIndexedAttribute
(PreIndexedAttributeName preIndexedAttrName) NB: only for internal use.byte[]
toCompressedBytesByIndex
(boolean rebuild) byte[]
toCompressedBytesByIndex
(boolean rebuild, Charset charset) gets the html string of the tag including the child tags/values.toHtmlString
(boolean rebuild) 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.toHtmlString
(boolean rebuild, String charset) Deprecated.toHtmlString
(boolean rebuild, Charset charset) Deprecated.toHtmlString
(String charset) Deprecated.toHtmlString
(Charset charset) Deprecated.toString()
gets the html string of the tag including the child tags/values.gets the attribute name and value in the format of name=value.boolean
unsetOwnerTag
(AbstractHtml ownerTag) NB:- this method is used for internal purpose, so it should not be consumed.Methods inherited from class com.webfirmframework.wffweb.tag.core.AbstractTagBase
equals, getData, hashCode, isModified, isRebuild, setData, setRebuild
-
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
- Returns:
String
equalent to the html string of the tag including the child tags.- Since:
- 1.0.0
-
getPrintStructure
-
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
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
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
- Returns:
- the attributeName set by
AbstractAttribute#setAttributeName(String)
- Since:
- 1.0.0
-
setAttributeName
Set attribute name, eg: width, height, name, type etc..- Parameters:
attributeName
- the attributeName to set- Since:
- 1.0.0
-
setPreIndexedAttribute
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
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
- Throws:
IOException
-
toCompressedBytesByIndex
- Throws:
IOException
-
toHtmlString
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.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
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.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.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
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. -
getAttributeValueMap
- Returns:
- the attributeValueMap
- Since:
- 1.0.0
-
setAttributeValueMap
- Parameters:
attributeValueMap
- the attributeValueMap to set- Since:
- 1.0.0
-
addToAttributeValueMap
adds the given key value.- Parameters:
key
-value
-- Returns:
- true if it is modified
- Since:
- 1.0.0
-
addAllToAttributeValueMap
adds all to the attribute value map.- Parameters:
map
-- Returns:
- true if it is modified
- Since:
- 1.0.0
-
removeFromAttributeValueMap
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
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
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
- Returns:
- the attributeValue
- Since:
- 1.0.0
-
setAttributeValue
- Parameters:
attributeValue
- the attributeValue to set- Since:
- 1.0.0
-
setAttributeValue
- 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.this method may be removed later as there could be multiple owner tags.- Returns:
- one of the ownerTags
- Since:
- 1.0.0
-
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
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
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 classAbstractTagBase
- Parameters:
modified
- the modified to set
-
setModifiedLockless
protected final void setModifiedLockless(boolean modified) - Parameters:
modified
-- Since:
- 3.0.15
-
getAttributeValueSet
NB:- this is only for getting values. Use addToAttributeValueSet method for adding- Returns:
- the attributeValueSet
- Since:
- 1.0.0
-
setAttributeValueSet
- Parameters:
attributeValueSet
- the attributeValueSet to set- Since:
- 1.0.0
-
addToAttributeValueSet
adds to the attribute value set.- Parameters:
value
-- Returns:
- Since:
- 1.0.0
-
addAllToAttributeValueSet
adds all to the attribute value set.- Parameters:
values
-- Since:
- 1.0.0
-
replaceAllInAttributeValueSet
removes all and then adds all to the attribute value set.- Parameters:
values
-- Since:
- 3.0.1
-
replaceAllInAttributeValueSet
removes all and then adds all to the attribute value set.- Parameters:
updateClient
- true to update client browser pagevalues
-- Since:
- 3.0.1
-
addAllToAttributeValueSet
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
removes the value from the the attribute set.- Parameters:
value
-- Since:
- 1.0.0
-
removeAllFromAttributeValueSet
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 beforegetPrintStructure(final boolean
method and only if the getPrintStructure(final boolean} rebuilds the structure.- Since:
- 1.0.0
-
beforePrintStructureCompressedByIndex
protected void beforePrintStructureCompressedByIndex()invokes just beforegetPrintStructureCompressedByIndex(final boolean
method and only if the getPrintStructureCompressedByIndex(final boolean} rebuilds the structure.- Since:
- 1.0.0
-
getCharset
- Returns:
- the charset
-
setCharset
- Parameters:
charset
- the charset to set
-
addValueChangeListener
adds value change lister which will be invoked when the value changed- Parameters:
valueChangeListener
-- Since:
- 2.0.0
-
removeValueChangeListener
removes the corresponding value change listener- Parameters:
valueChangeListener
-- Since:
- 2.0.0
-
getValueChangeListeners
- Returns:
- the set of value change listeners
- Since:
- 2.0.0
-
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
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
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
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
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
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
-