List of usage examples for java.util ArrayList iterator
public Iterator<E> iterator()
From source file:com.vangent.hieos.authutil.ldap.LDAPAuthenticationHandler.java
/** * * @param userAttrs//from w w w . jav a 2 s .c o m * @return */ private List<Role> getRoles(Map userAttrs) { ArrayList ldapRoles = (ArrayList) userAttrs.get("memberOf"); List<Role> roles = new ArrayList<Role>(); Iterator rolesIt = ldapRoles.iterator(); while (rolesIt.hasNext()) { String roleName = (String) rolesIt.next(); Role role = new Role(roleName); roles.add(role); } return roles; }
From source file:gr.ntua.ivml.awareness.search.SearchServiceAccess.java
public BasicDBObject searchEuropeana(String originalTerm, String type, int startPage) throws Exception { String[] termsarray = originalTerm.split(" "); List terms = Arrays.asList(termsarray); URI uri = constructURI(terms, type, startPage - 1); httpGet = new HttpGet(uri); BasicDBObject response = new BasicDBObject(); httpRes = httpClient.execute(httpGet); httpEntity = httpRes.getEntity();//from w w w. j av a 2s .c o m ByteArrayOutputStream out = new ByteArrayOutputStream(); httpEntity.writeTo(out); String resp = new String(out.toByteArray(), "UTF-8"); BasicDBObject obj = (BasicDBObject) JSON.parse(resp); response.put("itemsCount", obj.getString("itemsCount")); response.put("totalResults", obj.getString("totalResults")); response.put("term", originalTerm); response.put("type", type); response.put("pageNumber", startPage); @SuppressWarnings("unchecked") ArrayList<Object> items = (ArrayList<Object>) obj.get("items"); if (items != null) { Iterator<Object> it = items.iterator(); ArrayList<BasicDBObject> responseItems = new ArrayList<BasicDBObject>(); while (it.hasNext()) { BasicDBObject tmp = (BasicDBObject) it.next(); BasicDBObject re = new BasicDBObject(); String recid = tmp.getString("id"); re.put("europeanaid", recid); re.put("type", tmp.getString("type")); re.put("source", tmp.getString("guid")); BasicDBList titleslist = (BasicDBList) tmp.get("title"); if (titleslist != null) re.put("title", StringUtils.join(titleslist, ',')); BasicDBList providerslist = (BasicDBList) tmp.get("dataProvider"); if (providerslist != null) re.put("dataProvider", providerslist.get(0)); providerslist = (BasicDBList) tmp.get("provider"); if (providerslist != null) re.put("provider", providerslist.get(0)); BasicDBList creatorlist = (BasicDBList) tmp.get("dcCreator"); if (creatorlist != null) re.put("dcCreator", creatorlist.get(0)); BasicDBList languagelist = (BasicDBList) tmp.get("language"); if (languagelist != null) re.put("language", languagelist.get(0)); BasicDBList thumbslist = (BasicDBList) tmp.get("edmPreview"); if (thumbslist != null) re.put("url", thumbslist.get(0)); BasicDBList rightslist = (BasicDBList) tmp.get("rights"); if (rightslist != null) re.put("license", rightslist.get(0)); responseItems.add(re); } response.put("items", responseItems); } return response; }
From source file:de.klemp.middleware.controller.Controller.java
/** * This method is used by all methods of the first component. Every method * has to inform the controller about the class, the method belongs to, the * name of the method and the name of the input device. The method searches * the methods of the second component, which were defined by the GUI, and * invokes them.//ww w . j a va 2 s . c o m * * @param klasse * class the method belongs to * @param method * name of the method * @param name * name of the input device */ public static void informController(String klasse, String method, String name) { isBrokerStarted(); System.out.println("controller informed"); ArrayList<MethodToInvoke> list = controller.get(klasse + "," + method + "," + name); if (list != null) { Iterator iterator = list.iterator(); while (iterator.hasNext()) { MethodToInvoke m = (MethodToInvoke) iterator.next(); System.out.println("controller informed" + m.getdata()); boolean active = deviceActive.get(m.getClasses() + "," + m.getTopic()); if (active) { Method m2 = m.getMethod(); String data = m.getdata(); if (data.equals("")) { Object[] parameterWithoutdata = new Object[3]; parameterWithoutdata[0] = klasse; parameterWithoutdata[1] = name; parameterWithoutdata[2] = m.getTopic(); try { m2.invoke(null, parameterWithoutdata); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { logger.error("Method could not be invoced", e); } } if (!data.equals("Sensor")) { Object[] parameter = new Object[4]; parameter[0] = klasse; parameter[1] = name; Structure data2 = structures.get(data); if (data2 != null) { parameter[2] = data2; parameter[3] = m.getTopic(); try { m2.invoke(null, parameter); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { logger.error("Method of component2 could not be invoked", e); } } } } } } }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.MultiAxesCrosshairOverlay.java
@Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea);//from w w w . j av a 2s . co m JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); Iterator iterator = this.getDomainCrosshairs().iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double x = ch.getValue(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawVerticalCrosshair(g2, dataArea, xx, ch); } else { drawHorizontalCrosshair(g2, dataArea, xx, ch); } } } int rangeAxisIdx = 0; for (ArrayList<Crosshair> crosshairsForRange : rangeCrosshairs) { ValueAxis yAxis = plot.getRangeAxis(rangeAxisIdx); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(rangeAxisIdx); iterator = crosshairsForRange.iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double y = ch.getValue(); double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawHorizontalCrosshair(g2, dataArea, yy, ch); } else { drawVerticalCrosshair(g2, dataArea, yy, ch); } } } g2.setClip(savedClip); ++rangeAxisIdx; } }
From source file:com.dat255.ht13.grupp23.model.MapModel.java
private MessagePoint getMPcustom(int id, ArrayList<MessagePoint> list) { //returns a MessagePoint without calling the Server Iterator<MessagePoint> it = list.iterator(); while (it.hasNext()) { MessagePoint msgp = it.next();/*from ww w .j a va 2 s .c o m*/ if (msgp.getId() == id) { return msgp; } } return null; }
From source file:org.dataconservancy.dcs.integration.main.ManualDepositIT.java
/** * Ensure that the <code>href</code> attribute values for <collection>s are valid URLs. *//* ww w.j ava 2 s . co m*/ @Test public void testServiceDocCollectionUrls() throws IOException, XPathExpressionException { final HttpGet req = new HttpGet(serviceDocUrl); final HttpResponse resp = client.execute(req); assertEquals("Unable to retrieve atompub service document " + serviceDocUrl, 200, resp.getStatusLine().getStatusCode()); final XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new NamespaceContext() { @Override public String getNamespaceURI(String prefix) { if ("app".equals(prefix) || prefix == null || "".equals(prefix)) { return ATOM_NS; } throw new RuntimeException("Unknown xmlns prefix: '" + prefix + "'"); } @Override public String getPrefix(String nsUri) { if (ATOM_NS.equals(nsUri)) { return "app"; } throw new RuntimeException("Unknown xmlns uri '" + nsUri + "'"); } @Override public Iterator<String> getPrefixes(String s) { ArrayList<String> prefixes = new ArrayList<String>(); prefixes.add("app"); return prefixes.iterator(); } }); final String xpathExpression = "//app:collection/@href"; final NodeList collectionHrefs = (NodeList) xpath.evaluate(xpathExpression, new InputSource(resp.getEntity().getContent()), XPathConstants.NODESET); assertTrue( "No atompub collections found in service document " + serviceDocUrl + " (xpath search '" + xpathExpression + "' yielded no results.", collectionHrefs != null && collectionHrefs.getLength() > 0); for (int i = 0; i < collectionHrefs.getLength(); i++) { final String collectionUrl = collectionHrefs.item(i).getNodeValue(); assertNotNull("atompub collection url was null.", collectionUrl); assertTrue("atompub collection url was the empty string.", collectionUrl.trim().length() > 0); new URL(collectionUrl); assertTrue("Expected atompub collection url to start with " + serviceDocUrl + " (collection url was: " + collectionUrl, collectionUrl.startsWith(serviceDocUrl)); } }
From source file:de.suse.swamp.core.api.WorkflowAPI.java
/** * Returns a HashMap with /*from www . j a v a 2 s.co m*/ * key: path, value: DatabitTemplate * of all DatabitTemplates */ public HashMap getAllDatabitTemplates(String wftemplate, String username) throws StorageException, SecurityException, UnknownElementException { WorkflowTemplate wftemp = this.getWorkflowTemplate(wftemplate, username); HashMap bits = new HashMap(); ArrayList paths = wftemp.getAllDatabitPaths(); for (Iterator it = paths.iterator(); it.hasNext();) { // FIXME: add security checks for the databits here String path = (String) it.next(); DatabitTemplate bit = wftemp.getDatabitTemplate(path); bits.put(path, bit); } return bits; }
From source file:com.kircherelectronics.fusedgyroscopeexplorer.sensor.MagneticSensor.java
/** * Notify observers with new measurements. */// w ww . ja v a 2 s .c om private void notifyMagneticObserver() { // The iterator is a work around for a concurrency exception... Not the best work around, but it works for now. MagneticSensorObserver observer; ArrayList<MagneticSensorObserver> notificationList = new ArrayList<MagneticSensorObserver>( observersMagnetic); for (Iterator<MagneticSensorObserver> iterator = notificationList.iterator(); iterator.hasNext();) { observer = iterator.next(); observer.onMagneticSensorChanged(this.magnetic, this.timeStamp); } }
From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java
private XYDataset createDataset(ArrayList<Cluster_KMeans> clusters, LocalDateTime from) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); for (int i = 0; i < clusters.size(); i++) { Cluster_KMeans current_cluster = clusters.get(i); ArrayList<Sensor> member_time_series = current_cluster.getMembership(); for (Iterator iterator = member_time_series.iterator(); iterator.hasNext();) { final TimeSeries s1 = new TimeSeries("Cluster_" + current_cluster.getCluster_id(), Hour.class); Sensor current_series = (Sensor) iterator.next(); for (int j = 0; j < current_series.getDimensions(); j++) { LocalDateTime current_record_time = current_series.getInitial_record_time().plusHours(j); s1.add(new Hour(current_record_time.getHour(), current_record_time.getDayOfMonth(), current_record_time.getMonthValue(), current_record_time.getYear()), current_series.getMeasurement(j)); }//ww w .j a v a 2 s.c o m dataset.addSeries(s1); } } dataset.setDomainIsPointsInTime(true); return dataset; }
From source file:com.funambol.transport.http.server.Sync4jServlet.java
/** * Format the list of Ext objects to be printed as a Property * Example: X-funambol-smartslow,X-foo[val1,val2,val3],X-pippo[val] * @param exts// www . j a v a2 s . c om * @return */ static private String formatExtListAsProperties(ArrayList exts) { if (exts == null) { return ""; } StringBuilder formattedExtList = new StringBuilder(""); for (Iterator iterExtList = exts.iterator(); iterExtList.hasNext();) { Ext ext = (Ext) iterExtList.next(); if (ext == null || ext.getXNam().length() == 0) { continue; } if (formattedExtList.length() > 0) { formattedExtList.append(","); } String xnam = ext.getXNam(); xnam = xnam.replace("[", "\\[").replace("]", "\\]").replace(",", "\\,"); formattedExtList.append(xnam); ArrayList xvalList = ext.getXVal(); if (xvalList != null && !xvalList.isEmpty()) { formattedExtList.append("["); for (int i = 0; i < xvalList.size(); i++) { String xval = (String) xvalList.get(i); if (xval != null && xval.length() > 0) { if (i > 0) { formattedExtList.append(","); } xval = xval.replace("[", "\\[").replace("]", "\\]").replace(",", "\\,"); formattedExtList.append(xval); } } formattedExtList.append("]"); } } return formattedExtList.toString(); }