use of com.helger.css.handler.DoNothingCSSParseExceptionCallback in project ph-css by phax.
the class CSSReaderDeclarationListTest method testRead21.
@Test
public void testRead21() {
final ICSSParseExceptionCallback aHdl = new DoNothingCSSParseExceptionCallback();
for (final String sCSS : VALID) {
final CSSDeclarationList aDL = CSSReaderDeclarationList.readFromString(sCSS, ECSSVersion.CSS30, aHdl);
assertNotNull(aDL);
}
for (final String sCSS : INVALID) assertNull(sCSS, CSSReaderDeclarationList.readFromString(sCSS, ECSSVersion.CSS30, aHdl));
}
use of com.helger.css.handler.DoNothingCSSParseExceptionCallback in project ph-css by phax.
the class CSSReader 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 = _readStyleSheet(aCharStream, eVersion, getDefaultParseErrorHandler(), new DoNothingCSSParseExceptionCallback(), false);
return aNode != null;
} finally {
StreamHelper.close(aReader);
}
}
use of com.helger.css.handler.DoNothingCSSParseExceptionCallback 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