Example usage for java.util HashMap put

List of usage examples for java.util HashMap put

Introduction

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

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:io.syndesis.image.Application.java

private static Map<String, String> map(Object... values) {
    HashMap<String, String> rc = new HashMap<>();
    for (int i = 0; i + 1 < values.length; i += 2) {
        rc.put(values[i].toString(), values[i + 1].toString());
    }//from w  w w  .j  a v  a 2 s.  c o  m
    return rc;
}

From source file:mlbench.pagerank.PagerankMerge.java

private static void initConf(HashMap<String, String> conf) {
    conf.put(MPI_D_Constants.ReservedKeys.KEY_CLASS, org.apache.hadoop.io.IntWritable.class.getName());
    conf.put(MPI_D_Constants.ReservedKeys.VALUE_CLASS, org.apache.hadoop.io.Text.class.getName());

    if (maxUsedMemPercent != null) {
        conf.put(MPI_D_Constants.ReservedKeys.CommonModeKeys.MAX_MEM_USED_PERCENT, maxUsedMemPercent);
    }// w w w.  j  a  v  a 2 s  . co  m
    if (partSize != null) {
        conf.put(MPI_D_Constants.ReservedKeys.CommonModeKeys.BLOCK_SIZE, partSize);
    }
    if (outFileNum != null) {
        conf.put(MPI_D_Constants.ReservedKeys.CommonModeKeys.SEND_QUEUE_LENGTH, outFileNum);
    }
    if (spillPercent != null) {
        conf.put(MPI_D_Constants.ReservedKeys.CommonModeKeys.SPILL_PERCENT, spillPercent);
    }
}

From source file:org.camunda.bpm.elasticsearch.jackson.JacksonMixInFilterModule.java

public static HashMap<Class<? extends HistoryEvent>, Class> getDefaultMixInFilters() {
    HashMap<Class<? extends HistoryEvent>, Class> mixInFilters = new HashMap<Class<? extends HistoryEvent>, Class>();

    mixInFilters.put(HistoryEvent.class, HistoryEventMixIn.class);
    mixInFilters.put(HistoricScopeInstanceEvent.class, HistoricScopeInstanceEventMixIn.class); // introduced with 7.0.x
    mixInFilters.put(HistoricProcessInstanceEventEntity.class, HistoricProcessInstanceEventMixIn.class);
    mixInFilters.put(HistoricTaskInstanceEventEntity.class, HistoricTaskInstanceEventMixIn.class);
    mixInFilters.put(HistoricActivityInstanceEventEntity.class, HistoricActivityInstanceEventMixIn.class);
    mixInFilters.put(HistoricDetailEventEntity.class, HistoricDetailEventMixIn.class);
    mixInFilters.put(HistoricVariableUpdateEventEntity.class, HistoricVariableUpdateEventMixIn.class);
    mixInFilters.put(HistoricFormPropertyEventEntity.class, HistoricFormPropertyEventMixIn.class);

    return mixInFilters;
}

From source file:Main.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <K, V> Map<K, V> listToMap(Object... objects) {
    HashMap map = new HashMap();
    Object key = null;/*from  www .  j av a2s.c  o  m*/
    for (final Object object : objects) {
        if (key == null) {
            key = object;
        } else {
            map.put(key, object);
            key = null;
        }
    }
    return map;
}

From source file:Main.java

@SuppressWarnings({ "rawtypes", "unchecked" })
static HashMap<String, Object> toMap(JSONObject object) throws JSONException {
    if (object == null) {
        return null;
    }//www.  j a  v a 2  s.  c o  m
    HashMap<String, Object> map = new HashMap();
    Iterator keys = object.keys();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        map.put(key, fromJson(object.get(key)));
    }
    return map;
}

From source file:com.ibm.soatf.component.osb.ServiceManager.java

public static JMXConnector initConnection(String hostName, int port, String userName, String password)
        throws MalformedURLException, IOException {

    JMXServiceURL serviceUrl = new JMXServiceURL(DEFAULT_PROTO, hostName, port,
            JNDI_PREFIX + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME);
    HashMap<String, String> h = new HashMap<String, String>();
    h.put(Context.SECURITY_PRINCIPAL, userName);
    h.put(Context.SECURITY_CREDENTIALS, password);
    h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, DEFAULT_PROTO_PROVIDER_PACKAGES);
    return JMXConnectorFactory.connect(serviceUrl, h);

}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> map(Object... objects) {
    HashMap map = new HashMap();
    Object key = null;// w w w . j av  a 2  s. c o  m
    for (final Object object : objects) {
        if (key == null) {
            key = object;
        } else {
            map.put(key, object);
            key = null;
        }
    }
    return map;
}

From source file:de.tudarmstadt.ukp.dkpro.tc.weka.evaluation.MekaEvaluationUtils.java

/**
 * Calculates a number of evaluation measures for multi-label classification, without class-wise measures.
 * /*from w w  w.  j a  va 2 s .c o  m*/
 * @param predictions
 *            predictions by the classifier (ranking)
 * @param goldStandard
 *            gold standard (bipartition)
 * @param t
 *            a threshold to create bipartitions from rankings
 * @return the evaluation statistics
 */
public static HashMap<String, Double> calcMLStats(double predictions[][], int goldStandard[][], double t[]) {
    int N = goldStandard.length;
    int L = goldStandard[0].length;
    int Ypred[][] = ThresholdUtils.threshold(predictions, t);

    HashMap<String, Double> results = new LinkedHashMap<String, Double>();
    Mean mean = new Mean();

    results.put(NUMBER_LABELS, (double) L);
    results.put(NUMBER_EXAMPLES, (double) N);
    results.put(ZERO_ONE_LOSS, Metrics.L_ZeroOne(goldStandard, Ypred));
    results.put(LABEL_CARDINALITY_PRED, MLUtils.labelCardinality(Ypred));
    results.put(LABEL_CARDINALITY_REAL, MLUtils.labelCardinality(goldStandard));
    results.put(AVERAGE_THRESHOLD, mean.evaluate(t, 0, t.length)); // average
    results.put(EMPTY_VECTORS, MLUtils.emptyVectors(Ypred));

    return results;
}

From source file:Main.java

public static void incrementHashMap(HashMap map, String key, int n) {
    int count;//from w  ww .  ja  va  2 s . c  o  m
    Integer countI = (Integer) map.get(key);
    if (countI == null)
        count = 0;
    else {
        count = countI;
    }
    map.put(key, count + n);
}

From source file:Main.java

/**
 * Breaks key=value&key=value string to map
 *
 * @param queryString string to explode//w  w w .  ja v a  2 s.c o m
 * @return Key-value map of passed string
 */
public static Map<String, String> explodeQueryString(String queryString) {
    String[] keyValuePairs = queryString.split("&");
    HashMap<String, String> parameters = new HashMap<>(keyValuePairs.length);

    for (String keyValueString : keyValuePairs) {
        String[] keyValueArray = keyValueString.split("=");
        parameters.put(keyValueArray[0], keyValueArray[1]);
    }
    return parameters;
}