Search in sources :

Example 1 with CommonsLinkedHashMap

use of com.helger.commons.collection.impl.CommonsLinkedHashMap in project ph-css by phax.

the class MainReadAllCSSOnDisc method main.

@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
public static void main(final String[] args) {
    int nFilesOK = 0;
    int nFilesError = 0;
    final ICommonsOrderedMap<File, ParseException> aErrors = new CommonsLinkedHashMap<>();
    final Wrapper<File> aCurrentFile = new Wrapper<>();
    final ICSSParseExceptionCallback aHdl = ex -> aErrors.put(aCurrentFile.get(), ex);
    for (final File aFile : new FileSystemRecursiveIterator(new File("/")).withFilter(IFileFilter.filenameEndsWith(".css"))) {
        if (false)
            s_aLogger.info(aFile.getAbsolutePath());
        aCurrentFile.set(aFile);
        final CascadingStyleSheet aCSS = CSSReader.readFromFile(aFile, StandardCharsets.UTF_8, ECSSVersion.CSS30, aHdl);
        if (aCSS == null) {
            nFilesError++;
            s_aLogger.warn("  " + aFile.getAbsolutePath() + " failed!");
        } else
            nFilesOK++;
    }
    s_aLogger.info("Done");
    for (final Map.Entry<File, ParseException> aEntry : aErrors.entrySet()) s_aLogger.info("  " + aEntry.getKey().getAbsolutePath() + ":\n" + aEntry.getValue().getMessage() + "\n");
    s_aLogger.info("OK: " + nFilesOK + "; Error: " + nFilesError);
}
Also used : Logger(org.slf4j.Logger) ICSSParseExceptionCallback(com.helger.css.handler.ICSSParseExceptionCallback) CSSReader(com.helger.css.reader.CSSReader) LoggerFactory(org.slf4j.LoggerFactory) ICommonsOrderedMap(com.helger.commons.collection.impl.ICommonsOrderedMap) ECSSVersion(com.helger.css.ECSSVersion) ParseException(com.helger.css.parser.ParseException) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) FileSystemRecursiveIterator(com.helger.commons.io.file.FileSystemRecursiveIterator) IFileFilter(com.helger.commons.io.file.IFileFilter) Wrapper(com.helger.commons.wrapper.Wrapper) Map(java.util.Map) CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Wrapper(com.helger.commons.wrapper.Wrapper) CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) ICSSParseExceptionCallback(com.helger.css.handler.ICSSParseExceptionCallback) CascadingStyleSheet(com.helger.css.decl.CascadingStyleSheet) FileSystemRecursiveIterator(com.helger.commons.io.file.FileSystemRecursiveIterator) ParseException(com.helger.css.parser.ParseException) File(java.io.File) ICommonsOrderedMap(com.helger.commons.collection.impl.ICommonsOrderedMap) Map(java.util.Map) CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

CommonsLinkedHashMap (com.helger.commons.collection.impl.CommonsLinkedHashMap)1 ICommonsOrderedMap (com.helger.commons.collection.impl.ICommonsOrderedMap)1 FileSystemRecursiveIterator (com.helger.commons.io.file.FileSystemRecursiveIterator)1 IFileFilter (com.helger.commons.io.file.IFileFilter)1 Wrapper (com.helger.commons.wrapper.Wrapper)1 ECSSVersion (com.helger.css.ECSSVersion)1 CascadingStyleSheet (com.helger.css.decl.CascadingStyleSheet)1 ICSSParseExceptionCallback (com.helger.css.handler.ICSSParseExceptionCallback)1 ParseException (com.helger.css.parser.ParseException)1 CSSReader (com.helger.css.reader.CSSReader)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 File (java.io.File)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Map (java.util.Map)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1