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:com.aspire.mandou.framework.http.HttpPost.java

HttpPost(AbstractHttpClient httpClient, String url, HashMap<String, String> defaultHeaders) {
    super(httpClient);
    this.request = new org.apache.http.client.methods.HttpPost(url);
    for (String header : defaultHeaders.keySet()) {
        request.setHeader(header, defaultHeaders.get(header));
    }/*from   w w w.  j a  va 2 s  . c  o m*/
}

From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java

/**
 * This function loops over all sizes of ngrams, from minN to maxN, and creates
 * an ngram model, and also normalizes it.
 *
 * @param minN minimum size ngram/* w ww . j a v a  2s.co m*/
 * @param maxN maximum size ngram
 * @param examples list of examples
 * @param padding whether or not this should be padded
 * @return a hashmap of ngrams.
 */
public static HashMap<String, Double> GetNgramCounts(int minN, int maxN, Iterable<String> examples,
        boolean padding) {
    HashMap<String, Double> result = new HashMap<>();
    for (int i = minN; i <= maxN; i++) {
        HashMap<String, Integer> counts = GetNgramCounts(i, examples, padding);
        int total = 0;
        for (int v : counts.values()) {
            total += v;
        }

        for (String key : counts.keySet()) {
            int value = counts.get(key);
            result.put(key, ((double) value) / total);
        }
    }

    return result;
}

From source file:eu.scape_project.up2ti.output.SimpleKeyValueOutputWriter.java

/**
 * Record method for hadoop job./*from  w  ww  .java  2  s .  c  o m*/
 *
 * @param resultMap Result map where K: recordkey-identificationtype, V:
 * tool identificationtype identificationresult)
 * @param mos Multiple output writer
 */
@Override
public void write(HashMap<String, List<String>> resultMap, MultipleOutputs mos) {
    Iterator iter = resultMap.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        List<String> valueList = resultMap.get(key);
        try {
            for (String value : valueList) {
                mos.write("idtab", new Text(key), new Text(value));
            }
        } catch (IOException ex) {
            LOG.error("I/O Error", ex);
        } catch (InterruptedException ex) {
            LOG.error("Interrupted Error", ex);
        }
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ManageGrantsForIndividualController.java

private List<String> getAllSubclasses(HashMap<String, List<Map<String, String>>> grants) {
    List<String> allSubclasses = new ArrayList<String>(grants.keySet());
    Collections.sort(allSubclasses);
    return allSubclasses;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ManagePeopleForOrganizationController.java

private List<String> getAllSubclasses(HashMap<String, List<Map<String, String>>> people) {
    List<String> allSubclasses = new ArrayList<String>(people.keySet());
    Collections.sort(allSubclasses);
    return allSubclasses;
}

From source file:com.osbitools.ws.shared.prj.utils.EntityUtils.java

public EntityUtils() {
    // Index supported extensions
    HashMap<String, String[]> sdirs = getSubDirExtList();

    for (String name : sdirs.keySet()) {
        String[] extl = sdirs.get(name);
        HashSet<String> sx = new HashSet<String>();

        for (String ext : extl) {
            sx.add(ext);//from w w  w .j  a  v a2  s . c  om
            if (!_exts.contains(ext))
                _exts.add(ext);
        }

        _ffilters.put(name, new ExtListFileFilter(extl));
        _extl.put(name, sx);
    }
}

From source file:feedme.controller.AddOrDeleteCategoryServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);//from   w w  w .j  a v a2s .  c  o  m
    request.setCharacterEncoding("UTF-8");
    response.setStatus(HttpServletResponse.SC_OK);
    String CategoryName = request.getParameter("categoryName").trim();
    DbRestaurantsManagement ob = new DbRestaurantsManagement();

    boolean flag = false;

    HashMap<String, Integer> cat = new DbHPOnLoad().getCategories();

    for (String se : cat.keySet()) {
        if (se.contains(CategoryName))
            flag = true;
    }
    int result = 0;
    if (!flag)
        result = ob.addNewCategory(CategoryName);

    PrintWriter out = response.getWriter();
    if (result == 1) {
        if (isAjax(request) == true) { // Stay in the same page, and sand json message

            try {
                cat = new DbHPOnLoad().getCategories();
                JSONObject catObj = new JSONObject();
                JSONArray catArray = new JSONArray();
                for (Entry<String, Integer> entry : cat.entrySet()) {
                    catArray.put(
                            new JSONObject().put("cat_id", entry.getValue()).put("cat_name", entry.getKey()));
                }
                catObj.put("categories", catArray);
                catObj.put("status", true);
                response.setContentType("application/json");
                PrintWriter writer = response.getWriter();
                writer.print(catObj);
                response.getWriter().flush();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        } else { // redirect to othe page

        }
    }
}

From source file:org.wikimedia.analytics.kraken.schemas.JsonToClassConverterTest.java

@Test
public void readCountryJsonFile() throws JsonMappingException, JsonParseException, RuntimeException {
    JsonToClassConverter converter = new JsonToClassConverter();
    HashMap<String, Schema> map = converter.construct("org.wikimedia.analytics.kraken.schemas.Country",
            "country-codes.json", "getA2");
    assertEquals(map.keySet().size(), 249);

}

From source file:com.glluch.profilesparser.ICTProfile.java

/**
 * Transform the counts of the terms as in integers in a counts as doubles. 
 * @param pterms The map of terms to counts.
 *//*www . j  av  a 2  s.co m*/
public void setPtermsI2D(HashMap<String, Integer> pterms) {
    Set keys = pterms.keySet();
    for (Object key0 : keys) {
        String key = (String) key0;
        this.pterms.put(key, NumberUtils.createDouble(pterms.get(key).toString()));

    }

}

From source file:JasperPDF.PDF.java

@SuppressWarnings("unused")
private void setParameters(Object data, HashMap<String, Object> parametros) {
    try {/*ww w  . j  a  va  2 s  . c  o  m*/
        HashMap<String, Object> params = (HashMap<String, Object>) data;
        for (String key : params.keySet()) {
            parametros.put(key, params.get(key));
        }
    } catch (Exception e) {

    }
}