Example usage for java.util EnumSet noneOf

List of usage examples for java.util EnumSet noneOf

Introduction

In this page you can find the example usage for java.util EnumSet noneOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) 

Source Link

Document

Creates an empty enum set with the specified element type.

Usage

From source file:Main.java

public static void main(String[] args) {
    final EnumSet<Style> styles = EnumSet.noneOf(Style.class);
    styles.addAll(EnumSet.range(Style.BOLD, Style.STRIKETHROUGH));
    styles.removeAll(EnumSet.of(Style.UNDERLINE, Style.STRIKETHROUGH));
    assert EnumSet.of(Style.BOLD, Style.ITALIC).equals(styles);
    System.out.println(styles);/*from ww w  .ja va2 s.c  o  m*/
}

From source file:Numbers.java

public static void main(String[] args) {

    EnumSet<Numbers> set1 = EnumSet.allOf(Numbers.class);

    System.out.println("Set1:" + set1);

    // create a second set which is empty
    EnumSet<Numbers> set2 = EnumSet.noneOf(Numbers.class);

    System.out.println("Set2:" + set2);

}

From source file:pl.edu.icm.cermine.bx.DocumentMetadataCoverageFilter.java

public static void main(String[] args) throws TransformationException, IOException, AnalysisException,
        ParseException, CloneNotSupportedException {
    Options options = new Options();
    options.addOption("input", true, "input path");
    options.addOption("output", true, "output path");
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(options, args);
    String inDir = line.getOptionValue("input");
    String outDir = line.getOptionValue("output");

    File dir = new File(inDir);

    for (File f : FileUtils.listFiles(dir, new String[] { "xml" }, true)) {
        TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
        List<BxPage> pages = tvReader.read(new FileReader(f));
        BxDocument doc = new BxDocument().setPages(pages);
        doc.setFilename(f.getName());//from w  w w.j a  va  2 s .  co m

        Set<BxZoneLabel> set = EnumSet.noneOf(BxZoneLabel.class);

        for (BxZone z : doc.asZones()) {
            if (z.getLabel().isOfCategoryOrGeneral(BxZoneLabelCategory.CAT_METADATA)) {
                set.add(z.getLabel());
            }
        }
        System.out.println(doc.getFilename() + " " + set.size());

        File f2 = new File(outDir + doc.getFilename() + "." + set.size());
        FileUtils.copyFile(f, f2);

    }
}

From source file:pl.edu.icm.cermine.bx.DocumentAllCoverageFilter.java

public static void main(String[] args) throws TransformationException, IOException, AnalysisException,
        ParseException, CloneNotSupportedException {
    Options options = new Options();
    options.addOption("input", true, "input path");
    options.addOption("output", true, "output path");
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(options, args);
    String inDir = line.getOptionValue("input");
    String outDir = line.getOptionValue("output");

    File dir = new File(inDir);

    for (File f : FileUtils.listFiles(dir, new String[] { "xml" }, true)) {
        TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
        List<BxPage> pages = tvReader.read(new FileReader(f));
        BxDocument doc = new BxDocument().setPages(pages);
        doc.setFilename(f.getName());//  w  w w.j  ava  2  s . c  o m

        Set<BxZoneLabel> set = EnumSet.noneOf(BxZoneLabel.class);

        int all = 0;
        int good = 0;
        for (BxZone z : doc.asZones()) {
            all++;
            if (!z.getLabel().equals(BxZoneLabel.OTH_UNKNOWN)) {
                good++;
            }
            if (z.getLabel().isOfCategoryOrGeneral(BxZoneLabelCategory.CAT_METADATA)) {
                set.add(z.getLabel());
            }
        }

        int intcov = 0;
        if (all > 0) {
            intcov = good * 100 / all;
        }
        System.out.println(doc.getFilename() + " " + set.size() + " " + intcov);

        File f2 = new File(outDir + doc.getFilename() + "." + set.size() + "." + intcov);
        FileUtils.copyFile(f, f2);
    }
}

From source file:pl.edu.icm.cermine.bx.DocumentKeyZonesFilter.java

public static void main(String[] args) throws TransformationException, IOException, AnalysisException,
        ParseException, CloneNotSupportedException {
    Options options = new Options();
    options.addOption("input", true, "input path");
    options.addOption("output", true, "output path");
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(options, args);
    String inDir = line.getOptionValue("input");
    String outDir = line.getOptionValue("output");

    File dir = new File(inDir);

    for (File f : FileUtils.listFiles(dir, new String[] { "xml" }, true)) {
        TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
        List<BxPage> pages = tvReader.read(new FileReader(f));
        BxDocument doc = new BxDocument().setPages(pages);
        doc.setFilename(f.getName());/* w  ww . j av  a  2  s. c om*/

        Set<BxZoneLabel> set = EnumSet.noneOf(BxZoneLabel.class);

        int keys = 0;
        int all = 0;
        int good = 0;
        for (BxZone z : doc.asZones()) {
            all++;
            if (BxZoneLabel.REFERENCES.equals(z.getLabel())) {
                keys = 1;
            }
            if (!z.getLabel().equals(BxZoneLabel.OTH_UNKNOWN)) {
                good++;
            }
            if (z.getLabel().isOfCategoryOrGeneral(BxZoneLabelCategory.CAT_METADATA)) {
                set.add(z.getLabel());
            }
        }

        System.out.println(set);

        if (set.contains(BxZoneLabel.MET_AFFILIATION)) {
            keys++;
        }
        if (set.contains(BxZoneLabel.MET_AUTHOR)) {
            keys++;
        }
        if (set.contains(BxZoneLabel.MET_BIB_INFO)) {
            keys++;
        }
        if (set.contains(BxZoneLabel.MET_TITLE)) {
            keys++;
        }

        int intcov = 0;
        if (all > 0) {
            intcov = good * 100 / all;
        }
        System.out.println(doc.getFilename() + " " + set.size() + " " + intcov + " " + keys);

        File f2 = new File(outDir + doc.getFilename() + "." + set.size() + "." + intcov + "." + keys);
        FileUtils.copyFile(f, f2);
    }
}

From source file:com.yahoo.wiki.webservice.application.WikiMain.java

/**
 * Run the Wikipedia application.//from   ww w.  j  a  v  a2s  .c  o m
 *
 * @param args  command line arguments
 * @throws Exception if the server fails to start or crashes
 */
public static void main(String[] args) throws Exception {
    int port = 9998;

    Server server = new Server(port);
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);

    servletContextHandler.addEventListener(new MetricServletContextListener());
    servletContextHandler.addEventListener(new HealthCheckServletContextListener());

    servletContextHandler.setContextPath("/");
    servletContextHandler.setResourceBase("src/main/webapp");

    //Activate codahale metrics
    FilterHolder instrumentedFilterHolder = new FilterHolder(InstrumentedFilter.class);
    instrumentedFilterHolder.setName("instrumentedFilter");
    instrumentedFilterHolder.setAsyncSupported(true);
    servletContextHandler.addFilter(instrumentedFilterHolder, "/*", EnumSet.noneOf(DispatcherType.class));

    // Static resource handler
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setResourceBase("src/main/webapp");

    // Add the handlers to the server
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { resourceHandler, servletContextHandler });
    server.setHandler(handlers);

    ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/v1/*");
    servletHolder.setInitOrder(1);
    servletHolder.setInitParameter("javax.ws.rs.Application",
            "com.yahoo.bard.webservice.application.ResourceConfig");
    servletHolder.setInitParameter("jersey.config.server.provider.packages",
            "com.yahoo.bard.webservice.web.endpoints");

    servletContextHandler.addServlet(AdminServlet.class, "/*");

    server.start();

    markDimensionCacheHealthy(port);
}

From source file:com.genentech.chemistry.openEye.apps.SDFCatsIndexer.java

/**
 * @param args//from   www. ja  va 2  s  .  c  o m
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    options.addOption(opt);

    opt = new Option(OPT_NORMALIZATION, true,
            "Normalization method: Counts|CountsPerAtom|CountsPerFeature(def) multiple allowed");
    opt.setArgName("meth");
    options.addOption(opt);

    opt = new Option(OPT_PRINTDESC, false,
            "Causes the descriptor for describing each linear path in a molceule to be created");
    options.addOption(opt);

    opt = new Option(OPT_RGROUPTYPES, false, "treat RGroup attachement point ([U]) as atom type.");
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);

    AtomTyperInterface[] myTypes = CATSIndexer.typers;
    String tagPrefix = "";
    if (cmd.hasOption(OPT_RGROUPTYPES)) {
        myTypes = CATSIndexer.rgroupTypers;
        tagPrefix = "RG";
    }

    if (cmd.hasOption(OPT_PRINTDESC)) {
        SDFCatsIndexer sdfIndexer = new SDFCatsIndexer(myTypes, tagPrefix);
        sdfIndexer.printDescriptors(inFile, outFile);
        sdfIndexer.close();
        return;
    }

    EnumSet<Normalization> normMeth = EnumSet.noneOf(Normalization.class);
    if (cmd.hasOption(OPT_NORMALIZATION))
        for (String n : cmd.getOptionValues(OPT_NORMALIZATION))
            normMeth.add(Normalization.valueOf(n));
    else
        normMeth.add(Normalization.CountsPerFeature);

    SDFCatsIndexer sdfIndexer = new SDFCatsIndexer(myTypes, tagPrefix);
    sdfIndexer.run(inFile, outFile, normMeth);
    sdfIndexer.close();
}

From source file:net.tirasa.ilgrosso.lngenerator.Main.java

public static void main(final String[] args) throws IOException, URISyntaxException {
    assert args.length > 0 : "No arguments provided";

    File source = new File(args[0]);
    if (!source.isDirectory()) {
        throw new IllegalArgumentException("Not a directory: " + args[0]);
    }//from  w  ww  .j a v  a 2  s  .com

    String destPath = args.length > 1 ? args[1] : System.getProperty("java.io.tmpdir");
    File dest = new File(destPath);
    if (!dest.isDirectory() || !dest.canWrite()) {
        throw new IllegalArgumentException("Not a directory, or not writable: " + destPath);
    }

    LOG.debug("Local Maven repo is {}", LOCAL_M2_REPO);
    LOG.debug("Source Path is {}", source.getAbsolutePath());
    LOG.debug("Destination Path is {}", dest.getAbsolutePath());
    LOG.warn("Existing LICENSE and NOTICE files in {} will be overwritten!", dest.getAbsolutePath());

    Set<String> keys = new HashSet<>();

    Files.walk(source.toPath()).filter(Files::isRegularFile)
            .map((final Path path) -> path.getFileName().toString())
            .filter((String path) -> path.endsWith(".jar")).sorted().forEach((filename) -> {
                try (Stream<Path> stream = Files.find(LOCAL_M2_REPO_PATH, 10,
                        (path, attr) -> String.valueOf(path.getFileName().toString()).equals(filename))) {

                    String fullPath = stream.sorted().map(String::valueOf).collect(Collectors.joining("; "));
                    if (fullPath.isEmpty()) {
                        LOG.warn("Could not find {} in the local Maven repo", filename);
                    } else {
                        String path = fullPath.substring(LOCAL_M2_REPO.length() + 1);
                        Gav gav = GAV_CALCULATOR.pathToGav(path);
                        if (gav == null) {
                            LOG.error("Invalid Maven path: {}", path);
                        } else if (!gav.getGroupId().startsWith("org.apache.")
                                && !gav.getGroupId().startsWith("commons-")
                                && !gav.getGroupId().equals("org.codehaus.groovy")
                                && !gav.getGroupId().equals("jakarta-regexp")
                                && !gav.getGroupId().equals("xml-apis") && !gav.getGroupId().equals("batik")) {

                            if (ArrayUtils.contains(CONSOLIDATING_GROUP_IDS, gav.getGroupId())) {
                                keys.add(gav.getGroupId());
                            } else if (gav.getGroupId().startsWith("com.fasterxml.jackson")) {
                                keys.add("com.fasterxml.jackson");
                            } else if (gav.getGroupId().equals("org.webjars.bower") && (gav.getArtifactId()
                                    .startsWith("angular-animate")
                                    || gav.getArtifactId().startsWith("angular-cookies")
                                    || gav.getArtifactId().startsWith("angular-resource")
                                    || gav.getArtifactId().startsWith("angular-sanitize")
                                    || gav.getArtifactId().startsWith("angular-treasure-overlay-spinner"))) {

                                keys.add("org.webjars.bower:angular");
                            } else if (gav.getGroupId().equals("org.webjars.bower")
                                    && gav.getArtifactId().startsWith("angular-translate")) {

                                keys.add("org.webjars.bower:angular-translate");
                            } else if (gav.getGroupId().startsWith("de.agilecoders")) {
                                keys.add("wicket-bootstrap");
                            } else if ("org.webjars".equals(gav.getGroupId())) {
                                if (gav.getArtifactId().startsWith("jquery-ui")) {
                                    keys.add("jquery-ui");
                                } else {
                                    keys.add(gav.getArtifactId());
                                }
                            } else {
                                keys.add(gav.getGroupId() + ":" + gav.getArtifactId());
                            }
                        }
                    }
                } catch (IOException e) {
                    LOG.error("While looking for Maven artifacts from the local Maven repo", e);
                }
            });

    final Properties licenses = new Properties();
    licenses.loadFromXML(Main.class.getResourceAsStream("/licenses.xml"));

    final Properties notices = new Properties();
    notices.loadFromXML(Main.class.getResourceAsStream("/notices.xml"));

    BufferedWriter licenseWriter = Files.newBufferedWriter(new File(dest, "LICENSE").toPath(),
            StandardOpenOption.CREATE);
    licenseWriter.write(
            new String(Files.readAllBytes(Paths.get(Main.class.getResource("/LICENSE.template").toURI()))));

    BufferedWriter noticeWriter = Files.newBufferedWriter(new File(dest, "NOTICE").toPath(),
            StandardOpenOption.CREATE);
    noticeWriter.write(
            new String(Files.readAllBytes(Paths.get(Main.class.getResource("/NOTICE.template").toURI()))));

    EnumSet<LICENSE> outputLicenses = EnumSet.noneOf(LICENSE.class);

    keys.stream().sorted().forEach((final String dependency) -> {
        if (licenses.getProperty(dependency) == null) {
            LOG.error("Could not find license information about {}", dependency);
        } else {
            try {
                licenseWriter.write("\n==\n\nFor " + licenses.getProperty(dependency) + ":\n");

                String depLicense = licenses.getProperty(dependency + ".license");
                if (depLicense == null) {
                    licenseWriter.write("This is licensed under the AL 2.0, see above.");
                } else {
                    LICENSE license = LICENSE.valueOf(depLicense);

                    if (license == LICENSE.PUBLIC_DOMAIN) {
                        licenseWriter.write("This is " + license.getLabel() + ".");
                    } else {
                        licenseWriter.write("This is licensed under the " + license.getLabel());

                        if (outputLicenses.contains(license)) {
                            licenseWriter.write(", see above.");
                        } else {
                            outputLicenses.add(license);

                            licenseWriter.write(":\n\n");
                            licenseWriter.write(new String(Files.readAllBytes(
                                    Paths.get(Main.class.getResource("/LICENSE." + license.name()).toURI()))));
                        }
                    }
                }
                licenseWriter.write('\n');

                if (notices.getProperty(dependency) != null) {
                    noticeWriter.write("\n==\n\n" + notices.getProperty(dependency) + "\n");
                }
            } catch (Exception e) {
                LOG.error("While dealing with {}", dependency, e);
            }
        }
    });

    licenseWriter.close();
    noticeWriter.close();

    LOG.debug("Execution completed successfully, look at {} for the generated LICENSE and NOTICE files",
            dest.getAbsolutePath());
}

From source file:Main.java

private static <T extends Enum<T>> EnumSet bitwiseToEnumSet(Class<T> classType, int bitwise) {
    EnumSet<T> enumSet = EnumSet.noneOf(classType);
    for (T enumValue : EnumSet.allOf(classType)) {
        if ((bitwise & (int) Math.pow(2, enumValue.ordinal())) == (int) Math.pow(2, enumValue.ordinal()))
            enumSet.add(enumValue);//from  w ww .  j  a  v  a  2 s. c  o  m
    }
    return enumSet;
}

From source file:Main.java

public static <E extends Enum<E>> EnumSet<E> getEnumSetFromString(Class<E> enumType, String enumString) {
    EnumSet<E> es = EnumSet.noneOf(enumType);

    if (!Strings.isNullOrEmpty(enumString)) {
        String[] split = enumString.split(",");
        for (String s : split) {
            es.add(Enum.valueOf(enumType, s));
        }/*w w w. j a  v  a  2  s.  c o  m*/
    }
    return es;
}