Package com.helger.css.decl
Class CSSMediaQuery
- java.lang.Object
-
- com.helger.css.decl.CSSMediaQuery
-
- All Implemented Interfaces:
ICSSSourceLocationAware,ICSSWriteable
@NotThreadSafe public class CSSMediaQuery extends Object implements ICSSWriteable, ICSSSourceLocationAware
Represents a single media query- Author:
- Philip Helger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCSSMediaQuery.EModifierA global modifier that can be used in front of a single CSS media query.
-
Constructor Summary
Constructors Constructor Description CSSMediaQuery(CSSMediaQuery.EModifier eModifier, String sMedium)ConstructorCSSMediaQuery(String sMedium)Constructor without a modifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSMediaQueryaddMediaExpression(int nIndex, CSSMediaExpression aMediaExpression)Add a media expression to the list at the specified index.CSSMediaQueryaddMediaExpression(CSSMediaExpression aMediaExpression)Append a media expression to the list.booleanequals(Object o)com.helger.commons.collection.impl.ICommonsList<CSSMediaExpression>getAllMediaExpressions()StringgetAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)Get the contents of this object as a serialized CSS string for writing to an output.CSSMediaExpressiongetMediaExpression(int nExpressionIndex)Get the media expression at the specified index.intgetMediaExpressionCount()StringgetMedium()CSSMediaQuery.EModifiergetModifier()CSSSourceLocationgetSourceLocation()inthashCode()booleanhasMediaExpressions()booleanisNot()booleanisOnly()com.helger.commons.state.EChangeremoveAllMediaExpressions()Remove all media expressions.com.helger.commons.state.EChangeremoveMediaExpression(int nExpressionIndex)Remove the media expression at the specified index.com.helger.commons.state.EChangeremoveMediaExpression(CSSMediaExpression aMediaExpression)Remove the specified media expression.voidsetSourceLocation(CSSSourceLocation aSourceLocation)Set the source location of the object, determined while parsing.StringtoString()-
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
-
-
-
-
Constructor Detail
-
CSSMediaQuery
public CSSMediaQuery(@Nullable String sMedium)
Constructor without a modifier. This implicitly uses the modifierCSSMediaQuery.EModifier.NONE.- Parameters:
sMedium- The medium to use. May benull.
-
CSSMediaQuery
public CSSMediaQuery(@Nonnull CSSMediaQuery.EModifier eModifier, @Nullable String sMedium)
Constructor- Parameters:
eModifier- The modifier to use. May not benull.sMedium- The medium to use. May benull.
-
-
Method Detail
-
getModifier
@Nonnull public final CSSMediaQuery.EModifier getModifier()
- Returns:
- The media query modifier that was used. Never
null.
-
isNot
public final boolean isNot()
- Returns:
trueif the modifier isCSSMediaQuery.EModifier.NOT.- See Also:
getModifier()
-
isOnly
public final boolean isOnly()
- Returns:
trueif the modifier isCSSMediaQuery.EModifier.ONLY.- See Also:
getModifier()
-
hasMediaExpressions
public boolean hasMediaExpressions()
- Returns:
trueif at least a single media expression is present.
-
getMediaExpressionCount
@Nonnegative public int getMediaExpressionCount()
- Returns:
- The number of contained media expressions. Always ≥ 0.
-
addMediaExpression
@Nonnull public CSSMediaQuery addMediaExpression(@Nonnull CSSMediaExpression aMediaExpression)
Append a media expression to the list.- Parameters:
aMediaExpression- The media expression to be added. May not benull.- Returns:
- this
-
addMediaExpression
@Nonnull public CSSMediaQuery addMediaExpression(@Nonnegative int nIndex, @Nonnull CSSMediaExpression aMediaExpression)
Add a media expression to the list at the specified index.- Parameters:
nIndex- The index where the media expression should be added. Must be ≥ 0.aMediaExpression- The media expression to be added. May not benull.- Returns:
- this
-
removeMediaExpression
@Nonnull public com.helger.commons.state.EChange removeMediaExpression(@Nullable CSSMediaExpression aMediaExpression)
Remove the specified media expression.- Parameters:
aMediaExpression- The media expression to be removed. May benull.- Returns:
EChange.CHANGEDif removal succeeded,EChange.UNCHANGEDotherwise.
-
removeMediaExpression
@Nonnull public com.helger.commons.state.EChange removeMediaExpression(int nExpressionIndex)
Remove the media expression at the specified index.- Parameters:
nExpressionIndex- The index of the media expression to be removed.- Returns:
EChange.CHANGEDif removal succeeded,EChange.UNCHANGEDotherwise.
-
removeAllMediaExpressions
@Nonnull public com.helger.commons.state.EChange removeAllMediaExpressions()
Remove all media expressions.- Returns:
EChange.CHANGEDif any media expression was removed,EChange.UNCHANGEDotherwise. Nevernull.- Since:
- 3.7.3
-
getMediaExpression
@Nullable public CSSMediaExpression getMediaExpression(@Nonnegative int nExpressionIndex)
Get the media expression at the specified index.- Parameters:
nExpressionIndex- The index to be retrieved.- Returns:
nullif the index is < 0 or too large.
-
getAllMediaExpressions
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSMediaExpression> getAllMediaExpressions()
- Returns:
- A copy of all media expression. Never
nullbut maybe empty.
-
getAsCSSString
@Nonnull @Nonempty public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
Description copied from interface:ICSSWriteableGet the contents of this object as a serialized CSS string for writing to an output.- Specified by:
getAsCSSStringin 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.
-
getSourceLocation
@Nullable public final CSSSourceLocation getSourceLocation()
- Specified by:
getSourceLocationin interfaceICSSSourceLocationAware- Returns:
- The source location of this object when it was read by the parser.
May be
nullif an object was not read but manually created.
-
setSourceLocation
public final void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
Description copied from interface:ICSSSourceLocationAwareSet the source location of the object, determined while parsing.- Specified by:
setSourceLocationin interfaceICSSSourceLocationAware- Parameters:
aSourceLocation- The source location to use. May benull.
-
-