Example usage for java.util HashMap values

List of usage examples for java.util HashMap values

Introduction

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

Prototype

public Collection<V> values() 

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:org.apache.axis2.addressing.AddressingHelper.java

public static String getRequestAddressingRequirementParameterValue(MessageContext response) {
    String value = "";
    if (response != null) {
        HashMap<String, MessageContext> operationMessageContexts = response.getOperationContext()
                .getMessageContexts();// ww w  . j  av  a 2 s  .  co m
        for (MessageContext messageContext : operationMessageContexts.values()) {
            // Assumes at most 2 messages on operation, if there is more than 2 it
            // will use the value from the first message it gets that is != response
            if (!messageContext.equals(response)) {
                value = (String) messageContext
                        .getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER);
                if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
                    log.debug("getRequestAddressingRequirementParameterValue: got value from MessageContext "
                            + messageContext + ", value: '" + value + "'");
                }
                break;
            }
        }
        if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
            log.debug("getRequestAddressingRequirementParameterValue: value: '" + value + "'");
        }
    }

    if (value == null || "".equals(value)) {
        value = AddressingConstants.ADDRESSING_UNSPECIFIED;
    }
    return value;
}

From source file:edu.utexas.cs.tactex.utils.BrokerUtils.java

/**
 * Given a mapping from TariffSpecification to subscribed customers
 * compute the total number of customers
 */// w w  w.  j a v a  2  s  .c  o m
public static int getNumIndividualCustomers(
        HashMap<TariffSpecification, HashMap<CustomerInfo, Integer>> tariffSubscriptions) {

    int total = 0;
    for (HashMap<CustomerInfo, Integer> subscriptions : tariffSubscriptions.values()) {
        for (Integer numCustomers : subscriptions.values()) {
            total += numCustomers;
        }
    }
    return total;
}

From source file:com.likya.myra.jef.utils.JobQueueOperations.java

public static boolean hasActiveThreads(HashMap<String, JobImpl> jobQueue) {

    Iterator<JobImpl> jobsIterator = jobQueue.values().iterator();
    while (jobsIterator.hasNext()) {
        JobImpl scheduledJob = jobsIterator.next();
        Thread myExecuter = scheduledJob.getMyExecuter();
        if ((myExecuter != null) && myExecuter.isAlive()) {
            return true;
        }/*w  ww  .  j a va2 s  .c  o  m*/
    }

    return false;
}

From source file:com.likya.myra.jef.utils.JobQueueOperations.java

public static void resetJobQueue(LiveStateInfo exceptionLiveStateInfo, HashMap<String, JobImpl> jobQueue) {

    for (JobImpl tmpJobImpl : jobQueue.values()) {

        AbstractJobType abstractJobType = tmpJobImpl.getAbstractJobType();

        if (exceptionLiveStateInfo != null && LiveStateInfoUtils.equalStates(exceptionLiveStateInfo,
                LiveStateInfoUtils.getLastStateInfo(abstractJobType))) {
            continue;
        }/*from   ww  w.j  a  v a 2s  .  c o m*/

        JobHelper.resetJob(abstractJobType);

        //         if (scheduledJob.getJobQueue() == null) {
        //            /**
        //             * jobQueue transient olduunudun, serialize etmiyor Recover
        //             * ederken, bu alan null geliyor. Bu nedenle null ise yeninde
        //             * okumak gerekiyor.
        //             */
        //            scheduledJob.setJobQueue(jobQueue);
        //         }
    }

    return;
}

From source file:edu.utexas.cs.tactex.utils.BrokerUtils.java

public static int extractPredictionRecordLength(
        HashMap<CustomerInfo, HashMap<TariffSpecification, ShiftedEnergyData>> result) {

    Collection<HashMap<TariffSpecification, ShiftedEnergyData>> listOfHashTrf2Engy = result.values();
    if (listOfHashTrf2Engy == null || listOfHashTrf2Engy.size() == 0) {
        log.warn("empty list of mappings of tariff=>energy");
        return 0;
    }//from  w ww. j av  a  2s.  c  o  m

    HashMap<TariffSpecification, ShiftedEnergyData> someHashTrf2Engy = listOfHashTrf2Engy.iterator().next();
    if (someHashTrf2Engy == null || someHashTrf2Engy.size() == 0) {
        log.warn("empty mapping of tariff=>energy");
        return 0;
    }
    return someHashTrf2Engy.values().iterator().next().getShiftedEnergy().getDimension();
}

From source file:org.apache.catalina.util.ExtensionValidator.java

private static HashMap buildAvailableExtensionsMap(ArrayList resources) {

    HashMap availableMap = null;//from  w w  w  .j  av  a 2s.c  om

    Iterator it = resources.iterator();
    while (it.hasNext()) {
        ManifestResource mre = (ManifestResource) it.next();
        HashMap map = mre.getAvailableExtensions();
        if (map != null) {
            Iterator values = map.values().iterator();
            while (values.hasNext()) {
                Extension ext = (Extension) values.next();
                if (availableMap == null) {
                    availableMap = new HashMap();
                    availableMap.put(ext.getUniqueId(), ext);
                } else if (!availableMap.containsKey(ext.getUniqueId())) {
                    availableMap.put(ext.getUniqueId(), ext);
                }
            }
        }
    }

    return availableMap;
}

From source file:gov.vha.isaac.ucum.UCUMParser.java

/**
 * Read an arbitrary string, and return any units of measure (along with their immediately preceeding value)
 * @param text//from www.  java2s .  c  om
 * @return
 */
public static Collection<ParsedUCUM> findUnitsInString(String text) {
    HashMap<Integer, ParsedUCUM> results = new HashMap<>();

    Iterator<String> items = tokenize(text).iterator();

    String previous = null;
    String current = null;

    while (!Util.isNumeric(previous) && items.hasNext()) {
        previous = items.next();
    }
    if (!items.hasNext()) {
        return results.values();
    }
    current = items.next();

    parseHelper(text, previous, current, results);

    while (items.hasNext()) {
        previous = current;
        current = items.next();

        while (!Util.isNumeric(previous) && items.hasNext()) {
            previous = current;
            current = items.next();
        }
        if (previous.equals(current) || !Util.isNumeric(previous)) {
            continue;
        }
        parseHelper(text, previous, current, results);
    }
    return results.values();
}

From source file:com.soomla.levelup.LevelUp.java

private static void applyGatesStateToJSON(JSONObject modelJSON, JSONObject stateJSON) {
    JSONObject gatesStateJSON = new JSONObject();
    HashMap<String, JSONObject> gates = getGates(modelJSON);
    for (JSONObject gateJSON : gates.values()) {
        JSONObject gateValuesJSON = new JSONObject();
        try {//from   ww w.  j  ava 2s  .  c  o  m
            String gateId = gateJSON.getString("itemId");
            gateValuesJSON.put("open", GateStorage.isOpen(gateId));

            gatesStateJSON.put(gateId, gateValuesJSON);
        } catch (JSONException e) {
            SoomlaUtils.LogDebug(TAG, "Unable to get Gates state: " + e.getLocalizedMessage());
        }
    }

    try {
        stateJSON.put("gates", gatesStateJSON);
    } catch (JSONException e) {
        SoomlaUtils.LogDebug(TAG, "Unable to set Gates state: " + e.getLocalizedMessage());
    }
}

From source file:com.soomla.levelup.LevelUp.java

private static void applyScoresStateToJSON(JSONObject modelJSON, JSONObject stateJSON) {
    JSONObject scoresStateJSON = new JSONObject();
    HashMap<String, JSONObject> scores = getScores(modelJSON);
    for (JSONObject scoreJSON : scores.values()) {
        JSONObject scoreValuesJSON = new JSONObject();
        try {//from   ww  w.jav a 2s . co  m
            String scoreId = scoreJSON.getString("itemId");
            scoreValuesJSON.put("latest", ScoreStorage.getLatestScore(scoreId));
            scoreValuesJSON.put("record", ScoreStorage.getRecordScore(scoreId));

            scoresStateJSON.put(scoreId, scoreValuesJSON);
        } catch (JSONException e) {
            SoomlaUtils.LogDebug(TAG, "Unable to get Scores state: " + e.getLocalizedMessage());
        }
    }

    try {
        stateJSON.put("scores", scoresStateJSON);
    } catch (JSONException e) {
        SoomlaUtils.LogDebug(TAG, "Unable to set Scores state: " + e.getLocalizedMessage());
    }
}

From source file:com.soomla.levelup.LevelUp.java

private static HashMap<String, JSONObject> getListFromWorlds(JSONObject model, String listName) {
    HashMap<String, JSONObject> resultHash = new HashMap<String, JSONObject>();

    HashMap<String, JSONObject> worldJSONs = getWorlds(model);

    for (JSONObject worldJSON : worldJSONs.values()) {
        JSONArray objectJSONs = worldJSON.optJSONArray(listName);
        if (objectJSONs != null) {
            for (int i = 0; i < objectJSONs.length(); i++) {
                JSONObject objectJSON = objectJSONs.optJSONObject(i);
                if (objectJSON != null) {
                    String objectId = objectJSON.optString("itemId");
                    if (!TextUtils.isEmpty(objectId)) {
                        resultHash.put(objectId, objectJSON);
                    }//from  w  w  w . j a v  a  2 s .  c  o m
                }
            }
        }
    }

    return resultHash;
}