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 with CSSReader.
Since:
3.8.2
Author:
Philip Helger
  • Field Details

    • 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:
    • DEFAULT_KEEP_DEPRECATED_PROPERTIES

      public static final boolean DEFAULT_KEEP_DEPRECATED_PROPERTIES
      See Also:
    • DEFAULT_USE_SOURCE_LOCATION

      public static final boolean DEFAULT_USE_SOURCE_LOCATION
      See Also:
    • DEFAULT_TAB_SIZE

      public static final int DEFAULT_TAB_SIZE
      See Also:
  • Constructor Details

    • CSSReaderSettings

      public CSSReaderSettings()
    • CSSReaderSettings

      public CSSReaderSettings(@Nonnull CSSReaderSettings aOther)
  • Method Details

    • getCSSVersion

      @Nonnull public ECSSVersion getCSSVersion()
      Returns:
      The CSS version which should be read. Defaults to DEFAULT_VERSION. Never null.
    • setCSSVersion

      @Nonnull public CSSReaderSettings setCSSVersion(@Nonnull ECSSVersion eCSSVersion)
      Set the CSS version to be read.
      Parameters:
      eCSSVersion - The version number to use. May not be null.
      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. 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
    • isKeepDeprecatedProperties

      public boolean isKeepDeprecatedProperties()
      Returns:
      true if deprecated properties (e.g. *zoom) should be kept while reading, false if they should be discarded. The default is DEFAULT_KEEP_DEPRECATED_PROPERTIES.
      Since:
      7.0.4
    • setKeepDeprecatedProperties

      @Nonnull public CSSReaderSettings setKeepDeprecatedProperties(boolean bKeepDeprecatedProperties)
      Define, whether deprecated properties (e.g. *zoom) should be kept or not.
      Parameters:
      bKeepDeprecatedProperties - true to keep them, false to discard them on reading.
      Returns:
      this
      Since:
      7.0.4
    • 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
    • getClone

      @Nonnull public CSSReaderSettings getClone()
      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<CSSReaderSettings>
    • toString

      public String toString()
      Overrides:
      toString in class Object