@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, wait
getAsCSSString, getAsCSSString
public 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 final 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 final 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 final 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 final 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)
ICSSWriteable
getAsCSSString
in interface ICSSWriteable
aSettings
- The settings to be used to format the output. May not be
null
.nIndentLevel
- The current indentation levelnull
.public void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
ICSSSourceLocationAware
setSourceLocation
in interface ICSSSourceLocationAware
aSourceLocation
- The source location to use. May be null
.@Nullable public CSSSourceLocation getSourceLocation()
getSourceLocation
in interface ICSSSourceLocationAware
null
if an object was not read but manually
created.Copyright © 2014–2021 Philip Helger. All rights reserved.