/** * Check if the passed CSS file can be parsed without error * * @param aFile * The file to be parsed. May not be <code>null</code>. * @param aCharset * The charset to be used for reading the CSS file. May not be * <code>null</code>. * @param eVersion * The CSS version to be used for scanning. May not be * <code>null</code>. * @return <code>true</code> if the file can be parsed without error, * <code>false</code> if not */ public static boolean isValidCSS (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion) { return isValidCSS (new FileSystemResource (aFile), aCharset, eVersion); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion)); }
/** * Read the CSS from the passed {@link IHasInputStream}. * * @param aISP * The input stream provider to use. May not be <code>null</code>. * @param aCharset * The charset to be used. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CSSDeclarationList readFromStream (@Nonnull final IHasInputStream aISP, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion) { return readFromStream (aISP, aCharset, eVersion, null, null); }
aRealParseErrorHandler = getDefaultParseErrorHandler (); aRealParseExceptionHandler = getDefaultParseExceptionHandler (); final CSSNode aNode = _readStyleDeclaration (aCharStream, eVersion, aRealParseErrorHandler, aRealInterpretErrorHandler = getDefaultInterpretErrorHandler ();
String styleString) { CollectingCSSParseErrorHandler errorCollector = new CollectingCSSParseErrorHandler(); CSSDeclarationList parsed = CSSReaderDeclarationList.readFromString( styleString, ECSSVersion.LATEST, errorCollector); if (errorCollector.hasParseErrors()) {
final CSSNode aNode = _readStyleDeclaration (aCharStream, eVersion, getDefaultParseErrorHandler (), new DoNothingCSSParseExceptionCallback ()); return aNode != null;
String styleString) { CollectingCSSParseErrorHandler errorCollector = new CollectingCSSParseErrorHandler(); CSSDeclarationList parsed = CSSReaderDeclarationList.readFromString( styleString, ECSSVersion.LATEST, errorCollector); if (errorCollector.hasParseErrors()) {
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomExceptionHandler (aCustomExceptionHandler)); }
/** * Check if the passed String can be resembled to valid CSS content. This is * accomplished by fully parsing the CSS file each time the method is called. * This is similar to calling {@link #readFromString(String, ECSSVersion)} and * checking for a non-<code>null</code> result. * * @param sCSS * The CSS string to scan. 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 final String sCSS, @Nonnull final ECSSVersion eVersion) { ValueEnforcer.notNull (sCSS, "CSS"); return isValidCSS (new NonBlockingStringReader (sCSS), eVersion); }
/** * Read the CSS from the passed {@link IHasInputStream}. * * @param aISP * The input stream provider to use. May not be <code>null</code>. * @param aCharset * The charset to be used. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @param aCustomErrorHandler * An optional custom error handler that can be used to collect the * recoverable parsing errors. May be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CSSDeclarationList readFromStream (@Nonnull final IHasInputStream aISP, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromStream (aISP, aCharset, eVersion, aCustomErrorHandler, null); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler) .setCustomExceptionHandler (aCustomExceptionHandler)); }
/** * Check if the passed CSS resource can be parsed without error * * @param aRes * The resource to be parsed. May not be <code>null</code>. * @param aCharset * The charset to be used for reading the CSS file. May not be * <code>null</code>. * @param eVersion * The CSS version to be used for scanning. May not be * <code>null</code>. * @return <code>true</code> if the file can be parsed without error, * <code>false</code> if not */ public static boolean isValidCSS (@Nonnull final IReadableResource aRes, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion) { ValueEnforcer.notNull (aRes, "Resource"); ValueEnforcer.notNull (aCharset, "Charset"); ValueEnforcer.notNull (eVersion, "Version"); final Reader aReader = aRes.getReader (aCharset); if (aReader == null) { LOGGER.warn ("Failed to open CSS reader " + aRes); return false; } return isValidCSS (aReader, eVersion); }
/** * Read the CSS from the passed {@link IHasInputStream}. * * @param aISP * The input stream provider to use. May not be <code>null</code>. * @param aCharset * The charset to be used. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @param aCustomExceptionHandler * An optional custom exception handler that can be used to collect the * unrecoverable parsing errors. May be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CSSDeclarationList readFromStream (@Nonnull final IHasInputStream aISP, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromStream (aISP, aCharset, eVersion, null, aCustomExceptionHandler); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler)); }
/** * Check if the passed input stream can be resembled to valid CSS content. * This is accomplished by fully parsing the CSS file 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 aIS * The input stream to use. Is automatically closed. May not be * <code>null</code>. * @param aCharset * The charset to be used. 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 InputStream aIS, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion) { ValueEnforcer.notNull (aIS, "InputStream"); ValueEnforcer.notNull (aCharset, "Charset"); return isValidCSS (StreamHelper.createReader (aIS, aCharset), eVersion); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomExceptionHandler (aCustomExceptionHandler)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler) .setCustomExceptionHandler (aCustomExceptionHandler)); }
/** * Read the CSS from the passed {@link Reader}. * * @param aReader * The reader to use. Will be closed automatically after reading - * independent of success or error. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CSSDeclarationList readFromReader (@Nonnull @WillClose final Reader aReader, @Nonnull final ECSSVersion eVersion) { return readFromReader (aReader, new CSSReaderSettings ().setCSSVersion (eVersion)); }