@NotThreadSafe public class CSSStyleRule extends Object implements ICSSTopLevelRule, IHasCSSDeclarations<CSSStyleRule>, ICSSSourceLocationAware
div { color: red; }| Constructor and Description |
|---|
CSSStyleRule() |
| Modifier and Type | Method and Description |
|---|---|
CSSStyleRule |
addDeclaration(CSSDeclaration aDeclaration)
Add a new declaration.
|
CSSStyleRule |
addDeclaration(int nIndex,
CSSDeclaration aNewDeclaration)
Add a new declaration at the specified index.
|
CSSStyleRule |
addSelector(CSSSelector aSelector) |
CSSStyleRule |
addSelector(ICSSSelectorMember aSingleSelectorMember) |
CSSStyleRule |
addSelector(int nIndex,
CSSSelector aSelector) |
CSSStyleRule |
addSelector(int nIndex,
ICSSSelectorMember aSingleSelectorMember) |
boolean |
equals(Object o) |
com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> |
getAllDeclarations() |
com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> |
getAllDeclarationsOfPropertyName(String sPropertyName)
Get all declarations within this list that have the specified property
name.
|
com.helger.commons.collection.impl.ICommonsList<CSSSelector> |
getAllSelectors() |
String |
getAsCSSString(ICSSWriterSettings aSettings,
int nIndentLevel)
Get the contents of this object as a serialized CSS string for writing to
an output.
|
CSSDeclaration |
getDeclarationAtIndex(int nIndex) |
int |
getDeclarationCount() |
CSSDeclaration |
getDeclarationOfPropertyName(String sPropertyName)
Get the first declaration with the specified property name.
|
CSSSelector |
getSelectorAtIndex(int nSelectorIndex) |
int |
getSelectorCount() |
String |
getSelectorsAsCSSString(ICSSWriterSettings aSettings,
int nIndentLevel) |
CSSSourceLocation |
getSourceLocation() |
boolean |
hasDeclarations() |
int |
hashCode() |
boolean |
hasSelectors() |
com.helger.commons.state.EChange |
removeAllDeclarations()
Remove all declarations.
|
com.helger.commons.state.EChange |
removeAllSelectors()
Remove all selectors.
|
com.helger.commons.state.EChange |
removeDeclaration(CSSDeclaration aDeclaration)
Remove the given declaration
|
com.helger.commons.state.EChange |
removeDeclaration(int nDeclarationIndex)
Remove the declaration at the specified index
|
com.helger.commons.state.EChange |
removeSelector(CSSSelector aSelector) |
com.helger.commons.state.EChange |
removeSelector(int nSelectorIndex) |
CSSStyleRule |
setDeclarationAtIndex(int nIndex,
CSSDeclaration aNewDeclaration)
Set the declaration at the specified index with a new one.
|
void |
setSourceLocation(CSSSourceLocation aSourceLocation)
Set the source location of the object, determined while parsing.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitaddDeclaration, getAllDeclarationsOfPropertyNameCaseInsensitive, getDeclarationOfPropertyNameCaseInsensitivegetAsCSSString, getAsCSSStringpublic boolean hasSelectors()
@Nonnegative public int getSelectorCount()
@Nonnull public CSSStyleRule addSelector(@Nonnull ICSSSelectorMember aSingleSelectorMember)
@Nonnull public CSSStyleRule addSelector(@Nonnull CSSSelector aSelector)
@Nonnull public CSSStyleRule addSelector(@Nonnegative int nIndex, @Nonnull ICSSSelectorMember aSingleSelectorMember)
@Nonnull public CSSStyleRule addSelector(@Nonnegative int nIndex, @Nonnull CSSSelector aSelector)
@Nonnull public com.helger.commons.state.EChange removeSelector(@Nonnull CSSSelector aSelector)
@Nonnull public com.helger.commons.state.EChange removeSelector(@Nonnegative int nSelectorIndex)
@Nonnull public com.helger.commons.state.EChange removeAllSelectors()
EChange.CHANGED if any selector was removed,
EChange.UNCHANGED otherwise. Never null.@Nullable public CSSSelector getSelectorAtIndex(@Nonnegative int nSelectorIndex)
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSSelector> getAllSelectors()
@Nonnull public CSSStyleRule addDeclaration(@Nonnull CSSDeclaration aDeclaration)
IHasCSSDeclarationsaddDeclaration in interface IHasCSSDeclarations<CSSStyleRule>aDeclaration - The declaration to be added. May not be null.@Nonnull public CSSStyleRule addDeclaration(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
IHasCSSDeclarationsaddDeclaration in interface IHasCSSDeclarations<CSSStyleRule>nIndex - The index to retrieve. Must be ≥ 0. If the index is ≥ than
getDeclarationCount(), it behaves like
IHasCSSDeclarations.addDeclaration(CSSDeclaration).aNewDeclaration - The declaration to be added. May not be null.@Nonnull public com.helger.commons.state.EChange removeDeclaration(@Nonnull CSSDeclaration aDeclaration)
IHasCSSDeclarationsremoveDeclaration in interface IHasCSSDeclarations<CSSStyleRule>aDeclaration - The declaration to be removed. May not be null.EChange.CHANGED if the declaration was successfully removed@Nonnull public com.helger.commons.state.EChange removeDeclaration(@Nonnegative int nDeclarationIndex)
IHasCSSDeclarationsremoveDeclaration in interface IHasCSSDeclarations<CSSStyleRule>nDeclarationIndex - The index of the declaration to be removed. Must be ≥ 0.EChange.CHANGED if the declaration was successfully
removed, EChange.UNCHANGED if the index was invalid.@Nonnull public com.helger.commons.state.EChange removeAllDeclarations()
IHasCSSDeclarationsremoveAllDeclarations in interface IHasCSSDeclarations<CSSStyleRule>EChange.CHANGED if any declaration was removed,
EChange.UNCHANGED otherwise. Never null.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarations()
getAllDeclarations in interface IHasCSSDeclarations<CSSStyleRule>null copy of all contained
declarations.@Nullable public CSSDeclaration getDeclarationAtIndex(@Nonnegative int nIndex)
getDeclarationAtIndex in interface IHasCSSDeclarations<CSSStyleRule>nIndex - The index to retrievenull if the
index is invalid@Nonnull public CSSStyleRule setDeclarationAtIndex(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
IHasCSSDeclarationssetDeclarationAtIndex in interface IHasCSSDeclarations<CSSStyleRule>nIndex - The index to retrieve. Must be ≥ 0. If the index is ≥ than
getDeclarationCount(), it behaves like
IHasCSSDeclarations.addDeclaration(CSSDeclaration).aNewDeclaration - The new declaration to be set.public boolean hasDeclarations()
hasDeclarations in interface IHasCSSDeclarations<CSSStyleRule>true if at least one declaration is present,
false if no declaration is present.@Nonnegative public int getDeclarationCount()
getDeclarationCount in interface IHasCSSDeclarations<CSSStyleRule>@Nullable public CSSDeclaration getDeclarationOfPropertyName(@Nullable String sPropertyName)
IHasCSSDeclarationsnull is returned. If more than one
declaration ith the specified property name is present, always the first in
the list will be returned. The comparison happens case insensitive
(since v6.0.0).getDeclarationOfPropertyName in interface IHasCSSDeclarations<CSSStyleRule>sPropertyName - The property name of the declaration to search (e.g.
color). May be null.null if no such property name was found.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarationsOfPropertyName(@Nullable String sPropertyName)
IHasCSSDeclarationsgetAllDeclarationsOfPropertyName in interface IHasCSSDeclarations<CSSStyleRule>sPropertyName - The property name of the declaration to search (e.g.
color). May be null.null but maybe an empty list.@Nonnull public String getSelectorsAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
@Nonnull 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.@Nullable public final CSSSourceLocation getSourceLocation()
getSourceLocation in interface ICSSSourceLocationAwarenull if an object was not read but manually
created.public final void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
ICSSSourceLocationAwaresetSourceLocation in interface ICSSSourceLocationAwareaSourceLocation - The source location to use. May be null.Copyright © 2014–2022 Philip Helger. All rights reserved.