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 ClassesModifier and TypeClassDescriptionstatic enumA global modifier that can be used in front of a single CSS media query. -
Constructor Summary
ConstructorsConstructorDescriptionCSSMediaQuery(CSSMediaQuery.EModifier eModifier, String sMedium) ConstructorCSSMediaQuery(String sMedium) Constructor without a modifier. -
Method Summary
Modifier and TypeMethodDescriptionaddMediaExpression(int nIndex, CSSMediaExpression aMediaExpression) Add a media expression to the list at the specified index.addMediaExpression(CSSMediaExpression aMediaExpression) Append a media expression to the list.booleancom.helger.commons.collection.impl.ICommonsList<CSSMediaExpression>getAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel) Get the contents of this object as a serialized CSS string for writing to an output.getMediaExpression(int nExpressionIndex) Get the media expression at the specified index.intfinal Stringfinal CSSMediaQuery.EModifierfinal CSSSourceLocationinthashCode()booleanfinal booleanisNot()final booleanisOnly()com.helger.commons.state.EChangeRemove 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.final voidsetSourceLocation(CSSSourceLocation aSourceLocation) Set the source location of the object, determined while parsing.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString
-
Constructor Details
-
CSSMediaQuery
Constructor without a modifier. This implicitly uses the modifierCSSMediaQuery.EModifier.NONE.- Parameters:
sMedium- The medium to use. May benull.
-
CSSMediaQuery
Constructor- Parameters:
eModifier- The modifier to use. May not benull.sMedium- The medium to use. May benull.
-
-
Method Details
-
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:
-
isOnly
public final boolean isOnly()- Returns:
trueif the modifier isCSSMediaQuery.EModifier.ONLY.- See Also:
-
getMedium
- Returns:
- The medium passed in the constructor.
-
hasMediaExpressions
public boolean hasMediaExpressions()- Returns:
trueif at least a single media expression is present.
-
getMediaExpressionCount
- Returns:
- The number of contained media expressions. Always ≥ 0.
-
addMediaExpression
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
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
Remove all media expressions.- Returns:
EChange.CHANGEDif any media expression was removed,EChange.UNCHANGEDotherwise. Nevernull.- Since:
- 3.7.3
-
getMediaExpression
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
- 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
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.
-
equals
-
hashCode
public int hashCode() -
toString
-