List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:gov.nih.nci.protexpress.util.ExperimentToXar23FormatConversionHelper.java
private ExperimentArchiveType.StartingInputDefinitions getStartingInputDefinitions( HashMap<Long, InputOutputObject> startingInputs) { ExperimentArchiveType.StartingInputDefinitions xarStartingInputDefnElement = getObjectFactory() .createExperimentArchiveTypeStartingInputDefinitions(); for (InputOutputObject input : startingInputs.values()) { if (StringUtils.isNotBlank(input.getDataFileURL())) { DataBaseType xarDataBaseTypeElement = getDataBaseTypeElement(input); xarStartingInputDefnElement.getData().add(xarDataBaseTypeElement); } else {//from w w w.j av a 2s . c om MaterialBaseType xarMaterialBaseTypeElement = getMaterialBaseTypeElement(input); xarStartingInputDefnElement.getMaterial().add(xarMaterialBaseTypeElement); } } return xarStartingInputDefnElement; }
From source file:com.grupohqh.carservices.operator.ManipulateCarActivity.java
@Override public void onResume() { super.onResume(); new LoadCarBrandsAsyncTask().execute(CARBRAND_URL); if (useMiniMe) { txtStatus.setText("desconectado"); try {/*ww w . j av a 2s. c o m*/ HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); while (deviceIterator.hasNext()) { UsbDevice device = deviceIterator.next(); if (device.getProductId() == PID && device.getVendorId() == VID) if (!manager.hasPermission(device)) { txtStatus.setText("sin permisos"); manager.requestPermission(device, PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0)); break; } else { txtStatus.setText("conectado"); } } } catch (Exception e) { Log.d("USB error", e.getMessage()); } } }
From source file:ch.unibas.fittingwizard.application.tools.charges.ChargesFileParser.java
private List<OutputAtomType> createTypes(List<ChargeValue> chargeLines) { HashMap<AtomTypeId, OutputAtomType> typeValues = new HashMap<>(); for (ChargeValue chargeLine : chargeLines) { OutputAtomType atomType = typeValues.get(chargeLine.getAtomTypeId()); ChargeValue chargeValue = new ChargeValue(chargeLine.getAtomTypeId(), chargeLine.getType(), chargeLine.getValue());//from w w w . j a va 2 s . com if (atomType == null) { atomType = new OutputAtomType(chargeLine.getAtomTypeId(), Arrays.asList(chargeValue)); typeValues.put(chargeLine.getAtomTypeId(), atomType); } else { atomType.getChargeValues().add(chargeValue); } } return new ArrayList<>(typeValues.values()); }
From source file:org.apache.nutch.net.URLNormalizers.java
/** * searches a list of suitable url normalizer plugins for the given scope. * /*from ww w . j a v a2 s . c om*/ * @param scope * Scope for which we seek a url normalizer plugin. * @return List - List of extensions to be used for this scope. If none, * returns null. * @throws PluginRuntimeException */ private List<Extension> findExtensions(String scope) { String[] orders = null; String orderlist = conf.get("urlnormalizer.order." + scope); if (orderlist == null) orderlist = conf.get("urlnormalizer.order"); if (orderlist != null && !orderlist.trim().equals("")) { orders = orderlist.split("\\s+"); } String scopelist = conf.get("urlnormalizer.scope." + scope); Set<String> impls = null; if (scopelist != null && !scopelist.trim().equals("")) { String[] names = scopelist.split("\\s+"); impls = new HashSet<String>(Arrays.asList(names)); } Extension[] extensions = this.extensionPoint.getExtensions(); HashMap<String, Extension> normalizerExtensions = new HashMap<String, Extension>(); for (int i = 0; i < extensions.length; i++) { Extension extension = extensions[i]; if (impls != null && !impls.contains(extension.getClazz())) continue; normalizerExtensions.put(extension.getClazz(), extension); } List<Extension> res = new ArrayList<Extension>(); if (orders == null) { res.addAll(normalizerExtensions.values()); } else { // first add those explicitly named in correct order for (int i = 0; i < orders.length; i++) { Extension e = normalizerExtensions.get(orders[i]); if (e != null) { res.add(e); normalizerExtensions.remove(orders[i]); } } // then add all others in random order res.addAll(normalizerExtensions.values()); } return res; }
From source file:fr.arnaudguyon.xmltojsonlib.XmlToJson.java
private JSONObject convertTagToJson(Tag tag, boolean isListElement) { JSONObject json = new JSONObject(); // Content is injected as a key/value if (tag.getContent() != null) { String path = tag.getPath(); String name = getContentNameReplacement(path, DEFAULT_CONTENT_NAME); putContent(path, json, name, tag.getContent()); }// ww w . ja va 2 s . c o m try { HashMap<String, ArrayList<Tag>> groups = tag.getGroupedElements(); // groups by tag names so that we can detect lists or single elements for (ArrayList<Tag> group : groups.values()) { if (group.size() == 1) { // element, or list of 1 Tag child = group.get(0); if (isForcedList(child)) { // list of 1 JSONArray list = new JSONArray(); list.put(convertTagToJson(child, true)); String childrenNames = child.getName(); json.put(childrenNames, list); } else { // stand alone element if (child.hasChildren()) { JSONObject jsonChild = convertTagToJson(child, false); json.put(child.getName(), jsonChild); } else { String path = child.getPath(); putContent(path, json, child.getName(), child.getContent()); } } } else { // list JSONArray list = new JSONArray(); for (Tag child : group) { list.put(convertTagToJson(child, true)); } String childrenNames = group.get(0).getName(); json.put(childrenNames, list); } } return json; } catch (JSONException e) { e.printStackTrace(); } return null; }
From source file:hd3gtv.mydmam.useraction.fileoperation.UAFileOperationTrash.java
public void process(JobProgression progression, UserProfile userprofile, UAConfigurator user_configuration, HashMap<String, SourcePathIndexerElement> source_elements) throws Exception { String user_base_directory_name = userprofile.getBaseFileName_BasedOnEMail(); if (trash_directory_name == null) { trash_directory_name = "Trash"; }/*from w w w .j a v a2 s . c o m*/ Log2Dump dump = new Log2Dump(); dump.add("user", userprofile.key); dump.add("trash_directory_name", trash_directory_name); dump.add("user_base_directory_name", user_base_directory_name); dump.add("source_elements", source_elements.values()); Log2.log.debug("Prepare trash", dump); progression.update("Prepare trashs directories"); File current_user_trash_dir; HashMap<String, File> trashs_dirs = new HashMap<String, File>(); for (Map.Entry<String, SourcePathIndexerElement> entry : source_elements.entrySet()) { String storagename = entry.getValue().storagename; if (trashs_dirs.containsKey(storagename)) { continue; } File storage_dir = Explorer .getLocalBridgedElement(SourcePathIndexerElement.prepareStorageElement(storagename)); current_user_trash_dir = new File(storage_dir.getPath() + File.separator + trash_directory_name + File.separator + user_base_directory_name); if (current_user_trash_dir.exists() == false) { FileUtils.forceMkdir(current_user_trash_dir); } else { CopyMove.checkExistsCanRead(current_user_trash_dir); CopyMove.checkIsWritable(current_user_trash_dir); CopyMove.checkIsDirectory(current_user_trash_dir); } trashs_dirs.put(storagename, current_user_trash_dir); if (stop) { return; } } progression.update("Move item(s) to trash(s) directorie(s)"); progression.updateStep(1, source_elements.size()); Date now = new Date(); for (Map.Entry<String, SourcePathIndexerElement> entry : source_elements.entrySet()) { progression.incrStep(); File current_element = Explorer.getLocalBridgedElement(entry.getValue()); CopyMove.checkExistsCanRead(current_element); CopyMove.checkIsWritable(current_element); current_user_trash_dir = trashs_dirs.get(entry.getValue().storagename); File f_destination = new File(current_user_trash_dir.getPath() + File.separator + simpledateformat.format(now) + "_" + current_element.getName()); if (current_element.isDirectory()) { FileUtils.moveDirectory(current_element, f_destination); } else { FileUtils.moveFile(current_element, f_destination); } if (stop) { return; } ContainerOperations.copyMoveMetadatas(entry.getValue(), entry.getValue().storagename, "/" + trash_directory_name + "/" + user_base_directory_name, false, this); ElasticsearchBulkOperation bulk = Elasticsearch.prepareBulk(); explorer.deleteStoragePath(bulk, Arrays.asList(entry.getValue())); bulk.terminateBulk(); if (stop) { return; } } ElasticsearchBulkOperation bulk = Elasticsearch.prepareBulk(); ArrayList<SourcePathIndexerElement> spie_trashs_dirs = new ArrayList<SourcePathIndexerElement>(); for (String storage_name : trashs_dirs.keySet()) { SourcePathIndexerElement root_trash_directory = SourcePathIndexerElement .prepareStorageElement(storage_name); root_trash_directory.parentpath = root_trash_directory.prepare_key(); root_trash_directory.directory = true; root_trash_directory.currentpath = "/" + trash_directory_name; spie_trashs_dirs.add(root_trash_directory); } explorer.refreshStoragePath(bulk, spie_trashs_dirs, false); bulk.terminateBulk(); }
From source file:de.tudarmstadt.ukp.dkpro.core.io.conll.Conll2002Writer.java
private void convert(JCas aJCas, PrintWriter aOut) { Type neType = JCasUtil.getType(aJCas, NamedEntity.class); Feature neValue = neType.getFeatureByBaseName("value"); for (Sentence sentence : select(aJCas, Sentence.class)) { HashMap<Token, Row> ctokens = new LinkedHashMap<Token, Row>(); // Tokens List<Token> tokens = selectCovered(Token.class, sentence); // Chunks IobEncoder encoder = new IobEncoder(aJCas.getCas(), neType, neValue); for (int i = 0; i < tokens.size(); i++) { Row row = new Row(); row.id = i + 1;/* www. ja v a 2 s .c om*/ row.token = tokens.get(i); row.ne = encoder.encode(tokens.get(i)); ctokens.put(row.token, row); } // Write sentence in CONLL 2006 format for (Row row : ctokens.values()) { String chunk = UNUSED; if (writeNamedEntity && (row.ne != null)) { chunk = encoder.encode(row.token); } aOut.printf("%s %s\n", row.token.getCoveredText(), chunk); } aOut.println(); } }
From source file:gov.nih.nci.protexpress.util.ExperimentToXar23FormatConversionHelper.java
private ExperimentArchiveType.ProtocolActionDefinitions getProtocolActionDefinitions( HashMap<Long, ExperimentRunHolder> experimentRunHolders) { ExperimentArchiveType.ProtocolActionDefinitions xarProtocolActionDefsElement = getObjectFactory() .createExperimentArchiveTypeProtocolActionDefinitions(); for (ExperimentRunHolder expRunHolder : experimentRunHolders.values()) { xarProtocolActionDefsElement.getProtocolActionSet().add(getProtocolActionSetTypeElement(expRunHolder)); }/*w ww. ja v a 2 s . com*/ return xarProtocolActionDefsElement; }
From source file:edu.utexas.cs.tactex.tariffoptimization.TariffOptimizierTOUFixedMargin.java
private TotalEnergyRecords sumTotalEnergy(HashMap<CustomerInfo, ArrayRealVector> customer2estimatedEnergy, HashMap<TariffSpecification, HashMap<CustomerInfo, Integer>> tariffSubscriptions, int currentTimeslot) { List<TariffSpecification> allSpecs = new ArrayList<TariffSpecification>(); allSpecs.addAll(tariffSubscriptions.keySet()); HashMap<CustomerInfo, HashMap<TariffSpecification, ShiftedEnergyData>> customer2ShiftedEnergy = estimateShiftedPredictions( customer2estimatedEnergy, allSpecs, currentTimeslot); int predictionRecordLength = customer2estimatedEnergy.values().iterator().next().getDimension(); ArrayRealVector predictedMyCustomersEnergy = new ArrayRealVector(predictionRecordLength); // we currently predict cost by total amount of energy ////from www. j a va2s . c o m for (Entry<TariffSpecification, HashMap<CustomerInfo, Integer>> entry : tariffSubscriptions.entrySet()) { TariffSpecification spec = entry.getKey(); for (Entry<CustomerInfo, Integer> e : entry.getValue().entrySet()) { CustomerInfo customer = e.getKey(); int subs = e.getValue(); RealVector customerEnergy = customer2ShiftedEnergy.get(customer).get(spec).getShiftedEnergy() .mapMultiply(subs); predictedMyCustomersEnergy = predictedMyCustomersEnergy.add(customerEnergy); } } // competitor energy prediction ArrayRealVector predictedCompetitorsEnergyRecord = new ArrayRealVector(predictionRecordLength); HashMap<CustomerInfo, HashMap<TariffSpecification, Integer>> predictedCustomerSubscriptions = BrokerUtils .revertKeyMapping(tariffSubscriptions); for (CustomerInfo cust : predictedCustomerSubscriptions.keySet()) { double subsToOthers = cust.getPopulation() - BrokerUtils.sumMapValues(predictedCustomerSubscriptions.get(cust)); RealVector customerNonShiftedEnergy = customer2estimatedEnergy.get(cust).mapMultiply(subsToOthers); predictedCompetitorsEnergyRecord = predictedCompetitorsEnergyRecord.add(customerNonShiftedEnergy); } log.debug("predictedMyCustomersEnergy =" + predictedMyCustomersEnergy.toString()); log.debug("predictedCompetitorsEnergyRecord =" + predictedCompetitorsEnergyRecord.toString()); return new TotalEnergyRecords(predictedMyCustomersEnergy, predictedCompetitorsEnergyRecord); }
From source file:fr.bmartel.android.fadecandy.service.FadecandyService.java
/** * initialize usb device list to request permission if not already given for already connected USB devices. */// www . j a v a 2s . co m private void initUsbDeviceList() { mUsbDevices.clear(); HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); while (deviceIterator.hasNext()) { UsbDevice device = deviceIterator.next(); if (device.getVendorId() == Constants.FC_VENDOR && device.getProductId() == Constants.FC_PRODUCT) { dispatchAttached(device); } } }