Class 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 with CSSReader.
    Since:
    3.8.2
    Author:
    Philip Helger
    • 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
    • Constructor Detail

      • CSSReaderSettings

        public CSSReaderSettings()
    • Method Detail

      • 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. Never null. Defaults to DEFAULT_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. Never null. Defaults to the name of DEFAULT_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 be null.
        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 be null.
        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 be null.
        Returns:
        this
      • isBrowserCompliantMode

        public boolean isBrowserCompliantMode()
        Returns:
        true if browser compliant parsing is enabled, false otherwise. The default is DEFAULT_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 is DEFAULT_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 is null the default error handler from CSSReader 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 be null to indicate to use the default error handler from CSSReader.
        Returns:
        this for chaining
        Since:
        5.0.2