List of usage examples for java.util HashMap put
public V put(K key, V value)
From source file:ether.RDFHelper.java
private static HashMap<String, String> createMap_station() { HashMap<String, String> map = new HashMap<String, String>(); map.put("1", "Egnatias"); map.put("2", "Martiou"); map.put("3", "Lagkada"); map.put("4", "Eptapyrgiou"); map.put("5", "Toumpas"); map.put("6", "CityHall"); return map;// www . j av a2 s.co m }
From source file:eu.hydrologis.jgrass.geonotes.util.ExifHandler.java
private static void addTagToMap(JpegImageMetadata jpegMetadata, TagInfo tagInfo, HashMap<String, String> metadataMap) throws Exception { TiffField field = jpegMetadata.findEXIFValue(tagInfo); if (field != null) { metadataMap.put(tagInfo.name, field.getValueDescription()); }/*w w w.j a v a2s.com*/ }
From source file:com.nubits.nubot.utils.VersionInfo.java
private static HashMap getInfoFile() { String wdir = System.getProperty("user.dir"); String fp = wdir + "/" + Settings.INFO_FILE; File file = new File(fp); try {/*from w w w . j a v a2 s . c om*/ List lines = FileUtils.readLines(file, "UTF-8"); HashMap km = new HashMap(); for (Object o : lines) { String l = "" + o; try { String[] a = l.split("="); km.put(a[0], a[1]); } catch (Exception e) { //ignore line with "=" } } return km; } catch (Exception e) { //throw e; LOG.error(e.toString()); } return null; }
From source file:com.opengamma.analytics.util.surface.SurfaceValue.java
/** * Builder from on point./*from w ww .j a v a2 s. c o m*/ * @param point The surface point. * @param value The associated value. * @return The surface value. */ public static SurfaceValue from(final DoublesPair point, final Double value) { Validate.notNull(point, "Point"); HashMap<DoublesPair, Double> data = new HashMap<DoublesPair, Double>(); data.put(point, value); return new SurfaceValue(data); }
From source file:com.netatmo.weatherstation.api.NetatmoUtils.java
public static HashMap<String, String> parseOAuthResponse(JSONObject response) { HashMap<String, String> parsedResponse = new HashMap<String, String>(); try {/* www. j av a 2 s .co m*/ String refreshToken = response.getString("refresh_token"); parsedResponse.put("refresh_token", refreshToken); String accessToken = response.getString("access_token"); parsedResponse.put("access_token", accessToken); String expiresIn = response.getString("expires_in"); Long expiresAt = System.currentTimeMillis() + Long.valueOf(expiresIn) * 1000; parsedResponse.put("expires_at", expiresAt.toString()); } catch (JSONException e) { e.printStackTrace(); } return parsedResponse; }
From source file:com.opengamma.analytics.util.surface.CubeValue.java
/** * Builder from on point.// w w w . java 2 s . com * @param point The surface point. * @param value The associated value. * @return The surface value. */ public static CubeValue from(final Triple<Double, Double, Double> point, final Double value) { Validate.notNull(point, "Point"); HashMap<Triple<Double, Double, Double>, Double> data = new HashMap<Triple<Double, Double, Double>, Double>(); data.put(point, value); return new CubeValue(data); }
From source file:com.opengamma.analytics.util.surface.StringValue.java
/** * Create a new object containing the point of the initial object with the all values multiplied by a given factor. * @param stringValue The surface value. * @param factor The multiplicative factor. * @return The multiplied surface./*w w w .j av a 2 s .co m*/ */ public static StringValue multiplyBy(final StringValue stringValue, final double factor) { Validate.notNull(stringValue, "Surface value"); final HashMap<String, Double> multiplied = new HashMap<String, Double>(); for (final String p : stringValue._data.keySet()) { multiplied.put(p, stringValue._data.get(p) * factor); } return new StringValue(multiplied); }
From source file:Main.java
public static void putSumInClass(HashMap<String, Integer> suminclass, String text) { int i = 0, index; String info = text;//from w w w . j a va 2 s . com while ((index = info.indexOf("//@")) > 0) { i++; info = info.substring(index + 2); } if (suminclass.get(Integer.toString(i)) == null) { suminclass.put(Integer.toString(i), 1); } else { suminclass.put(Integer.toString(i), suminclass.get(Integer.toString(i)) + 1); } }
From source file:com.ettoremastrogiacomo.sktradingjava.starters.Temp.java
public static void fetchEuroNext() throws Exception { String u0 = "https://www.euronext.com/en/equities/directory"; com.ettoremastrogiacomo.utils.HttpFetch httpf = new com.ettoremastrogiacomo.utils.HttpFetch(); if (Init.use_http_proxy.equals("true")) { httpf.setProxy(Init.http_proxy_host, Integer.parseInt(Init.http_proxy_port), Init.http_proxy_user, Init.http_proxy_password); }/*ww w . j av a 2s . c o m*/ String s = new String(httpf.HttpGetUrl(u0, Optional.empty(), Optional.empty())); int k1 = s.indexOf("\\/en\\/popup\\/data\\/download?"); int k2 = s.indexOf("\"", k1); String u1 = s.substring(k1, k2 - 1); //LOG.debug(u1); u1 = u1.replace("\\u0026", "&"); u1 = "https://www.euronext.com" + u1.replace("/", ""); u1 = u1.replace("\\", "/"); LOG.debug(u1); s = new String(httpf.HttpGetUrl(u1, Optional.empty(), Optional.empty())); Document doc = Jsoup.parse(s); java.util.HashMap<String, String> vmap = new java.util.HashMap<>(); vmap.put("format", "1"); vmap.put("layout", "2"); vmap.put("decimal_separator", "1"); vmap.put("date_format", "1"); vmap.put("op", "Go"); Elements links = doc.select("input[name=\"form_build_id\"]"); links.forEach((x) -> { vmap.put("form_build_id", x.attr("value")); }); links = doc.select("input[name=\"form_id\"]"); links.forEach((x) -> { vmap.put("form_id", x.attr("value")); }); HttpURLConnection post = httpf.sendPostRequest(u1, vmap); StringBuffer response; try (BufferedReader in = new BufferedReader(new InputStreamReader(post.getInputStream()))) { String inputLine; response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append("\n").append(inputLine); } } String res = response.toString(); String[] lines = res.split("\n"); for (String line : lines) { String[] row = line.split("\t"); if (row.length == 13) { LOG.debug(row[0] + "\t" + row[1] + "\t" + row[2] + "\t" + row[3] + "\t" + row[4] + "\t" + row[5]); } } }
From source file:com.ibm.util.merge.CompareArchives.java
/** * @param archive// w w w.j a v a 2 s. c o m * @return * @throws IOException */ private static final HashMap<String, TarArchiveEntry> getMembers(String archive) throws IOException { TarArchiveInputStream input = new TarArchiveInputStream( new BufferedInputStream(new FileInputStream(archive))); TarArchiveEntry entry; HashMap<String, TarArchiveEntry> map = new HashMap<>(); while ((entry = input.getNextTarEntry()) != null) { map.put(entry.getName(), entry); } input.close(); return map; }