Class Style
java.lang.Object
com.webfirmframework.wffweb.tag.core.AbstractTagBase
com.webfirmframework.wffweb.tag.html.attribute.core.AbstractAttribute
com.webfirmframework.wffweb.tag.html.attribute.global.Style
- All Implemented Interfaces:
StateChangeInformer<CssProperty>
,TagBase
,GlobalAttributable
,Serializable
,Cloneable
public class Style
extends AbstractAttribute
implements GlobalAttributable, StateChangeInformer<CssProperty>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String,
AbstractCssProperty<?>> style name as key and value as object ofAbstractCssProperty
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCssProperties
(boolean important, CssProperty... cssProperties) addCssProperties
(CssProperty... cssProperties) void
addCssProperties
(String cssProperties) addCssProperties
(Collection<? extends CssProperty> cssProperties) Deprecated.boolean
addCssProperties
(Map<String, String> cssProperties) addCssProperty
(CssProperty cssProperty) boolean
addCssProperty
(String cssName, String cssValue) eg:addCssProperty("color", "green")
static void
addSupportForNewCustomCssClass
(String cssName, Class<?> cssClass) protected void
invokes just beforegetPrintStructure(final boolean
method and only if the getPrintStructure(final boolean} rebuilds the structure.boolean
contains
(CssProperty cssProperty) Checks if the given cssProperty object exists in this style object.gets theCollection<CssProperty>
.int
getCssProperty
(String cssName) protected StampedLock
protected void
init()
invokes only once per objectboolean
boolean
isImportant
(CssProperty cssProperty) boolean
isImportant
(String styleName) boolean
markAsImportant
(String styleName) marks as important.boolean
markAsUnimportant
(String styleName) marks as unimportant.void
Removes all css propertiesremoveCssProperties
(CssProperty... cssProperties) removeCssProperties
(Collection<CssProperty> cssProperties) Deprecated.After using this method, adding or removing any value in the collection will not have any effect onStyle
, so this method may be removed later.boolean
removeCssProperty
(CssProperty cssProperty) removes the style.boolean
removeCssProperty
(String cssName) removes the style.boolean
removeCssProperty
(String cssName, String cssValue) removes only if it contains the given style name and value.static void
removeSupportOfCssClass
(Class<?> cssClass) removes the support for the class fromStyle class
or its extended class.static void
removeSupportOfCssClasses
(Class<?>... cssClasses) removes the support for the classes fromStyle class
or its extended class.void
stateChanged
(CssProperty stateChangedObject) Methods inherited from class com.webfirmframework.wffweb.tag.html.attribute.core.AbstractAttribute
addAllToAttributeValueMap, addAllToAttributeValueSet, addAllToAttributeValueSet, addToAttributeValueMap, addToAttributeValueSet, addValueChangeListener, beforePrintStructureCompressedByIndex, beforeWffPrintStructure, getAttributeName, getAttributeValueMap, getAttributeValueSet, getBinaryStructureCompressedByIndex, getBinaryStructureCompressedByIndex, getCharset, getOwnerTag, getOwnerTags, getPrintStructure, getPrintStructure, getReadLocks, getValueChangeListeners, getWffPrintStructure, getWriteLocks, lockAndGetReadLocks, lockAndGetReadLocksWithAttrLock, lockAndGetWriteLocks, lockAndGetWriteLocksWithAttrLock, removeAllFromAttributeValueMap, removeAllFromAttributeValueSet, removeAllFromAttributeValueSet, removeFromAttributeValueMap, removeFromAttributeValueMap, removeFromAttributeValueMapByKeys, removeFromAttributeValueSet, removeValueChangeListener, replaceAllInAttributeValueSet, replaceAllInAttributeValueSet, setAttributeName, setAttributeValue, setAttributeValue, setAttributeValueMap, setAttributeValueSet, setCharset, setModified, setModifiedLockless, setOwnerTag, setPreIndexedAttribute, toCompressedBytesByIndex, toCompressedBytesByIndex, toHtmlString, toHtmlString, toHtmlString, toHtmlString, toHtmlString, toHtmlString, toString, toWffString, unsetOwnerTag
Methods inherited from class com.webfirmframework.wffweb.tag.core.AbstractTagBase
equals, getData, hashCode, isModified, isRebuild, setData, setRebuild
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.webfirmframework.wffweb.tag.core.TagBase
toHtmlString, toHtmlString, toHtmlString, toHtmlString, toHtmlString, toHtmlString, toString
-
Field Details
-
abstractCssPropertyClassObjects
style name as key and value as object ofAbstractCssProperty
-
-
Constructor Details
-
Style
public Style() -
Style
- Parameters:
styles
- styles separated by semicolon.
eg :-color:blue;text-align:center
-
Style
- Parameters:
styles
-Map
containing styles,
eg :
Map<String, String> styles = new HashMap<String, String>();
styles.put("color", "green");
-
Style
- Parameters:
cssProperties
- eg :-addCssProperties(AlignContent.FLEX_END, AlignItems.FLEX_END)
- Since:
- 1.0.0
-
Style
- Parameters:
important
- true to mark the given style as important.cssProperties
- eg :-addStyles(true, AlignContent.FLEX_END, AlignItems.FLEX_END)
- Since:
- 1.0.0
-
-
Method Details
-
addSupportForNewCustomCssClass
- Parameters:
cssName
- custom css name eg:-"custom-width"
cssClass
- corresponding custom css class/enum for"custom-width"
, may beCustomWidth.class
- Since:
- 1.0.0
-
removeSupportOfCssClass
removes the support for the class fromStyle class
or its extended class.- Parameters:
cssClass
-- Since:
- 1.0.0
-
removeSupportOfCssClasses
removes the support for the classes fromStyle class
or its extended class.- Parameters:
cssClasses
-- Since:
- 1.0.0
-
getStyleLock
- Returns:
- the lock for this object
- Since:
- 3.0.1
-
addCssProperties
- Parameters:
cssProperties
- styles separated by semicolon.
eg :-color:blue;text-align:center
- Since:
- 1.0.0
-
addCssProperties
- Parameters:
cssProperties
-Map
containing styles,
eg :
Map<String, String> cssProperties = new HashMap<String, String>();
cssProperties.put("color", "green");
- Returns:
- true if the values are added otherwise false.
-
addCssProperty
eg:addCssProperty("color", "green")
- Parameters:
cssName
- eg: colorcssValue
- eg: green (for color styleName)- Returns:
- true if the cssName and cssValue has been added or modified. If it contains same style name and value then it will return false.
- Since:
- 1.0.0
-
addCssProperties
- Parameters:
important
- true to mark the given style as important.cssProperties
- eg :-addCssProperties(true, AlignContent.FLEX_END, AlignItems.FLEX_END)
- Since:
- 1.0.0
-
addCssProperties
- Parameters:
cssProperties
- eg :-addStyles(AlignContent.FLEX_END, AlignItems.FLEX_END)
- Returns:
- the added
CssProperty
objects as aList<CssProperty>
. - Since:
- 1.0.0
-
addCssProperties
@Deprecated public List<CssProperty> addCssProperties(Collection<? extends CssProperty> cssProperties) Deprecated.After using this method, adding or removing any value in the collection will not have any effect onStyle
, so this method may be removed later.adds each cssProperty from the given collection.
NB:- After using this method, adding or removing any value in the collection will not have any effect onStyle
, so this method may be removed later.- Parameters:
cssProperties
- eg :-addStyles(Arrays.asList(AlignContent.FLEX_END, AlignItems.FLEX_END))
- Returns:
- the added
CssProperty
objects as aList<CssProperty>
. - Since:
- 1.0.0
-
addCssProperty
- Parameters:
cssProperty
- eg :-addStyle(AlignContent.FLEX_END)
- Returns:
- the added
CssProperty
objects as aCssProperty
. - Since:
- 1.0.0
-
removeCssProperty
removes the style.- Parameters:
cssName
- eg: color- Returns:
- true if the given cssName (as well as value contained corresponding to it) has been removed, if it contains no cssName then false.
- Since:
- 1.0.0
-
removeCssProperty
removes only if it contains the given style name and value.- Parameters:
cssName
- eg: colorcssValue
- eg: green (for color styleName)- Returns:
- true if the given syleName (as well as value contained corresponding to it) has been removed, or false if it doesn't contain the given styleName and value.
- Since:
- 1.0.0
-
removeCssProperty
removes the style.- Parameters:
cssProperty
-- Returns:
- true if the given syleName (as well as value contained corresponding to it) has been removed, or false if it doesn't contain the given styleName and value.
- Since:
- 1.0.0
-
removeCssProperties
- Parameters:
cssProperties
-- Returns:
- the
List<Boolean>
of status whether the corresponding object has been removed. - Since:
- 1.0.0
-
removeAllCssProperties
public void removeAllCssProperties()Removes all css properties- Since:
- 3.0.1
-
contains
Checks if the given cssProperty object exists in this style object.- Returns:
- Since:
- 3.0.1
-
removeCssProperties
Deprecated.After using this method, adding or removing any value in the collection will not have any effect onStyle
, so this method may be removed later.NB:- After using this method, adding or removing any value in the collection will not have any effect onStyle
, so this method may be removed later.- Parameters:
cssProperties
-- Returns:
- the
List<Boolean>
of status whether the corresponding object has been removed. - Since:
- 1.0.0
-
markAsImportant
marks as important. i.e. it will add!important
from the corresponding styleName value- Parameters:
styleName
-- Returns:
- true if it's marked as important or false if it already marked as important
- Since:
- 1.0.0
-
markAsUnimportant
marks as unimportant. i.e. it will remove!important
from the corresponding styleName value- Parameters:
styleName
-- Returns:
- true if it's marked as unimportant or false if it already marked as unimportant
- Since:
- 1.0.0
-
init
protected void init()invokes only once per object- Since:
- 1.0.0
-
isImportant
- Parameters:
cssProperty
-- Returns:
- true if the given style value has been set as important otherwise
false. eg : for content-align : flex-end,
isImportant(AlignContent.FLEX_END)
will return true butisImportant(AlignContent.CENTER)
will return false. UseisImportant(alignContent.getName())
orisImportant(StyleContants.ALIGN_CONTENT)
to avoid checking of the value. - Since:
- 1.0.0
-
isImportant
- Parameters:
styleName
-- Returns:
- true if the given style name is marked as important. eg:- for
content-align : flex-end,
isImportant(alignContent.getName())
andisImportant(StyleContants.ALIGN_CONTENT)
will return true. - Since:
- 1.0.0
-
getCssProperty
- Parameters:
cssName
-- Returns:
- the Enum object which implements
CssProperty
interface. This object be may type casted in to the corresponding enum, eg:-
CssProperty cssProperty = style.getCssProperty(CssConstants.ALIGN_CONTENT);
if (cssProperty != null && CssConstants.ALIGN_CONTENT.equals(cssProperty.getName()))
AlignContent alignContent = (AlignContent) cssProperty;
- Since:
- 1.0.0
-
getCssProperties
gets theCollection<CssProperty>
. It's unmodifiable set since 3.0.1.- Returns:
Collection<CssProperty>
- Since:
- 1.0.0
-
getCssPropertiesSize
public int getCssPropertiesSize()- Returns:
- the size
- Since:
- 3.0.1
-
isCssPropertiesEmpty
public boolean isCssPropertiesEmpty()- Returns:
- true if empty
- Since:
- 3.0.1
-
stateChanged
- Specified by:
stateChanged
in interfaceStateChangeInformer<CssProperty>
-
beforePrintStructure
protected void beforePrintStructure()Description copied from class:AbstractAttribute
invokes just beforegetPrintStructure(final boolean
method and only if the getPrintStructure(final boolean} rebuilds the structure.- Overrides:
beforePrintStructure
in classAbstractAttribute
-
getSupportedCsspropertyClasses
- Returns:
- the csspropertyClasses
- Since:
- 1.0.0
-
getAttributeValue
- Overrides:
getAttributeValue
in classAbstractAttribute
- Returns:
- the value string of css properties
- Since:
- 2.1.9
-
Style
, so this method may be removed later.