Example usage for java.util HashMap get

List of usage examples for java.util HashMap get

Introduction

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

Prototype

public 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.symbian.driver.core.processors.EmulatorPreProcessor.java

/**
 * @param lEmulatorHashBackup/*from   ww w . ja va  2 s.  co  m*/
 * 
 * @deprecated This needs to use the emulator ROM tool
 */
public static void restoreEmulator(HashMap<File, File> lEmulatorHashBackup) {
    if (lEmulatorHashBackup != null) {
        for (File lEmulatorOrginal : lEmulatorHashBackup.keySet()) {
            File lEmulatorBackup = lEmulatorHashBackup.get(lEmulatorOrginal);

            if (lEmulatorBackup != null && !lEmulatorBackup.renameTo(lEmulatorOrginal)) {
                LOGGER.fine("Could not restore Emulator backup of: " + lEmulatorBackup.toString() + " to "
                        + lEmulatorOrginal.toString());
            }
        }
    }
}

From source file:es.pode.soporte.auditoria.registrar.Registrar.java

private static void hashMap2Traza(HashMap tabla) {

    for (Iterator it = tabla.keySet().iterator(); it.hasNext();) {
        String s = (String) it.next();
        String s1 = (String) tabla.get(s);
        log.debug("Valores Hash: " + s + " " + s1);
    }//from www. j ava2  s .  co  m
}

From source file:net.triptech.buildulator.model.Person.java

/**
 * Gets the user status.//from w  ww. java 2  s  . c  o  m
 *
 * @param value the value
 * @param context the context
 * @return the user status
 */
public static UserStatus getUserStatus(final String value, final ApplicationContext context) {
    UserStatus pUserStatus = UserStatus.ACTIVE;

    HashMap<String, UserStatus> statuses = new HashMap<String, UserStatus>();

    for (UserStatus status : UserStatus.values()) {
        statuses.put(getMessage(status.getMessageKey(), context), status);
    }
    if (statuses.containsKey(value)) {
        pUserStatus = statuses.get(value);
    }
    return pUserStatus;
}

From source file:org.grameenfoundation.consulteca.utils.HttpHelpers.java

/**
 * Adds our common headers/*from   w  w  w . j a va2s .  c om*/
 */
public static void addCommonHeaders(HttpPost httpPost) {
    HashMap<String, String> commonHeaders = getCommonHeaders();
    Set<String> keys = commonHeaders.keySet();
    for (String key : keys) {
        httpPost.addHeader(key, commonHeaders.get(key));
    }
}

From source file:de.tor.tribes.util.VillageUtils.java

public static Village[] getVillagesByTag(Tag[] pTags, Tribe pTribe, RELATION pRelation, boolean pWithBarbarians,
        Comparator pComparator) {
    if (pTags == null) {
        return new Village[0];
    }//from w ww .ja  v a 2 s .  co  m
    List<Village> villages = new ArrayList<>();
    HashMap<Village, Integer> usageCount = new HashMap<>();
    for (Tag tag : pTags) {
        for (Integer id : tag.getVillageIDs()) {
            Village v = DataHolder.getSingleton().getVillagesById().get(id);
            if (pWithBarbarians || !v.getTribe().equals(Barbarians.getSingleton())) {
                if (pTribe == null || v.getTribe().getId() == pTribe.getId()) {
                    usageCount.put(v, (usageCount.get(v) == null) ? 1 : usageCount.get(v) + 1);
                    if (!villages.contains(v)) {
                        villages.add(v);
                    }
                }
            }
        }
    }
    if (pRelation.equals(RELATION.AND)) {
        //remove villages that are tagges by less tags than tagCount
        int tagAmount = pTags.length;
        for (Entry<Village, Integer> entry : usageCount.entrySet()) {
            if (entry.getValue() == null || entry.getValue() != tagAmount) {
                villages.remove(entry.getKey());
            }
        }
    }

    if (pComparator != null) {
        Collections.sort(villages, pComparator);
    }

    return villages.toArray(new Village[villages.size()]);
}

From source file:com.ibm.bi.dml.runtime.controlprogram.parfor.RemoteParForUtils.java

/**
 * //from   w w  w .  j  av  a 2s. c o  m
 * @param out
 * @return
 * @throws DMLRuntimeException
 * @throws IOException
 */
public static LocalVariableMap[] getResults(List<Tuple2<Long, String>> out, Log LOG)
        throws DMLRuntimeException {
    HashMap<Long, LocalVariableMap> tmp = new HashMap<Long, LocalVariableMap>();

    int countAll = 0;
    for (Tuple2<Long, String> entry : out) {
        Long key = entry._1();
        String val = entry._2();
        if (!tmp.containsKey(key))
            tmp.put(key, new LocalVariableMap());
        Object[] dat = ProgramConverter.parseDataObject(val);
        tmp.get(key).put((String) dat[0], (Data) dat[1]);
        countAll++;
    }

    if (LOG != null) {
        LOG.debug("Num remote worker results (before deduplication): " + countAll);
        LOG.debug("Num remote worker results: " + tmp.size());
    }

    //create return array
    return tmp.values().toArray(new LocalVariableMap[0]);
}

From source file:com.opengamma.analytics.financial.interestrate.InstrumentSingleCurveSensitivityCalculatorTest.java

private static YieldCurveBundle getYieldCurveMap(final YieldCurveFittingTestDataBundle data,
        final DoubleMatrix1D yieldCurveNodes) {
    final HashMap<String, double[]> yields = unpackYieldVector(data, yieldCurveNodes);
    final LinkedHashMap<String, YieldAndDiscountCurve> curves = new LinkedHashMap<String, YieldAndDiscountCurve>();
    for (final String name : data.getCurveNames()) {
        final YieldAndDiscountCurve curve = makeYieldCurve(yields.get(name),
                data.getCurveNodePointsForCurve(name), data.getInterpolatorForCurve(name));
        curves.put(name, curve);//from  w  w  w  . j  a  v  a 2  s  .co  m
    }
    return new YieldCurveBundle(curves);
}

From source file:org.grameenfoundation.consulteca.utils.HttpHelpers.java

public static void addCommonHeaders(URLConnection connection) {
    HashMap<String, String> commonHeaders = getCommonHeaders();
    Set<String> keys = commonHeaders.keySet();
    for (String key : keys) {
        connection.setRequestProperty(key, commonHeaders.get(key));
    }//www  .  j av  a2s .  c o  m
}

From source file:org.eclipse.swt.examples.launcher.LauncherPlugin.java

/**
 * Adds an item to the category tree.//from w  w w . j  a  va 2 s . c o m
 */
private static void addItemByCategory(IConfigurationElement ce, ItemTreeNode root, ItemTreeNode theNode,
        HashMap<String, ItemTreeNode> idMap) {
    final String attribCategory = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_CATEGORY, null);

    // locate the parent node
    ItemTreeNode parentNode = null;
    if (attribCategory != null) {
        parentNode = idMap.get(attribCategory);
    }
    if (parentNode == null)
        parentNode = root;

    // add the item
    parentNode.addSortedNode(theNode);
}

From source file:edu.ehu.galan.wiki2wordnet.wikipedia2wordnet.Mapper.java

private static void disambiguateUKB(HashMap<String, List<Wiki2WordnetMapping>> pUkbList,
        List<String> pDesambContext, String pFile, IDictionary pWordnet, HashMap<String, Integer> pMappings,
        String pUkbBinDir) {//from  w  w  w .ja  v  a  2s .  c o m
    logger.debug("Desambiguating Wornet synsets via UKB method");
    HashMap<String, List<String>> toDisam = new HashMap<>();
    logger.debug("Finding gold topics for disambiguation...");
    Function<String, String> contextSynsets = (String t) -> pWordnet
            .getSynset(new SynsetID(pMappings.get(t), POS.NOUN)).getWords().get(0).getLemma();
    List<String> context = pDesambContext.stream().map(contextSynsets).collect(toList());
    for (String topics21 : pUkbList.keySet()) {
        toDisam.put(pWordnet.getSynset(new SynsetID(pMappings.get(topics21), POS.NOUN)).getWords().get(0)
                .getLemma().toLowerCase(), context);
    }
    UKBUtils.prepareInput(toDisam, pFile);
    HashMap<String, Integer> synsets = UKBUtils.processUKB(pUkbBinDir, pFile);
    if (toDisam.size() == synsets.size()) {
        for (String topics21 : pUkbList.keySet()) {
            Integer inte = synsets.get(pWordnet.getSynset(new SynsetID(pMappings.get(topics21), POS.NOUN))
                    .getWords().get(0).getLemma().toLowerCase());
            pMappings.put(topics21, inte);
        }
        logger.debug("UKB disambiguation using WordNet finished");
    } else {
        logger.error("The number of topics to disambiguate via ukb must be the same than the ouput size");
    }

}