List of usage examples for java.util HashMap clone
@SuppressWarnings("unchecked") @Override public Object clone()
From source file:com.ooyala.api.OoyalaApiClient.java
/** * Generate the URL including the authentication parameters * * @param methodType The HTTP Method/*from w ww . j a v a 2s . co m*/ * @param requestPath The request's path * @param parameters The query parameters * @param requestBody The string request body * @return * @throws NoSuchAlgorithmException * @throws IOException */ @SuppressWarnings("unchecked") private String generateURLWithAuthenticationParameters(HttpMethodType methodType, String requestPath, HashMap<String, String> parameters, String requestBody) throws NoSuchAlgorithmException, IOException { HashMap<String, String> parametersWithAuthentication = (HashMap<String, String>) parameters.clone(); String signature = signatureGenerator.generateSignature(methodType.toString(), requestPath, parametersWithAuthentication, requestBody, null); parametersWithAuthentication.put("signature", signature); return buildURL(methodType, requestPath, parametersWithAuthentication); }
From source file:HtmlCharacterEntities.java
/** * Creates a new CharacterEntityParser and initializes the parser with the * given set of entities.//from ww w.jav a 2 s. c o m * * @param characterEntities the entities used for the parser */ public CharacterEntityParser(final HashMap characterEntities) { if (characterEntities == null) { throw new NullPointerException("CharacterEntities must not be null"); } entities = (HashMap) characterEntities.clone(); charMap = new String[65536]; final Iterator entries = entities.entrySet().iterator(); while (entries.hasNext()) { final Map.Entry entry = (Map.Entry) entries.next(); final String value = (String) entry.getValue(); final String entityName = (String) entry.getKey(); if (value.length() != 1) { throw new IllegalStateException(); } charMap[value.charAt(0)] = entityName; } }
From source file:com.ooyala.api.OoyalaAPI.java
/** * Generate the URL including the authentication parameters * @param HTTPMethod The HTTP Method//from ww w. j a va 2s .c om * @param requestPath The request's path * @param parameters The query parameters * @param requestBody The string request body * @return * @throws NoSuchAlgorithmException * @throws IOException * @throws JsonMappingException * @throws JsonGenerationException */ @SuppressWarnings("unchecked") private String generateURLWithAuthenticationParameters(String HTTPMethod, String requestPath, HashMap<String, String> parameters, String requestBody) throws NoSuchAlgorithmException, IOException { HashMap<String, String> parametersWithAuthentication = (HashMap<String, String>) parameters.clone(); parametersWithAuthentication.put("api_key", apiKey); parametersWithAuthentication.put("expires", String.format("%d", getExpiration())); String signature = generateSignature(HTTPMethod.toUpperCase(), requestPath, parametersWithAuthentication, requestBody); log.d("Signature: " + signature); parametersWithAuthentication.put("signature", signature); return buildURL(HTTPMethod, requestPath, parametersWithAuthentication); }
From source file:com.google.gwt.emultest.java.util.HashMapTest.java
@SuppressWarnings("unchecked") private HashMap<String, String> cloneMap(HashMap<String, String> hashMap) { return (HashMap<String, String>) hashMap.clone(); }
From source file:com.k42b3.neodym.oauth.Oauth.java
@SuppressWarnings("unchecked") public void signRequest(HttpRequestBase request) throws Exception { // add values HashMap<String, String> values = new HashMap<String, String>(); HashMap<String, String> auth; values.put("oauth_consumer_key", this.provider.getConsumerKey()); values.put("oauth_token", this.token); values.put("oauth_signature_method", provider.getMethod()); values.put("oauth_timestamp", this.getTimestamp()); values.put("oauth_nonce", this.getNonce()); auth = (HashMap<String, String>) values.clone(); // add get vars to values values.putAll(parseQuery(request.getURI().getQuery())); // build base string String baseString = this.buildBaseString(request.getMethod(), request.getURI().toString(), values); // get signature SignatureInterface signature = this.getSignature(); if (signature == null) { throw new Exception("Invalid signature method"); }/*from w w w . j ava2s. c o m*/ // build signature auth.put("oauth_signature", signature.build(baseString, provider.getConsumerSecret(), this.tokenSecret)); // add header to request request.addHeader("Authorization", "OAuth realm=\"neodym\", " + this.buildAuthString(auth)); }
From source file:org.openbravo.erpCommon.modules.ImportModule.java
private static void addParentUpdates(HashMap<String, String> updates, ConnectionProvider conn) { @SuppressWarnings("unchecked") final HashMap<String, String> iniUpdates = (HashMap<String, String>) updates.clone(); for (final String node : iniUpdates.keySet()) { addParentNode(node, updates, iniUpdates, conn); }//from ww w . j a v a 2 s.c o m }
From source file:adminviews.MCCView.java
@SuppressWarnings("unchecked") private List<List<ISampleBean>> prepDefaultMCCSamples() { String timepoint = this.timepoint.getValue(); String treatment = this.treatment.getValue(); String patient = this.patient.getValue(); List<List<ISampleBean>> res = new ArrayList<List<ISampleBean>>(); List<ISampleBean> patients = new ArrayList<ISampleBean>(); List<ISampleBean> urine = new ArrayList<ISampleBean>(); List<ISampleBean> uAliquots = new ArrayList<ISampleBean>(); List<ISampleBean> liver = new ArrayList<ISampleBean>(); List<ISampleBean> plasma = new ArrayList<ISampleBean>(); List<ISampleBean> pAliquots = new ArrayList<ISampleBean>(); List<ISampleBean> molecules = new ArrayList<ISampleBean>(); String project = (String) mccProjects.getValue(); if (!newProject.isEmpty()) project = newProject.getValue(); String patientID = project + "ENTITY-" + patient;// new parent if (patient.length() < 2) patient = "0" + patient; String patientExtID = treatment.substring(0, 1).toUpperCase() + ":" + patient; HashMap<String, Object> metadata = new HashMap<String, Object>(); // if new patient, add to samples to register if (!this.patients.contains(patientExtID)) { metadata.put("Q_EXTERNALDB_ID", patientExtID); metadata.put("Q_NCBI_ORGANISM", "9606"); patients.add(new TSVSampleBean(patientID, project + "E1", project, mccSpace, "Q_BIOLOGICAL_ENTITY", "patient #" + patient, "", metadata)); }//from w w w . j av a 2 s. com String extIDBase = patientExtID + ":" + timepoint + ":"; String urineExtIDBase = extIDBase + "U:1"; metadata = new HashMap<String, Object>(); metadata.put("XML_FACTORS", "treatment: " + treatment + "; timepoint: evaluation #" + timepoint); metadata.put("Q_PRIMARY_TISSUE", "URINE"); metadata.put("Q_EXTERNALDB_ID", urineExtIDBase); String urineID = counter.getNewBarcode();// parent urine.add(new TSVSampleBean(urineID, project + "E2", project, mccSpace, "Q_BIOLOGICAL_SAMPLE", "urine sample", patientID, (HashMap<String, Object>) metadata.clone())); for (int i = 1; i < 6; i++) { char lower = (char) ('a' + i - 1); String ID = counter.getNewBarcode(); metadata.put("Q_EXTERNALDB_ID", urineExtIDBase + lower); uAliquots.add(new TSVSampleBean(ID, project + "E3", project, mccSpace, "Q_BIOLOGICAL_SAMPLE", "aliquot #" + i, urineID, (HashMap<String, Object>) metadata.clone())); } for (int i = 1; i < 4; i++) { String plasmaExtID = extIDBase + "B:" + i; String plasmaID = counter.getNewBarcode();// parent metadata.put("Q_EXTERNALDB_ID", plasmaExtID); metadata.put("Q_PRIMARY_TISSUE", "BLOOD_PLASMA"); plasma.add(new TSVSampleBean(plasmaID, project + "E4", project, mccSpace, "Q_BIOLOGICAL_SAMPLE", "EDTA plasma #" + i, patientID, (HashMap<String, Object>) metadata.clone())); if (i == 1) { for (int j = 1; j < 3; j++) { char lower = (char) ('a' + j - 1); String ID = counter.getNewBarcode(); metadata.put("Q_EXTERNALDB_ID", plasmaExtID + lower); pAliquots.add(new TSVSampleBean(ID, project + "E4", project, mccSpace, "Q_BIOLOGICAL_SAMPLE", "plasma aliquot #" + j, plasmaID, (HashMap<String, Object>) metadata.clone())); } } if (i == 3) { metadata.remove("Q_PRIMARY_TISSUE"); for (int j = 1; j < 5; j++) { char lower = (char) ('a' + j - 1); String ID = counter.getNewBarcode(); metadata.put("Q_EXTERNALDB_ID", plasmaExtID + lower); metadata.put("Q_SAMPLE_TYPE", "SMALLMOLECULES"); molecules.add(new TSVSampleBean(ID, project + "E5", project, mccSpace, "Q_TEST_SAMPLE", "cryovial #" + j, plasmaID, (HashMap<String, Object>) metadata.clone())); } metadata.remove("Q_SAMPLE_TYPE"); } } String tumorExtBase = extIDBase + "T"; for (int i = 1; i < 9; i++) { String ID = counter.getNewBarcode(); metadata.put("Q_EXTERNALDB_ID", tumorExtBase + i); metadata.put("Q_PRIMARY_TISSUE", "HEPATOCELLULAR_CARCINOMA"); liver.add(new TSVSampleBean(ID, project + "E6", project, mccSpace, "Q_BIOLOGICAL_SAMPLE", "tumor biopsy #" + i, patientID, (HashMap<String, Object>) metadata.clone())); } String liverExtBase = extIDBase + "L"; for (int i = 1; i < 5; i++) { String ID = counter.getNewBarcode(); metadata.put("Q_EXTERNALDB_ID", liverExtBase + i); metadata.put("Q_PRIMARY_TISSUE", "LIVER"); liver.add(new TSVSampleBean(ID, project + "E6", project, mccSpace, "Q_BIOLOGICAL_SAMPLE", "liver biopsy #" + i, patientID, (HashMap<String, Object>) metadata.clone())); } List<List<ISampleBean>> dummy = new ArrayList<List<ISampleBean>>( Arrays.asList(patients, urine, uAliquots, plasma, pAliquots, molecules, liver)); for (List<ISampleBean> l : dummy) if (l.size() > 0) res.add(l); return res; }
From source file:com.hangum.tadpole.rdb.core.editors.table.TableViewerEditPart.java
/** * ?? ./* ww w. j a v a2s .c om*/ * * 1) ResultSetMetaData ?? ? . * * @param requestQuery * @param startResultPos * @param endResultPos */ private void runSQLSelect(String whereSQL) throws Exception { String requestQuery = "SELECT * FROM " + initTableNameStr; //$NON-NLS-1$ if (!"".equals(whereSQL)) { //$NON-NLS-1$ requestQuery += " where " + whereSQL; //$NON-NLS-1$ } // . // // // // // if(DBDefine.MSSQL_DEFAULT != DBDefine.getDBDefine(userDB.getTypes())) { requestQuery = PartQueryUtil.makeSelect(userDB, requestQuery, 0, 500); // } else { // requestQuery = requestQuery + " top 500"; // } ResultSet rs = null; java.sql.Connection javaConn = null; try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); PreparedStatement stmt = null; stmt = javaConn.prepareStatement(requestQuery); rs = stmt.executeQuery();//Query( selText ); // table column? ResultSetMetaData rsm = rs.getMetaData(); int columnCount = rsm.getColumnCount(); for (int i = 0; i < rsm.getColumnCount(); i++) { // if(logger.isDebugEnabled()) logger.debug(i + "[type]" + rsm.getColumnClassName(i+1) ); //$NON-NLS-1$ tableDataTypeList.put(i, rsm.getColumnClassName(i + 1)); } // rs set? ?? tableDataList = new ArrayList<HashMap<Integer, Object>>(); originalDataList = new ArrayList<HashMap<Integer, Object>>(); HashMap<Integer, Object> tmpRs = null; mapColumns = SQLUtil.mataDataToMap(rs); while (rs.next()) { tmpRs = new HashMap<Integer, Object>(); /** column modify info */ tmpRs.put(0, TbUtils.COLUMN_MOD_TYPE.NONE.toString()); for (int i = 1; i < columnCount + 1; i++) { try { tmpRs.put(i, XMLUtils.xmlToString(rs.getString(i) == null ? "" : rs.getString(i))); } catch (Exception e) { logger.error("ResutSet fetch error", e); tmpRs.put(i, ""); } } tableDataList.add(tmpRs); // ?? update where . HashMap<Integer, Object> clondRs = (HashMap<Integer, Object>) tmpRs.clone(); originalDataList.add(clondRs); } } finally { try { rs.close(); } catch (Exception e) { } try { javaConn.close(); } catch (Exception e) { } } }
From source file:org.talend.dataprofiler.core.ui.editor.indicator.IndicatorDefinitionMaterPage.java
/** * clone Expression./*w w w.j ava 2 s .c o m*/ * * @param exp * @return */ public static final TdExpression cloneExpression(TdExpression exp) { if (exp == null) { return null; } TdExpression copy = EcoreUtil.copy(exp); HashMap<String, String> expressionVariableMap = exp.getExpressionVariableMap(); if (expressionVariableMap != null) { copy.setExpressionVariableMap((HashMap<String, String>) expressionVariableMap.clone()); } return copy; }