Class LoggingCSSParseErrorHandler

java.lang.Object
com.helger.css.reader.errorhandler.LoggingCSSParseErrorHandler
All Implemented Interfaces:
ICSSParseErrorHandler

@Immutable public class LoggingCSSParseErrorHandler extends Object implements ICSSParseErrorHandler
A logging implementation of ICSSParseErrorHandler. So in case a recoverable error occurs, the details are logged to an SLF4J logger.
Author:
Philip Helger
  • Constructor Details

    • LoggingCSSParseErrorHandler

      public LoggingCSSParseErrorHandler()
      Default constructor.
  • Method Details

    • createLoggingStringParseError

      @Nonnull @Nonempty public static String createLoggingStringParseError(@Nonnull ParseException ex)
    • createLoggingStringParseError

      @Nonnull @Nonempty public static String createLoggingStringParseError(@Nonnull Token aLastValidToken, @Nonnull int[][] aExpectedTokenSequencesVal, @Nonnull String[] aTokenImageVal, @Nullable Token aLastSkippedToken)
    • onCSSParseError

      public void onCSSParseError(@Nonnull ParseException aParseEx, @Nullable Token aLastSkippedToken) throws ParseException
      Description copied from interface: ICSSParseErrorHandler
      Called upon a recoverable error. The parameter list is similar to the one of the ParseException.
      Specified by:
      onCSSParseError in interface ICSSParseErrorHandler
      Parameters:
      aParseEx - The original parse exception. May not be null.
      aLastSkippedToken - The token until which was skipped (incl.) May be null.
      Throws:
      ParseException - In case the error is fatal and should be propagated.
    • createLoggingStringUnexpectedRule

      @Nonnull @Nonempty public static String createLoggingStringUnexpectedRule(@Nonnull Token aCurrentToken, @Nonnull @Nonempty String sRule, @Nonnull @Nonempty String sMsg)
      Create a common string to be used for unexpected rules.
      Parameters:
      aCurrentToken - The current token that caused an error. Never null.
      sRule - The name of the rule. Always starts with a '@'. May neither be null nor empty.
      sMsg - The custom error message. Neither null nor empty.
      Returns:
      The concatenated string with source location, rule and message. May neither be null nor empty.
    • onCSSUnexpectedRule

      public void onCSSUnexpectedRule(@Nonnull Token aCurrentToken, @Nonnull @Nonempty String sRule, @Nonnull @Nonempty String sMsg) throws ParseException
      Description copied from interface: ICSSParseErrorHandler
      Called upon an unexpected rule. This happens e.g. when @import is used in the middle of the file.
      Specified by:
      onCSSUnexpectedRule in interface ICSSParseErrorHandler
      Parameters:
      aCurrentToken - The token that could not be interpreted. Never null.
      sRule - The name of the rule. Always starts with a '@'. Neither null nor empty.
      sMsg - The custom error message. Neither null nor empty.
      Throws:
      ParseException - In case the error is fatal and should be propagated.
    • createLoggingStringDeprecatedProperty

      @Nonnull @Nonempty public static String createLoggingStringDeprecatedProperty(@Nonnull Token aPrefixToken, @Nonnull Token aIdentifierToken)
      Create a common string to be used for deprecated properties. To be called, if a deprecated old IE 6/7 property is found.
      Parameters:
      aPrefixToken - The prefix token found (like '$' or '*'). Never null.
      aIdentifierToken - The identifier token found. Never null.
      Returns:
      The concatenated string with source location, etc. May neither be null nor empty.
      Throws:
      ParseException - In case the error is fatal and should be propagated.
    • onCSSDeprecatedProperty

      public void onCSSDeprecatedProperty(@Nonnull Token aPrefixToken, @Nonnull Token aIdentifierToken)
      Description copied from interface: ICSSParseErrorHandler
      To be called, if a deprecated old IE 6/7 property is found.
      Specified by:
      onCSSDeprecatedProperty in interface ICSSParseErrorHandler
      Parameters:
      aPrefixToken - The prefix token found (like '$' or '*'). Never null.
      aIdentifierToken - The identifier token found. Never null.
    • createLoggingStringBrowserCompliantSkip

      @Nonnull @Nonempty public static String createLoggingStringBrowserCompliantSkip(@Nullable ParseException ex, @Nonnull Token aFromToken, @Nonnull Token aToToken)
    • onCSSBrowserCompliantSkip

      public void onCSSBrowserCompliantSkip(@Nullable ParseException ex, @Nonnull Token aFromToken, @Nonnull Token aToToken) throws ParseException
      Description copied from interface: ICSSParseErrorHandler
      This method is only called in browser compliant mode if a certain part of the CSS is skipped.
      Specified by:
      onCSSBrowserCompliantSkip in interface ICSSParseErrorHandler
      Parameters:
      ex - The original ParseException that causes the parser to skip. May be null.
      aFromToken - Original token that caused the error and was skipped (inclusive). Never null.
      aToToken - The end token until which was skipped (exclusive). Never null.
      Throws:
      ParseException - In case the error is fatal and should be propagated.
      See Also:
    • createLoggingStringIllegalCharacter

      @Nonnull @Nonempty public static String createLoggingStringIllegalCharacter(char cIllegalChar)
    • onIllegalCharacter

      public void onIllegalCharacter(char cIllegalChar)
      Description copied from interface: ICSSParseErrorHandler
      This method is invoked, when an illegal character is encountered (in TokenManager), and the respective rule is part of the JavaCC grammar.
      Specified by:
      onIllegalCharacter in interface ICSSParseErrorHandler
      Parameters:
      cIllegalChar - The illegal char
    • toString

      public String toString()
      Overrides:
      toString in class Object