Class CollectingCSSParseErrorHandler
java.lang.Object
com.helger.css.reader.errorhandler.CollectingCSSParseErrorHandler
- All Implemented Interfaces:
ICSSParseErrorHandler
@ThreadSafe
public class CollectingCSSParseErrorHandler
extends Object
implements ICSSParseErrorHandler
A collecting implementation of
ICSSParseErrorHandler. So in case a
recoverable error occurs, it is remembered in the internal list and can be
retrieved by getAllParseErrors().- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.helger.commons.collection.impl.ICommonsList<CSSParseError>intbooleanvoidonCSSBrowserCompliantSkip(ParseException ex, Token aFromToken, Token aToToken) This method is only called in browser compliant mode if a certain part of the CSS is skipped.voidonCSSDeprecatedProperty(Token aPrefixToken, Token aIdentifierToken) To be called, if a deprecated old IE 6/7 property is found.voidonCSSParseError(ParseException aParseEx, Token aLastSkippedToken) Called upon a recoverable error.voidonCSSUnexpectedRule(Token aCurrentToken, String sRule, String sMsg) Called upon an unexpected rule.voidonIllegalCharacter(char cIllegalChar) This method is invoked, when an illegal character is encountered (in TokenManager), and the respective rule is part of the JavaCC grammar.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.css.reader.errorhandler.ICSSParseErrorHandler
and
-
Constructor Details
-
CollectingCSSParseErrorHandler
public CollectingCSSParseErrorHandler()
-
-
Method Details
-
onCSSParseError
public void onCSSParseError(@Nonnull ParseException aParseEx, @Nullable Token aLastSkippedToken) throws ParseException Description copied from interface:ICSSParseErrorHandlerCalled upon a recoverable error. The parameter list is similar to the one of theParseException.- Specified by:
onCSSParseErrorin interfaceICSSParseErrorHandler- Parameters:
aParseEx- The original parse exception. May not benull.aLastSkippedToken- The token until which was skipped (incl.) May benull.- Throws:
ParseException- In case the error is fatal and should be propagated.
-
onCSSUnexpectedRule
public void onCSSUnexpectedRule(@Nonnull Token aCurrentToken, @Nonnull @Nonempty String sRule, @Nonnull @Nonempty String sMsg) throws ParseException Description copied from interface:ICSSParseErrorHandlerCalled upon an unexpected rule. This happens e.g. when@importis used in the middle of the file.- Specified by:
onCSSUnexpectedRulein interfaceICSSParseErrorHandler- Parameters:
aCurrentToken- The token that could not be interpreted. Nevernull.sRule- The name of the rule. Always starts with a '@'. Neithernullnor empty.sMsg- The custom error message. Neithernullnor empty.- Throws:
ParseException- In case the error is fatal and should be propagated.
-
onCSSDeprecatedProperty
Description copied from interface:ICSSParseErrorHandlerTo be called, if a deprecated old IE 6/7 property is found.- Specified by:
onCSSDeprecatedPropertyin interfaceICSSParseErrorHandler- Parameters:
aPrefixToken- The prefix token found (like '$' or '*'). Nevernull.aIdentifierToken- The identifier token found. Nevernull.
-
onCSSBrowserCompliantSkip
public void onCSSBrowserCompliantSkip(@Nullable ParseException ex, @Nonnull Token aFromToken, @Nonnull Token aToToken) throws ParseException Description copied from interface:ICSSParseErrorHandlerThis method is only called in browser compliant mode if a certain part of the CSS is skipped.- Specified by:
onCSSBrowserCompliantSkipin interfaceICSSParseErrorHandler- Parameters:
ex- The originalParseExceptionthat causes the parser to skip. May benull.aFromToken- Original token that caused the error and was skipped (inclusive). Nevernull.aToToken- The end token until which was skipped (exclusive). Nevernull.- Throws:
ParseException- In case the error is fatal and should be propagated.- See Also:
-
onIllegalCharacter
public void onIllegalCharacter(char cIllegalChar) Description copied from interface:ICSSParseErrorHandlerThis method is invoked, when an illegal character is encountered (in TokenManager), and the respective rule is part of the JavaCC grammar.- Specified by:
onIllegalCharacterin interfaceICSSParseErrorHandler- Parameters:
cIllegalChar- The illegal char
-
hasParseErrors
- Returns:
trueif at least one parse error is contained,falseotherwise.
-
getParseErrorCount
- Returns:
- The number of contained parse errors. Always ≥ 0.
-
getAllParseErrors
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSParseError> getAllParseErrors()- Returns:
- A copy of the list with all contained errors. Never
nullbut maybe empty. - See Also:
-
toString
-