Example usage for java.util HashMap keySet

List of usage examples for java.util HashMap keySet

Introduction

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

Prototype

public Set<K> keySet() 

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:net.antidot.semantic.rdf.rdb2rdf.dm.core.DirectMapper.java

private static void convertNextTuple(SesameDataSet result, TupleExtractor te, DirectMappingEngine dme,
        DriverType driver, String baseURI) throws UnsupportedEncodingException {
    Tuple tuple = te.getCurrentTuple();//from  w ww.  j a  v  a  2 s  . com
    //Tuple tuple = null;
    log.debug("[DirectMapper:convertNextTuple] Tuple extracted : " + tuple);
    try {
        // Extract referenced rows
        HashMap<Key, Tuple> referencedTuples = te.getReferencedTuples(driver, tuple);
        // Extract primary-is-foreign Key 
        Key primaryIsForeignKey = te.getCurrentPrimaryIsForeignKey(referencedTuples.keySet(), tuple);
        log.debug("[DirectMapper:convertNextTuple] Number of referenced tuples generated : "
                + referencedTuples.values().size());

        HashSet<Statement> statements = dme.extractTriplesFrom(tuple, referencedTuples, primaryIsForeignKey,
                baseURI);
        for (Statement triple : statements) {
            log.debug("[DirectMapper:convertNextTuple] Triple generated : " + triple);
            result.add(triple.getSubject(), triple.getPredicate(), triple.getObject());
            nbTriples++;
        }
        if (nbTriples / 50000 > lastModulo) {
            log.info(nbTriples + " triples has already been extracted.");
            lastModulo = nbTriples / 50000;
        }
    } catch (UnsupportedEncodingException e) {
        log.error("[DirectMapper:generateDirectMapping] Encoding not supported.");
        e.printStackTrace();
    }
}

From source file:com.clustercontrol.accesscontrol.util.UserRoleCache.java

/**
 * ID?//  ww w .  jav a2s  .  co m
 * refresh???????????????????
 * 
 * @return ID????
 */
public static List<String> getAllRoleIdList() {
    HashMap<String, ArrayList<String>> cache = getRoleUserCache();
    return new ArrayList<String>(cache.keySet());
}

From source file:com.clustercontrol.accesscontrol.util.UserRoleCache.java

/**
 * ID?/*ww  w  .j a  v a  2 s.  c om*/
 * @return ID????
 */
public static List<String> getAllUserIdList() {
    // ?????????????????????????
    // (?????????????????????????)
    HashMap<String, ArrayList<String>> cache = getUserRoleCache();
    return new ArrayList<String>(cache.keySet());
}

From source file:Main.java

private static Document documentFromSoapBody(SOAPBodyElement element,
        HashMap<String, String> namespaceDeclarations) throws ParserConfigurationException {
    Document document = dbf.newDocumentBuilder().newDocument();
    Node node = document.importNode(element, true);
    document.appendChild(node);/*from   w w  w.ja  v  a2  s  .  c  o  m*/

    for (String prefix : namespaceDeclarations.keySet()) {
        String uri = namespaceDeclarations.get(prefix);
        if (node.lookupNamespaceURI(prefix) == null) {
            document.getDocumentElement().setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + prefix,
                    uri);
        }
    }
    return document;
}

From source file:communicator.Constants.java

public static JSONObject checkForAllKeys(JSONObject mJSONObject, HashMap<String, String> map) {

    JSONObject mResponseObject = new JSONObject();
    Iterator mIterator = map.keySet().iterator();//signUpRequestParams.keySet().iterator();
    String key = null;//from w  w w  .j a va 2  s . co  m
    boolean keyMissing = false;
    while (mIterator.hasNext()) {
        key = (String) mIterator.next();

        if (!mJSONObject.has(key)) {
            keyMissing = true;

        } else {

        }

    }

    try {
        if (keyMissing) {
            mResponseObject.put(Constants.JSON_STATUS, Constants.JSON_FAILURE);
            mResponseObject.put(Constants.JSON_MSG, key + JSON_KEY_MISSING);

        } else {
            mResponseObject.put(Constants.JSON_STATUS, Constants.JSON_SUCCESS);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return mResponseObject;
}

From source file:com.adobe.sign.utils.validator.ApiValidatorHelper.java

/**
 * Function to validate a list of mandatory parameters.
 *.//  w w  w .  ja  v a  2 s  .com
 * @param hashMap The parameter List from which every parameter needs to be validated.
 * @throws ApiException
 */
public static void validateRequiredParameters(HashMap hashMap) throws ApiException {
    Set<String> keys = hashMap.keySet();
    for (String key : keys) {
        validateParameter(hashMap.get(key), key);
    }
}

From source file:com.ibm.mobilefirstplatform.clientsdk.cordovaplugins.core.CDVMFPLogger.java

public static JSONObject HashMapToJSONObject(HashMap<String, LEVEL> pairs) {
    if (pairs == null) {
        return new JSONObject();
    }/*from   www  .jav a 2 s . co  m*/

    Set<String> set = pairs.keySet();
    JSONObject jsonObj = new JSONObject();
    @SuppressWarnings("rawtypes")
    Iterator it = set.iterator();
    while (it.hasNext()) {
        String n = (String) it.next();
        try {
            jsonObj.put(n, pairs.get(n).toString());
        } catch (JSONException e) {
            // not possible
        }
    }
    return jsonObj;
}

From source file:Main.java

public static HashMap<Integer, HashMap<Integer, Integer>> getAvailableTime(HashMap<Date, Date> bookedTimes,
        Date date) {/*from   www . ja v a 2  s. com*/
    HashMap<Integer, HashMap<Integer, Integer>> availableTime = createFullAvailableTime();

    HashMap<Date, Date> bookedTimeInOneDate = getBookedTimeInOneDate(bookedTimes, date);
    Calendar startCalendar = Calendar.getInstance();
    Calendar endCalendar = Calendar.getInstance();
    for (Date keyBooked : bookedTimeInOneDate.keySet()) {
        startCalendar.setTime(keyBooked);
        int startHour = startCalendar.get(Calendar.HOUR_OF_DAY);
        for (int hourIndex = 0; hourIndex < 24; hourIndex++) {

            if (hourIndex == startHour) {
                int startMinute = startCalendar.get(Calendar.MINUTE);
                int endMinute;

                endCalendar.setTime(bookedTimeInOneDate.get(keyBooked));

                int endHour = endCalendar.get(Calendar.HOUR_OF_DAY);

                //startHour = endHour = hourIndex
                if (endHour == hourIndex) {
                    endMinute = endCalendar.get(Calendar.MINUTE);
                    removeMinute(startMinute, endMinute, hourIndex, availableTime);
                }
                //startHour = hourIndex != endHour
                else {
                    for (int i = hourIndex; i < endHour + 1; i++) {
                        if (i == hourIndex) {
                            if (startMinute == 0) {
                                availableTime.remove(startHour);
                            } else {
                                removeMinute(startMinute, 59, hourIndex, availableTime);
                            }

                        } else if (i == endHour) {

                            endMinute = endCalendar.get(Calendar.MINUTE);
                            if (endMinute == 59) {
                                availableTime.remove(endHour);
                            } else {
                                removeMinute(0, endMinute, endHour, availableTime);
                            }

                        } else {

                            availableTime.remove(i);
                        }
                    }
                }
            }
        }
    }
    return availableTime;
}

From source file:net.triptech.metahive.model.Submission.java

/**
 * Count the submissions.//from  ww w.java 2s  .c  om
 *
 * @param filter the filter
 * @return the long
 */
public static long countSubmissions(final SubmissionFilter filter) {

    StringBuilder sql = new StringBuilder("SELECT COUNT(s) FROM Submission s");
    sql.append(buildWhere(filter));

    TypedQuery<Long> q = entityManager().createQuery(sql.toString(), Long.class);

    HashMap<String, Long> variables = buildVariables(filter);
    for (String variable : variables.keySet()) {
        q.setParameter(variable, variables.get(variable));
    }

    return q.getSingleResult();
}

From source file:net.triptech.metahive.model.Submission.java

/**
 * Find submission entries.//from  w  w w .  j a v a2  s .c  o m
 *
 * @param filter the submission filter
 * @param firstResult the first result
 * @param maxResults the max results
 * @return the list
 */
public static List<Submission> findSubmissionEntries(final SubmissionFilter filter, final int firstResult,
        final int maxResults) {

    StringBuilder sql = new StringBuilder("SELECT s FROM Submission s");
    sql.append(buildWhere(filter));
    sql.append(" ORDER BY s.created ASC");

    TypedQuery<Submission> q = entityManager().createQuery(sql.toString(), Submission.class)
            .setFirstResult(firstResult).setMaxResults(maxResults);

    HashMap<String, Long> variables = buildVariables(filter);
    for (String variable : variables.keySet()) {
        q.setParameter(variable, variables.get(variable));
    }

    return q.getResultList();
}