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.rackspacecloud.blueflood.tools.ops.RollupTool.java

public static void main(String args[]) {
    Map<String, Object> options = parseOptions(args);
    Locator locator = Locator.createLocatorFromPathComponents((String) options.get(TENANT_ID),
            (String) options.get(METRIC));
    Long from = (Long) options.get(FROM);
    Long to = (Long) options.get(TO);

    if (from >= to) {
        System.err.println("End time " + to + " has to be greater than start time " + from);
        System.exit(2);/*  w w w  .  j a  va  2 s .com*/
    }

    rerollData(locator, new Range(from, to));
}

From source file:com.laex.cg2d.render.MyGdxGameDesktop.java

/**
 * The main method./*www.j av  a  2  s. c  o m*/
 * 
 * @param args
 *          the arguments
 * @throws ParseException
 *           the parse exception
 */
public static void main(String[] args) throws ParseException {
    Options options = construct();

    Map<String, Object> prefs = parse(options, args);
    String screenFile = (String) prefs.get(PreferenceConstants.SCREEN_FILE);
    String screenControllerFile = (String) prefs.get(PreferenceConstants.SCREEN_CONTROLLER);

    InputStream is;
    CGScreenModel model = null;

    try {
        is = new FileInputStream(screenFile);
        model = CGScreenModel.parseFrom(is);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return;
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }

    int cardWidth = model.getScreenPrefs().getCardPrefs().getCardWidth();
    int cardHeight = model.getScreenPrefs().getCardPrefs().getCardHeight();

    LwjglApplicationConfiguration lwapp = new LwjglApplicationConfiguration();
    lwapp.width = cardWidth;
    lwapp.height = cardHeight;
    // lwapp.title = screenFile;
    lwapp.forceExit = false;

    final CGScreenModel modelMain = model;
    MyGdxGame mgd = new MyGdxGame(screenControllerFile) {
        @Override
        public CGScreenModel loadGameModel() {
            return modelMain;
        }
    };

    // new JoglApplication(mgd, jac);
    lapp = new LwjglApplication(mgd, lwapp);
}

From source file:au.edu.uws.eresearch.cr8it.Main.java

/**
 * Load the Spring Integration Application Context
 *
 * @param args - command line arguments//  w w  w  .ja v  a2  s .  c om
 */
public static void main(final String... args) {

    String contextFilePath = "spring-integration-context.xml";
    String configFilePath = "config/config-file.groovy";
    String environment = System.getProperty("environment");

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("\n========================================================="
                + "\n                                                         "
                + "\n          Welcome to C8it Integration!                 "
                + "\n                                                         "
                + "\n    For more information please visit:                   "
                + "\n    http://www.springsource.org/spring-integration       "
                + "\n                                                         "
                + "\n=========================================================");
    }

    ConfigObject config = Config.getConfig(environment, configFilePath);
    Map configMap = config.flatten();
    System.setProperty("environment", environment);
    System.setProperty("cr8it.client.config.file", (String) configMap.get("file.runtimePath"));

    //final AbstractApplicationContext context =
    //new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml");

    String absContextPath = "config/integration/" + contextFilePath;
    File contextFile = new File(absContextPath);
    final AbstractApplicationContext context;
    if (!contextFile.exists()) {
        absContextPath = "classpath:" + absContextPath;
        context = new ClassPathXmlApplicationContext(absContextPath);
    } else {
        absContextPath = "file:" + absContextPath;
        context = new FileSystemXmlApplicationContext(absContextPath);
    }

    context.registerShutdownHook();

    SpringIntegrationUtils.displayDirectories(context);

    final Scanner scanner = new Scanner(System.in);

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("\n========================================================="
                + "\n                                                         "
                + "\n    Please press 'q + Enter' to quit the application.    "
                + "\n                                                         "
                + "\n=========================================================");
    }

    while (!scanner.hasNext("q")) {
        //Do nothing unless user presses 'q' to quit.
    }

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Exiting application...bye.");
    }

    System.exit(0);

}

From source file:com.rackspacecloud.blueflood.tools.ops.GetPoints.java

public static void main(String args[]) {
    Map<String, Object> options = parseOptions(args);

    Locator locator = Locator.createLocatorFromPathComponents((String) options.get(TENANT_ID),
            (String) options.get(METRIC));

    AstyanaxReader reader = AstyanaxReader.getInstance();

    Long from = (Long) options.get(FROM);
    Long to = (Long) options.get(TO);

    if (from == null || to == null) {
        System.out.println("Either start time or end time is null.");
        to = System.currentTimeMillis();
        from = to - DEFAULT_RANGE.toMillis();
        System.out.println("Using range: " + from + " - " + to);
    }//from  w w w  . j  a  v a2s. c  o  m

    if (from >= to) {
        System.err.println("End time " + to + " has to be greater than start time " + from);
        System.exit(2);
    }

    Granularity gran = Granularity.FULL;
    String res = (String) options.get("resolution");
    try {
        gran = Granularity.fromString(res.toLowerCase());
    } catch (Exception ex) {
        System.out.println("Exception mapping resolution to Granularity. Using FULL resolution instead.");
        gran = Granularity.FULL;
    } finally {
        if (gran == null) {
            gran = Granularity.FULL;
        }
    }

    System.out.println(
            "Locator: " + locator + ", from: " + from + ", to: " + to + ", resolution: " + gran.shortName());

    MetricData data = reader.getDatapointsForRange(locator, new Range(from, to), gran);
    Map<Long, Points.Point> points = data.getData().getPoints();
    for (Map.Entry<Long, Points.Point> item : points.entrySet()) {
        String output = String.format("Timestamp: %d, Data: %s, Unit: %s", item.getKey(),
                item.getValue().getData().toString(), data.getUnit());
        System.out.println(output);
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map<Integer, String> map = new HashMap<>();

    for (int i = 0; i < 10; i++) {
        map.putIfAbsent(i, "val" + i);
    }/*from  w  ww.  jav  a  2 s.c o  m*/

    map.forEach((id, val) -> System.out.println(val));

    map.computeIfPresent(3, (num, val) -> val + num);
    System.out.println(map.get(3)); // val33

    map.computeIfPresent(9, (num, val) -> null);
    System.out.println(map.containsKey(9)); // false

    map.computeIfAbsent(23, num -> "val" + num);
    System.out.println(map.containsKey(23)); // true

    map.computeIfAbsent(3, num -> "bam");
    System.out.println(map.get(3)); // val33
}

From source file:Main.java

public static void main(String[] args) {
    Map<Character, Integer> map = new TreeMap<>();

    String blah = "aaaabbbbddd";

    for (int i = 0; i < blah.length(); i++) {
        char c = blah.charAt(i);
        if (!map.containsKey(c)) {
            map.put(c, 1);//from   ww  w.  j  a v a 2 s. c om
        } else {
            map.put(c, (map.get(c) + 1));
        }
    }

    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
        System.out.print(entry.getKey() + "" + entry.getValue());
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map<Integer, String> map = new HashMap<>();

    for (int i = 0; i < 10; i++) {
        map.putIfAbsent(i, "val" + i);
    }//from   ww  w .  j  a  v  a  2s  . c  om

    map.forEach((id, val) -> System.out.println(val));

    map.merge(9, "val9", (value, newValue) -> value.concat(newValue));
    System.out.println(map.get(9)); // val9

    map.merge(9, "concat", (value, newValue) -> value.concat(newValue));
    System.out.println(map.get(9)); // val9concat
}

From source file:com.act.biointerpretation.metadata.Genus.java

public static void main(String[] args) throws Exception {
    Map<String, Genus> nameToGenus = Genus.parseGenuses();
    for (String name : nameToGenus.keySet()) {
        Genus genus = nameToGenus.get(name);
        if (genus == null) {
            System.err.println("Null genus");
            continue;
        }/*www .ja v  a  2  s . com*/

        if (genus.Kingdom == null) {
            System.err.println("Null Kingdom " + name);
        }

        if (genus.Domain == null) {
            System.err.println("Null Domain " + name);
        }

        if (genus.Phylum == null) {
            System.err.println("Null Phylum " + name);
        }
    }
    System.out.println("done");
}

From source file:edu.gslis.ts.RunQuery.java

public static void main(String[] args) {
    try {//from w  ww  .  ja  v  a2  s .  co m
        // Get the commandline options
        Options options = createOptions();
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(options, args);

        String inputPath = cmd.getOptionValue("input");
        String eventsPath = cmd.getOptionValue("events");
        String stopPath = cmd.getOptionValue("stop");
        int queryId = Integer.valueOf(cmd.getOptionValue("query"));

        List<String> ids = FileUtils.readLines(new File(inputPath + File.separator + "ids.txt"));

        Stopper stopper = new Stopper(stopPath);
        Map<Integer, FeatureVector> queries = readEvents(eventsPath, stopper);

        FeatureVector query = queries.get(queryId);

        Pairtree ptree = new Pairtree();
        Bag<String> words = new HashBag<String>();

        for (String streamId : ids) {

            String ppath = ptree.mapToPPath(streamId.replace("-", ""));

            String inpath = inputPath + File.separator + ppath + File.separator + streamId + ".xz";
            //                System.out.println(inpath);
            File infile = new File(inpath);
            InputStream in = new XZInputStream(new FileInputStream(infile));

            TTransport inTransport = new TIOStreamTransport(new BufferedInputStream(in));
            TBinaryProtocol inProtocol = new TBinaryProtocol(inTransport);
            inTransport.open();
            final StreamItem item = new StreamItem();

            while (true) {
                try {
                    item.read(inProtocol);
                    //                        System.out.println("Read " + item.stream_id);

                } catch (TTransportException tte) {
                    // END_OF_FILE is used to indicate EOF and is not an exception.
                    if (tte.getType() != TTransportException.END_OF_FILE)
                        tte.printStackTrace();
                    break;
                }
            }

            // Do something with this document...
            String docText = item.getBody().getClean_visible();

            StringTokenizer itr = new StringTokenizer(docText);
            while (itr.hasMoreTokens()) {
                words.add(itr.nextToken());
            }

            inTransport.close();

        }

        for (String term : words.uniqueSet()) {
            System.out.println(term + ":" + words.getCount(term));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.alibaba.otter.manager.web.home.module.screen.CheckDelayStat.java

public static void main(String[] args) {
    Map<Long, Long> alertMap = parseAlert("20-1000000, 30-20000");

    for (Long pipelineId : alertMap.keySet()) {
        System.out.println(pipelineId + " : " + alertMap.get(pipelineId));
    }//from ww  w. jav a  2 s  . co  m
}