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.teamd.taxi.validation.DriverValidateUtil.java

@Override
public List<FieldError> filterErrors(List<FieldError> errors) {
    HashMap<String, FieldError> result = new HashMap<>();
    for (FieldError error : errors) {
        String field = error.getField();
        if (!result.keySet().contains(field)) {
            result.put(field, error);//from w ww .  j  a  v  a  2s . co m
        } else {
            result.put(field, higherError(result.get(field), error));
        }
    }
    return new ArrayList<>(result.values());
}

From source file:com.github.ignition.support.http.IgnitedHttpGet.java

public IgnitedHttpGet(IgnitedHttpClient ignitedHttp, String url, HashMap<String, String> defaultHeaders) {
    super(ignitedHttp);
    request = new org.apache.http.client.methods.HttpGet(url);
    for (String header : defaultHeaders.keySet()) {
        request.setHeader(header, defaultHeaders.get(header));
    }/*from w  ww  .  j a  v  a  2 s  .com*/
}

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

/**
 * Record method for command line application.
 *
 * @param resultMap Result map where K: recordkey-identificationtype, V:
 * tool identificationtype identificationresult)
 */// ww  w. jav a 2  s  . c  om
@Override
public void write(HashMap<String, List<String>> resultMap) {
    Iterator iter = resultMap.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        List<String> valueList = resultMap.get(key);
        PrintStream pout = null;
        if (outputPathStr != null) {
            FileOutputStream fos;
            try {
                fos = new FileOutputStream(outputPathStr, true);
                pout = new PrintStream(fos);
                System.setOut(pout);
            } catch (FileNotFoundException ex) {
                LOG.error("File not found error", ex);
            }
        }
        for (String value : valueList) {
            System.out.println(key + separator + value);
        }
        if (pout != null) {
            pout.close();
        }
    }
}

From source file:inflor.core.plots.CategoricalNumberAxis.java

public CategoricalNumberAxis(String name, HashMap<Integer, String> lableMap) {
    super(name);// w  w  w  . ja v a  2 s  .c  o  m
    this.labelMap = lableMap;

    Integer[] yValues = lableMap.keySet().toArray(new Integer[lableMap.size()]);
    double yMin = Double.MAX_VALUE;
    double yMax = Double.MIN_VALUE;

    for (Integer d : yValues) {
        if (d < yMin) {
            yMin = d;
        }
        if (d > yMax) {
            yMax = d;
        }
    }
    this.setRange(new Range(yMin - 0.5, yMax + 0.5));
    NumberFormat formatter = new CategoryNumberFormat(lableMap);
    this.setNumberFormatOverride(formatter);
    this.setTickMarkOutsideLength(2);
}

From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java

/** Writes the class information to a file in SOMLib format. */
public static void writeAsSOMLib(HashMap<String, String> classInfo, HashSet<String> classNames, String fileName)
        throws IOException, SOMLibFileFormatException {
    ArrayList<String> classNamesList = new ArrayList<String>(classNames);
    Collections.sort(classNamesList);

    PrintWriter writer = FileUtils.openFileForWriting("SOMLib class info", fileName);
    writer.println("$TYPE class_information");

    writer.println("$NUM_CLASSES " + classNames.size());
    writer.println("$CLASS_NAMES " + StringUtils.toString(classNamesList, "", "", " "));
    writer.println("$XDIM 2");
    writer.println("$YDIM " + classInfo.size());
    for (String key : classInfo.keySet()) {
        writer.println(key + " " + classNamesList.indexOf(classInfo.get(key)));
    }/*from w  w w  . java 2s  . co  m*/

    writer.flush();
    writer.close();
}

From source file:com.example.common.ApiRequestFactory.java

/**
 * Generate the API XML request body//w w  w  .  j a v a2s .  c  om
 */
@SuppressWarnings("unchecked")
private static String generateXmlRequestBody(Object params) {

    if (params == null) {
        return "<request version=\"2\"></request>";
    }

    HashMap<String, Object> requestParams;
    if (params instanceof HashMap) {
        requestParams = (HashMap<String, Object>) params;
    } else {
        return "<request version=\"2\"></request>";
    }

    final StringBuilder buf = new StringBuilder();

    // TODO: add local_version parameter if exist
    // 2010/12/29 update version to 2 to get comments from bbs
    buf.append("<request version=\"2\"");
    if (requestParams.containsKey("local_version")) {
        buf.append(" local_version=\"" + requestParams.get("local_version") + "\" ");
        requestParams.remove("local_version");
    }
    buf.append(">");

    // add parameter node
    final Iterator<String> keySet = requestParams.keySet().iterator();
    while (keySet.hasNext()) {
        final String key = keySet.next();

        if ("upgradeList".equals(key)) {
            buf.append("<products>");
            List<PackageInfo> productsList = (List<PackageInfo>) requestParams.get(key);
            for (PackageInfo info : productsList) {
                buf.append("<product package_name=\"").append(info.packageName);
                buf.append("\" version_code=\"").append(info.versionCode).append("\"/>");
            }
            buf.append("</products>");
            continue;
        } else if ("appList".equals(key)) {
            buf.append("<apps>");
            List<UpgradeInfo> productsList = (List<UpgradeInfo>) requestParams.get(key);
            for (UpgradeInfo info : productsList) {
                buf.append("<app package_name=\"").append(info.pkgName);
                buf.append("\" version_code=\"").append(info.versionCode);
                buf.append("\" version_name=\"").append(info.versionName);
                buf.append("\" app_name=\"").append(wrapText(info.name));
                //                    buf.append("\" md5=\"").append(info.md5);
                buf.append("\"/>");
            }
            buf.append("</apps>");
            continue;
        }

        buf.append("<").append(key).append(">");
        buf.append(requestParams.get(key));
        buf.append("</").append(key).append(">");
    }

    // add the enclosing quote
    buf.append("</request>");
    return buf.toString();
}

From source file:com.aspire.mandou.framework.http.HttpPut.java

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

From source file:com.github.ignition.support.http.HttpPut.java

HttpPut(IgnitedHttp ignitedHttp, String url, HashMap<String, String> defaultHeaders) {
    super(ignitedHttp);
    this.request = new org.apache.http.client.methods.HttpPut(url);
    for (String header : defaultHeaders.keySet()) {
        request.setHeader(header, defaultHeaders.get(header));
    }/*from   ww w .j a  v  a2s . c o m*/
}

From source file:com.github.ignition.support.http.HttpPost.java

HttpPost(IgnitedHttp ignitedHttp, String url, HashMap<String, String> defaultHeaders) {
    super(ignitedHttp);
    this.request = new org.apache.http.client.methods.HttpPost(url);
    for (String header : defaultHeaders.keySet()) {
        request.setHeader(header, defaultHeaders.get(header));
    }//from   w  ww .j ava  2 s  .co m
}

From source file:com.github.ignition.support.http.IgnitedHttpPut.java

IgnitedHttpPut(IgnitedHttpClient ignitedHttp, String url, HashMap<String, String> defaultHeaders) {
    super(ignitedHttp);
    this.request = new org.apache.http.client.methods.HttpPut(url);
    for (String header : defaultHeaders.keySet()) {
        request.setHeader(header, defaultHeaders.get(header));
    }// w w w .  jav  a2  s  . c o  m
}