List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:org.apache.nutch.webapp.common.BaseSearch.java
protected Collection setup(String xPoint, Configuration conf) { LOG.info("setting up:" + xPoint); HashMap filters = new HashMap(); try {/* w w w . j a v a 2 s . com*/ ExtensionPoint point = serviceLocator.getPluginRepository().getExtensionPoint(xPoint); if (point != null) { Extension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { Extension extension = extensions[i]; Object extensionInstance = extension.getExtensionInstance(); if (!filters.containsKey(extensionInstance.getClass().getName())) { filters.put(extensionInstance.getClass().getName(), extensionInstance); } } return filters.values(); } } catch (Exception e) { LOG.info("Error setting up extensions :" + e); } return Collections.EMPTY_LIST; }
From source file:uk.ac.horizon.ug.exploding.client.Client.java
public List<Object> getFacts(String typeName) { synchronized (facts) { LinkedList<Object> fs = new LinkedList<Object>(); HashMap<Object, Object> typeFacts = facts.get(typeName); if (typeFacts != null) { fs.addAll(typeFacts.values()); }/*from ww w . j av a 2 s . com*/ return fs; } }
From source file:dynamite.zafroshops.app.fragment.AllZopsFragment.java
private void setZops(boolean force) { Activity activity = getActivity();//w w w. ja v a 2s.c o m adapter = new AllZopsGridViewAdapter(activity, R.id.gridItem, types); final SharedPreferences preferences = activity.getPreferences(0); final SharedPreferences.Editor editor = preferences.edit(); if (!preferences.contains(StorageKeys.ZOPCATEGORY_KEY)) { InputStream is = getResources().openRawResource(R.raw.zops); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); HashMap<String, MobileZop> temp = new HashMap<>(); types = new ArrayList<>( (ArrayList<MobileZop>) new Gson().fromJson(reader, new TypeToken<ArrayList<MobileZop>>() { }.getType())); for (MobileZop type : types) { String key = type.Type.toString(); if (!temp.containsKey(key)) { temp.put(key, type); } } types = new ArrayList<>(temp.values()); if (adapter != null) { adapter.setObjects(types); adapter.notifyDataSetChanged(); } try { FileOutputStream fos = activity.openFileOutput(StorageKeys.ZOPCATEGORY_KEY, Context.MODE_PRIVATE); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(types); oos.close(); fos.close(); editor.putString(StorageKeys.ZOPCATEGORY_KEY, Integer.toString(types.size())); editor.commit(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { if (preferences.contains(StorageKeys.ZOPCATEGORY_KEY)) { try { FileInputStream fis = activity.openFileInput(StorageKeys.ZOPCATEGORY_KEY); ObjectInputStream ois = new ObjectInputStream(fis); types = (ArrayList) ois.readObject(); ois.close(); fis.close(); if (adapter != null) { adapter.setObjects(types); adapter.notifyDataSetChanged(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (StreamCorruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } ListenableFuture<JsonElement> result = MainActivity.MobileClient.invokeApi("mobileZop", "GET", new ArrayList<Pair<String, String>>() { { add(new Pair<String, String>("count", "true")); } }); Futures.addCallback(result, new FutureCallback<JsonElement>() { @Override public void onSuccess(JsonElement result) { Activity activity = getActivity(); JsonArray typesAsJson = result.getAsJsonArray(); if (typesAsJson != null) { types = new Gson().fromJson(result, new TypeToken<ArrayList<MobileZop>>() { }.getType()); try { FileOutputStream fos = activity.openFileOutput(StorageKeys.ZOPCATEGORY_KEY, Context.MODE_PRIVATE); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(types); oos.close(); fos.close(); editor.putString(StorageKeys.ZOPCATEGORY_KEY, Integer.toString(types.size())); editor.commit(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } if (adapter != null) { adapter.setObjects(types); GridView zops = (GridView) activity.findViewById(R.id.gridViewZops); RelativeLayout loader = (RelativeLayout) activity.findViewById(R.id.relativeLayoutLoader); loader.setVisibility(View.INVISIBLE); zops.setVisibility(View.VISIBLE); adapter.notifyDataSetChanged(); } } @Override public void onFailure(@NonNull Throwable t) { Activity activity = getActivity(); if (activity != null && types.size() == 0) { GridView zops = (GridView) activity.findViewById(R.id.gridViewZops); RelativeLayout loader = (RelativeLayout) activity.findViewById(R.id.relativeLayoutLoader); zops.setVisibility(View.INVISIBLE); loader.setVisibility(View.VISIBLE); } } }); } }
From source file:UI.CityMayor.CityMayorFrame.java
public HashMap sortHashMapByValuesD(HashMap passedMap) { List mapKeys = new ArrayList(passedMap.keySet()); List mapValues = new ArrayList(passedMap.values()); Collections.sort(mapValues);/* w w w.ja v a 2s. c om*/ Collections.sort(mapKeys); HashMap sortedMap = new HashMap(); Iterator valueIt = mapValues.iterator(); while (valueIt.hasNext()) { Object val = valueIt.next(); Iterator keyIt = mapKeys.iterator(); while (keyIt.hasNext()) { Object key = keyIt.next(); String comp1 = passedMap.get(key).toString(); String comp2 = val.toString(); if (comp1.equals(comp2)) { mapKeys.remove(key); sortedMap.put((String) key, (Integer) val); break; } } } return sortedMap; }
From source file:gov.nih.nci.cabig.caaers.service.synchronizer.StudyInterventionSynchronizer.java
public void migrate(Study dest, Study src, DomainObjectImportOutcome<Study> studyDomainObjectImportOutcome) { HashMap<String, OtherIntervention> map = new HashMap<String, OtherIntervention>(); for (OtherIntervention otherIntervention : dest.getActiveOtherInterventions()) { map.put(otherIntervention.getHashKey(), otherIntervention); }/*from w w w . j a v a2 s . c o m*/ for (OtherIntervention xmlOtherIntervention : src.getOtherInterventions()) { OtherIntervention otherIntervention = map.remove(xmlOtherIntervention.getHashKey()); if (otherIntervention == null) { //newly added one, so add it to study dest.addOtherIntervention(xmlOtherIntervention); continue; } //Update- do nothing } //now soft delete, all the ones not present in XML Study AbstractMutableRetireableDomainObject.retire(map.values()); // List<OtherIntervention> otherInterventions = src.getOtherInterventions(); // if (CollectionUtils.isEmpty(otherInterventions)) return; // Set<String> destInterventionsSet = new HashSet<String>(); // // for (OtherIntervention otherIntervention : dest.getOtherInterventions()) { // destInterventionsSet.add(otherIntervention.getHashKey()); // } // // for (OtherIntervention otherIntervention : otherInterventions) { // if (destInterventionsSet.add(otherIntervention.getHashKey())) { // dest.addOtherIntervention(otherIntervention); // } // } }
From source file:gov.nih.nci.protexpress.util.ExperimentToXar23FormatConversionHelper.java
private ExperimentArchiveType.ProtocolDefinitions getProtocolDefinitions( HashMap<Long, ExperimentRunHolder> expRunHolders, HashMap<Long, Protocol> protocols) { ExperimentArchiveType.ProtocolDefinitions xarProtocolDefinitionElement = getObjectFactory() .createExperimentArchiveTypeProtocolDefinitions(); // Add start/stop protocols for each experiment run. for (ExperimentRunHolder expRunHolder : expRunHolders.values()) { xarProtocolDefinitionElement.getProtocol() .add(getProtocolBaseTypeElement(expRunHolder.getStartProtocol(), CpasType.EXPERIMENT_RUN.getDisplayName(), expRunHolder.getStartProtocolLsidString())); xarProtocolDefinitionElement.getProtocol().add(getProtocolBaseTypeElement(expRunHolder.getEndProtocol(), CpasType.EXPERIMENT_RUN_OUTPUT.getDisplayName(), expRunHolder.getEndProtocolLsidString())); }/*w ww .j a va 2 s . c o m*/ for (Protocol protocol : protocols.values()) { xarProtocolDefinitionElement.getProtocol().add( getProtocolBaseTypeElement(protocol, CpasType.PROTOCOL_APPLICATION.getDisplayName(), null)); } return xarProtocolDefinitionElement; }
From source file:gridool.db.partitioning.phihash.DBPartitioningJob.java
@Override public GridTaskResultPolicy result(GridTaskResult result) throws GridException { final HashMap<GridNode, MutableLong> processed = result.getResult(); if (processed == null || processed.isEmpty()) { Exception err = result.getException(); if (err == null) { throw new GridException("failed to execute a task: " + result.getTaskId()); } else {/*www.ja v a2s .c om*/ throw new GridException("failed to execute a task: " + result.getTaskId(), err); } } if (LOG.isInfoEnabled()) { final long elapsed = System.currentTimeMillis() - started; final int numNodes = processed.size(); final long[] counts = new long[numNodes]; long maxRecords = -1L, minRecords = -1L; int i = 0; for (final MutableLong e : processed.values()) { long v = e.longValue(); numProcessed += v; counts[i++] = v; maxRecords = Math.max(v, maxRecords); minRecords = (minRecords == -1L) ? v : Math.min(v, minRecords); } double mean = numProcessed / numNodes; double sd = MathUtils.stddev(counts); double avg = numProcessed / numNodes; float percent = ((float) (sd / mean)) * 100.0f; LOG.info("Job executed in " + DateTimeFormatter.formatTime(elapsed) + ".\n\tSTDDEV of data distribution in " + numNodes + " nodes: " + sd + " (" + percent + "%)\n\tAverage records: " + PrintUtils.formatNumber(avg) + " [ total: " + numProcessed + ", max: " + maxRecords + ", min: " + minRecords + " ]"); } else { for (MutableLong e : processed.values()) { numProcessed += e.intValue(); } } return GridTaskResultPolicy.CONTINUE; }
From source file:edu.psu.citeseerx.misc.charts.CiteChartBuilderJFree.java
private XYDataset collectData(java.util.List<ThinDoc> docs) { Calendar now = Calendar.getInstance(); int currentYear = now.get(Calendar.YEAR); HashMap<Integer, DataPoint> data = new HashMap<Integer, DataPoint>(); for (ThinDoc doc : docs) { try {//from www .j ava 2 s.com Integer year = new Integer(doc.getYear()); if (year.intValue() < 1930 || year.intValue() > currentYear + 2) { continue; } DataPoint point; if (data.containsKey(year)) { point = data.get(year); } else { point = new DataPoint(year.intValue()); data.put(year, point); } point.ncites++; } catch (Exception e) { } } XYSeries series = new XYSeries("Years"); for (DataPoint point : data.values()) { System.out.println(point.year); System.out.println(point.ncites); series.add(point.year, point.ncites); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); return dataset; }
From source file:gov.utah.dts.sdc.actions.ThirdPartyStudentSearchAction.java
public String dbSearch() throws Exception { log.debug("...thirdparty dbSearch"); boolean studentExists = false; HashMap hm = new HashMap(); // Redmine 9505 third party (road tester). hm.put("firstName", "%" + currentStudent.getFirstName() + "%"); hm.put("lastName", "%" + currentStudent.getLastName() + "%"); hm.put("dob", currentStudent.getDob()); log.debug("...hm values = " + hm.values()); List list = getStudentService().getStudentList(hm); if (!list.isEmpty()) { studentExists = true;/* w ww. j av a2 s.com*/ if (list.size() == 1) { setCurrentStudent((Student) list.get(0)); } else { // multiple result - redmine 9505 high school // set school name in list setSchoolName(list); setStudentListSearchResult(list); return "multipleResult"; } } if (studentExists) { return SUCCESS; } else { addActionError("Student Not Found"); return INPUT; } }
From source file:org.apache.hadoop.hdfs.job.MyJob_20110926.java
public void stopJob(Job j) { LongWritable jobId = j.getJobId();/* w ww .j a v a 2 s. c o m*/ LOG.info("stop job : " + jobId); HashMap<Class<? extends JobProtocol>, RunJob> runJobs = this.jobIdtoRunJob.remove(jobId); if (runJobs == null) { LOG.info("job with id " + jobId + "has stoped!!!"); return; } else { for (RunJob runJob : runJobs.values()) { runJob.stop(); } if (this.nameNode != null && this.dataNode == null) { Thread stopJobThread; StopJob stopJob = new StopJob(j, this.nameNode, this.confg); stopJobThread = new Thread(stopJob); stopJobThread.start(); } } }