Example usage for java.util Map putAll

List of usage examples for java.util Map putAll

Introduction

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

Prototype

void putAll(Map<? extends K, ? extends V> m);

Source Link

Document

Copies all of the mappings from the specified map to this map (optional operation).

Usage

From source file:Main.java

public static void main(String[] args) {
    Map<String, String> oldMap = new HashMap<String, String>();
    oldMap.put("a", "1");
    oldMap.put("A", "2");

    Map<String, String> newMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    newMap.putAll(oldMap);
    String value = newMap.get("a");
    System.out.println(value);//w  w  w.j  a  va2s  . co  m
}

From source file:org.fusesource.cloudmix.tests.consumer.Main.java

public static void main(String[] args) {
    if (args.length > 0 && args[0].equals("-debug")) {
        Map<Object, Object> properties = new TreeMap<Object, Object>();
        properties.putAll(System.getProperties());
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            System.out.println(" " + entry.getKey() + " = " + entry.getValue());
        }//from  w w w . j  ava2s. com
    }

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "META-INF/spring/context.xml");
    applicationContext.start();

    System.out.println("Enter quit to stop");

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.trim().equalsIgnoreCase("quit")) {
                break;
            }
        }
    } catch (IOException e) {
        System.err.println("Caught: " + e);
        e.printStackTrace(System.err);
    }

    applicationContext.close();
}

From source file:org.fusesource.cloudmix.tests.broker.Main.java

public static void main(String[] args) {
    if (verbose || (args.length > 0 && args[0].equals("-debug"))) {
        Map<Object, Object> properties = new TreeMap<Object, Object>();
        properties.putAll(System.getProperties());
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            System.out.println(" " + entry.getKey() + " = " + entry.getValue());
        }//ww w. j av  a2s .co  m
    }

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "META-INF/spring/activemq.xml");
    applicationContext.start();

    System.out.println("Enter quit to stop");

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.trim().equalsIgnoreCase("quit")) {
                break;
            }
        }
    } catch (IOException e) {
        System.err.println("Caught: " + e);
        e.printStackTrace(System.err);
    }

    applicationContext.close();
}

From source file:edu.hku.sdb.driver.SdbDriver.java

/**
 * @param args//from  w  ww .jav  a 2 s  . c o  m
 */
public static void main(String[] args) {
    CommandLine line = parseAndValidateInput(args);

    String confDir = line.getOptionValue(CONF);
    Properties properties = line.getOptionProperties("D");

    File sdbConnectionConfigFile = new File(confDir + "/" + ConnectionConf.CONF_FILE);
    File sdbServerConfigFile = new File(confDir + "/" + ServerConf.CONF_FILE);
    File sdbMetadbConfigFile = new File(confDir + "/" + MetadbConf.CONF_FILE);

    XMLPropParser propParser = new XMLPropParser();
    // Parse all the sdb connection config
    Map<String, String> prop = propParser.importXML(sdbConnectionConfigFile);
    // Parse all the server config
    prop.putAll(propParser.importXML(sdbServerConfigFile));
    // Parse all the metadb config
    prop.putAll(propParser.importXML(sdbMetadbConfigFile));

    // Override the config if any
    Set<Object> states = properties.keySet(); // get set-view of keys
    for (Object object : states) {
        String key = (String) object;
        String value = properties.getProperty(key);
        prop.put(key, value);
    }

    // Cet log4j config
    PropertyConfigurator.configure(confDir + "/" + "log4j.properties");

    ServerConf serverConf = ServerConfFactory.getServerConf(prop);
    MetadbConf metadbConf = MetadbConfFactory.getMetadbConf(prop);
    ConnectionConf connectionConf = new ConnectionConf(prop);

    SdbConf sdbConf = new SdbConf(connectionConf, serverConf, metadbConf);

    // Start the SDB proxy
    startConnectionPool(sdbConf);
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.put(null, null);//from  w  ww . j a v  a 2s .  co  m

    Map<String, String> map2 = new HashMap<String, String>();
    map2.put("key4", "value4");
    map2.put("key5", "value5");
    map2.put("key6", "value6");
    map.putAll(map2);

    System.out.println(map);
}

From source file:com.yourmediashelf.fedora.cargo.FedoraHome.java

/**
 * Command-line entry point./*from   w w w.  j  a  v a 2 s.c o m*/
 */
public static void main(String[] args) throws Exception {
    InstallOptions opts;
    Map<String, String> props = new HashMap<String, String>();
    for (String file : args) {
        props.putAll(loadMap(new File(file)));
    }
    opts = new InstallOptions(props);
    FedoraHome fh = new FedoraHome(opts);
    fh.install();
}

From source file:com.alibaba.jstorm.hdfs.transaction.RocksDbHdfsState.java

public static void main(String[] args) {
    Map conf = new HashMap<Object, Object>();
    conf.putAll(Utils.loadConf(args[0]));
    RocksDbHdfsState<String, Integer> state = new RocksDbHdfsState<String, Integer>();
    state.setStateName(String.valueOf(1));

    // setup checkpoint
    int batchNum = JStormUtils.parseInt(conf.get("batch.num"), 100);
    state.initEnv("test", conf, "/tmp/rocksdb_test");
    String remoteCpPath = null;// w  ww. j  a  v a2s . com
    for (int i = 0; i < batchNum; i++) {
        state.put(String.valueOf(i % 20), i);
        state.checkpoint(i);
        remoteCpPath = state.backup(i);
        state.remove(i);
    }
    state.cleanup();

    state.initEnv("test", conf, "/tmp/rocksdb_test");
    state.restore(remoteCpPath);
    for (int i = 0; i < 20; i++) {
        Integer value = state.get(String.valueOf(i));
        LOG.info("key={}, value={}", String.valueOf(i), value);
    }
    state.cleanup();
}

From source file:com.joymove.service.impl.JOYUserServiceImpl.java

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

    ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test.xml");
    Map<String, Object> likeCondition = new HashMap<String, Object>();
    JOYUser user = new JOYUser();
    DateFormat formatWithTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    user.registerTime = formatWithTime.parse("2013-04-29 15:08:41");

    JOYUserDao dao = (JOYUserDao) context.getBean("JOYUserDao");
    likeCondition.putAll(user.toMap());
    likeCondition.put("filter", user);
    List<Map<String, Object>> mapList = dao.getPagedRecordList(likeCondition);
    for (int i = 0; i < mapList.size(); i++) {
        JOYUser userObj = new JOYUser();
        user.fromMap(mapList.get(i));//from  w  ww. j  a v a  2  s  . com
        System.out.println(user);
    }

    /*
            
            
    JOYPayHistoryService service = (JOYPayHistoryService)context.getBean("JOYPayHistoryService");
    JOYPayHistory payHistoryNew = new JOYPayHistory();
    payHistoryNew.balance = 0.2;
    payHistoryNew.type = 2;
    service.deleteByProperties(payHistoryNew);
            
            
    /*
    JOYUserService service = (JOYUserService)context.getBean("JOYUserService");
    JOYUser user = new JOYUser();
    user.mobileNo = "18500217642";
    List<Map<String,Object>> mapList = service.getExtendInfoPagedList(" select u.*, m.driverLicenseNumber  from JOY_Users u left join JOY_DriverLicense m on u.mobileNo = m.mobileNo ",user);
            
            
    //   JOYUser user2 = new JOYUser();
    Map<String,Object> t = mapList.get(0);
    Iterator i =t.entrySet().iterator();
    JSONObject tt = new JSONObject();
    while(i.hasNext()) {
            
       Map.Entry<String,Object> haha = (Map.Entry<String,Object>)i.next();
        if(String.valueOf(haha.getValue()).equals("null")) {
    logger.trace(haha.getKey()+" is null");
       }
    }
            
    /*
    user2.username = "?";
    user.mobileNo="18500217642";
    service.updateRecord(user2,user);
    user = service.getNeededRecord(user);
      logger.trace(user);
            
    /*
    JOYOrderService service = (JOYOrderService) context.getBean("JOYOrderService");
    JOYOrder order = new JOYOrder();
    order = service.getNeededRecord(order);
    JOYOrder order2 = new JOYOrder();
    order2.startTime = order.startTime;
    order = new JOYOrder();
    order.startTime = new Date(System.currentTimeMillis());
    service.updateRecord(order,order2);
       /*
    JOYNReserveOrderService  service  = (JOYNReserveOrderService)context.getBean("JOYNReserveOrderService");
    JOYReserveOrder order = new JOYReserveOrder();
    //service.insertRecord(order);
    JOYReserveOrder order2 = new JOYReserveOrder();
    order2.mobileNo = "18500217642";
    order2.startTime = new Date(System.currentTimeMillis());
      service.insertRecord(order2);
    order2.startTime = null;
    order = service.getNeededRecord(order2);
     order.startTime = new Date(System.currentTimeMillis());
    service.updateRecord(order,order2);
      order2.startTime = order.startTime;
    order2.mobileNo = null;
    order = service.getNeededRecord(order2);
    logger.trace(order);
    /*
    order.delFlag = 1;
    order.startTime = new Date(System.currentTimeMillis()+30);
    service.updateRecord(order,order2);
            
    order2.mobileNo = null;
    order2.startTime = order.startTime;
    order = service.getNeededRecord(order2);
    logger.trace(order);
    //service.deleteByProperties(order);
            
            
    /*
    JOYIdAuthInfoService service  = (JOYIdAuthInfoService)context.getBean("JOYIdAuthInfoService");
    JOYIdAuthInfo dl = new JOYIdAuthInfo();
    dl.idAuthInfo = "nihao".getBytes();
    dl.idAuthInfo_back = "Hello world".getBytes();
    JOYIdAuthInfo dl2 = new JOYIdAuthInfo();
    dl2.mobileNo = "15577586649";
    service.updateRecord(dl,dl2);
            
            
    service.getNeededList(dl2,null,null);
            
            
            
    List<JOYIdAuthInfo> dList = service.getNeededList(dl,null,null);
    logger.trace(dList.get(0));
            
    for(int i=0;i<dList.get(0).idAuthInfo.length;i++)
    System.out.format("%c",dList.get(0).idAuthInfo[i]);
    /*
    JOYUser user = new JOYUser();
    JOYUser user1 = new JOYUser();
    user.mobileNo = ("18500217642");
    List<JOYUser> userList =  service.getNeededList(user,0,10);
      logger.trace("sdfdsdsf :"+userList.size());
    JOYUser u = userList.get(0);
    logger.trace(u);
     */
}

From source file:com.act.analysis.similarity.SimilarityAnalysis.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());// w  w  w . j  a  v a  2  s.  c  o m
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        return;
    }

    LicenseManager.setLicenseFile(cl.getOptionValue(OPTION_LICENSE_FILE));

    if (cl.hasOption(OPTION_TARGET_INCHI) && cl.hasOption(OPTION_TARGET_FILE)) {
        System.err.format("Specify only one of -%s or -%s\n", OPTION_TARGET_INCHI, OPTION_TARGET_FILE);
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    List<SimilarityOperator> querySimilarityOperators = new ArrayList<>();
    List<String> header = new ArrayList<>();
    header.add("name");
    header.add("id");
    header.add("inchi");

    if (cl.hasOption(OPTION_QUERY_INCHI) && !cl.hasOption(OPTION_QUERY_FILE)) {
        SimilarityOperator so = makeSimilarityOperators("from inchi", cl.getOptionValue(OPTION_QUERY_INCHI));
        so.init();
        querySimilarityOperators.add(so);
        header.addAll(so.getResultFields());
    } else if (cl.hasOption(OPTION_QUERY_FILE) && !cl.hasOption(OPTION_QUERY_INCHI)) {
        TSVParser parser = new TSVParser();
        parser.parse(new File(cl.getOptionValue(OPTION_QUERY_FILE)));
        for (Map<String, String> row : parser.getResults()) {
            System.out.format("Compiling query for %s, %s\n", row.get("name"), row.get("inchi"));
            SimilarityOperator so = makeSimilarityOperators(row.get("name"), row.get("inchi"));
            so.init();
            querySimilarityOperators.add(so);
            header.addAll(so.getResultFields());
        }
    } else {
        System.err.format("Specify exactly one of -%s or -%s\n", OPTION_QUERY_INCHI, OPTION_QUERY_FILE);
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    List<Map<String, String>> targetChemicals = null;
    if (cl.hasOption(OPTION_TARGET_INCHI) && !cl.hasOption(OPTION_TARGET_FILE)) {
        String inchi = cl.getOptionValue(OPTION_TARGET_INCHI);
        targetChemicals = Collections.singletonList(new HashMap<String, String>() {
            {
                put("name", "direct-input");
                put("id", null);
                put("inchi", inchi);
            }
        });
    } else if (cl.hasOption(OPTION_TARGET_FILE) && !cl.hasOption(OPTION_TARGET_INCHI)) {
        TSVParser parser = new TSVParser();
        parser.parse(new File(cl.getOptionValue(OPTION_TARGET_FILE)));
        targetChemicals = parser.getResults();
    } else {
        System.err.format("Specify exactly one of -%s or -%s\n", OPTION_TARGET_INCHI, OPTION_TARGET_FILE);
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    AlignmentMoleculeFactory alignmentMoleculeFactory = new AlignmentMoleculeFactory();

    // TODO: add symmetric computations for target as query and each query as target.
    TSVWriter<String, String> writer = new TSVWriter<>(header);
    writer.open(new File(cl.getOptionValue(OPTION_OUTPUT_FILE)));
    try {
        for (Map<String, String> row : targetChemicals) {
            Molecule targetMol = MolImporter.importMol(row.get("inchi"));
            Cleaner.clean(targetMol, 3); // This will assign 3D atom coordinates to the MolAtoms in targetMol.
            Molecule targetFragment = findLargestFragment(targetMol.convertToFrags());
            AlignmentMolecule am = alignmentMoleculeFactory.create(targetFragment,
                    AlignmentProperties.DegreeOfFreedomType.TRANSLATE_ROTATE_FLEXIBLE);
            Map<String, String> outputRow = new HashMap<>(row);
            System.out.format("Processing target %s\n", row.get("name"));
            for (SimilarityOperator so : querySimilarityOperators) {
                System.out.format("  running query %s\n", so.getName());
                Map<String, Double> results = so.calculateSimilarity(am);
                outputRow.putAll(doubleMapToStringMap(results));
            }
            writer.append(outputRow);
            writer.flush();
        }
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
    System.out.format("Done\n");
}

From source file:Main.java

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

    atomNums.put("A", 1);
    atomNums.put("B", 2);
    atomNums.put("C", 3);
    atomNums.put("D", 4);
    atomNums.put("E", 5);
    atomNums.put("F", 6);

    System.out.println("The map contains these " + atomNums.size() + " entries:");

    Set<Map.Entry<String, Integer>> set = atomNums.entrySet();

    for (Map.Entry<String, Integer> me : set) {
        System.out.print(me.getKey() + ", Atomic Number: ");
        System.out.println(me.getValue());
    }// w  w w  .  j a  v  a 2  s.c o m
    TreeMap<String, Integer> atomNums2 = new TreeMap<String, Integer>();

    atomNums2.put("Q", 30);
    atomNums2.put("W", 82);

    atomNums.putAll(atomNums2);

    set = atomNums.entrySet();

    System.out.println("The map now contains these " + atomNums.size() + " entries:");
    for (Map.Entry<String, Integer> me : set) {
        System.out.print(me.getKey() + ", Atomic Number: ");
        System.out.println(me.getValue());
    }

    if (atomNums.containsKey("A"))
        System.out.println("A has an atomic number of " + atomNums.get("A"));

    if (atomNums.containsValue(82))
        System.out.println("The atomic number 82 is in the map.");
    System.out.println();

    if (atomNums.remove("A") != null)
        System.out.println("A has been removed.\n");
    else
        System.out.println("Entry not found.\n");

    Set<String> keys = atomNums.keySet();
    for (String str : keys)
        System.out.println(str + " ");

    Collection<Integer> vals = atomNums.values();
    for (Integer n : vals)
        System.out.println(n + " ");

    atomNums.clear();
    if (atomNums.isEmpty())
        System.out.println("The map is now empty.");
}