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:Main.java

/**
 * @author TheMrMilchmann/*from  www  .  j  av a  2  s .  c  o m*/
 * @since DerpieLang v1.0.0
 */
@SuppressWarnings("unchecked")
public static final <K, V, OK> HashMap<K, V> transform(Map<OK, ?> toTransform) throws IllegalArgumentException {
    HashMap<K, V> map = new HashMap<K, V>();

    try {
        for (Object key : toTransform.keySet()) {
            map.put((K) key, (V) toTransform.get((OK) key));
        }

        return map;
    } catch (Throwable t) {
        throw new IllegalArgumentException(t);
    }
}

From source file:Main.java

/**
 * Parses the attributes of a node.//w w w.  j  a  va 2s  .com
 * 
 * @param parser
 *            the parser.
 * @return a hashtable containing the attributes.
 */
public static HashMap<String, String> parseAttributes(XmlPullParser parser) {
    int attributeCount = parser.getAttributeCount();
    HashMap<String, String> attributes = new HashMap<>(attributeCount);
    for (int i = -1; ++i < attributeCount;) {
        attributes.put(parser.getAttributeName(i), parser.getAttributeValue(i));
    }
    return attributes;
}

From source file:Main.java

public static HashMap tallyPrint(String phrase) {
    int count = 0;
    HashMap<Character, Integer> fav = new HashMap<Character, Integer>();
    for (int i = 0; i < phrase.length(); i++) {
        if (fav.containsKey(phrase.charAt(i)))
            fav.put(phrase.charAt(i), (fav.get(phrase.charAt(i))) + 1);
        else// w  w  w  .j a  v  a2s. c o  m
            fav.put(phrase.charAt(i), 1);
    }
    return fav;
}

From source file:Main.java

public static <K, V> HashMap<K, V> createHashMap(Object... args) {
    if (args == null || args.length < 2) {
        return new HashMap<K, V>();
    }/*from ww w .  ja va  2s. co  m*/
    HashMap<K, V> m = new HashMap<K, V>();
    for (int i = 0; i < args.length; i = i + 2) {
        m.put((K) args[i], (V) args[i + 1]);
    }
    return m;
}

From source file:LogToFile.java

public static void LogToFile(String log) {
    try {/*  w  w  w. j a  va 2  s  . co  m*/
        HashMap<String, String> params = new HashMap<String, String>();
        params.put(LOG_TO_FILE_LOG_PARAMETER, log);
        HttpPost request = Post(
                String.format("%s:%d%s", LOG_TO_FILE_ADDRESS, LOG_TO_FILE_PORT, LOG_TO_FILE_URL), params, null);
        HttpResponse response = ExecuteRequest(request);
        response.getEntity().consumeContent();
    } catch (Exception e) {
        Log.e("", e.getClass().getName() + "\n" + e.getMessage());
    }
}

From source file:iudex.da.DataSourceFactory.java

public static DataSource create() {
    DataSourceFactory factory = new DataSourceFactory();
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("dsf.driver.class", "org.postgresql.Driver");
    params.put("dsf.uri", "jdbc:postgresql:iudex_test");
    params.put("user", "iudex");
    params.put("loglevel", "2");
    return factory.create(params);
}

From source file:Main.java

public static <T> void mapKeysToBooleanInHashMap(T[] array, HashMap<T, Boolean> map, boolean boo) {
    int startLength = array.length;
    for (int i = 0; i < startLength; i++) {
        map.put(array[i], boo);
    }/*w  ww .ja  va  2 s  .  c  o  m*/
}

From source file:azkaban.utils.TestUtils.java

public static ExecutableFlow createTestExecutableFlow(final String projectName, final String flowName)
        throws IOException {
    final File jsonFlowFile = ExecutionsTestUtil.getFlowFile(projectName, flowName + ".flow");
    final HashMap<String, Object> flowObj = (HashMap<String, Object>) JSONUtils.parseJSONFromFile(jsonFlowFile);

    final Flow flow = Flow.flowFromObject(flowObj);
    final Project project = new Project(1, "flow");
    final HashMap<String, Flow> flowMap = new HashMap<>();
    flowMap.put(flow.getId(), flow);
    project.setFlows(flowMap);/*from  www  . j av a  2 s  . c om*/
    final ExecutableFlow execFlow = new ExecutableFlow(project, flow);

    return execFlow;
}

From source file:de.adorsys.multibanking.hbci.model.HbciDialogFactory.java

private static HbciPassport createPassport(String hbciVersion, String bankCode, String customerId, String login,
        HBCIProduct hbciProduct, HbciCallback callback) {
    HashMap<String, String> properties = new HashMap<>();
    properties.put("kernel.rewriter", "InvalidSegment,WrongStatusSegOrder,WrongSequenceNumbers,MissingMsgRef,"
            + "HBCIVersion,SigIdLeadingZero,InvalidSuppHBCIVersion,SecTypeTAN,KUmsDelimiters,KUmsEmptyBDateSets");
    properties.put("log.loglevel.default", "2");
    properties.put("default.hbciversion", "FinTS3");
    properties.put("client.passport.PinTan.checkcert", "1");
    properties.put("client.passport.PinTan.init", "1");
    properties.put("client.errors.ignoreJobNotSupported", "yes");

    properties.put("client.passport.country", "DE");
    properties.put("client.passport.blz", bankCode);
    properties.put("client.passport.customerId", customerId);
    properties.put("client.errors.ignoreCryptErrors", "yes");

    if (StringUtils.isNotBlank(login)) {
        properties.put("client.passport.userId", login);
    }//  w  ww  .  j a  v  a  2s . c  o m

    return new HbciPassport(hbciVersion, properties, callback, hbciProduct);
}

From source file:Main.java

private static HashMap<Integer, HashMap<Integer, Integer>> createFullAvailableTime() {
    HashMap<Integer, HashMap<Integer, Integer>> availableTime = new HashMap<Integer, HashMap<Integer, Integer>>();
    for (int hour = 0; hour < 24; hour++) {
        HashMap<Integer, Integer> minutes = new HashMap<Integer, Integer>(60);
        for (int minute = 0; minute < 60; minute++) {
            minutes.put(minute, minute);
        }//from   ww w .j  a  v a2 s .co m

        availableTime.put(hour, minutes);
    }
    return availableTime;
}