/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }