Package com.helger.css.decl
Interface IHasCSSDeclarations<IMPLTYPE extends IHasCSSDeclarations<IMPLTYPE>>
- Type Parameters:
IMPLTYPE- Implementation type
- All Superinterfaces:
ICSSWriteable,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
- All Known Implementing Classes:
CSSDeclarationContainer,CSSDeclarationList,CSSFontFaceRule,CSSKeyframesBlock,CSSPageMarginBlock,CSSStyleRule,CSSViewportRule
public interface IHasCSSDeclarations<IMPLTYPE extends IHasCSSDeclarations<IMPLTYPE>>
extends ICSSWriteable, com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
Sanity interface for all objects having CSS declarations.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionaddDeclaration(int nIndex, CSSDeclaration aDeclaration) Add a new declaration at the specified index.addDeclaration(CSSDeclaration aDeclaration) Add a new declaration.default IMPLTYPEaddDeclaration(String sProperty, CSSExpression aExpression, boolean bImportant) Add a new declaration.com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>getAllDeclarationsOfPropertyName(String sPropertyName) Get all declarations within this list that have the specified property name.default com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>getAllDeclarationsOfPropertyNameCaseInsensitive(String sPropertyName) Deprecated.getDeclarationAtIndex(int nIndex) intgetDeclarationOfPropertyName(String sPropertyName) Get the first declaration with the specified property name.default CSSDeclarationgetDeclarationOfPropertyNameCaseInsensitive(String sPropertyName) Deprecated.Since 6.0.0 - usegetDeclarationOfPropertyName(String)instead.booleancom.helger.commons.state.EChangeRemove all declarations.com.helger.commons.state.EChangeremoveDeclaration(int nDeclarationIndex) Remove the declaration at the specified indexcom.helger.commons.state.EChangeremoveDeclaration(CSSDeclaration aDeclaration) Remove the given declarationsetDeclarationAtIndex(int nIndex, CSSDeclaration aNewDeclaration) Set the declaration at the specified index with a new one.Methods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString, getAsCSSStringMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Method Details
-
addDeclaration
Add a new declaration.- Parameters:
aDeclaration- The declaration to be added. May not benull.- Returns:
- this
-
addDeclaration
@Nonnull default IMPLTYPE addDeclaration(@Nonnull @Nonempty String sProperty, @Nonnull CSSExpression aExpression, boolean bImportant) Add a new declaration.- Parameters:
sProperty- The name of the property. E.g. "color". May neither benullnor empty.aExpression- The value of the property. May not benull.bImportant-trueif it is important,falseif not.- Returns:
- this
-
addDeclaration
Add a new declaration at the specified index.- Parameters:
nIndex- The index to retrieve. Must be ≥ 0. If the index is ≥ thangetDeclarationCount(), it behaves likeaddDeclaration(CSSDeclaration).aDeclaration- The declaration to be added. May not benull.- Returns:
- this
-
removeDeclaration
Remove the given declaration- Parameters:
aDeclaration- The declaration to be removed. May not benull.- Returns:
EChange.CHANGEDif the declaration was successfully removed
-
removeDeclaration
Remove the declaration at the specified index- Parameters:
nDeclarationIndex- The index of the declaration to be removed. Must be ≥ 0.- Returns:
EChange.CHANGEDif the declaration was successfully removed,EChange.UNCHANGEDif the index was invalid.
-
removeAllDeclarations
Remove all declarations.- Returns:
EChange.CHANGEDif any declaration was removed,EChange.UNCHANGEDotherwise. Nevernull.- Since:
- 3.7.3
-
getAllDeclarations
@Nonnull @ReturnsMutableCopy com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarations()- Returns:
- A mutable, non-
nullcopy of all contained declarations.
-
getDeclarationAtIndex
- Parameters:
nIndex- The index to retrieve- Returns:
- The declaration at the specified index or
nullif the index is invalid
-
setDeclarationAtIndex
@Nonnull IMPLTYPE setDeclarationAtIndex(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration) Set the declaration at the specified index with a new one. If an existing declaration is present at that index, it is overwritten.- Parameters:
nIndex- The index to retrieve. Must be ≥ 0. If the index is ≥ thangetDeclarationCount(), it behaves likeaddDeclaration(CSSDeclaration).aNewDeclaration- The new declaration to be set.- Returns:
- this
-
hasDeclarations
boolean hasDeclarations()- Returns:
trueif at least one declaration is present,falseif no declaration is present.
-
getDeclarationCount
- Returns:
- The number of contained declarations. Always ≥ 0.
-
getDeclarationOfPropertyName
Get the first declaration with the specified property name. If no such property name is present,nullis 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).- Parameters:
sPropertyName- The property name of the declaration to search (e.g.color). May benull.- Returns:
nullif no such property name was found.- Since:
- 3.7.4
-
getDeclarationOfPropertyNameCaseInsensitive
@Nullable @Deprecated default CSSDeclaration getDeclarationOfPropertyNameCaseInsensitive(@Nullable String sPropertyName) Deprecated.Since 6.0.0 - usegetDeclarationOfPropertyName(String)instead.Get the first declaration with the specified property name. If no such property name is present,nullis 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.- Parameters:
sPropertyName- The property name of the declaration to search (e.g.color). May benull.- Returns:
nullif no such property name was found.- Since:
- 3.7.4
-
getAllDeclarationsOfPropertyName
@Nonnull @ReturnsMutableCopy com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarationsOfPropertyName(@Nullable String sPropertyName) Get all declarations within this list that have the specified property name. The comparison happens case insensitive (since v6.0.0).- Parameters:
sPropertyName- The property name of the declaration to search (e.g.color). May benull.- Returns:
- Never
nullbut maybe an empty list. - Since:
- 3.7.4
-
getAllDeclarationsOfPropertyNameCaseInsensitive
@Nonnull @ReturnsMutableCopy @Deprecated default com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarationsOfPropertyNameCaseInsensitive(@Nullable String sPropertyName) Deprecated.Since 6.0.0 - usegetAllDeclarationsOfPropertyName(String)instead.Get all declarations within this list that have the specified property name. The comparison happens case insensitive.- Parameters:
sPropertyName- The property name of the declaration to search (e.g.color). May benull.- Returns:
- Never
nullbut maybe an empty list. - Since:
- 3.7.4
-
getAllDeclarationsOfPropertyName(String)instead.