List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:org.apache.axis2.util.Utils.java
public static void calculateDefaultModuleVersion(HashMap modules, AxisConfiguration axisConfig) { Iterator allModules = modules.values().iterator(); Map<String, Version> defaultModules = new HashMap<String, Version>(); while (allModules.hasNext()) { AxisModule axisModule = (AxisModule) allModules.next(); String name = axisModule.getName(); Version currentDefaultVersion = defaultModules.get(name); Version version = axisModule.getVersion(); if (currentDefaultVersion == null || (version != null && version.compareTo(currentDefaultVersion) > 0)) { defaultModules.put(name, version); }/* w w w . j a v a2 s .c om*/ } Iterator def_mod_itr = defaultModules.keySet().iterator(); while (def_mod_itr.hasNext()) { String moduleName = (String) def_mod_itr.next(); Version version = defaultModules.get(moduleName); axisConfig.addDefaultModuleVersion(moduleName, version == null ? null : version.toString()); } }
From source file:com.morphoss.jumble.models.ModelParser.java
public static Collection<Category> readJsonData(String json) throws IOException, JSONException { JSONObject file = new JSONObject(json); JSONObject cats = file.getJSONObject("categories"); JSONObject Words = file.getJSONObject("words"); HashMap<Integer, Category> catMap = Category.getCategoriesFromJson(cats); HashMap<String, Word> words = Word.getWordFromJson(Words, catMap); HashMap<String, ArrayList<Localisation>> localisations = Localisation .getLocalisationFromJson(file.getJSONObject("localisations")); for (String cc : localisations.keySet()) { ArrayList<Localisation> locs = localisations.get(cc); for (Localisation loc : locs) { Word word = words.get(loc.getNameKey()); if (word != null) { word.addLocalisation(cc, loc); } else { Log.e(TAG, "Unable to find original word with name key: " + loc.getNameKey()); }/* w w w . jav a 2 s. com*/ } } return catMap.values(); }
From source file:org.apache.axis2.context.externalize.ActivateUtils.java
/** * Find the AxisOperation object that matches the criteria * //from ww w.j a v a2s. co m * @param axisConfig The AxisConfiguration object * @param opClassName the class name string for the target object * (could be a derived class) * @param opQName the name associated with the operation * @return the AxisOperation object that matches the given criteria */ public static AxisOperation findOperation(AxisConfiguration axisConfig, String opClassName, QName opQName) { HashMap services = axisConfig.getServices(); Iterator its = services.values().iterator(); while (its.hasNext()) { AxisService service = (AxisService) its.next(); Iterator ito = service.getOperations(); while (ito.hasNext()) { AxisOperation operation = (AxisOperation) ito.next(); String tmpOpName = operation.getClass().getName(); QName tmpOpQName = operation.getName(); if ((tmpOpName.equals(opClassName)) && (tmpOpQName.equals(opQName))) { // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findOperation(axisCfg): returning [" + opClassName + "] [" + opQName.toString() + "]"); } return operation; } } } // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findOperation(axisCfg): [" + opClassName + "] [" + opQName.toString() + "] returning [null]"); } return null; }
From source file:org.apache.hadoop.hdfs.server.common.JspHelper.java
public static DatanodeInfo bestNode(LocatedBlocks blks, Configuration conf) throws IOException { HashMap<DatanodeInfo, NodeRecord> map = new HashMap<>(); for (LocatedBlock block : blks.getLocatedBlocks()) { DatanodeInfo[] nodes = block.getLocations(); for (DatanodeInfo node : nodes) { NodeRecord record = map.get(node); if (record == null) { map.put(node, new NodeRecord(node, 1)); } else { record.frequency++;//w w w. j a va 2s. com } } } NodeRecord[] nodes = map.values().toArray(new NodeRecord[map.size()]); Arrays.sort(nodes, new NodeRecordComparator()); return bestNode(nodes, false); }
From source file:org.apache.axis2.context.externalize.ActivateUtils.java
public static AxisService findService(AxisConfiguration axisConfig, String serviceClassName, String serviceName, String extraName) {//from w w w . ja v a 2s . co m if (log.isDebugEnabled()) { log.debug("ActivateUtils.findService serviceName: " + serviceName + ", extraName: " + extraName); } HashMap services = axisConfig.getServices(); Iterator its = services.values().iterator(); // We loop through all the axis services looking for an exact match of the name, and if // it exists, the extra information of the fully qualified Service QName and the port // name. If we find an exact match, including the name of the service, we stop looking. // If no exact match is found after searching the entire list, then we use the first // match of the extra information we found. Note that picking the first one found is arbitrary. boolean exactServiceNameMatch = false; AxisService foundService = null; while (its.hasNext() && !exactServiceNameMatch) { AxisService service = (AxisService) its.next(); switch (checkAxisService(service, serviceClassName, serviceName, extraName)) { case NAME_MATCH: foundService = service; exactServiceNameMatch = true; break; case SERVICE_PORT_MATCH: if (foundService == null) { foundService = service; } break; case NONE: break; } } if (foundService != null) { // Store the original serviceName on the service for use in findServiceGroup // This is the name from when the service was originally externalized. try { foundService.addParameter(EXTERNALIZED_AXIS_SERVICE_NAME, serviceName); } catch (AxisFault e) { // I don't think this can actually ever happen. The exception occurs if the // parameter is locked, but this is the only code that references that parameter if (log.isDebugEnabled()) { log.debug("Got fault trying to add parameter " + EXTERNALIZED_AXIS_SERVICE_NAME + " for service name " + serviceName + " to AxisService " + foundService, e); } } if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findService(): returning [" + serviceClassName + "] [" + serviceName + "] AxisService name [" + foundService.getName() + "]"); } return foundService; } // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findService(): [" + serviceClassName + "] [" + serviceName + "] returning [null]"); } return null; }
From source file:org.apache.axis2.context.externalize.ActivateUtils.java
/** * Find the TransportListener object that matches the criteria * <p/>/*from w w w . j a v a 2s .com*/ * <B>Note<B> the saved meta information may not * match up with any of the objects that * are in the current AxisConfiguration object. * * @param axisConfig The AxisConfiguration object * @param listenerClassName the class name string for the target object * (could be a derived class) * @return the TransportListener object that matches the criteria */ public static TransportListener findTransportListener(AxisConfiguration axisConfig, String listenerClassName) { // TODO: investigate a better technique to match up with a TransportListener HashMap transportsIn = axisConfig.getTransportsIn(); // get a collection of the values in the map Collection values = transportsIn.values(); Iterator i = values.iterator(); while (i.hasNext()) { TransportInDescription ti = (TransportInDescription) i.next(); TransportListener tl = ti.getReceiver(); String tlClassName = tl.getClass().getName(); if (tlClassName.equals(listenerClassName)) { // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findTransportListener(): [" + listenerClassName + "] returned"); } return tl; } } // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findTransportListener(): returning [null]"); } return null; }
From source file:com.google.gwt.emultest.java.util.HashMapTest.java
/** * Check the state of a newly constructed, empty HashMap. * * @param hashMap// ww w . j a v a2 s .c o m */ private static void checkEmptyHashMapAssumptions(HashMap<?, ?> hashMap) { assertNotNull(hashMap); assertTrue(hashMap.isEmpty()); assertNotNull(hashMap.values()); assertTrue(hashMap.values().isEmpty()); assertTrue(hashMap.values().size() == 0); assertNotNull(hashMap.keySet()); assertTrue(hashMap.keySet().isEmpty()); assertTrue(hashMap.keySet().size() == 0); assertNotNull(hashMap.entrySet()); assertTrue(hashMap.entrySet().isEmpty()); assertTrue(hashMap.entrySet().size() == 0); assertEmptyIterator(hashMap.entrySet().iterator()); }
From source file:com.ibm.bi.dml.runtime.controlprogram.parfor.RemoteParForUtils.java
/** * // www . ja v a 2 s .c o m * @param out * @return * @throws DMLRuntimeException * @throws IOException */ public static LocalVariableMap[] getResults(List<Tuple2<Long, String>> out, Log LOG) throws DMLRuntimeException { HashMap<Long, LocalVariableMap> tmp = new HashMap<Long, LocalVariableMap>(); int countAll = 0; for (Tuple2<Long, String> entry : out) { Long key = entry._1(); String val = entry._2(); if (!tmp.containsKey(key)) tmp.put(key, new LocalVariableMap()); Object[] dat = ProgramConverter.parseDataObject(val); tmp.get(key).put((String) dat[0], (Data) dat[1]); countAll++; } if (LOG != null) { LOG.debug("Num remote worker results (before deduplication): " + countAll); LOG.debug("Num remote worker results: " + tmp.size()); } //create return array return tmp.values().toArray(new LocalVariableMap[0]); }
From source file:com.fpuna.preproceso.PreprocesoTS.java
/** * Metodo estatico que calcula los features * * @param sensor nombre del sensor a tener en cuenta * @param CantMuestras cantidad de muestras a tomar. *///from www. j a v a 2 s . co m public static void preProceso(HashMap<String, SessionTS> sessiones, String sensor, float ventanaTiempo) { // Anteriormente ventanaTiempo = cantMuestras List<Registro> muestras = new ArrayList<Registro>(); int cantR, cantTomados; int i; long TimeInicio, TimeFin; List<TrainingSetFeature> featureList = new ArrayList<TrainingSetFeature>(); //Extraer la cantidad de muestras del sensor for (SessionTS session : sessiones.values()) { Registro registros[] = Util.maf(session.getRegistros(), 5); cantTomados = 0; i = 0; TimeInicio = registros[0].getTiempo().getTime(); //Extraemos el primer timestamp para calcular luego las ventanas de tiempo System.out.println("*-*-*-*-*-*-*-* " + session.getActividad() + " *-*-*-*-*-*-*-*"); while (i < registros.length) { if (registros[i].getSensor().contentEquals(sensor)) { muestras.add(registros[i]); //Agregamos un registro TimeFin = registros[i].getTiempo().getTime(); cantTomados++; //System.out.println("Tomamos: " + cantTomados + " muestras"); if (ventanaTiempo <= ((float) (TimeFin - TimeInicio) / 1000.0)) { //calculoFeatures(muestras, session.getActividad()); featureList.add(calculoFeaturesMagnitud(muestras, session.getActividad())); TimeInicio = registros[i].getTiempo().getTime(); cantTomados = 0; muestras.clear(); } } i++; } } //Guarda los feature GuardarFeature(featureList); }
From source file:oculus.memex.rest.PreclusterDetailsResource.java
public static void getDetails(HashSet<Integer> ads, List<DataRow> results, String user_name) { StringBuffer adstring = new StringBuffer("("); boolean isFirst = true; for (Integer ads_id : ads) { if (isFirst) isFirst = false;/*from w ww .ja v a2 s . c o m*/ else adstring.append(","); adstring.append(ads_id); } adstring.append(")"); HashMap<Integer, DataRow> adDetails = new HashMap<Integer, DataRow>(); HashMap<Integer, HashSet<Pair<String, String>>> adKeywords = AdKeywords.getAdKeywords(adstring.toString()); MemexHTDB htdb = MemexHTDB.getInstance(); Connection htconn = htdb.open(); HashMap<Integer, String> sources = ClusterDetails.getSources(htconn); htdb.close(); getMainDetails(adKeywords, adDetails, sources, adstring); getExtraDetails(adDetails, adstring); getLocations(adDetails, adstring); getTags(adDetails, adstring, user_name); getImages(adDetails, adstring); for (DataRow row : adDetails.values()) { results.add(row); } }