Package com.helger.css.reader
Class CSSReader
java.lang.Object
com.helger.css.reader.CSSReader
This is the central user class for reading and parsing CSS from different
sources. This class reads full CSS declarations only. To read only a
declaration list (like from an HTML
<style> attribute) the
CSSReaderDeclarationList is available.- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic CharsetgetCharsetDeclaredInCSS(com.helger.commons.io.IHasInputStream aISP) Determine the charset to read the CSS file.static ICSSInterpretErrorHandlerstatic ICSSParseErrorHandlerstatic ICSSParseExceptionCallbackstatic booleanisValidCSS(com.helger.commons.io.resource.IReadableResource aRes, Charset aFallbackCharset, ECSSVersion eVersion) Check if the passed CSS resource can be parsed without errorstatic booleanisValidCSS(File aFile, Charset aFallbackCharset, ECSSVersion eVersion) Check if the passed CSS file can be parsed without errorstatic booleanisValidCSS(InputStream aIS, Charset aFallbackCharset, ECSSVersion eVersion) Check if the passed input stream can be resembled to valid CSS content.static booleanisValidCSS(Reader aReader, ECSSVersion eVersion) Check if the passed reader can be resembled to valid CSS content.static booleanisValidCSS(String sCSS, ECSSVersion eVersion) Check if the passed String can be resembled to valid CSS content.static CascadingStyleSheetreadFromFile(File aFile, CSSReaderSettings aSettings) Read the CSS from the passed File.static CascadingStyleSheetreadFromFile(File aFile, Charset aFallbackCharset, ECSSVersion eVersion) Read the CSS from the passed File.static CascadingStyleSheetreadFromFile(File aFile, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed File.static CascadingStyleSheetreadFromFile(File aFile, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passed File.static CascadingStyleSheetreadFromFile(File aFile, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed File.static CascadingStyleSheetreadFromReader(com.helger.commons.io.IHasReader aRP, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passedIHasReader.static CascadingStyleSheetreadFromReader(com.helger.commons.io.IHasReader aRP, CSSReaderSettings aSettings) Read the CSS from the passedIHasReader.static CascadingStyleSheetreadFromStream(com.helger.commons.io.IHasInputStream aISP, CSSReaderSettings aSettings) Read the CSS from the passedIHasInputStream.static CascadingStyleSheetreadFromStream(com.helger.commons.io.IHasInputStream aISP, Charset aFallbackCharset, ECSSVersion eVersion) Read the CSS from the passedIHasInputStream.static CascadingStyleSheetreadFromStream(com.helger.commons.io.IHasInputStream aISP, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passedIHasInputStream.static CascadingStyleSheetreadFromStream(com.helger.commons.io.IHasInputStream aISP, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passedIHasInputStream.static CascadingStyleSheetreadFromStream(com.helger.commons.io.IHasInputStream aISP, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passedIHasInputStream.static CascadingStyleSheetreadFromString(String sCSS, ECSSVersion eVersion) Read the CSS from the passed String using a character stream.static CascadingStyleSheetreadFromString(String sCSS, ECSSVersion eVersion, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a character stream.static CascadingStyleSheetreadFromString(String sCSS, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passed String using a character stream.static CascadingStyleSheetreadFromString(String sCSS, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a character stream.static CascadingStyleSheetreadFromString(String sCSS, Charset aFallbackCharset, ECSSVersion eVersion) Read the CSS from the passed String using a byte stream.static CascadingStyleSheetreadFromString(String sCSS, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a byte stream.static CascadingStyleSheetreadFromString(String sCSS, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passed String using a byte stream.static CascadingStyleSheetreadFromString(String sCSS, Charset aFallbackCharset, ECSSVersion eVersion, ICSSParseErrorHandler aCustomErrorHandler, ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a byte stream.static CascadingStyleSheetreadFromStringReader(String sCSS, CSSReaderSettings aSettings) Read the CSS from the passed String using a character stream.static CascadingStyleSheetreadFromStringStream(String sCSS, CSSReaderSettings aSettings) Read the CSS from the passed String using a byte stream.static voidsetDefaultInterpretErrorHandler(ICSSInterpretErrorHandler aDefaultErrorHandler) Set the default interpret error handler to handle interpretation errors in successfully parsed CSS.static voidsetDefaultParseErrorHandler(ICSSParseErrorHandler aDefaultParseErrorHandler) Set the default CSS parse error handler (for recoverable errors).static voidsetDefaultParseExceptionHandler(ICSSParseExceptionCallback aDefaultParseExceptionHandler) Set the default CSS parse exception handler (for unrecoverable errors).
-
Method Details
-
getDefaultParseErrorHandler
- Returns:
- The default CSS parse error handler. May be
null. For backwards compatibility reasons this is be default an instance ofLoggingCSSParseErrorHandler.
-
setDefaultParseErrorHandler
public static void setDefaultParseErrorHandler(@Nullable ICSSParseErrorHandler aDefaultParseErrorHandler) Set the default CSS parse error handler (for recoverable errors).- Parameters:
aDefaultParseErrorHandler- The new default error handler to be used. May benullto indicate that no special error handler should be used.
-
getDefaultParseExceptionHandler
- Returns:
- The default CSS parse exception handler. May not be
null. For backwards compatibility reasons this is be default an instance ofLoggingCSSParseExceptionCallback. - Since:
- 3.7.4
-
setDefaultParseExceptionHandler
public static void setDefaultParseExceptionHandler(@Nonnull ICSSParseExceptionCallback aDefaultParseExceptionHandler) Set the default CSS parse exception handler (for unrecoverable errors).- Parameters:
aDefaultParseExceptionHandler- The new default exception handler to be used. May not benull.- Since:
- 3.7.4
-
getDefaultInterpretErrorHandler
- Returns:
- The default interpret error handler to handle interpretation errors
in successfully parsed CSS. Never
null. - Since:
- 5.0.2
-
setDefaultInterpretErrorHandler
public static void setDefaultInterpretErrorHandler(@Nonnull ICSSInterpretErrorHandler aDefaultErrorHandler) Set the default interpret error handler to handle interpretation errors in successfully parsed CSS.- Parameters:
aDefaultErrorHandler- The default error handler to be used. May not benull.- Since:
- 5.0.2
-
isValidCSS
public static boolean isValidCSS(@Nonnull File aFile, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion) Check if the passed CSS file can be parsed without error- Parameters:
aFile- The file to be parsed. May not benull.aFallbackCharset- The charset to be used for reading the CSS file in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to be used for scanning. May not benull.- Returns:
trueif the file can be parsed without error,falseif not
-
isValidCSS
public static boolean isValidCSS(@Nonnull com.helger.commons.io.resource.IReadableResource aRes, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion) Check if the passed CSS resource can be parsed without error- Parameters:
aRes- The resource to be parsed. May not benull.aFallbackCharset- The charset to be used for reading the CSS file in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to be used for scanning. May not benull.- Returns:
trueif the file can be parsed without error,falseif not
-
isValidCSS
public static boolean isValidCSS(@Nonnull @WillClose InputStream aIS, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion) Check if the passed input stream can be resembled to valid CSS content. This is accomplished by fully parsing the CSS file each time the method is called. This is similar to callingreadFromStream(IHasInputStream,Charset, ECSSVersion)and checking for a non-nullresult.- Parameters:
aIS- The input stream to use. Is automatically closed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
trueif the CSS is valid according to the version,falseif not
-
isValidCSS
Check if the passed String can be resembled to valid CSS content. This is accomplished by fully parsing the CSS file each time the method is called. This is similar to callingreadFromString(String, Charset, ECSSVersion)and checking for a non-nullresult.- Parameters:
sCSS- The CSS string to scan. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
trueif the CSS is valid according to the version,falseif not
-
isValidCSS
Check if the passed reader can be resembled to valid CSS content. This is accomplished by fully parsing the CSS each time the method is called. This is similar to callingreadFromStream(IHasInputStream, Charset, ECSSVersion)and checking for a non-nullresult.- Parameters:
aReader- The reader to use. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
trueif the CSS is valid according to the version,falseif not
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion) Read the CSS from the passed String using a byte stream.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passed String using a byte stream.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a byte stream.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a byte stream.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.7.3
-
readFromStringStream
@Nullable public static CascadingStyleSheet readFromStringStream(@Nonnull String sCSS, @Nonnull CSSReaderSettings aSettings) Read the CSS from the passed String using a byte stream.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.aSettings- The settings to be used for reading the CSS. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.8.2
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull ECSSVersion eVersion) Read the CSS from the passed String using a character stream. An eventually contained@charsetrule is ignored.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.7.3
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passed String using a character stream. An eventually contained@charsetrule is ignored.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.7.3
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a character stream. An eventually contained@charsetrule is ignored.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.eVersion- The CSS version to use. May not benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.7.3
-
readFromString
@Nullable public static CascadingStyleSheet readFromString(@Nonnull String sCSS, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed String using a character stream. An eventually contained@charsetrule is ignored.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.7.3
-
readFromStringReader
@Nullable public static CascadingStyleSheet readFromStringReader(@Nonnull String sCSS, @Nonnull CSSReaderSettings aSettings) Read the CSS from the passed String using a character stream. An eventually contained@charsetrule is ignored.- Parameters:
sCSS- The source string containing the CSS to be parsed. May not benull.aSettings- The settings to be used for reading the CSS. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.8.2
-
readFromFile
@Nullable public static CascadingStyleSheet readFromFile(@Nonnull File aFile, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion) Read the CSS from the passed File.- Parameters:
aFile- The file containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromFile
@Nullable public static CascadingStyleSheet readFromFile(@Nonnull File aFile, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passed File.- Parameters:
aFile- The file containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromFile
@Nullable public static CascadingStyleSheet readFromFile(@Nonnull File aFile, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed File.- Parameters:
aFile- The file containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromFile
@Nullable public static CascadingStyleSheet readFromFile(@Nonnull File aFile, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passed File.- Parameters:
aFile- The file containing the CSS to be parsed. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromFile
@Nullable public static CascadingStyleSheet readFromFile(@Nonnull File aFile, @Nonnull CSSReaderSettings aSettings) Read the CSS from the passed File.- Parameters:
aFile- The file containing the CSS to be parsed. May not benull.aSettings- The settings to be used for reading the CSS. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.8.2
-
readFromStream
@Nullable public static CascadingStyleSheet readFromStream(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion) Read the CSS from the passedIHasInputStream. If the CSS contains an explicit charset, the whole CSS is parsed again, with the charset found inside the file, so the passedIHasInputStreammust be able to create a new input stream on second invocation!- Parameters:
aISP- The input stream provider to use. Must be able to create new input streams on every invocation, in case an explicit charset node was found. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromStream
@Nullable public static CascadingStyleSheet readFromStream(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler) Read the CSS from the passedIHasInputStream. If the CSS contains an explicit charset, the whole CSS is parsed again, with the charset found inside the file, so the passedIHasInputStreammust be able to create a new input stream on second invocation!- Parameters:
aISP- The input stream provider to use. Must be able to create new input streams on every invocation, in case an explicit charset node was found. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
getCharsetDeclaredInCSS
@Nullable public static Charset getCharsetDeclaredInCSS(@Nonnull com.helger.commons.io.IHasInputStream aISP) Determine the charset to read the CSS file. The logic is as follows:- Determine the charset used to read the @charset from the stream. If a BOM is present and a matching Charset is present, this charset is used. As a fallback the CSS file is initially read with ISO-8859-1.
- If the CSS content contains a valid @charset rule, the defined charset is returned even if a different BOM is present.
- If the CSS content does not contain a valid @charset rule than the charset of the BOM is returned (if any).
- Otherwise
nullis returned.
- Parameters:
aISP- The input stream provider to read from. May not benull.- Returns:
nullif the input stream could not be opened or if neither a BOM nor a charset is specified. Otherwise a non-nullCharset is returned.- Throws:
IllegalStateException- if an invalid charset is supplied
-
readFromStream
@Nullable public static CascadingStyleSheet readFromStream(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passedIHasInputStream. If the CSS contains an explicit charset, the whole CSS is parsed again, with the charset found inside the file, so the passedIHasInputStreammust be able to create a new input stream on second invocation!- Parameters:
aISP- The input stream provider to use. Must be able to create new input streams on every invocation, in case an explicit charset node was found. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromStream
@Nullable public static CascadingStyleSheet readFromStream(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull Charset aFallbackCharset, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passedIHasInputStream. If the CSS contains an explicit charset, the whole CSS is parsed again, with the charset found inside the file, so the passedIHasInputStreammust be able to create a new input stream on second invocation!- Parameters:
aISP- The input stream provider to use. Must be able to create new input streams on every invocation, in case an explicit charset node was found. May not benull.aFallbackCharset- The charset to be used in case neither a@charsetrule nor a BOM is present. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.
-
readFromStream
@Nullable public static CascadingStyleSheet readFromStream(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull CSSReaderSettings aSettings) Read the CSS from the passedIHasInputStream. If the CSS contains an explicit charset, the whole CSS is parsed again, with the charset found inside the file, so the passedIHasInputStreammust be able to create a new input stream on second invocation!- Parameters:
aISP- The input stream provider to use. Must be able to create new input streams on every invocation, in case an explicit charset node was found. May not benull.aSettings- The settings to be used for reading the CSS. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.8.2
-
readFromReader
@Nullable public static CascadingStyleSheet readFromReader(@Nonnull com.helger.commons.io.IHasReader aRP, @Nonnull ECSSVersion eVersion, @Nullable ICSSParseErrorHandler aCustomErrorHandler, @Nullable ICSSParseExceptionCallback aCustomExceptionHandler) Read the CSS from the passedIHasReader. If the CSS contains an explicit@charsetrule, it is ignored and the charset used to create the reader is used instead!- Parameters:
aRP- The reader provider to use. The reader is retrieved exactly once and closed anyway. May not benull.eVersion- The CSS version to use. May not benull.aCustomErrorHandler- An optional custom error handler that can be used to collect the recoverable parsing errors. May benull.aCustomExceptionHandler- An optional custom exception handler that can be used to collect the unrecoverable parsing errors. May benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.7.3
-
readFromReader
@Nullable public static CascadingStyleSheet readFromReader(@Nonnull com.helger.commons.io.IHasReader aRP, @Nonnull CSSReaderSettings aSettings) Read the CSS from the passedIHasReader. If the CSS contains an explicit@charsetrule, it is ignored and the charset used to create the reader is used instead! Also the fallback charset from theCSSReaderSettingsis ignored.- Parameters:
aRP- The reader provider to use. The reader is retrieved exactly once and closed anyway. May not benull.aSettings- The settings to be used for reading the CSS. May not benull.- Returns:
nullif reading failed, the CSS declarations otherwise.- Since:
- 3.8.2
-