Package com.helger.css.tools
Class MediaQueryTools
- java.lang.Object
-
- com.helger.css.tools.MediaQueryTools
-
@Immutable public final class MediaQueryTools extends Object
A small utility class to wrap an existingCascadingStyleSheetwithin a specific media, if possible.CascadingStyleSheetcan only be wrapped, if they don't contain a media rule themselves.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanWrapInMediaQuery(CascadingStyleSheet aCSS, boolean bAllowNestedMediaQueries)Check if the passed CSS can be wrapped in an external media rule.static CascadingStyleSheetgetWrappedInMediaQuery(CascadingStyleSheet aCSS, CSSMediaQuery aMediaQuery, boolean bAllowNestedMediaQueries)Get the CSS wrapped in the specified media query.static CascadingStyleSheetgetWrappedInMediaQuery(CascadingStyleSheet aCSS, Iterable<? extends CSSMediaQuery> aMediaQueries, boolean bAllowNestedMediaQueries)Get the CSS wrapped in the specified media query.static com.helger.commons.collection.impl.ICommonsList<CSSMediaQuery>parseToMediaQuery(String sMediaQuery, ECSSVersion eVersion)Utility method to convert a media query string to a structured list ofCSSMediaQueryobjects.
-
-
-
Method Detail
-
parseToMediaQuery
@Nullable public static com.helger.commons.collection.impl.ICommonsList<CSSMediaQuery> parseToMediaQuery(@Nullable String sMediaQuery, @Nonnull ECSSVersion eVersion)
Utility method to convert a media query string to a structured list ofCSSMediaQueryobjects.- Parameters:
sMediaQuery- The media query string to parse. May benull.eVersion- The CSS version to use. May not benull.- Returns:
nullif the passed media query isnullor empty or not parsable.
-
canWrapInMediaQuery
public static boolean canWrapInMediaQuery(@Nullable CascadingStyleSheet aCSS, boolean bAllowNestedMediaQueries)
Check if the passed CSS can be wrapped in an external media rule.- Parameters:
aCSS- The CSS to be checked for wrapping. May benull.bAllowNestedMediaQueries- iftruenested media queries are allowed,falseif they are prohibited.- Returns:
trueif the CSS can be wrapped,falseif it can't be wrapped.
-
getWrappedInMediaQuery
@Nullable public static CascadingStyleSheet getWrappedInMediaQuery(@Nonnull CascadingStyleSheet aCSS, @Nonnull CSSMediaQuery aMediaQuery, boolean bAllowNestedMediaQueries)
Get the CSS wrapped in the specified media query. Note: all existing rule objects are reused, so modifying them also modifies the original CSS!- Parameters:
aCSS- The CSS to be wrapped. May not benull.aMediaQuery- The media query to use.bAllowNestedMediaQueries- iftruenested media queries are allowed,falseif they are prohibited.- Returns:
nullif out CSS cannot be wrapped, the newly createdCascadingStyleSheetobject otherwise.
-
getWrappedInMediaQuery
@Nullable public static CascadingStyleSheet getWrappedInMediaQuery(@Nonnull CascadingStyleSheet aCSS, @Nonnull @Nonempty Iterable<? extends CSSMediaQuery> aMediaQueries, boolean bAllowNestedMediaQueries)
Get the CSS wrapped in the specified media query. Note: all existing rule objects are reused, so modifying them also modifies the original CSS!- Parameters:
aCSS- The CSS to be wrapped. May not benull.aMediaQueries- The media queries to use. May neither benullnor empty nor may it containnullelements.bAllowNestedMediaQueries- iftruenested media queries are allowed,falseif they are prohibited.- Returns:
nullif out CSS cannot be wrapped, the newly createdCascadingStyleSheetobject otherwise.
-
-