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
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description IMPLTYPE
addDeclaration(int nIndex, CSSDeclaration aDeclaration)
Add a new declaration at the specified index.IMPLTYPE
addDeclaration(CSSDeclaration aDeclaration)
Add a new declaration.default IMPLTYPE
addDeclaration(String sProperty, CSSExpression aExpression, boolean bImportant)
Add a new declaration.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.default com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>
getAllDeclarationsOfPropertyNameCaseInsensitive(String sPropertyName)
Deprecated.Since 6.0.0 - usegetAllDeclarationsOfPropertyName(String)
instead.CSSDeclaration
getDeclarationAtIndex(int nIndex)
int
getDeclarationCount()
CSSDeclaration
getDeclarationOfPropertyName(String sPropertyName)
Get the first declaration with the specified property name.default CSSDeclaration
getDeclarationOfPropertyNameCaseInsensitive(String sPropertyName)
Deprecated.Since 6.0.0 - usegetDeclarationOfPropertyName(String)
instead.boolean
hasDeclarations()
com.helger.commons.state.EChange
removeAllDeclarations()
Remove all declarations.com.helger.commons.state.EChange
removeDeclaration(int nDeclarationIndex)
Remove the declaration at the specified indexcom.helger.commons.state.EChange
removeDeclaration(CSSDeclaration aDeclaration)
Remove the given declarationIMPLTYPE
setDeclarationAtIndex(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, getAsCSSString
-
-
-
-
Method Detail
-
addDeclaration
@Nonnull IMPLTYPE addDeclaration(@Nonnull CSSDeclaration aDeclaration)
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 benull
nor empty.aExpression
- The value of the property. May not benull
.bImportant
-true
if it is important,false
if not.- Returns:
- this
-
addDeclaration
@Nonnull IMPLTYPE addDeclaration(@Nonnegative int nIndex, @Nonnull CSSDeclaration aDeclaration)
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
@Nonnull com.helger.commons.state.EChange removeDeclaration(@Nonnull CSSDeclaration aDeclaration)
Remove the given declaration- Parameters:
aDeclaration
- The declaration to be removed. May not benull
.- Returns:
EChange.CHANGED
if the declaration was successfully removed
-
removeDeclaration
@Nonnull com.helger.commons.state.EChange removeDeclaration(@Nonnegative int nDeclarationIndex)
Remove the declaration at the specified index- Parameters:
nDeclarationIndex
- The index of the declaration to be removed. Must be ≥ 0.- Returns:
EChange.CHANGED
if the declaration was successfully removed,EChange.UNCHANGED
if the index was invalid.
-
removeAllDeclarations
@Nonnull com.helger.commons.state.EChange removeAllDeclarations()
Remove all declarations.- Returns:
EChange.CHANGED
if any declaration was removed,EChange.UNCHANGED
otherwise. Nevernull
.- Since:
- 3.7.3
-
getAllDeclarations
@Nonnull @ReturnsMutableCopy com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarations()
- Returns:
- A mutable, non-
null
copy of all contained declarations.
-
getDeclarationAtIndex
@Nullable CSSDeclaration getDeclarationAtIndex(@Nonnegative int nIndex)
- Parameters:
nIndex
- The index to retrieve- Returns:
- The declaration at the specified index or
null
if 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:
true
if at least one declaration is present,false
if no declaration is present.
-
getDeclarationCount
@Nonnegative int getDeclarationCount()
- Returns:
- The number of contained declarations. Always ≥ 0.
-
getDeclarationOfPropertyName
@Nullable CSSDeclaration getDeclarationOfPropertyName(@Nullable String sPropertyName)
Get the first declaration with the specified property name. If no such property name is present,null
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).- Parameters:
sPropertyName
- The property name of the declaration to search (e.g.color
). May benull
.- Returns:
null
if 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,null
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.- Parameters:
sPropertyName
- The property name of the declaration to search (e.g.color
). May benull
.- Returns:
null
if 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
null
but 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
null
but maybe an empty list. - Since:
- 3.7.4
-
-