use of com.helger.css.parser.CSSCharStream in project ph-css by phax.
the class CSSReaderDeclarationList method isValidCSS.
/**
* Check if the passed reader can be resembled to valid CSS content. This is
* accomplished by fully parsing the CSS each time the method is called. This
* is similar to calling
* {@link #readFromStream(IHasInputStream, Charset, ECSSVersion)} and checking
* for a non-<code>null</code> result.
*
* @param aReader
* The reader to use. May not be <code>null</code>.
* @param eVersion
* The CSS version to use. May not be <code>null</code>.
* @return <code>true</code> if the CSS is valid according to the version,
* <code>false</code> if not
*/
public static boolean isValidCSS(@Nonnull @WillClose final Reader aReader, @Nonnull final ECSSVersion eVersion) {
ValueEnforcer.notNull(aReader, "Reader");
ValueEnforcer.notNull(eVersion, "Version");
try {
final CSSCharStream aCharStream = new CSSCharStream(aReader);
final CSSNode aNode = _readStyleDeclaration(aCharStream, eVersion, getDefaultParseErrorHandler(), new DoNothingCSSParseExceptionCallback());
return aNode != null;
} finally {
StreamHelper.close(aReader);
}
}
Aggregations