Package com.helger.css.decl
Class CSSViewportRule
- java.lang.Object
-
- com.helger.css.decl.CSSViewportRule
-
- All Implemented Interfaces:
com.helger.commons.traits.IGenericImplTrait<CSSViewportRule>
,ICSSTopLevelRule
,IHasCSSDeclarations<CSSViewportRule>
,ICSSSourceLocationAware
,ICSSVersionAware
,ICSSWriteable
@NotThreadSafe public class CSSViewportRule extends Object implements ICSSTopLevelRule, IHasCSSDeclarations<CSSViewportRule>, ICSSVersionAware, ICSSSourceLocationAware
Represents a single@viewport
rule.
Example:
@viewport { width: device-width; }
- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description CSSViewportRule(String sDeclaration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSViewportRule
addDeclaration(int nIndex, CSSDeclaration aNewDeclaration)
Add a new declaration at the specified index.CSSViewportRule
addDeclaration(CSSDeclaration aDeclaration)
Add a new declaration.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.String
getAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)
Get the contents of this object as a serialized CSS string for writing to an output.String
getDeclaration()
CSSDeclaration
getDeclarationAtIndex(int nIndex)
int
getDeclarationCount()
CSSDeclaration
getDeclarationOfPropertyName(String sPropertyName)
Get the first declaration with the specified property name.ECSSVersion
getMinimumCSSVersion()
CSSSourceLocation
getSourceLocation()
boolean
hasDeclarations()
int
hashCode()
static boolean
isValidDeclaration(String sDeclaration)
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 declarationCSSViewportRule
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()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString
-
Methods inherited from interface com.helger.css.decl.IHasCSSDeclarations
addDeclaration, getAllDeclarationsOfPropertyNameCaseInsensitive, getDeclarationOfPropertyNameCaseInsensitive
-
-
-
-
Method Detail
-
isValidDeclaration
public static boolean isValidDeclaration(@Nonnull @Nonempty String sDeclaration)
-
getDeclaration
@Nonnull @Nonempty public String getDeclaration()
- Returns:
- The rule declaration string used in the CSS. Neither
null
nor empty. Always starting with@
and ending withviewport
.
-
addDeclaration
@Nonnull public CSSViewportRule addDeclaration(@Nonnull CSSDeclaration aDeclaration)
Description copied from interface:IHasCSSDeclarations
Add a new declaration.- Specified by:
addDeclaration
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
aDeclaration
- The declaration to be added. May not benull
.- Returns:
- this
-
addDeclaration
@Nonnull public CSSViewportRule addDeclaration(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
Description copied from interface:IHasCSSDeclarations
Add a new declaration at the specified index.- Specified by:
addDeclaration
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
nIndex
- The index to retrieve. Must be ≥ 0. If the index is ≥ thangetDeclarationCount()
, it behaves likeIHasCSSDeclarations.addDeclaration(CSSDeclaration)
.aNewDeclaration
- The declaration to be added. May not benull
.- Returns:
- this
-
removeDeclaration
@Nonnull public com.helger.commons.state.EChange removeDeclaration(@Nonnull CSSDeclaration aDeclaration)
Description copied from interface:IHasCSSDeclarations
Remove the given declaration- Specified by:
removeDeclaration
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
aDeclaration
- The declaration to be removed. May not benull
.- Returns:
EChange.CHANGED
if the declaration was successfully removed
-
removeDeclaration
@Nonnull public com.helger.commons.state.EChange removeDeclaration(@Nonnegative int nDeclarationIndex)
Description copied from interface:IHasCSSDeclarations
Remove the declaration at the specified index- Specified by:
removeDeclaration
in interfaceIHasCSSDeclarations<CSSViewportRule>
- 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 public com.helger.commons.state.EChange removeAllDeclarations()
Description copied from interface:IHasCSSDeclarations
Remove all declarations.- Specified by:
removeAllDeclarations
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Returns:
EChange.CHANGED
if any declaration was removed,EChange.UNCHANGED
otherwise. Nevernull
.
-
getAllDeclarations
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarations()
- Specified by:
getAllDeclarations
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Returns:
- A mutable, non-
null
copy of all contained declarations.
-
getDeclarationAtIndex
@Nullable public CSSDeclaration getDeclarationAtIndex(@Nonnegative int nIndex)
- Specified by:
getDeclarationAtIndex
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
nIndex
- The index to retrieve- Returns:
- The declaration at the specified index or
null
if the index is invalid
-
setDeclarationAtIndex
@Nonnull public CSSViewportRule setDeclarationAtIndex(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
Description copied from interface:IHasCSSDeclarations
Set the declaration at the specified index with a new one. If an existing declaration is present at that index, it is overwritten.- Specified by:
setDeclarationAtIndex
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
nIndex
- The index to retrieve. Must be ≥ 0. If the index is ≥ thangetDeclarationCount()
, it behaves likeIHasCSSDeclarations.addDeclaration(CSSDeclaration)
.aNewDeclaration
- The new declaration to be set.- Returns:
- this
-
hasDeclarations
public boolean hasDeclarations()
- Specified by:
hasDeclarations
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Returns:
true
if at least one declaration is present,false
if no declaration is present.
-
getDeclarationCount
@Nonnegative public int getDeclarationCount()
- Specified by:
getDeclarationCount
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Returns:
- The number of contained declarations. Always ≥ 0.
-
getDeclarationOfPropertyName
@Nullable public CSSDeclaration getDeclarationOfPropertyName(@Nullable String sPropertyName)
Description copied from interface:IHasCSSDeclarations
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).- Specified by:
getDeclarationOfPropertyName
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
sPropertyName
- The property name of the declaration to search (e.g.color
). May benull
.- Returns:
null
if no such property name was found.
-
getAllDeclarationsOfPropertyName
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarationsOfPropertyName(@Nullable String sPropertyName)
Description copied from interface:IHasCSSDeclarations
Get all declarations within this list that have the specified property name. The comparison happens case insensitive (since v6.0.0).- Specified by:
getAllDeclarationsOfPropertyName
in interfaceIHasCSSDeclarations<CSSViewportRule>
- Parameters:
sPropertyName
- The property name of the declaration to search (e.g.color
). May benull
.- Returns:
- Never
null
but maybe an empty list.
-
getAsCSSString
@Nonnull @Nonempty public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
Description copied from interface:ICSSWriteable
Get the contents of this object as a serialized CSS string for writing to an output.- Specified by:
getAsCSSString
in interfaceICSSWriteable
- Parameters:
aSettings
- The settings to be used to format the output. May not benull
.nIndentLevel
- The current indentation level- Returns:
- The content of this object as CSS string. Never
null
.
-
getMinimumCSSVersion
@Nonnull public ECSSVersion getMinimumCSSVersion()
- Specified by:
getMinimumCSSVersion
in interfaceICSSVersionAware
- Returns:
- The minimum CSS version that is required to read or write this
artifact. May not be
null
.
-
getSourceLocation
@Nullable public final CSSSourceLocation getSourceLocation()
- Specified by:
getSourceLocation
in interfaceICSSSourceLocationAware
- Returns:
- The source location of this object when it was read by the parser.
May be
null
if an object was not read but manually created.
-
setSourceLocation
public final void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
Description copied from interface:ICSSSourceLocationAware
Set the source location of the object, determined while parsing.- Specified by:
setSourceLocation
in interfaceICSSSourceLocationAware
- Parameters:
aSourceLocation
- The source location to use. May benull
.
-
-