Example usage for java.util Map keySet

List of usage examples for java.util Map keySet

Introduction

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

Prototype

Set<K> keySet();

Source Link

Document

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

Usage

From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils.java

/** Manually replace query variables with uris when prebinding causes the query to fail, probably
 * due to a Jena bug./*  ww  w. j a v  a2  s  .co m*/
 */
public static String subUrisForQueryVars(String queryString, Map<String, String> varsToUris) {

    for (String var : varsToUris.keySet()) {
        queryString = subUriForQueryVar(queryString, var, varsToUris.get(var));
    }
    return queryString;
}

From source file:com.microsoft.services.sharepoint.http.FroyoHttpConnection.java

/**
 * Creates a request that can be accepted by the AndroidHttpClient
 * //w w  w . j  a  v  a  2  s  .  c o  m
 * @param request
 *            The request information
 */
private static BasicHttpEntityEnclosingRequest createRealRequest(Request request) {
    BasicHttpEntityEnclosingRequest realRequest = new BasicHttpEntityEnclosingRequest(request.getVerb(),
            request.getUrl());

    if (request.getContent() != null) {
        realRequest.setEntity(new ByteArrayEntity(request.getContent()));
    }

    Map<String, String> headers = request.getHeaders();

    for (String key : headers.keySet()) {
        realRequest.addHeader(key, headers.get(key));
    }

    return realRequest;
}

From source file:de.hybris.platform.integration.cis.payment.strategies.impl.CisPaymentIntegrationTestHelper.java

public static List<BasicNameValuePair> convertMap(final Map<String, String> formData) {
    final Set<String> fields = formData.keySet();
    final List<BasicNameValuePair> resultList = new ArrayList<BasicNameValuePair>();
    for (final String field : fields) {
        resultList.add(new BasicNameValuePair(field, formData.get(field)));
    }//  w  w w  .j av a  2  s  .c o m

    return resultList;
}

From source file:com.lucidtechnics.blackboard.util.Utility.java

public static String toString(Object _object) {
    StringBuffer stringBuffer = new StringBuffer();

    try {//  ww w  .ja v  a 2 s.  c  o m

        Map propertyMap = BeanUtils.describe(_object);

        stringBuffer.append(_object.getClass().getName() + "\n");

        Iterator propertyNames = propertyMap.keySet().iterator();

        while (propertyNames.hasNext() == true) {
            String property = (String) propertyNames.next();

            if ("class".equalsIgnoreCase(property) == false) {
                String value = (String) propertyMap.get(property);
                stringBuffer.append("  -- " + property + " --> " + value + "\n");
            }
        }
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }

    return stringBuffer.toString();
}

From source file:ch.oakmountain.tpa.solver.TrainPathAllocationProblem.java

public static double getTotalWeightOfSolutionCandidates(
        Map<SimpleTrainPathApplication, SolutionCandidate> allocations) {
    double objective = 0;
    for (SimpleTrainPathApplication simpleTrainPathApplication : allocations.keySet()) {
        SolutionCandidate allocation = allocations.get(simpleTrainPathApplication);
        objective += allocation.getWeight();
    }//w w  w.  j  a  v a2  s.c  o  m
    return objective;
}

From source file:gov.nij.bundles.intermediaries.ers.osgi.EntityResolutionConversionUtils.java

/**
 * Convert a collectio of SERF-independent AttributeWrappers to equivalent SERF Attributes
 * @param attributes a collection of attribute wrappers - as a map keyed by the attribute name
 * @return equvalent map of SERF attributes, keyed by attribute name
 *//*from   w  w w.  ja  v  a2 s  .co m*/
public static Map<String, Attribute> convertAttributeWrappers(Map<String, AttributeWrapper> attributes) {
    Map<String, Attribute> ret = new HashMap<String, Attribute>();
    for (String key : attributes.keySet()) {
        AttributeWrapper aw = attributes.get(key);
        LOG.debug("In convertAttributeWrappers, key=" + key + ", aw=" + aw);
        ret.put(key, convertAttributeWrapper(aw));
    }
    return ret;
}

From source file:cn.vlabs.duckling.common.http.WebSite.java

public static String getBodyContent(String url) {
    int index = url.indexOf("?");
    String query = "";
    if (index > 0) {
        query = url.substring(index + 1, url.length());
        url = url.substring(0, index);//from w  w  w.j a  v a2 s  . co  m
    }
    WebSite site = new WebSite(url);
    if (query.trim().length() > 0) {
        PostMethod method = site.createPostMethod(null);
        Map<String, String> params = extractParams(query.trim());
        for (String key : params.keySet()) {
            method.addParameter(key, params.get(key));
        }
        try {
            int code = site.exec(method);
            if (code == 200) {
                return method.getResponseBodyAsString();
            }
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            method.releaseConnection();
            site.close();
        }
    } else {
        GetMethod method = site.createGetMethod("");
        try {
            int code = site.exec(method);
            if (code == 200) {
                return method.getResponseBodyAsString();
            }
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            method.releaseConnection();
            site.close();
        }
    }
    return null;
}

From source file:Main.java

/**
 * /*from   www .j a va2s.  c  om*/
 * @param pressingLength length of pause between clicks
 * @return mathExpectation values list 
 */
public static List<Double> mathExpectation(Map<String, Long> pressingLength) {
    List<Double> mathExpectation = new ArrayList<Double>();
    int N = pressingLength.size() - 1;
    //math Expectation
    double expectation = 0.0;

    for (String key : pressingLength.keySet()) {
        for (String k : pressingLength.keySet()) {
            if (!k.equals(key)) {
                expectation += pressingLength.get(k);
            }
        }
        mathExpectation.add(expectation / N);
        expectation = 0.0;
    }
    return mathExpectation;
}

From source file:com.alibaba.openapi.client.util.InvokeUtil.java

/**
 * //from w w  w  . jav  a 2s .  c o  m
 * @param params
 * @param secretKey
 * @param signatureDataPref
 * @return the signature
 */
public static String signatureData(Map<String, Object> params, String secretKey, String signatureDataPref) {
    final List<String> paramValueList = new ArrayList<String>(params.size());
    for (String key : params.keySet()) {
        paramValueList.add(key + params.get(key));
    }
    return signature(paramValueList, secretKey, signatureDataPref);
}

From source file:com.microsoft.office365.http.FroyoHttpConnection.java

/**
 * Creates a request that can be accepted by the AndroidHttpClient
 * //  w  w w .  ja va  2s.  c o  m
 * @param request
 *            The request information
 * @throws UnsupportedEncodingException
 */
private static BasicHttpEntityEnclosingRequest createRealRequest(Request request)
        throws UnsupportedEncodingException {
    BasicHttpEntityEnclosingRequest realRequest = new BasicHttpEntityEnclosingRequest(request.getVerb(),
            request.getUrl());

    if (request.getContent() != null) {
        realRequest.setEntity(new ByteArrayEntity(request.getContent()));
    }

    Map<String, String> headers = request.getHeaders();

    for (String key : headers.keySet()) {
        realRequest.addHeader(key, headers.get(key));
    }

    return realRequest;
}