Package com.helger.css.reader
Class CSSReaderSettings
- java.lang.Object
-
- com.helger.css.reader.CSSReaderSettings
-
- All Implemented Interfaces:
com.helger.commons.lang.ICloneable<CSSReaderSettings>
public class CSSReaderSettings extends Object implements com.helger.commons.lang.ICloneable<CSSReaderSettings>
A settings class for usage withCSSReader
.- Since:
- 3.8.2
- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_BROWSER_COMPLIANT_MODE
static Charset
DEFAULT_CHARSET
static int
DEFAULT_TAB_SIZE
static boolean
DEFAULT_USE_SOURCE_LOCATION
static ECSSVersion
DEFAULT_VERSION
-
Constructor Summary
Constructors Constructor Description CSSReaderSettings()
CSSReaderSettings(CSSReaderSettings aOther)
-
Method Summary
-
-
-
Field Detail
-
DEFAULT_VERSION
public static final ECSSVersion DEFAULT_VERSION
-
DEFAULT_CHARSET
public static final Charset DEFAULT_CHARSET
-
DEFAULT_BROWSER_COMPLIANT_MODE
public static final boolean DEFAULT_BROWSER_COMPLIANT_MODE
- See Also:
- Constant Field Values
-
DEFAULT_USE_SOURCE_LOCATION
public static final boolean DEFAULT_USE_SOURCE_LOCATION
- See Also:
- Constant Field Values
-
DEFAULT_TAB_SIZE
public static final int DEFAULT_TAB_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CSSReaderSettings
public CSSReaderSettings()
-
CSSReaderSettings
public CSSReaderSettings(@Nonnull CSSReaderSettings aOther)
-
-
Method Detail
-
getCSSVersion
@Nonnull public ECSSVersion getCSSVersion()
- Returns:
- The CSS version which should be read. Defaults to
DEFAULT_VERSION
. Nevernull
.
-
setCSSVersion
@Nonnull public CSSReaderSettings setCSSVersion(@Nonnull ECSSVersion eCSSVersion)
Set the CSS version to be read.- Parameters:
eCSSVersion
- The version number to use. May not benull
.- Returns:
- this
-
getFallbackCharset
@Nonnull public Charset getFallbackCharset()
- Returns:
- The charset to be used for reading a CSS file in case neither a
@charset
rule nor a BOM is present. Nevernull
. Defaults toDEFAULT_CHARSET
.
-
getFallbackCharsetName
@Nonnull public String getFallbackCharsetName()
- Returns:
- The name of the charset to be used for reading a CSS file in case
neither a
@charset
rule nor a BOM is present. Nevernull
. Defaults to the name ofDEFAULT_CHARSET
.
-
setFallbackCharset
@Nonnull public CSSReaderSettings setFallbackCharset(@Nonnull @Nonempty Charset aFallbackCharset)
- Parameters:
aFallbackCharset
- The charset to be used for reading the CSS file in case neither a@charset
rule nor a BOM is present. May not benull
.- Returns:
- this
-
getCustomErrorHandler
@Nullable public ICSSParseErrorHandler getCustomErrorHandler()
- Returns:
- An optional custom error handler that can be used to collect the
recoverable parsing errors. May be
null
.
-
setCustomErrorHandler
@Nonnull public CSSReaderSettings setCustomErrorHandler(@Nullable ICSSParseErrorHandler aCustomErrorHandler)
- Parameters:
aCustomErrorHandler
- A custom error handler that can be used to collect the recoverable parsing errors. May benull
.- Returns:
- this
-
getCustomExceptionHandler
@Nullable public ICSSParseExceptionCallback getCustomExceptionHandler()
- Returns:
- An optional custom exception handler that can be used to collect
the unrecoverable parsing errors. May be
null
.
-
setCustomExceptionHandler
@Nonnull public CSSReaderSettings setCustomExceptionHandler(@Nullable ICSSParseExceptionCallback aCustomExceptionHandler)
- Parameters:
aCustomExceptionHandler
- A custom exception handler that can be used to collect the unrecoverable parsing errors. May benull
.- Returns:
- this
-
isBrowserCompliantMode
public boolean isBrowserCompliantMode()
- Returns:
true
if browser compliant parsing is enabled,false
otherwise. The default isDEFAULT_BROWSER_COMPLIANT_MODE
.
-
setBrowserCompliantMode
@Nonnull public CSSReaderSettings setBrowserCompliantMode(boolean bBrowserCompliantMode)
Change the browser compliant mode to use.- Parameters:
bBrowserCompliantMode
-true
to use enable browser compliant parsing,false
to disable it.- Returns:
- this
-
isUseSourceLocation
public boolean isUseSourceLocation()
- Returns:
true
if the source location should be stored,false
to ignore them. The default isDEFAULT_USE_SOURCE_LOCATION
.- Since:
- 6.1.3
-
setUseSourceLocation
@Nonnull public CSSReaderSettings setUseSourceLocation(boolean bUseSourceLocation)
Change if source location should be used or not. If source location usage is disabled, it improves parsing speed.- Parameters:
bUseSourceLocation
-true
to remember the source location,false
to ignore them.- Returns:
- this
- Since:
- 6.1.3
-
getTabSize
@Nonnegative public int getTabSize()
- Returns:
- The tab size to be used to determine the source location. Always
> 0. Default value is
DEFAULT_TAB_SIZE
. - Since:
- 5.0.2
-
setTabSize
@Nonnull public CSSReaderSettings setTabSize(@Nonnegative int nTabSize)
Set the tab size to be used to determine the source location.- Parameters:
nTabSize
- The tab size to use. Must be > 0.- Returns:
- this for chaining
- Since:
- 5.0.2
-
getInterpretErrorHandler
@Nullable public ICSSInterpretErrorHandler getInterpretErrorHandler()
- Returns:
- The special error handler to be used to interpret a successfully
parsed CSS. May be
null
. If this isnull
the default error handler fromCSSReader
is used. - Since:
- 5.0.2
-
setInterpretErrorHandler
@Nonnull public CSSReaderSettings setInterpretErrorHandler(@Nullable ICSSInterpretErrorHandler aInterpretErrorHandler)
Set a special interpret error handler for handling errors in successfully parsed CSS.- Parameters:
aInterpretErrorHandler
- The special error handler to be used. May benull
to indicate to use the default error handler fromCSSReader
.- Returns:
- this for chaining
- Since:
- 5.0.2
-
getClone
@Nonnull public CSSReaderSettings getClone()
- Specified by:
getClone
in interfacecom.helger.commons.lang.ICloneable<CSSReaderSettings>
-
-