Java Code Examples for java.util.HashMap#toString()

The following examples show how to use java.util.HashMap#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQLMapperTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void replacePlaceholders() throws Exception {
  HashMap<String, Object> map = new HashMap<>();
  map.put("1", 1);
  map.put("2", 1);
  map.put("3", 3);
  map.put("4", 4);
  map.put("5", -1);
  String s = map.toString();
  Assert.assertEquals(ParameterReplace.orderedParam("(?0)", s.substring(1, s.length() - 1)),
      "(1=1, 2=1, 3=3, 4=4, 5=-1)");
  String key = map.keySet().toString();
  String value = map.values().toString();
  Assert.assertEquals(ParameterReplace.orderedParam("(?0), (?1)",
      key.substring(1, key.length() - 1), value.substring(1, value.length() - 1)), "(1, 2, 3, 4, 5), (1, 1, 3, 4, -1)");
}
 
Example 2
Source File: SpeciesMapper.java    From ASTRAL with Apache License 2.0 6 votes vote down vote up
public String getSpeciesNames() {
    if (this.taxonIdToSpeciesId.length == this.speciesNameIdMap.taxonCount()) {
        return Arrays.toString(this.speciesNameIdMap.getAllTaxonNames());
    } else {
        HashMap<String, String> stToGtNameMap = new HashMap<String, String>();
        int i = 0;
        for (List<Integer> set : this.speciesIdtoTaxonId) {
            ArrayList<String> gtNames = new ArrayList<String>();
            for (Integer gi : set) {
                gtNames.add(GlobalMaps.taxonIdentifier.getTaxonName(gi));
            }
            stToGtNameMap.put(this.getSpeciesName(i++), gtNames.toString());
        }
        return stToGtNameMap.toString();
    }
}
 
Example 3
Source File: BaseClient.java    From galaxy-sdk-java with Apache License 2.0 6 votes vote down vote up
protected HttpUriRequest prepareRequestMethod(URI uri, HttpMethod method, ContentType contentType,
    HashMap<String, String> params, Map<String, List<Object>> headers, HttpEntity requestEntity)
    throws IOException {
  if (params != null) {
    URIBuilder builder = new URIBuilder(uri);
    for (Entry<String, String> param : params.entrySet()) {
      builder.addParameter(param.getKey(), param.getValue());
    }
    try {
      uri = builder.build();
    } catch (URISyntaxException e) {
      throw new IOException("Invalid param: " + params.toString(), e);
    }
  }

  Map<String, Object> h = prepareRequestHeader(uri, method, contentType);
  headers = mergeToHeaders(headers, h);
  return createHttpRequest(uri, method, headers, requestEntity);
}
 
Example 4
Source File: HashMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.util.AbstractMap#toString()
 */
public void test_toString() {

    HashMap m = new HashMap();
    m.put(m, m);
    String result = m.toString();
    assertTrue("should contain self ref", result.indexOf("(this") > -1);
}
 
Example 5
Source File: DemoDataCommitImpl.java    From android_viewtracker with Apache License 2.0 4 votes vote down vote up
@Override
public void commitClickEvent(HashMap<String, Object> commonInfo, String viewName, HashMap<String, Object> viewData) {
    String extra = viewData == null ? "" : "  extra=" + viewData.toString();
    Log.i(TAG, "commitClickEvent: viewName=" + viewName + extra);
}
 
Example 6
Source File: DemoDataCommitImpl.java    From android_viewtracker with Apache License 2.0 4 votes vote down vote up
@Override
public void commitExposureEvent(HashMap<String, Object> commonInfo, String viewName, HashMap<String, Object> viewData, long exposureData, HashMap<String, Object> exposureIndex) {
    String extra = viewData == null ? "" : "  extra=" + viewData.toString();
    Log.i(TAG, "commitExposureEvent: viewName=" + viewName + " exposureTime=" + exposureData + extra);
}
 
Example 7
Source File: ContactEntry.java    From AndroidLinkup with GNU General Public License v2.0 4 votes vote down vote up
public String toString() {
	HashMap<String, Object> map = new HashMap<String, Object>();
	map.put(key, value);
	return map.toString();
}