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 (!important
or 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 aCSSDeclaration
because 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 boolean
DEFAULT_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 boolean
areConsistencyChecksEnabled()
boolean
equals(Object o)
String
getAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)
Get the contents of this object as a serialized CSS string for writing to an output.ECSSProperty
getProp()
ICSSProperty
getProperty()
String
getPropertyName()
String
getValue()
int
hashCode()
boolean
isImportant()
static void
setConsistencyChecksEnabled(boolean bEnabled)
Enable or disable consistency checks.CSSValue
setImportant(boolean bIsImportant)
Set the important flag of this value.CSSValue
setProperty(ICSSProperty aProperty)
Set the property of this CSS value (e.g.CSSValue
setValue(String sValue)
Set the value of this CSS value (e.g.String
toString()
-
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!important
flag! The value is internally trimmed to avoid leading and trailing.bIsImportant
-true
if the value should be important,false
otherwise
-
-
Method Detail
-
areConsistencyChecksEnabled
public static boolean areConsistencyChecksEnabled()
- Returns:
true
if consistency checks are enabled (by default),false
if 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
-true
to enable them,false
to 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
null
nor 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
null
but maybe empty.
-
setValue
@Nonnull public CSSValue setValue(@Nonnull String sValue)
Set the value of this CSS value (e.g.red
in case the property isbackground-color
).- Parameters:
sValue
- The value to be set. May not benull
. The value may NOT contain the!important
flag! The value is internally trimmed to avoid leading and trailing.- Returns:
- this
- Since:
- 3.7.3
-
isImportant
public boolean isImportant()
- Returns:
true
if it is important,false
if not
-
setImportant
@Nonnull public CSSValue setImportant(boolean bIsImportant)
Set the important flag of this value.- Parameters:
bIsImportant
-true
to mark it important,false
to remove it.- Returns:
- this
- Since:
- 3.7.3
-
getAsCSSString
@Nonnull public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
Description copied from interface:ICSSWriteable
Get the contents of this object as a serialized CSS string for writing to an output.- Specified by:
getAsCSSString
in 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
.
-
-