Package com.helger.css.propertyvalue
Class CSSValue
- java.lang.Object
-
- com.helger.css.propertyvalue.CSSValue
-
- All Implemented Interfaces:
ICSSWriteable,ICSSValue
@NotThreadSafe public class CSSValue extends Object implements ICSSValue
Represents the combination of a single CSS property (ICSSProperty) and it's according value plus the important state (!importantor not). The main purpose of this class to make building a CSS from scratch simpler. When an existing CSS is read the information resides in aCSSDeclarationbecause it contains the declaration value in a more structured form.
Instances of this class are mutable since 3.7.3.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_CONSISTENCY_CHECKS_ENABLED
-
Constructor Summary
Constructors Constructor Description CSSValue(ICSSProperty aProperty, String sValue, boolean bIsImportant)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanareConsistencyChecksEnabled()booleanequals(Object o)StringgetAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)Get the contents of this object as a serialized CSS string for writing to an output.ECSSPropertygetProp()ICSSPropertygetProperty()StringgetPropertyName()StringgetValue()inthashCode()booleanisImportant()static voidsetConsistencyChecksEnabled(boolean bEnabled)Enable or disable consistency checks.CSSValuesetImportant(boolean bIsImportant)Set the important flag of this value.CSSValuesetProperty(ICSSProperty aProperty)Set the property of this CSS value (e.g.CSSValuesetValue(String sValue)Set the value of this CSS value (e.g.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString
-
-
-
-
Field Detail
-
DEFAULT_CONSISTENCY_CHECKS_ENABLED
public static final boolean DEFAULT_CONSISTENCY_CHECKS_ENABLED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CSSValue
public CSSValue(@Nonnull ICSSProperty aProperty, @Nonnull String sValue, boolean bIsImportant)
Constructor- Parameters:
aProperty- The CSS property. May not benull.sValue- The String value to use. May benull. The value may NOT contain the!importantflag! The value is internally trimmed to avoid leading and trailing.bIsImportant-trueif the value should be important,falseotherwise
-
-
Method Detail
-
areConsistencyChecksEnabled
public static boolean areConsistencyChecksEnabled()
- Returns:
trueif consistency checks are enabled (by default),falseif not.- Since:
- 5.0.2
-
setConsistencyChecksEnabled
public static void setConsistencyChecksEnabled(boolean bEnabled)
Enable or disable consistency checks. By default the consistency checks are enabled (for backwards compatibility) but if performance is a real matter, you may want to disable them globally.- Parameters:
bEnabled-trueto enable them,falseto disable them.- Since:
- 5.0.2
-
getProperty
@Nonnull public ICSSProperty getProperty()
- Returns:
- The CSS property used. Never
null.
-
getProp
@Nonnull public ECSSProperty getProp()
-
getPropertyName
@Nonnull @Nonempty public String getPropertyName()
- Returns:
- The property name including an eventually contained vendor prefix.
Neither
nullnor empty. - Since:
- 3.9.0
-
setProperty
@Nonnull public CSSValue setProperty(@Nonnull ICSSProperty aProperty)
Set the property of this CSS value (e.g.background-color).- Parameters:
aProperty- The CSS property to set. May not benull.- Returns:
- this
- Since:
- 3.7.3
-
getValue
@Nonnull public String getValue()
- Returns:
- The CSS value used. May not be
nullbut maybe empty.
-
setValue
@Nonnull public CSSValue setValue(@Nonnull String sValue)
Set the value of this CSS value (e.g.redin case the property isbackground-color).- Parameters:
sValue- The value to be set. May not benull. The value may NOT contain the!importantflag! The value is internally trimmed to avoid leading and trailing.- Returns:
- this
- Since:
- 3.7.3
-
isImportant
public boolean isImportant()
- Returns:
trueif it is important,falseif not
-
setImportant
@Nonnull public CSSValue setImportant(boolean bIsImportant)
Set the important flag of this value.- Parameters:
bIsImportant-trueto mark it important,falseto remove it.- Returns:
- this
- Since:
- 3.7.3
-
getAsCSSString
@Nonnull public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
Description copied from interface:ICSSWriteableGet the contents of this object as a serialized CSS string for writing to an output.- Specified by:
getAsCSSStringin interfaceICSSWriteable- Parameters:
aSettings- The settings to be used to format the output. May not benull.nIndentLevel- The current indentation level- Returns:
- The content of this object as CSS string. Never
null.
-
-