List of usage examples for java.util HashSet iterator
public Iterator<E> iterator()
From source file:com.tremolosecurity.proxy.ProxyRequest.java
@Override public Enumeration getParameterNames() { HashSet<String> paramListLocal = new HashSet<String>(); paramListLocal.addAll(this.paramList); for (NVP p : this.queryString) { if (!paramListLocal.contains(p.getName())) { paramListLocal.add(p.getName()); }// www. j a v a 2 s . c om } return new IteratorEnumeration(paramListLocal.iterator()); }
From source file:com.javadog.cgeowear.cgeoWearService.java
@Override public void onConnected(Bundle bundle) { //As soon as the Google APIs are connected, grab the connected Node ID new Thread(new Runnable() { @Override/*from w w w. j a v a2 s . c o m*/ public void run() { HashSet<String> connectedWearDevices = new HashSet<>(); NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await(); for (Node node : nodes.getNodes()) { connectedWearDevices.add(node.getId()); } try { connectedNodeId = connectedWearDevices.iterator().next(); } catch (NoSuchElementException e) { Log.wtf(DEBUG_TAG, "No paired devices found."); connectedNodeId = null; } } }).start(); }
From source file:prototype.TreeLayoutDemo.java
/** * /* w ww.ja v a 2s . c om*/ */ private void createTree() { //ReadXLSStructure xlsread = new ReadXLSStructure(); // HashSet Nodes = xlsread.returnNodes0_Links1(0, "C:\\Users\\frisch\\Desktop\\CRR_Off_Balance_Structure.xls"); // HashSet Links = xlsread.returnNodes0_Links1(1, "C:\\Users\\frisch\\Desktop\\CRR_Off_Balance_Structure.xls"); HashSet Links = new HashSet(); HashSet Nodes = new HashSet(); addNodes(Nodes, "C:\\Users\\frisch\\Desktop\\GFViewerData\\GFNodes.txt"); addLinks(Links, "C:\\Users\\frisch\\Desktop\\GFViewerData\\GFLinks.txt"); Iterator it = Nodes.iterator(); while (it.hasNext()) { graph.addVertex((String) it.next()); } it = Links.iterator(); while (it.hasNext()) { String dummy = (String) it.next(); String[] x = dummy.split("///"); graph.addEdge(edgeFactory.create(), x[0], x[1]); } /// // // graph.addVertex("V0"); // graph.addEdge(edgeFactory.create(), "V0", "V1"); // graph.addEdge(edgeFactory.create(), "V0", "V2"); // graph.addEdge(edgeFactory.create(), "V1", "V4"); // graph.addEdge(edgeFactory.create(), "V2", "V3"); // graph.addEdge(edgeFactory.create(), "V2", "V5"); // graph.addEdge(edgeFactory.create(), "V4", "V6"); // graph.addEdge(edgeFactory.create(), "V4", "V7"); // graph.addEdge(edgeFactory.create(), "V3", "V8"); // graph.addEdge(edgeFactory.create(), "V6", "V9"); // graph.addEdge(edgeFactory.create(), "V4", "V10"); // // graph.addVertex("A0"); // graph.addEdge(edgeFactory.create(), "A0", "A1"); // graph.addEdge(edgeFactory.create(), "A0", "A2"); // graph.addEdge(edgeFactory.create(), "A0", "A3"); // // graph.addVertex("B0"); // graph.addEdge(edgeFactory.create(), "B0", "B1"); // graph.addEdge(edgeFactory.create(), "B0", "B2"); // graph.addEdge(edgeFactory.create(), "B1", "B4"); // graph.addEdge(edgeFactory.create(), "B2", "B3"); // graph.addEdge(edgeFactory.create(), "B2", "B5"); // graph.addEdge(edgeFactory.create(), "B4", "B6"); // graph.addEdge(edgeFactory.create(), "B4", "B7"); // graph.addEdge(edgeFactory.create(), "B3", "B8"); // graph.addEdge(edgeFactory.create(), "B6", "B9"); }
From source file:de.suse.swamp.core.container.WorkflowManager.java
/** * Do a bulk load of workflow ids./* www . jav a2 s . c om*/ * If one of the workflows cannot be loaded, an exception is thrown. */ public List getWorkflows(HashSet ids) throws StorageException { List workflows = new ArrayList(); List idsToLoad = new ArrayList(); for (Iterator it = ids.iterator(); it.hasNext();) { Integer idObj = (Integer) it.next(); if (workflowCache.containsKey(idObj)) { workflows.add(workflowCache.get(idObj)); } else { idsToLoad.add(idObj); } } if (idsToLoad.size() > 0) { for (Iterator it = WorkflowStorage.loadWorkflows(idsToLoad).values().iterator(); it.hasNext();) { Workflow wf = (Workflow) it.next(); synchronized (workflowCache) { workflowCache.put(new Integer(wf.getId()), wf); workflows.add(wf); } } } return workflows; }
From source file:com.javadog.cgeowear.cgeoWear.java
@Override public void onConnected(Bundle bundle) { //As soon as the Google APIs are connected, grab the connected Node ID new Thread(new Runnable() { @Override/*from www . j a v a 2 s . co m*/ public void run() { HashSet<String> connectedWearDevices = new HashSet<String>(); NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await(); for (Node node : nodes.getNodes()) { connectedWearDevices.add(node.getId()); } try { connectedNodeId = connectedWearDevices.iterator().next(); } catch (NoSuchElementException e) { Log.wtf(DEBUG_TAG, "No paired devices found."); connectedNodeId = null; } } }).start(); }
From source file:org.jfree.data.xy.DefaultTableXYDataset.java
/** * Removes all x-values for which all the y-values are <code>null</code>. *///w w w. jav a 2 s . c o m public void prune() { HashSet hs = (HashSet) this.xPoints.clone(); Iterator iterator = hs.iterator(); while (iterator.hasNext()) { Number x = (Number) iterator.next(); if (canPrune(x)) { removeAllValuesForX(x); } } }
From source file:org.apache.tika.parser.ner.NamedEntityParserTest.java
@Test public void testParse() throws Exception { //test config is added to resources directory TikaConfig config = new TikaConfig(getClass().getResourceAsStream(CONFIG_FILE)); Tika tika = new Tika(config); JSONParser parser = new JSONParser(); String text = ""; HashMap<Integer, String> hmap = new HashMap<Integer, String>(); HashMap<String, HashMap<Integer, String>> outerhmap = new HashMap<String, HashMap<Integer, String>>(); int index = 0; //Input Directory Path String inputDirPath = "/Users/AravindMac/Desktop/polardata_json_grobid/application_pdf"; int count = 0; try {//from ww w .j a v a 2 s . c o m File root = new File(inputDirPath); File[] listDir = root.listFiles(); for (File filename : listDir) { if (!filename.getName().equals(".DS_Store") && count < 3573) { count += 1; System.out.println(count); String absoluteFilename = filename.getAbsolutePath().toString(); // System.out.println(absoluteFilename); //Read the json file, parse and retrieve the text present in the content field. Object obj = parser.parse(new FileReader(absoluteFilename)); BufferedWriter bw = new BufferedWriter(new FileWriter(new File(absoluteFilename))); JSONObject jsonObject = (JSONObject) obj; text = (String) jsonObject.get("content"); Metadata md = new Metadata(); tika.parse(new ByteArrayInputStream(text.getBytes()), md); //Parse the content and retrieve the values tagged as the NER entities HashSet<String> set = new HashSet<String>(); set.addAll(Arrays.asList(md.getValues("X-Parsed-By"))); // Store values tagged as NER_PERSON set.clear(); set.addAll(Arrays.asList(md.getValues("NER_PERSON"))); hmap = new HashMap<Integer, String>(); index = 0; for (Iterator<String> i = set.iterator(); i.hasNext();) { String f = i.next(); hmap.put(index, f); index++; } if (!hmap.isEmpty()) { outerhmap.put("PERSON", hmap); } // Store values tagged as NER_LOCATION set.clear(); set.addAll(Arrays.asList(md.getValues("NER_LOCATION"))); hmap = new HashMap<Integer, String>(); index = 0; for (Iterator<String> i = set.iterator(); i.hasNext();) { String f = i.next(); hmap.put(index, f); index++; } if (!hmap.isEmpty()) { outerhmap.put("LOCATION", hmap); } //Store values tagged as NER_ORGANIZATION set.clear(); set.addAll(Arrays.asList(md.getValues("NER_ORGANIZATION"))); hmap = new HashMap<Integer, String>(); index = 0; for (Iterator<String> i = set.iterator(); i.hasNext();) { String f = i.next(); hmap.put(index, f); index++; } if (!hmap.isEmpty()) { outerhmap.put("ORGANIZATION", hmap); } // Store values tagged as NER_DATE set.clear(); set.addAll(Arrays.asList(md.getValues("NER_DATE"))); hmap = new HashMap<Integer, String>(); index = 0; for (Iterator<String> i = set.iterator(); i.hasNext();) { String f = i.next(); hmap.put(index, f); index++; } if (!hmap.isEmpty()) { outerhmap.put("DATE", hmap); } JSONArray array = new JSONArray(); array.put(outerhmap); if (!outerhmap.isEmpty()) { jsonObject.put("OpenNLP", array); //Add the NER entities to the json under NER key as a JSON array. } System.out.println(jsonObject); bw.write(jsonObject.toJSONString()); //Stringify thr JSON and write it back to the file bw.close(); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.javadog.cgeowear.MobileService.java
@Override public void onConnected(Bundle bundle) { Log.d(DEBUG_TAG, "Connected to Play Services"); // Start tracking all requested info on the phone side locationUtils.startLocationTracking(apiClient); if (!useWatchCompass) { locationUtils.startDirectionalTracking(getApplicationContext()); }/*from w w w . j a v a 2 s . c o m*/ //Get ID of connected Wear device and send it the initial cache info (in another thread) new Thread(new Runnable() { @Override public void run() { HashSet<String> connectedWearDevices = new HashSet<>(); NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await(); for (Node node : nodes.getNodes()) { connectedWearDevices.add(node.getId()); } Message m = new Message(); try { wearInterface = new WearInterface(apiClient, connectedWearDevices.iterator().next()); wearInterface.initTracking(cacheName, geocode, 0f, 0f, useWatchCompass, geocacheLocation); m.obj = MESSAGE_NAVIGATING_NOW; } catch (ConnectException e) { Log.e(DEBUG_TAG, "Couldn't send initial tracking data."); m.obj = MESSAGE_ERROR_COMMUNICATING; } catch (NoSuchElementException e) { Log.e(DEBUG_TAG, "No Wear devices connected. Killing service..."); m.obj = MESSAGE_NO_WEAR_DEVICE; } finally { initThreadHandler.sendMessage(m); } } }).start(); }
From source file:com.vsct.dt.hesperides.templating.platform.PropertiesData.java
public MustacheScope toMustacheScope(Set<KeyValueValorisationData> instanceValorisations, Set<KeyValueValorisationData> platformValorisations, Boolean buildingFile) { if (instanceValorisations == null) { instanceValorisations = new HashSet<>(); }//from ww w . j a v a 2s . c o m if (platformValorisations == null) { platformValorisations = new HashSet<>(); } HashSet<ValorisationData> valorisations = new HashSet<>(); valorisations.addAll(keyValueProperties); valorisations.addAll(iterableProperties); if (platformValorisations != null) { /* addAll doesn't replace existing values, but we want to, so iterate */ for (KeyValueValorisationData v : platformValorisations) { //Remove local valorisation if it exists (ie has the same name even if the value is different) for (Iterator<ValorisationData> it = valorisations.iterator(); it.hasNext();) { ValorisationData existingValorisation = it.next(); if (existingValorisation.getName().equals(v.getName())) { it.remove(); } } valorisations.add(v); } } /* Prepare what will be injected in the values */ Map<String, String> injectableKeyValueValorisations = keyValueProperties.stream() .collect(Collectors.toMap(ValorisationData::getName, KeyValueValorisationData::getValue)); Map<String, String> injectablePlatformValorisations = platformValorisations.stream() .collect(Collectors.toMap(ValorisationData::getName, KeyValueValorisationData::getValue)); /* Erase local valorisations by platform valorisations */ injectableKeyValueValorisations.putAll(injectablePlatformValorisations); Map<String, String> injectableInstanceProperties = instanceValorisations.stream() .collect(Collectors.toMap(ValorisationData::getName, KeyValueValorisationData::getValue)); injectableKeyValueValorisations.replaceAll((key, value) -> value.replace("$", "\\$")); injectableInstanceProperties.replaceAll((key, value) -> value.replace("$", "\\$")); InjectableMustacheScope injectable = MustacheScope.from(valorisations) /* First re-inject keyValueValorisations, so they can refer to themselves */ .inject(injectableKeyValueValorisations) /* Do it a second time in case global properties where referring to themselves */ .inject(injectableKeyValueValorisations) /* Finally inject instance valorisations */ .inject(injectableInstanceProperties) /* Do it a third time in case instances properties where referring to global properties */ .inject(injectableKeyValueValorisations); MustacheScope mustacheScope = injectable.create(); if (mustacheScope.getMissingKeyValueProperties().size() > 0 && buildingFile) { Map<String, String> missing_valuation = new HashMap<>(); Set<KeyValuePropertyModel> missing = mustacheScope.getMissingKeyValueProperties(); missing.stream().forEach(prop -> { missing_valuation.put(prop.getName(), ""); }); mustacheScope = injectable.inject(missing_valuation).create(); } return mustacheScope; }
From source file:org.openflexo.foundation.ie.widget.IERadioButtonWidget.java
public void setValue(boolean value) { if (value != this._value && value && getGroupName() != null && !isDeserializing() && getWOComponent() != null) { HashSet<IERadioButtonWidget> v = getWOComponent().getRadioButtonManager().getButtons(this.groupName); if (v == null) { v = getWOComponent().getRadioButtonManager().registerButton(this, groupName); }//from ww w . j a v a2 s . c o m Iterator<IERadioButtonWidget> i = v.iterator(); while (i.hasNext()) { IERadioButtonWidget element = i.next(); if (element != this) { element.setValue(false); } } } this._value = value; if (!isDeserializing()) { setChanged(); notifyObservers(new DataModification(DataModification.ATTRIBUTE, ATTRIB_DEFAULTVALUE_NAME, null, null)); } }