List of usage examples for java.util HashMap put
public V put(K key, V value)
From source file:Main.java
public static HashMap<String, String> convertXmlAttributeToHashMap(NamedNodeMap inputNodeMap) { HashMap<String, String> outputHashMap = new HashMap<String, String>(); for (int i = 0; i < inputNodeMap.getLength(); i++) { Attr inputNodeMapAttribute = (Attr) inputNodeMap.item(i); outputHashMap.put(inputNodeMapAttribute.getName().trim(), inputNodeMapAttribute.getValue().trim()); }/*from w w w . j a v a 2s .c o m*/ return outputHashMap; }
From source file:lsafunctions.LSA.java
private static HashMap addToDicry(String[] listLema1, HashMap dicry, int i) { for (String item : listLema1) { if (!dicry.containsValue(item.toLowerCase())) { dicry.put(i, item.toLowerCase()); i++;/*from ww w. j av a 2s. com*/ } } return dicry; }
From source file:net.kayateia.lifestream.Network.java
static public synchronized String DoLogin(Context context, String userText, String passText) { Settings settings = new Settings(context); // See if we have a GCM ID first. String gcmId = settings.getGcmId(); if (gcmId.equals("")) gcmId = GCMRegistrar.getRegistrationId(context); if (gcmId.equals("")) { // Request one. We'll pick up its contents and re-register later. GCMRegistrar.register(context, GCMIntentService.GCM_SENDER_ID); } else {//from w w w . ja v a 2s .c o m String oldId = settings.getGcmId(); if (!oldId.equals("") && !gcmId.equals(oldId)) { Log.w(LOG_TAG, "GCMRegistrar returned a different ID (" + gcmId + ") than we thought we had (" + oldId + ")"); } } Log.i(LOG_TAG, "Our GCM ID for user login is: " + gcmId); // Do we have an auth ID? String authId = settings.getAuthToken(); if (authId.equals("")) { authId = userText + "+" + Settings.GetAndroidID(context); } // Now contact the LifeStream server. HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("login", userText); parameters.put("pass", passText); parameters.put("gcm", gcmId); parameters.put("auth", authId); String resultText = ""; try { String baseUrl = Settings.GetBaseUrl(); resultText = HttpMultipartUpload.DownloadString(new URL(baseUrl + "login.php"), parameters, context); // Crack the JSON. If we can't parse it, we fail below. If we // parse it but get a 'message', we failed too. Otherwise we // should have some login info. JSONObject result = new JSONObject(resultText); String message = result.optString("message"); if (message != null && message.length() > 0) { Log.e(LOG_TAG, "Couldn't log in: " + message); return null; } settings.setUserName(userText); settings.setPassword(passText); settings.setGcmId(gcmId); settings.setAuthToken(authId); settings.commit(); return result.optString("name"); } catch (IOException e) { Log.e(LOG_TAG, "Couldn't log in: " + e); return null; } catch (JSONException e) { Log.e(LOG_TAG, "Couldn't parse login response: " + resultText); return null; } }
From source file:gov.nist.healthcare.ttt.webapp.api.GetCCDAFolderTest.java
public static HashMap<String, Object> createFile(String filename) { HashMap<String, Object> res = new HashMap<>(); HashMap<String, String> fileHash = new HashMap<>(); fileHash.put("name", filename); List filesList = new ArrayList<>(); filesList.add(fileHash);/*w w w.j a v a 2 s . co m*/ res.put("files", filesList); return res; }
From source file:gov.nist.healthcare.ttt.webapp.api.GetCCDAFolderTest.java
public static HashMap<String, Object> createDir(String dirname) { HashMap<String, Object> res = new HashMap<>(); HashMap<String, String> fileHash = new HashMap<>(); fileHash.put("name", dirname); List dirsList = new ArrayList<>(); dirsList.add(fileHash);//w w w.ja v a 2 s .c o m res.put("dirs", dirsList); return res; }
From source file:com.qcadoo.mes.deviationCausesReporting.dataProvider.DeviationWithOccurrencesDataProvider.java
private static String prepareTotalOccurrencesForProblemProjection() { Collection<String> subQueries = Collections2.transform(Arrays.asList(DeviationType.values()), new Function<DeviationType, String>() { @Override//from w ww .jav a 2 s .co m public String apply(final DeviationType deviationType) { DeviationModelDescriber modelDescriber = deviationType.getModelDescriber(); HashMap<String, String> placeholderValues = Maps.newHashMap(); placeholderValues.put("MODEL_PLUGIN", modelDescriber.getModelPlugin()); placeholderValues.put("MODEL_NAME", modelDescriber.getModelName()); placeholderValues.put("REASON_TYPE_FIELD_NAME", modelDescriber.getReasonTypeFieldName()); placeholderValues.put("ORDER_PATH", deviationType.getPathToOrder()); placeholderValues.put("ORDER_STATE", OrderFields.STATE); StrSubstitutor substitutor = new StrSubstitutor(placeholderValues, "${", "}"); return substitutor.replace(PARTIAL_COUNT_SUB_QUERY_TPL).toString(); } }); return StringUtils.join(subQueries, " + "); }
From source file:Main.java
/** * Breaks key=value&key=value string to map * * @param queryString string to explode/*from w ww . j a v a2 s . c o m*/ * @return Key-value map of passed string */ @Nullable public static Map<String, String> explodeQueryString(@Nullable String queryString) { if (queryString == null) { return null; } String[] keyValuePairs = queryString.split("&"); HashMap<String, String> parameters = new HashMap<>(keyValuePairs.length); for (String keyValueString : keyValuePairs) { String[] keyValueArray = keyValueString.split("="); parameters.put(keyValueArray[0], keyValueArray[1]); } return parameters; }
From source file:net.pocketpixels.hubmanager.DBmanager.java
/** *Loads all the objects of class type out of JSON from the given folder * @param type The class of the objects to be loaded * @param loc the location of the folder to load the data from * @return returns a HashMap of the file names and the Objects loaded *//*from w w w. ja v a 2s . com*/ public static HashMap<String, Object> loadAllObj(Class type, File loc) { if (!loc.exists()) { loc.mkdirs(); return null; } HashMap<String, Object> rtn = new HashMap<String, Object>(); for (File f : loc.listFiles()) { rtn.put(f.getName(), loadObj(type, f)); } return rtn; }
From source file:Main.java
/** * Breaks key=value&key=value string to map * * @param queryString string to explode/*from w w w .j a va 2 s. co m*/ * @return Key-value map of passed string */ public static Map<String, String> explodeQueryString(String queryString) { String[] keyValuePairs = queryString.split("&"); HashMap<String, String> parameters = new HashMap<String, String>(keyValuePairs.length); for (String keyValueString : keyValuePairs) { String[] keyValueArray = keyValueString.split("="); parameters.put(keyValueArray[0], keyValueArray[1]); } return parameters; }
From source file:com.opengamma.analytics.util.surface.StringValue.java
/** * Builder from on point./*w ww . j a v a 2s .com*/ * @param point The surface point. * @param value The associated value. * @return The surface value. */ public static StringValue from(final String point, final Double value) { Validate.notNull(point, "Point"); HashMap<String, Double> data = new HashMap<String, Double>(); data.put(point, value); return new StringValue(data); }