Package com.helger.css.decl
Class CSSImportRule
- java.lang.Object
-
- com.helger.css.decl.CSSImportRule
-
- All Implemented Interfaces:
ICSSSourceLocationAware,ICSSWriteable
@NotThreadSafe public class CSSImportRule extends Object implements ICSSWriteable, ICSSSourceLocationAware
Represents a single import rule on top level. It consists of a mandatory URI and an optional list of media queries.
Example:
@import url("style.css") screen;- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description CSSImportRule(CSSURI aLocation)CSSImportRule(String sLocation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSImportRuleaddMediaQuery(int nIndex, CSSMediaQuery aMediaQuery)Add a media query at the specified index of the list.CSSImportRuleaddMediaQuery(CSSMediaQuery aMediaQuery)Add a media query at the end of the list.booleanequals(Object o)com.helger.commons.collection.impl.ICommonsList<CSSMediaQuery>getAllMediaQueries()StringgetAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)Get the contents of this object as a serialized CSS string for writing to an output.CSSURIgetLocation()StringgetLocationString()intgetMediaQueryCount()CSSSourceLocationgetSourceLocation()inthashCode()booleanhasMediaQueries()com.helger.commons.state.EChangeremoveAllMediaQueries()Remove all contained media queries.com.helger.commons.state.EChangeremoveMediaQuery(int nMediumIndex)Remove the media query at the specified index.com.helger.commons.state.EChangeremoveMediaQuery(CSSMediaQuery aMediaQuery)Remove the specified media query.CSSImportRulesetLocation(CSSURI aLocation)Set the URI of the file to be imported.CSSImportRulesetLocationString(String sLocationURI)Set the URI of the file to be imported.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
-
-
-
-
Method Detail
-
hasMediaQueries
public boolean hasMediaQueries()
- Returns:
trueif this import rule has any specific media queries, to which it belongs,falseif not.
-
getMediaQueryCount
@Nonnegative public int getMediaQueryCount()
- Returns:
- The number of contained media queries. Always ≥ 0.
-
addMediaQuery
@Nonnull public CSSImportRule addMediaQuery(@Nonnull CSSMediaQuery aMediaQuery)
Add a media query at the end of the list.- Parameters:
aMediaQuery- The media query to be added. May not benull.- Returns:
- this
-
addMediaQuery
@Nonnull public CSSImportRule addMediaQuery(@Nonnegative int nIndex, @Nonnull CSSMediaQuery aMediaQuery)
Add a media query at the specified index of the list.- Parameters:
nIndex- The index where to add the media query. Must be ≥ 0.aMediaQuery- The media query to be added. May not benull.- Returns:
- this
-
removeMediaQuery
@Nonnull public com.helger.commons.state.EChange removeMediaQuery(@Nullable CSSMediaQuery aMediaQuery)
Remove the specified media query.- Parameters:
aMediaQuery- The media query to be removed. May benull.- Returns:
EChange.CHANGEDif removal was successful.
-
removeMediaQuery
@Nonnull public com.helger.commons.state.EChange removeMediaQuery(int nMediumIndex)
Remove the media query at the specified index.- Parameters:
nMediumIndex- The index of the media query to be removed.- Returns:
EChange.CHANGEDif removal was successful.
-
removeAllMediaQueries
@Nonnull public com.helger.commons.state.EChange removeAllMediaQueries()
Remove all contained media queries.- Returns:
EChange.CHANGEDif at least one media query was contained.
-
getAllMediaQueries
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSMediaQuery> getAllMediaQueries()
- Returns:
- A list with all contained media queries. Never
nulland always a copy of the underlying list.
-
getLocation
@Nonnull public final CSSURI getLocation()
- Returns:
- The URL object of the CSS file to import. Never
null.
-
getLocationString
@Nonnull @Nonempty public final String getLocationString()
- Returns:
- The URL of the CSS file to import. Never
null. This is a shortcut forgetLocation().getURI()
-
setLocation
@Nonnull public final CSSImportRule setLocation(@Nonnull CSSURI aLocation)
Set the URI of the file to be imported.- Parameters:
aLocation- The location to use. May not benull.- Returns:
- this;
-
setLocationString
@Nonnull public final CSSImportRule setLocationString(@Nonnull String sLocationURI)
Set the URI of the file to be imported.- Parameters:
sLocationURI- The location URI to use. May not benull.- Returns:
- this;
-
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.
-
-