Example usage for java.util Map get

List of usage examples for java.util Map get

Introduction

In this page you can find the example usage for java.util Map get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.badlogicgames.packr.Packr.java

public static void main(String[] args) throws IOException {
    if (args.length > 1) {
        Map<String, String> arguments = parseArgs(args);
        Config config = new Config();
        config.platform = Platform.valueOf(arguments.get("platform"));
        config.jdk = arguments.get("jdk");
        config.executable = arguments.get("executable");
        config.jar = arguments.get("appjar");
        config.mainClass = arguments.get("mainclass");
        if (arguments.get("vmargs") != null) {
            config.vmArgs = Arrays.asList(arguments.get("vmargs").split(";"));
        }/*  w w w . j a  v  a2s. c  o m*/
        config.outDir = arguments.get("outdir");
        if (arguments.get("minimizejre") != null) {
            if (new File(arguments.get("minimizejre")).exists()) {
                config.minimizeJre = FileUtils.readFileToString(new File(arguments.get("minimizejre")))
                        .split("\r?\n");
            } else {
                InputStream in = Packr.class.getResourceAsStream("/minimize/" + arguments.get("minimizejre"));
                if (in != null) {
                    config.minimizeJre = IOUtils.toString(in).split("\r?\n");
                    in.close();
                } else {
                    config.minimizeJre = new String[0];
                }
            }
        }
        if (arguments.get("resources") != null)
            config.resources = Arrays.asList(arguments.get("resources").split(";"));
        new Packr().pack(config);
    } else {
        if (args.length == 0) {
            printHelp();
        } else {
            JsonObject json = JsonObject.readFrom(FileUtils.readFileToString(new File(args[0])));
            Config config = new Config();
            config.platform = Platform.valueOf(json.get("platform").asString());
            config.jdk = json.get("jdk").asString();
            config.executable = json.get("executable").asString();
            config.jar = json.get("appjar").asString();
            config.mainClass = json.get("mainclass").asString();
            if (json.get("vmargs") != null) {
                for (JsonValue val : json.get("vmargs").asArray()) {
                    config.vmArgs.add(val.asString());
                }
            }
            config.outDir = json.get("outdir").asString();
            if (json.get("minimizejre") != null) {
                if (new File(json.get("minimizejre").asString()).exists()) {
                    config.minimizeJre = FileUtils
                            .readFileToString(new File(json.get("minimizejre").asString())).split("\r?\n");
                } else {
                    InputStream in = Packr.class.getResourceAsStream("/minimize/" + json.get("minimizejre"));
                    if (in != null) {
                        config.minimizeJre = IOUtils.toString(in).split("\r?\n");
                        in.close();
                    } else {
                        config.minimizeJre = new String[0];
                    }
                }
            }
            if (json.get("resources") != null) {
                config.resources = toStringArray(json.get("resources").asArray());
            }
            new Packr().pack(config);
        }
    }
}

From source file:de.ingrid.iplug.PlugServer.java

/**
 * To start the plug server from the commandline.
 * @param args Arguments for the plug server e.g. --descriptor .
 * @throws Exception If something goes wrong.
 *//*from w w  w . j  av a2s  . c om*/
public static void main(String[] args) throws Exception {
    Map arguments = readParameters(args);
    PlugDescription plugDescription = null;
    File plugDescriptionFile = new File(PLUG_DESCRIPTION);
    if (arguments.containsKey("--plugdescription")) {
        plugDescriptionFile = new File((String) arguments.get("--plugdescription"));
    }
    plugDescription = loadPlugDescriptionFromFile(plugDescriptionFile);

    PlugServer server = null;
    if (arguments.containsKey("--resetPassword")) {
        String pw = (String) arguments.get("--resetPassword");
        fLogger.info("Resetting password to '" + pw + "' ...");
        plugDescription.setIplugAdminPassword(BCrypt.hashpw(pw, BCrypt.gensalt()));
        XMLSerializer serializer = new XMLSerializer();
        serializer.serialize(plugDescription, plugDescriptionFile);
        fLogger.info("Done ... please restart iPlug.");
        return;
    } else if (arguments.containsKey("--migratePassword")) {
        fLogger.info("Migrating plain text password from PlugDescription to encrypted one ...");
        plugDescription.setIplugAdminPassword(
                BCrypt.hashpw(plugDescription.getIplugAdminPassword(), BCrypt.gensalt()));
        XMLSerializer serializer = new XMLSerializer();
        serializer.serialize(plugDescription, plugDescriptionFile);
        fLogger.info("Done ... please restart iPlug.");
        return;
    } else if (arguments.containsKey("--descriptor")) {
        File commConf = new File((String) arguments.get("--descriptor"));
        server = new PlugServer(plugDescription, commConf, plugDescriptionFile, 60 * 1000);
    }
    if (server != null) {
        server.initPlugServer();
    }
}

From source file:com.seavus.wordcountermaven.WordCounter.java

/**
 * @param args the command line arguments
 * @throws java.io.FileNotFoundException
 *///from   ww  w  .  jav a  2s.c  o m
public static void main(String[] args) throws FileNotFoundException {
    InputStream fileStream = WordCounter.class.getClassLoader().getResourceAsStream("test.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(fileStream));

    Map<String, Integer> wordMap = new HashMap<>();
    String line;

    boolean tokenFound = false;
    try {
        while ((line = br.readLine()) != null) {
            String[] tokens = line.trim().split("\\s+"); //trims surrounding whitespaces and splits lines into tokens
            for (String token : tokens) {
                for (Map.Entry<String, Integer> entry : wordMap.entrySet()) {
                    if (StringUtils.equalsIgnoreCase(token, entry.getKey())) {
                        wordMap.put(entry.getKey(), (wordMap.get(entry.getKey()) + 1));
                        tokenFound = true;
                    }
                }
                if (!token.equals("") && !tokenFound) {
                    wordMap.put(token.toLowerCase(), 1);
                }
                tokenFound = false;
            }
        }
        br.close();
    } catch (IOException ex) {
        Logger.getLogger(WordCounter.class.getName()).log(Level.SEVERE, null, ex);
    }

    System.out.println("string : " + "frequency\r\n" + "-------------------");
    //prints out each unique word (i.e. case-insensitive string token) and its frequency to the console
    for (Map.Entry<String, Integer> entry : wordMap.entrySet()) {
        System.out.println(entry.getKey() + " : " + entry.getValue());
    }

}

From source file:com.pureinfo.srm.reports.table.data.sci.SCIBySchoolStatistic.java

public static void main(String[] args) throws PureException {
    IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class);
    IStatement stat = mgr.createQuery(//from   w w  w. ja v a2s .com
            "select count({this.id}) _NUM, {this.englishScience} AS _SUB from {this} group by _SUB", 0);
    IObjects nums = stat.executeQuery(false);
    DolphinObject num = null;
    Map map = new HashedMap();
    while ((num = nums.next()) != null) {
        String subest = num.getStrProperty("_SUB");
        if (subest == null || subest.trim().length() == 0)
            continue;
        String[] subs = subest.split(";");
        int nNum = num.getIntProperty("_NUM", 0);
        for (int i = 0; i < subs.length; i++) {
            String sSub = subs[i].trim();
            Integer odValue = (Integer) map.get(sSub);
            int sum = odValue == null ? nNum : (nNum + odValue.intValue());
            map.put(sSub, new Integer(sum));
        }
    }
    List l = new ArrayList(map.size());

    for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
        Map.Entry en = (Map.Entry) iter.next();
        l.add(new Object[] { en.getKey(), en.getValue() });
    }
    Collections.sort(l, new Comparator() {

        public int compare(Object _sO1, Object _sO2) {
            Object[] arr1 = (Object[]) _sO1;
            Object[] arr2 = (Object[]) _sO2;
            Comparable s1 = (Comparable) arr1[1];
            Comparable s2 = (Comparable) arr2[01];
            return s1.compareTo(s2);
        }
    });
    for (Iterator iter = l.iterator(); iter.hasNext();) {
        Object[] arr = (Object[]) iter.next();
        System.out.println(arr[0] + " = " + arr[1]);
    }

}

From source file:at.newmedialab.ldpath.backend.linkeddata.LDQuery.java

public static void main(String[] args) {
    Options options = buildOptions();//  w w  w .j  a  v a 2 s .  c om

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        Level logLevel = Level.WARN;

        if (cmd.hasOption("loglevel")) {
            String logLevelName = cmd.getOptionValue("loglevel");
            if ("DEBUG".equals(logLevelName.toUpperCase())) {
                logLevel = Level.DEBUG;
            } else if ("INFO".equals(logLevelName.toUpperCase())) {
                logLevel = Level.INFO;
            } else if ("WARN".equals(logLevelName.toUpperCase())) {
                logLevel = Level.WARN;
            } else if ("ERROR".equals(logLevelName.toUpperCase())) {
                logLevel = Level.ERROR;
            } else {
                log.error("unsupported log level: {}", logLevelName);
            }
        }

        if (logLevel != null) {
            for (String logname : new String[] { "at", "org", "net", "com" }) {

                ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory
                        .getLogger(logname);
                logger.setLevel(logLevel);
            }
        }

        String format = null;
        if (cmd.hasOption("format")) {
            format = cmd.getOptionValue("format");
        }

        GenericSesameBackend backend;
        if (cmd.hasOption("store")) {
            backend = new LDPersistentBackend(new File(cmd.getOptionValue("store")));
        } else {
            backend = new LDMemoryBackend();
        }

        Resource context = null;
        if (cmd.hasOption("context")) {
            context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
        }

        if (backend != null && context != null) {
            LDPath<Value> ldpath = new LDPath<Value>(backend);

            if (cmd.hasOption("path")) {
                String path = cmd.getOptionValue("path");

                for (Value v : ldpath.pathQuery(context, path, null)) {
                    System.out.println(v.stringValue());
                }
            } else if (cmd.hasOption("program")) {
                File file = new File(cmd.getOptionValue("program"));

                Map<String, Collection<?>> result = ldpath.programQuery(context, new FileReader(file));

                for (String field : result.keySet()) {
                    StringBuilder line = new StringBuilder();
                    line.append(field);
                    line.append(" = ");
                    line.append("{");
                    for (Iterator it = result.get(field).iterator(); it.hasNext();) {
                        line.append(it.next().toString());
                        if (it.hasNext()) {
                            line.append(", ");
                        }
                    }
                    line.append("}");
                    System.out.println(line);

                }
            }
        }

        if (backend instanceof LDPersistentBackend) {
            ((LDPersistentBackend) backend).shutdown();
        }

    } catch (ParseException e) {
        System.err.println("invalid arguments");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    } catch (LDPathParseException e) {
        System.err.println("path or program could not be parsed");
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        System.err.println("file or program could not be found");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    } catch (IOException e) {
        System.err.println("could not access cache data directory");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    }

}

From source file:org.apache.hive.ptest.execution.JIRAService.java

public static void main(String[] args) throws Exception {
    CommandLine cmd = null;

    try {//ww  w.j  av  a 2s .  c  o m
        cmd = parseCommandLine(args);
    } catch (ParseException e) {
        System.out.println("Error parsing command arguments: " + e.getMessage());
        System.exit(1);
    }

    // If null is returned, then help message was displayed in parseCommandLine method
    if (cmd == null) {
        System.exit(0);
    }

    Map<String, Object> jsonValues = parseJsonFile(cmd.getOptionValue(OPT_FILE_LONG));

    Map<String, String> context = Maps.newHashMap();
    context.put(FIELD_JIRA_URL, (String) jsonValues.get(FIELD_JIRA_URL));
    context.put(FIELD_JIRA_USER, cmd.getOptionValue(OPT_USER_LONG));
    context.put(FIELD_JIRA_PASS, cmd.getOptionValue(OPT_PASS_LONG));
    context.put(FIELD_LOGS_URL, (String) jsonValues.get(FIELD_LOGS_URL));
    context.put(FIELD_REPO, (String) jsonValues.get(FIELD_REPO));
    context.put(FIELD_REPO_NAME, (String) jsonValues.get(FIELD_REPO_NAME));
    context.put(FIELD_REPO_TYPE, (String) jsonValues.get(FIELD_REPO_TYPE));
    context.put(FIELD_REPO_BRANCH, (String) jsonValues.get(FIELD_REPO_BRANCH));
    context.put(FIELD_JENKINS_URL, (String) jsonValues.get(FIELD_JENKINS_URL));

    TestLogger logger = new TestLogger(System.err, TestLogger.LEVEL.TRACE);
    TestConfiguration configuration = new TestConfiguration(new Context(context), logger);
    configuration.setJiraName((String) jsonValues.get(FIELD_JIRA_NAME));
    configuration.setPatch((String) jsonValues.get(FIELD_PATCH_URL));

    JIRAService service = new JIRAService(logger, configuration, (String) jsonValues.get(FIELD_BUILD_TAG));
    List<String> messages = (List) jsonValues.get(FIELD_MESSAGES);
    SortedSet<String> failedTests = (SortedSet) jsonValues.get(FIELD_FAILED_TESTS);
    boolean error = (Integer) jsonValues.get(FIELD_BUILD_STATUS) == 0 ? false : true;
    service.postComment(error, (Integer) jsonValues.get(FIELD_NUM_TESTS_EXECUTED), failedTests, messages);
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step4MTurkOutputCollector.java

@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    String inputDirWithArgumentPairs = args[0];

    File[] resultFiles;/*www.  j  av a  2 s  .com*/

    if (args[1].contains("*")) {
        File path = new File(args[1]);
        File directory = path.getParentFile();
        String regex = path.getName().replaceAll("\\*", "");

        List<File> files = new ArrayList<>(FileUtils.listFiles(directory, new String[] { regex }, false));
        resultFiles = new File[files.size()];
        for (int i = 0; i < files.size(); i++) {
            resultFiles[i] = files.get(i);
        }
    } else {
        // result file is a comma-separated list of CSV files from MTurk
        String[] split = args[1].split(",");
        resultFiles = new File[split.length];
        for (int i = 0; i < split.length; i++) {
            resultFiles[i] = new File(split[i]);
        }
    }

    File outputDir = new File(args[2]);

    if (!outputDir.exists()) {
        if (!outputDir.mkdirs()) {
            throw new IOException("Cannot create directory " + outputDir);
        }
    }

    // error if output folder not empty to prevent any confusion by mixing files
    if (!FileUtils.listFiles(outputDir, null, false).isEmpty()) {
        throw new IllegalArgumentException("Output dir " + outputDir + " is not empty");
    }

    // collected assignments with empty reason for rejections
    Set<String> assignmentsWithEmptyReason = new HashSet<>();

    // parse with first line as header
    MTurkOutputReader mTurkOutputReader = new MTurkOutputReader(resultFiles);

    Collection<File> files = FileUtils.listFiles(new File(inputDirWithArgumentPairs), new String[] { "xml" },
            false);

    if (files.isEmpty()) {
        throw new IOException("No xml files found in " + inputDirWithArgumentPairs);
    }

    // statistics: how many hits with how many assignments ; hit ID / assignments
    Map<String, Map<String, Integer>> assignmentsPerHits = new HashMap<>();

    // collect accept/reject statistics
    for (Map<String, String> record : mTurkOutputReader) {
        boolean wasRejected = "Rejected".equals(record.get("assignmentstatus"));
        String hitID = record.get("hitid");
        String hitTypeId = record.get("hittypeid");

        if (!wasRejected) {
            // update statistics
            if (!assignmentsPerHits.containsKey(hitTypeId)) {
                assignmentsPerHits.put(hitTypeId, new HashMap<String, Integer>());
            }

            if (!assignmentsPerHits.get(hitTypeId).containsKey(hitID)) {
                assignmentsPerHits.get(hitTypeId).put(hitID, 0);
            }

            assignmentsPerHits.get(hitTypeId).put(hitID, assignmentsPerHits.get(hitTypeId).get(hitID) + 1);
        }
    }

    // statistics: how many hits with how many assignments ; hit ID / assignments
    Map<String, Integer> approvedAssignmentsPerHit = new HashMap<>();
    Map<String, Integer> rejectedAssignmentsPerHit = new HashMap<>();

    // collect accept/reject statistics
    for (Map<String, String> record : mTurkOutputReader) {
        boolean approved = "Approved".equals(record.get("assignmentstatus"));
        boolean rejected = "Rejected".equals(record.get("assignmentstatus"));
        String hitID = record.get("hitid");

        if (approved) {
            // update statistics
            if (!approvedAssignmentsPerHit.containsKey(hitID)) {
                approvedAssignmentsPerHit.put(hitID, 0);
            }

            approvedAssignmentsPerHit.put(hitID, approvedAssignmentsPerHit.get(hitID) + 1);
        } else if (rejected) {
            // update statistics
            if (!rejectedAssignmentsPerHit.containsKey(hitID)) {
                rejectedAssignmentsPerHit.put(hitID, 0);
            }

            rejectedAssignmentsPerHit.put(hitID, rejectedAssignmentsPerHit.get(hitID) + 1);
        } else {
            throw new IllegalStateException(
                    "Unknown state: " + record.get("assignmentstatus") + " HITID: " + hitID);
        }
    }

    //        System.out.println("Approved: " + approvedAssignmentsPerHit);
    //        System.out.println("Rejected: " + rejectedAssignmentsPerHit);

    System.out.println("Approved (values): " + new HashSet<>(approvedAssignmentsPerHit.values()));
    System.out.println("Rejected (values): " + new HashSet<>(rejectedAssignmentsPerHit.values()));
    // rejection statistics
    int totalRejected = 0;
    for (Map.Entry<String, Integer> rejectionEntry : rejectedAssignmentsPerHit.entrySet()) {
        totalRejected += rejectionEntry.getValue();
    }

    System.out.println("Total rejections: " + totalRejected);

    /*
    // generate .success files for adding more annotations
    for (File resultFile : resultFiles) {
    String hitTypeID = mTurkOutputReader.getHitTypeIdForFile().get(resultFile);
            
    // assignments for that hittypeid (= file)
    Map<String, Integer> assignments = assignmentsPerHits.get(hitTypeID);
            
    prepareUpdateHITsFiles(assignments, hitTypeID, resultFile);
    }
    */

    int totalSavedPairs = 0;

    // load all previously prepared argument pairs
    for (File file : files) {
        List<ArgumentPair> argumentPairs = (List<ArgumentPair>) XStreamTools.getXStream().fromXML(file);

        List<AnnotatedArgumentPair> annotatedArgumentPairs = new ArrayList<>();

        for (ArgumentPair argumentPair : argumentPairs) {
            AnnotatedArgumentPair annotatedArgumentPair = new AnnotatedArgumentPair(argumentPair);

            // is there such an answer?
            String key = "Answer." + argumentPair.getId();

            // iterate only if there is such column to save time
            if (mTurkOutputReader.getColumnNames().contains(key)) {
                // now find the results
                for (Map<String, String> record : mTurkOutputReader) {
                    if (record.containsKey(key)) {
                        // extract the values
                        AnnotatedArgumentPair.MTurkAssignment assignment = new AnnotatedArgumentPair.MTurkAssignment();

                        boolean wasRejected = "Rejected".equals(record.get("assignmentstatus"));

                        // only non-rejected (if required)
                        if (!wasRejected) {
                            String hitID = record.get("hitid");
                            String workerID = record.get("workerid");
                            String assignmentId = record.get("assignmentid");
                            try {
                                assignment.setAssignmentAcceptTime(
                                        DATE_FORMAT.parse(record.get("assignmentaccepttime")));
                                assignment.setAssignmentSubmitTime(
                                        DATE_FORMAT.parse(record.get("assignmentsubmittime")));
                                assignment.setHitComment(record.get("Answer.feedback"));
                                assignment.setHitID(hitID);
                                assignment.setTurkID(workerID);
                                assignment.setAssignmentId(assignmentId);

                                // and answer specific fields
                                String valueRaw = record.get(key);

                                // so far the label has had format aXXX_aYYY_a1, aXXX_aYYY_a2, or aXXX_aYYY_equal
                                // strip now only true label
                                String label = valueRaw.split("_")[2];

                                assignment.setValue(label);
                                String reason = record.get(key + "_reason");

                                // missing reason
                                if (reason == null) {
                                    assignmentsWithEmptyReason.add(assignmentId);
                                } else {
                                    assignment.setReason(reason);

                                    // get worker's stance
                                    String stanceRaw = record.get(key + "_stance");
                                    if (stanceRaw != null) {
                                        // parse stance
                                        String stance = stanceRaw.split("_stance_")[1];
                                        assignment.setWorkerStance(stance);
                                    }

                                    // we take maximal 5 assignments
                                    Collections.sort(annotatedArgumentPair.mTurkAssignments,
                                            new Comparator<AnnotatedArgumentPair.MTurkAssignment>() {
                                                @Override
                                                public int compare(AnnotatedArgumentPair.MTurkAssignment o1,
                                                        AnnotatedArgumentPair.MTurkAssignment o2) {
                                                    return o1.getAssignmentAcceptTime()
                                                            .compareTo(o2.getAssignmentAcceptTime());
                                                }
                                            });

                                    if (annotatedArgumentPair.mTurkAssignments
                                            .size() < MAXIMUM_ASSIGNMENTS_PER_HIT) {
                                        annotatedArgumentPair.mTurkAssignments.add(assignment);
                                    }
                                }
                            } catch (IllegalArgumentException | NullPointerException ex) {
                                System.err.println("Malformed annotations for HIT " + hitID + ", worker "
                                        + workerID + ", assignment " + assignmentId + "; " + ex.getMessage()
                                        + ", full record: " + record);
                            }
                        }
                    }
                }
            }

            // and if there are some annotations, add it to the result set
            if (!annotatedArgumentPair.mTurkAssignments.isEmpty()) {
                annotatedArgumentPairs.add(annotatedArgumentPair);
            }
        }

        if (!annotatedArgumentPairs.isEmpty()) {
            File outputFile = new File(outputDir, file.getName());
            XStreamTools.toXML(annotatedArgumentPairs, outputFile);

            System.out.println("Saved " + annotatedArgumentPairs.size() + " annotated pairs to " + outputFile);
            totalSavedPairs += annotatedArgumentPairs.size();
        }
    }

    System.out.println("Total saved " + totalSavedPairs + " pairs");

    // print assignments with empty reasons
    if (!assignmentsWithEmptyReason.isEmpty()) {
        System.out.println(
                "== Assignments with empty reason:\nassignmentIdToReject\tassignmentIdToRejectComment");
        for (String assignmentId : assignmentsWithEmptyReason) {
            System.out.println(
                    assignmentId + "\t\"Dear worker, you did not fill the required field with a reason.\"");
        }
    }

}

From source file:com.sun.faces.generate.HtmlComponentGenerator.java

public static void main(String args[]) throws Exception {

    try {/* w w w. j a va 2s .  c  om*/

        // Perform setup operations
        if (log.isDebugEnabled()) {
            log.debug("Processing command line options");
        }
        Map options = options(args);
        String dtd = (String) options.get("--dtd");
        if (log.isDebugEnabled()) {
            log.debug("Configuring digester instance with public identifiers and DTD '" + dtd + "'");
        }
        StringTokenizer st = new StringTokenizer(dtd, "|");
        int arrayLen = st.countTokens();
        if (arrayLen == 0) {
            // PENDING I18n
            throw new Exception("No DTDs specified");
        }
        String[] dtds = new String[arrayLen];
        int i = 0;
        while (st.hasMoreTokens()) {
            dtds[i] = st.nextToken();
            i++;
        }

        copyright((String) options.get("--copyright"));
        directories((String) options.get("--dir"));
        Digester digester = digester(dtds, false, true, false);
        String config = (String) options.get("--config");
        if (log.isDebugEnabled()) {
            log.debug("Parsing configuration file '" + config + "'");
        }
        digester.push(new FacesConfigBean());
        fcb = parse(digester, config);
        if (log.isInfoEnabled()) {
            log.info("Generating HTML component classes");
        }

        // Generate concrete HTML component classes
        ComponentBean cbs[] = fcb.getComponents();
        for (i = 0; i < cbs.length; i++) {
            String componentClass = cbs[i].getComponentClass();
            if (componentClass.startsWith("javax.faces.component.html.")) {
                cb = cbs[i];
                generate();
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
    System.exit(0);

}

From source file:org.eclipseplugins.impexeditor.http.ImpexHttpClient.java

public static void main(final String[] args) throws Exception {

    final ImpexHttpClient impexHttpClient = new ImpexHttpClient("http://localhost:9001/hac");
    final long startTime = System.currentTimeMillis();
    final Map<String, JsonArray> allatypes = new HashMap<String, JsonArray>();
    for (final JsonValue type : impexHttpClient.getAllTypes()) {
        allatypes.put(type.asString(),/*from w  w w.j  a v a 2  s  .co  m*/
                impexHttpClient.getTypeandAttribute(type.asString()).get("attributes").asArray());
    }
    for (final String type : allatypes.keySet()) {
        System.out.println("type :" + type);
        for (final JsonValue string : allatypes.get(type)) {
            System.out.println("---- " + string.asString());
        }
    }
    final long stopTime = System.currentTimeMillis();
    final long elapsedTime = stopTime - startTime;
    System.out.println("Success elapsed time in seconde " + TimeUnit.MILLISECONDS.toSeconds(elapsedTime));
}

From source file:com.px100systems.data.utility.RestoreUtility.java

public static void main(String[] args) {
    if (args.length < 3) {
        System.err.println("Usage: java -cp ... com.px100systems.data.utility.RestoreUtility "
                + "<springXmlConfigFile> <persisterBeanName> <backupDirectory> [compare]");
        return;/*w w  w.j a  va  2 s .  c o  m*/
    }

    FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext("file:" + args[0]);
    try {
        PersistenceProvider persister = ctx.getBean(args[1], PersistenceProvider.class);

        File directory = new File(args[2]);
        if (!directory.isDirectory()) {
            System.err.println(directory.getName() + " is not a directory");
            return;
        }

        List<File> files = new ArrayList<File>();
        //noinspection ConstantConditions
        for (File file : directory.listFiles())
            if (BackupFile.isBackup(file))
                files.add(file);

        if (files.isEmpty()) {
            System.err.println(directory.getName() + " directory has no backup files");
            return;
        }

        if (args.length == 4 && args[3].equalsIgnoreCase("compare")) {
            final Map<String, Map<Long, RawRecord>> units = new HashMap<String, Map<Long, RawRecord>>();

            for (String storage : persister.storage()) {
                System.out.println("Storage " + storage);
                persister.loadByStorage(storage, new PersistenceProvider.LoadCallback() {
                    @Override
                    public void process(RawRecord record) {
                        Map<Long, RawRecord> unitList = units.get(record.getUnitName());
                        if (unitList == null) {
                            unitList = new HashMap<Long, RawRecord>();
                            units.put(record.getUnitName(), unitList);
                        }
                        unitList.put(record.getId(), record);
                    }
                });

                for (final Map.Entry<String, Map<Long, RawRecord>> unit : units.entrySet()) {
                    BackupFile file = null;
                    for (int i = 0, n = files.size(); i < n; i++)
                        if (BackupFile.isBackup(files.get(i), unit.getKey())) {
                            file = new BackupFile(files.get(i));
                            files.remove(i);
                            break;
                        }

                    if (file == null)
                        throw new RuntimeException("Could not find backup file for unit " + unit.getKey());

                    final Long[] count = new Long[] { 0L };
                    file.read(new PersistenceProvider.LoadCallback() {
                        @Override
                        public void process(RawRecord record) {
                            RawRecord r = unit.getValue().get(record.getId());
                            if (r == null)
                                throw new RuntimeException("Could not find persisted record " + record.getId()
                                        + " for unit " + unit.getKey());
                            if (!r.equals(record))
                                throw new RuntimeException(
                                        "Record " + record.getId() + " mismatch for unit " + unit.getKey());
                            count[0] = count[0] + 1;
                        }
                    });

                    if (count[0] != unit.getValue().size())
                        throw new RuntimeException("Extra persisted records for unit " + unit.getKey());
                    System.out.println("   Unit " + unit.getKey() + ": OK");
                }

                units.clear();
            }

            if (!files.isEmpty()) {
                System.err.println("Extra backups: ");
                for (File file : files)
                    System.err.println("   " + file.getName());
            }
        } else {
            persister.init();
            for (File file : files) {
                InMemoryDatabase.readBackupFile(file, persister);
                System.out.println("Loaded " + file.getName());
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        ctx.close();
    }
}