@NotThreadSafe public class CSSDeclaration extends Object implements ICSSSourceLocationAware, ICSSPageRuleMember
color:red;
or background:uri(a.gif) !important;)| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_IMPORTANT |
| Constructor and Description |
|---|
CSSDeclaration(String sProperty,
CSSExpression aExpression)
Constructor for non-important values.
|
CSSDeclaration(String sProperty,
CSSExpression aExpression,
boolean bIsImportant)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
CSSExpression |
getExpression() |
String |
getExpressionAsCSSString()
Get the CSS expression, but without an eventual `!
|
String |
getProperty() |
CSSSourceLocation |
getSourceLocation() |
int |
hashCode() |
boolean |
hasProperty(ECSSProperty eProperty)
Check if this declaration has the specified property.
|
boolean |
hasProperty(String sProperty)
Check if this declaration has the specified property.
|
boolean |
isImportant() |
CSSDeclaration |
setExpression(CSSExpression aExpression)
Set the expression (= value) of this declaration.
|
CSSDeclaration |
setImportant(boolean bIsImportant)
Set the important flag of this value.
|
CSSDeclaration |
setProperty(ECSSProperty eProperty)
Set the property of this CSS value (e.g.
|
CSSDeclaration |
setProperty(String sProperty)
Set the property of this CSS value (e.g.
|
void |
setSourceLocation(CSSSourceLocation aSourceLocation)
Set the source location of the object, determined while parsing.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetAsCSSString, getAsCSSStringpublic static final boolean DEFAULT_IMPORTANT
public CSSDeclaration(@Nonnull @Nonempty String sProperty, @Nonnull CSSExpression aExpression)
sProperty - The name of the property. E.g. "color". May neither be
null nor empty. The property value is automatically
lowercased!aExpression - The value of the property. May not be null.public CSSDeclaration(@Nonnull @Nonempty String sProperty, @Nonnull CSSExpression aExpression, boolean bIsImportant)
sProperty - The name of the property. E.g. "color". May neither be
null nor empty. The property value is automatically
lowercased!aExpression - The value of the property. May not be null.bIsImportant - true if it is important, false if not.@Nonnull @Nonempty public String getProperty()
null.public boolean hasProperty(@Nonnull String sProperty)
sProperty - The property to check. May not be null.true if this declaration has the specified property.hasProperty(ECSSProperty)public boolean hasProperty(@Nonnull ECSSProperty eProperty)
eProperty - The property to check. May not be null.true if this declaration has the specified property.hasProperty(String)@Nonnull public CSSDeclaration setProperty(@Nonnull @Nonempty String sProperty)
background-color).sProperty - The CSS property name to set. May neither be null nor
empty. The property value is automatically lowercased!@Nonnull public CSSDeclaration setProperty(@Nonnull ECSSProperty eProperty)
background-color).eProperty - The CSS property to set. May not be null.@Nonnull @ReturnsMutableObject public CSSExpression getExpression()
null.@Nonnull public String getExpressionAsCSSString()
null.@Nonnull public CSSDeclaration setExpression(@Nonnull CSSExpression aExpression)
aExpression - The value of the property. May not be null.public boolean isImportant()
true if this declaration is important (
!important) or false if not.@Nonnull public CSSDeclaration setImportant(boolean bIsImportant)
bIsImportant - true to mark it important, false to remove
it.@Nonnull @Nonempty public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
ICSSWriteablegetAsCSSString in interface ICSSWriteableaSettings - The settings to be used to format the output. May not be
null.nIndentLevel - The current indentation levelnull.public void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
ICSSSourceLocationAwaresetSourceLocation in interface ICSSSourceLocationAwareaSourceLocation - The source location to use. May be null.@Nullable public CSSSourceLocation getSourceLocation()
getSourceLocation in interface ICSSSourceLocationAwarenull if an object was not read but manually
created.Copyright © 2014–2018 Philip Helger. All rights reserved.