Example usage for java.util Map put

List of usage examples for java.util Map put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:net.itransformers.topologyviewer.fulfilmentfactory.impl.TestFulfilmentImpl.java

public static void main(String[] args) throws IOException {
    TelnetCLIInterface cli1 = new TelnetCLIInterface("10.10.10.10", "user", "pass!", "hostname#", 1000,
            Logger.getAnonymousLogger());
    cli1.open();/*from  w w  w. ja v a 2s  . c  om*/
    TestFulfilmentImpl ful = new TestFulfilmentImpl(cli1);
    Map<String, String> params = new HashMap<String, String>();
    params.put("username", "user");
    params.put("password", "pass!");
    params.put("site", "hostname");
    ful.execute("fulfilment-factory/conf/txt/configureInterface.txt", params);
    cli1.close();
}

From source file:es.uam.eps.ir.ranksys.examples.RerankerExample.java

public static void main(String[] args) throws Exception {
    String trainDataPath = args[0];
    String featurePath = args[1];
    String recIn = args[2];//w ww.j a va  2  s.c o  m

    int cutoff = 100;
    PreferenceData<Long, Long> trainData = SimplePreferenceData
            .load(SimpleRatingPreferencesReader.get().read(trainDataPath, lp, lp));
    FeatureData<Long, String, Double> featureData = SimpleFeatureData
            .load(SimpleFeaturesReader.get().read(featurePath, lp, sp));

    Map<String, Supplier<Reranker<Long, Long>>> rerankersMap = new HashMap<>();

    rerankersMap.put("MMR", () -> {
        double lambda = 0.5;
        ItemDistanceModel<Long> dist = new JaccardFeatureItemDistanceModel<>(featureData);
        return new MMR<>(lambda, cutoff, dist);
    });

    rerankersMap.put("xQuAD", () -> {
        double lambda = 0.5;
        IntentModel<Long, Long, String> intentModel = new FeatureIntentModel<>(trainData, featureData);
        AspectModel<Long, Long, String> aspectModel = new ScoresAspectModel<>(intentModel);
        return new XQuAD<>(aspectModel, lambda, cutoff, true);
    });

    rerankersMap.put("RxQuAD", () -> {
        double alpha = 0.5;
        double lambda = 0.5;
        IntentModel<Long, Long, String> intentModel = new FeatureIntentModel<>(trainData, featureData);
        AspectModel<Long, Long, String> aspectModel = new ScoresRelevanceAspectModel<>(intentModel);
        return new AlphaXQuAD<>(aspectModel, alpha, lambda, cutoff, true);
    });

    rerankersMap.put("PM", () -> {
        double alpha = 0.5;
        double lambda = 0.9;
        BinomialModel<Long, Long, String> binomialModel = new BinomialModel<>(false, Stream.empty(), trainData,
                featureData, alpha);
        return new PM<>(featureData, binomialModel, lambda, cutoff);
    });

    RecommendationFormat<Long, Long> format = new SimpleRecommendationFormat<>(lp, lp);

    rerankersMap.forEach(Unchecked.biConsumer((name, rerankerSupplier) -> {
        String recOut = Paths.get(Paths.get(recIn).getParent().toString(),
                String.format("%s-%s", name, FilenameUtils.getName(recIn))).toString();
        System.out.printf("running %s, output to %s\n", name, recOut);
        Reranker<Long, Long> reranker = rerankerSupplier.get();
        try (RecommendationFormat.Writer<Long, Long> writer = format.getWriter(recOut)) {
            format.getReader(recIn).readAll().map(rec -> reranker.rerankRecommendation(rec, cutoff))
                    .forEach(Unchecked.consumer(writer::write));
        }
    }));
}

From source file:InsertCustomType2_Oracle.java

public static void main(String[] args) {
    String id = "001";
    String isbn = "1234567890";
    String title = "Java Oracle";
    String author = "java2s";
    int edition = 1;

    // create the Book object
    Book book = new Book(isbn, title, author, edition);
    book.print();/*from   ww w. j  av a2 s  .co  m*/

    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
        conn = getConnection();
        // create type map
        java.util.Map map = conn.getTypeMap();
        System.out.println("map=" + map);
        map.put("BOOK", Class.forName("Book"));
        System.out.println("map=" + map);

        String insert = "insert into book_table(ID, BOOK) values(?, ?)";
        pstmt = conn.prepareStatement(insert);
        pstmt.setString(1, id);
        pstmt.setObject(2, book);
        pstmt.executeUpdate();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        try {
            pstmt.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.hillert.botanic.MainApp.java

/**
 * Main class initializes the Spring Application Context and populates seed
 * data using {@link SeedDataService}.//www .  j av  a2s. com
 *
 * @param args Not used.
 */
public static void main(String[] args) {
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("redisPort", SocketUtils.findAvailableTcpPort());

    SpringApplication app = new SpringApplication(MainApp.class);
    app.setDefaultProperties(props);

    ConfigurableApplicationContext context = app.run(args);

    MapPropertySource propertySource = new MapPropertySource("ports", props);

    context.getEnvironment().getPropertySources().addFirst(propertySource);

    SeedDataService seedDataService = context.getBean(SeedDataService.class);
    seedDataService.populateSeedData();
}

From source file:org.apache.streams.elasticsearch.example.ElasticsearchReidentify.java

public static void main(String[] args) {
    LOGGER.info(StreamsConfigurator.config.toString());

    Config reindex = StreamsConfigurator.config.getConfig("reindex");

    Config source = reindex.getConfig("source");
    Config destination = reindex.getConfig("destination");

    ElasticsearchReaderConfiguration elasticsearchSourceConfiguration = ElasticsearchConfigurator
            .detectReaderConfiguration(source);

    ElasticsearchPersistReader elasticsearchPersistReader = new ElasticsearchPersistReader(
            elasticsearchSourceConfiguration);

    ElasticsearchWriterConfiguration elasticsearchDestinationConfiguration = ElasticsearchConfigurator
            .detectWriterConfiguration(destination);

    ElasticsearchPersistWriter elasticsearchPersistWriter = new ElasticsearchPersistWriter(
            elasticsearchDestinationConfiguration);

    Reidentifier reidentifier = new Reidentifier();

    Map<String, Object> streamConfig = Maps.newHashMap();
    streamConfig.put(LocalStreamBuilder.TIMEOUT_KEY, 20 * 60 * 1000);
    StreamBuilder builder = new LocalStreamBuilder(1000, streamConfig);

    builder.newPerpetualStream(ElasticsearchPersistReader.STREAMS_ID, elasticsearchPersistReader);
    builder.addStreamsProcessor(Reidentifier.STREAMS_ID, reidentifier, 2,
            ElasticsearchPersistReader.STREAMS_ID);
    builder.addStreamsPersistWriter(ElasticsearchPersistWriter.STREAMS_ID, elasticsearchPersistWriter, 1,
            Reidentifier.STREAMS_ID);//from www .j a  v a2  s  .c o  m
    builder.start();

}

From source file:com.jkoolcloud.tnt4j.streams.sample.builder.SampleStreamingApp.java

/**
 * Main entry point for running as a standalone application.
 *
 * @param args//www.  ja v  a  2s  . c o  m
 *            program command-line arguments. Supported arguments:
 *            <table summary="TNT4J-Streams agent command line arguments">
 *            <tr>
 *            <td>&nbsp;&nbsp;</td>
 *            <td>&nbsp;&lt;orders_log_file_path&gt;</td>
 *            <td>(optional) path of "orders.log" file. Default value is working dir.</td>
 *            </tr>
 *            </table>
 * @throws Exception
 *             if any exception occurs while running application
 */
public static void main(String... args) throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put(ParserProperties.PROP_FLD_DELIM, "|"); // NON-NLS

    ActivityTokenParser atp = new ActivityTokenParser();
    atp.setName("TokenParser"); // NON-NLS
    atp.setProperties(props.entrySet());

    ActivityField f = new ActivityField(StreamFieldType.StartTime.name());
    ActivityFieldLocator afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "1");
    afl.setFormat("dd MMM yyyy HH:mm:ss", "en-US"); // NON-NLS
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.ServerIp.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "2");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.ApplName.name());
    afl = new ActivityFieldLocator("orders"); // NON-NLS
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.Correlator.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "3");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.UserName.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "4");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.EventName.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "5");
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField(StreamFieldType.EventType.name());
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "5");
    afl.addValueMap("Order Placed", "START").addValueMap("Order Received", "RECEIVE") // NON-NLS
            .addValueMap("Order Processing", "OPEN").addValueMap("Order Processed", "SEND") // NON-NLS
            .addValueMap("Order Shipped", "END"); // NON-NLS
    f.addLocator(afl);
    atp.addField(f);

    f = new ActivityField("MsgValue"); // NON-NLS
    afl = new ActivityFieldLocator(ActivityFieldLocatorType.Index, "8");
    f.addLocator(afl);
    atp.addField(f);

    props = new HashMap<>();
    props.put(StreamProperties.PROP_FILENAME, ArrayUtils.isEmpty(args) ? "orders.log" : args[0]); // NON-NLS

    FileLineStream fls = new FileLineStream();
    fls.setName("FileStream"); // NON-NLS
    fls.setProperties(props.entrySet());
    fls.addParser(atp);
    // if (fls.getOutput() == null) {
    // fls.setDefaultStreamOutput();
    // }

    StreamsAgent.runFromAPI(fls);
}

From source file:org.apache.streams.elasticsearch.example.ElasticsearchReserialize.java

public static void main(String[] args) {
    LOGGER.info(StreamsConfigurator.config.toString());

    Config reindex = StreamsConfigurator.config.getConfig("reindex");

    Config source = reindex.getConfig("source");
    Config destination = reindex.getConfig("destination");

    ElasticsearchReaderConfiguration elasticsearchSourceConfiguration = ElasticsearchConfigurator
            .detectReaderConfiguration(source);

    ElasticsearchPersistReader elasticsearchPersistReader = new ElasticsearchPersistReader(
            elasticsearchSourceConfiguration);

    ElasticsearchWriterConfiguration elasticsearchDestinationConfiguration = ElasticsearchConfigurator
            .detectWriterConfiguration(destination);

    ElasticsearchPersistWriter elasticsearchPersistWriter = new ElasticsearchPersistWriter(
            elasticsearchDestinationConfiguration);

    Reserializer reserializer = new Reserializer();

    Map<String, Object> streamConfig = Maps.newHashMap();
    streamConfig.put(LocalStreamBuilder.TIMEOUT_KEY, 20 * 60 * 1000);
    StreamBuilder builder = new LocalStreamBuilder(1000, streamConfig);

    builder.newPerpetualStream(ElasticsearchPersistReader.STREAMS_ID, elasticsearchPersistReader);
    builder.addStreamsProcessor(Reserializer.STREAMS_ID, reserializer, 2,
            ElasticsearchPersistReader.STREAMS_ID);
    builder.addStreamsPersistWriter(ElasticsearchPersistWriter.STREAMS_ID, elasticsearchPersistWriter, 1,
            Reserializer.STREAMS_ID);/*from  w  w  w .  j a va2s . c om*/
    builder.start();

}

From source file:com.roncoo.pay.permission.utils.EncryptUtil.java

public static void main(String[] args) {
    String loginName = "513781560@qq.com";
    Long timeStamp = System.currentTimeMillis();
    String key = "rcPayLoginSign268";
    String sign = RonCooSignUtil.getSign(key, timeStamp, loginName);

    String url = "http://192.168.1.181:8080/roncoo-dev-admin/mydata/getByLoginName";
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("userName", loginName);
    params.put("timeStamp", timeStamp);
    params.put("sign", sign);
    String json = JSON.toJSONString(params);

    String httpResponse = RoncooHttpClientUtils.post(url, json);
    Map<String, Object> parseObject = JSONObject.parseObject(httpResponse, Map.class);
    String code = (String) parseObject.get("code");
    String desc = (String) parseObject.get("desc");
    System.out.println(code);//from  w w w . j av  a2  s  . c  om
    JSONObject data = (JSONObject) parseObject.get("data");

    Map<String, Object> mapInfo = JSONObject.parseObject(data.toJSONString(), Map.class);
    String returnPWD = (String) mapInfo.get("pwd");
    String userId = (String) mapInfo.get("userId");
    System.out.println(httpResponse);
}

From source file:Main.java

public static void main(String[] args) {
    Map<Character, Integer> counting = new HashMap<Character, Integer>();
    String testcase1 = "this is a test";
    for (char ch : testcase1.toCharArray()) {
        Integer freq = counting.get(ch);
        counting.put(ch, (freq == null) ? 1 : freq + 1);
    }/* w  ww.  j ava 2s  .com*/
    System.out.println(counting.size() + " distinct characters:");
    System.out.println(counting);
}

From source file:Counter.java

public static void main(String[] args) {
    Map hm = new HashMap();
    for (int i = 0; i < 10; i++) {
        Integer r = new Integer(20);
        if (hm.containsKey(r))
            ((Counter) hm.get(r)).i++;/*  w  w w.  java  2 s . c  o  m*/
        else
            hm.put(r, new Counter());
    }
    System.out.println(hm);
}