List of usage examples for java.util HashMap get
public V get(Object key)
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils.java
/** Make a copy of a Map<String,List<String>> */ public static Map<String, List<String>> copyListMap(Map<String, List<String>> source) { HashMap<String, List<String>> map = new HashMap<String, List<String>>(); Set<String> keys = map.keySet(); for (String key : keys) { List<String> vals = map.get(key); map.put(new String(key), copy(vals)); }//from w ww . ja v a2 s .c o m return map; }
From source file:eu.fbk.dkm.sectionextractor.pantheon.WikipediaGoodTextExtractor.java
private static void addRedirects(HashSet<String> pagesToConsider, HashMap<String, String> redirects, String line, int depth) { if (depth > MAX_DEPTH) { return;// ww w. ja v a 2 s . com } String red = redirects.get(line); if (red != null) { pagesToConsider.add(red); addRedirects(pagesToConsider, redirects, red, depth + 1); } }
From source file:com.cloudera.impala.analysis.ToSqlUtils.java
/** * Returns a "CREATE TABLE" statement that creates the specified table. */// w w w . j a va 2 s . c o m public static String getCreateTableSql(Table table) throws CatalogException { Preconditions.checkNotNull(table); org.apache.hadoop.hive.metastore.api.Table msTable = table.getMetaStoreTable(); HashMap<String, String> properties = Maps.newHashMap(msTable.getParameters()); boolean isExternal = msTable.getTableType() != null && msTable.getTableType().equals(TableType.EXTERNAL_TABLE.toString()); String comment = properties.get("comment"); for (String hiddenProperty : HIDDEN_TABLE_PROPERTIES) { properties.remove(hiddenProperty); } ArrayList<String> colsSql = Lists.newArrayList(); ArrayList<String> partitionColsSql = Lists.newArrayList(); boolean isHbaseTable = table instanceof HBaseTable; for (int i = 0; i < table.getColumns().size(); i++) { if (!isHbaseTable && i < table.getNumClusteringCols()) { partitionColsSql.add(columnToSql(table.getColumns().get(i))); } else { colsSql.add(columnToSql(table.getColumns().get(i))); } } RowFormat rowFormat = RowFormat.fromStorageDescriptor(msTable.getSd()); HdfsFileFormat format = HdfsFileFormat.fromHdfsInputFormatClass(msTable.getSd().getInputFormat()); HdfsCompression compression = HdfsCompression.fromHdfsInputFormatClass(msTable.getSd().getInputFormat()); String location = isHbaseTable ? null : msTable.getSd().getLocation(); Map<String, String> serdeParameters = msTable.getSd().getSerdeInfo().getParameters(); return getCreateTableSql(table.getDb().getName(), table.getName(), comment, colsSql, partitionColsSql, properties, serdeParameters, isExternal, false, rowFormat, format, compression, table.getStorageHandlerClassName(), location); }
From source file:lee.util.jtap.JTapCli.java
/** * @param argsMap//from ww w . j a v a2s .c o m * @return */ protected static String setSession(HashMap<String, String> argsMap) { if (!argsMap.containsKey("host") || !argsMap.containsKey("bucket")) { return "Host and bucket values are required for session to be set."; } int portInt = 0; try { if (argsMap.containsKey("port")) { portInt = Integer.parseInt(argsMap.get("port")); } if (portInt == 0) { portInt = JTapSession.DEFAULT_PORT; } } catch (Exception e) { //Just use default. portInt = JTapSession.DEFAULT_PORT; } JTapCli.session = new JTapSession(argsMap.get("host"), portInt, argsMap.get("bucket"), argsMap.get("password")); JTapCli.session.save(); return "Session set. host=" + JTapCli.session.getHost() + ":" + JTapCli.session.getPort() + " bucket=" + JTapCli.session.getBucket(); }
From source file:com.sugarcrm.candybean.datasource.CsvDataAdapterSystemTest.java
private static void printDataSource(HashMap<String, DataSource> dataSourceHashMap) { for (String filenameNoExt : dataSourceHashMap.keySet()) { System.out.println(/*from w ww.jav a 2 s. co m*/ "CsvDataAdapterTest: printDataSourceData(): dataSource filenameNoExt = " + filenameNoExt); DataSource ds = dataSourceHashMap.get(filenameNoExt); printDataSourceFieldSet(ds); } }
From source file:com.caris.oscarexchange4j.proxy.PreviewCoverage.java
/** * @param serviceEndpoint// w w w . ja va 2 s . com * The service end point. * @param parameterMap * A map of parameters. * @return A url generated based on the end point and the parameters. * @throws MalformedURLException * If something goes wrong. */ public static URL generateUrl(String serviceEndpoint, HashMap<String, String> parameterMap) throws MalformedURLException { verifyParameters(parameterMap); List<String> params = new ArrayList<>(); Set<String> keys = parameterMap.keySet(); for (String key : keys) { params.add(key + "=" + parameterMap.get(key)); } if (!serviceEndpoint.endsWith("?")) { serviceEndpoint += "?"; } serviceEndpoint += StringUtils.join(params, "&"); return new URL(serviceEndpoint); }
From source file:com.ushahidi.android.app.net.UshahidiHttpClient.java
public static boolean PostFileUpload(String URL, HashMap<String, String> params) throws IOException { ClientHttpRequest req = null;//from w w w.ja va 2 s. c o m try { URL url = new URL(URL); req = new ClientHttpRequest(url); req.setParameter("task", params.get("task")); req.setParameter("incident_title", params.get("incident_title")); req.setParameter("incident_description", params.get("incident_description")); req.setParameter("incident_date", params.get("incident_date")); req.setParameter("incident_hour", params.get("incident_hour")); req.setParameter("incident_minute", params.get("incident_minute")); req.setParameter("incident_ampm", params.get("incident_ampm")); req.setParameter("incident_category", params.get("incident_category")); req.setParameter("latitude", params.get("latitude")); req.setParameter("longitude", params.get("longitude")); req.setParameter("location_name", params.get("location_name")); req.setParameter("person_first", params.get("person_first")); req.setParameter("person_last", params.get("person_last")); req.setParameter("person_email", params.get("person_email")); Log.i("HTTP Client:", "filename:" + UshahidiPref.savePath + params.get("filename")); if (!TextUtils.isEmpty(params.get("filename"))) req.setParameter("incident_photo[]", new File(UshahidiPref.savePath + params.get("filename"))); InputStream serverInput = req.post(); if (Util.extractPayloadJSON(GetText(serverInput))) { return true; } } catch (MalformedURLException ex) { return false; // fall through and return false } return false; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.utils.LocalNamespaceClassUtils.java
public static HashMap<String, String> getLocalNamespacesClasses(VitroRequest vreq, HashMap<String, String> namespaces) { HashMap<String, String> localClasses = new HashMap<String, String>(); List<VClass> allClasses = vreq.getWebappDaoFactory().getVClassDao().getAllVclasses(); for (VClass v : allClasses) { String classNamespace = v.getNamespace(); String classUri = v.getURI(); if (namespaces.containsKey(classNamespace)) { String namespaceLabel = namespaces.get(classNamespace); String prefix = namespaceLabel.substring(namespaceLabel.indexOf("(") + 1, namespaceLabel.indexOf(")")); localClasses.put(classUri, v.getName() + " ( " + prefix + ")"); }// w w w . j a va2 s . c o m } return localClasses; }
From source file:flpitu88.web.backend.psicoweb.config.Jwt.java
/** * Static method to decode a JSON Web Token * * @param token Token to decode/*from www . j a va2 s . c om*/ * @param key Key used for the signature * @param verify True if you want to verify the signature * * @return payload * * @throws IllegalStateException * @throws IllegalArgumentException * @throws VerifyException * @throws NoSuchAlgorithmException * @throws UnsupportedEncodingException * @throws InvalidKeyException * @throws AlgorithmException */ public static Map<String, Object> decode(String token, String key, Boolean verify) throws IllegalStateException, VerifyException, IllegalArgumentException, NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException, AlgorithmException { if (token == null || token.length() == 0) { throw new IllegalStateException("Token not set"); } // Check key if (key == null || key.length() == 0) { throw new IllegalArgumentException("Key cannot be null or empty"); } String[] segments = StringUtils.split(token, "."); if (segments.length != 3) { throw new IllegalStateException("Bad number of segments: " + segments.length); } // All segment should be base64 String headerSeg = segments[0]; String payloadSeg = segments[1]; String signatureSeg = segments[2]; Type stringObjectMap = new TypeToken<HashMap<String, Object>>() { }.getType(); Gson gson = new Gson(); HashMap<String, Object> header = gson.fromJson(base64Decode(headerSeg), stringObjectMap); HashMap<String, Object> payload = gson.fromJson(base64Decode(payloadSeg), stringObjectMap); if (verify) { Algorithm algorithm = getAlgorithm(header.get("alg").toString()); // Verify signature. `sign` will return base64 String String signinInput = StringUtils.join(new String[] { headerSeg, payloadSeg }, "."); if (!verify(signinInput, key, algorithm.getValue(), signatureSeg)) { throw new VerifyException("Bad signature"); } } return payload; }
From source file:Main.java
public static Bitmap getLedouBitmapFromNum(Context mContext, int num, HashMap<String, Bitmap> numBitmaps) { if (num < 0) { return null; }// w w w . j a v a 2 s. c o m char[] nums = (num + "").toCharArray(); ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(); for (int i = 0; i < nums.length; i++) { char tempNum = nums[i]; switch (tempNum) { case '0': Bitmap bitmap = numBitmaps.get("0"); if (bitmap != null) { bitmaps.add(bitmap); } break; case '1': Bitmap bitmap1 = numBitmaps.get("1"); if (bitmap1 != null) { bitmaps.add(bitmap1); } break; case '2': Bitmap bitmap2 = numBitmaps.get("2"); if (bitmap2 != null) { bitmaps.add(bitmap2); } break; case '3': Bitmap bitmap3 = numBitmaps.get("3"); if (bitmap3 != null) { bitmaps.add(bitmap3); } break; case '4': Bitmap bitmap4 = numBitmaps.get("4"); if (bitmap4 != null) { bitmaps.add(bitmap4); } break; case '5': Bitmap bitmap5 = numBitmaps.get("5"); if (bitmap5 != null) { bitmaps.add(bitmap5); } break; case '6': Bitmap bitmap6 = numBitmaps.get("6"); if (bitmap6 != null) { bitmaps.add(bitmap6); } break; case '7': Bitmap bitmap7 = numBitmaps.get("7"); if (bitmap7 != null) { bitmaps.add(bitmap7); } break; case '8': Bitmap bitmap8 = numBitmaps.get("8"); if (bitmap8 != null) { bitmaps.add(bitmap8); } break; case '9': Bitmap bitmap9 = numBitmaps.get("9"); if (bitmap9 != null) { bitmaps.add(bitmap9); } break; } } return buildBitmap(bitmaps); }