List of usage examples for java.util ArrayList iterator
public Iterator<E> iterator()
From source file:com.concursive.connect.web.portal.PortalURLParserImpl.java
/** * Parse a servlet request to a portal URL. * * @param request the servlet request to parse. * @return the portal URL./*www .j av a 2s . c o m*/ */ public PortalURL parse(HttpServletRequest request) { LOG.debug("Parsing URL: " + request.getRequestURI()); if (LOG.isDebugEnabled()) { Enumeration params = request.getParameterNames(); while (params.hasMoreElements()) { String param = (String) params.nextElement(); LOG.debug(" parameter: " + param + "=" + request.getParameter(param)); } } StringBuffer url = new StringBuffer(); if (request.getParameterMap() != null) { // To construct the base URL for the portal, append the allowed portal URL // parameters that are specified by the portal manager ArrayList allowedPortalParams = (ArrayList) request.getAttribute(ALLOWED_PORTAL_PARAMETERS); if (allowedPortalParams != null) { Iterator i = allowedPortalParams.iterator(); while (i.hasNext()) { String paramName = (String) i.next(); String paramValue = request.getParameter(paramName); if (paramValue != null) { // @note TEST TEST TEST //appendParameter(url, paramName + "=" + paramValue); appendParameter(url, paramName + "=" + StringUtils.encodeUrl(paramValue)); } } } } String servletName = request.getServletPath() + url.toString(); // Construct portal URL using info retrieved from servlet request String contextPath = request.getContextPath(); LOG.debug("contextPath: " + contextPath); PortalURL portalURL = new RelativePortalURLImpl(contextPath, servletName, getParser()); // Action window definition: portalURL.setActionWindow() String portletAction = request.getParameter("portletAction"); if (portletAction != null && portletAction.startsWith(PREFIX + ACTION)) { LOG.debug("found action"); portalURL.setActionWindow(decodeControlParameter(portletAction)[0]); portalURL.setRenderPath(contextPath + "."); } // Window state definition: portalURL.setWindowState() String portletWindowState = null; int windowStateCount = 0; while ((portletWindowState = request.getParameter("portletWindowState" + (++windowStateCount))) != null) { String[] decoded = decodeControlParameter(portletWindowState); portalURL.setWindowState(decoded[0], new WindowState(decoded[1])); } // Portlet mode definition: portalURL.setPortletMode() String portletMode = request.getParameter("portletMode"); if (portletMode != null) { String[] decoded = decodeControlParameter(portletMode); portalURL.setPortletMode(decoded[0], new PortletMode(decoded[1])); } // Portal URL parameter: portalURL.addParameter() Enumeration params = request.getParameterNames(); while (params.hasMoreElements()) { String parameter = (String) params.nextElement(); if (parameter.startsWith(PREFIX + RENDER_PARAM)) { String value = request.getParameter(parameter); LOG.debug("parameter: " + parameter); // @note TEST TEST TEST //portalURL.addParameter(decodeParameter(parameter, value)); portalURL.addParameter(decodeParameter(parameter, StringUtils.encodeUrl(value))); } } // Return the portal URL. return portalURL; }
From source file:com.kloudtek.buildmagic.tools.createinstaller.deb.CreateDebTask.java
private void writeTemplate(final TarArchive tarArchive, final ArrayList<TemplateEntry> templateEntries) throws IOException { final Writer w = new StringWriter(); for (Iterator<TemplateEntry> iterator = templateEntries.iterator(); iterator.hasNext();) { final TemplateEntry entry = iterator.next(); if (entry.getFullId() == null) { throw new BuildException("template id missing"); }//from ww w . jav a 2s. c om if (entry.getShortDesc() == null) { throw new BuildException("template " + entry.getId() + " has no shortDesc defined"); } w.write("Template: "); w.write(entry.getFullId()); if (entry.getDefaultValue() != null) { w.write("\nDefault: "); w.write(entry.getDefaultValue()); } w.write("\nType: "); w.write(entry.getType().name().toLowerCase()); w.write("\nDescription: "); w.write(entry.getShortDesc()); w.write("\n"); String longDesc = entry.getLongDesc(); if (longDesc == null) { longDesc = entry.getShortDesc(); } w.write(generateExtendedControlField(longDesc)); w.write("\n"); if (iterator.hasNext()) { w.write("\n"); } } w.close(); tarArchive.write(w.toString(), "templates"); }
From source file:au.edu.uq.cmm.paul.grabber.Analyser.java
private ArrayList<Group> mergeGroupsFromFolder(ArrayList<Group> groups, Collection<DatasetMetadata> inFolder) { ArrayList<Group> res = new ArrayList<Group>(); Iterator<Group> git = groups.iterator(); Iterator<DatasetMetadata> dit = inFolder.iterator(); Group group = git.hasNext() ? git.next() : null; DatasetMetadata dataset = dit.hasNext() ? dit.next() : null; while (group != null || dataset != null) { if (dataset == null) { res.add(group);// w ww . j a v a2 s . c o m group = git.hasNext() ? git.next() : null; } else if (group == null) { if (intertidal(dataset.getLastFileTimestamp())) { Group newGroup = new Group(dataset.getSourceFilePathnameBase()); newGroup.setInFolder(dataset); res.add(newGroup); } dataset = dit.hasNext() ? dit.next() : null; } else { int cmp = group.getBasePathname().compareTo(dataset.getSourceFilePathnameBase()); if (cmp == 0) { res.add(group); group.setInFolder(dataset); group = git.hasNext() ? git.next() : null; dataset = dit.hasNext() ? dit.next() : null; } else if (cmp < 0) { res.add(group); group = git.hasNext() ? git.next() : null; } else { if (intertidal(dataset.getLastFileTimestamp())) { Group newGroup = new Group(dataset.getSourceFilePathnameBase()); newGroup.setInFolder(dataset); res.add(newGroup); } dataset = dit.hasNext() ? dit.next() : null; } } } return res; }
From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java
protected JPanel getSeriesPanel(final JDialog dialog, ChartMouseEvent event) { MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset(); MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer(); MotionTableModel model = dataset.getTableModel(); DefaultTableModel tModel = new DefaultTableModel(); ArrayList<Integer> visibleSeries = renderer.getVisibleSeries(); ArrayList<String> rowIds = new ArrayList<String>(); int columnCount = model.getColumnCount(); int r = 0;/* ww w . j av a2 s . com*/ for (int c = 0; c < columnCount; c++) { tModel.addColumn(model.getColumnName(c)); } Iterator<Integer> itr = visibleSeries.iterator(); while (itr.hasNext()) { ArrayList<Integer> rows = model.getKeyMap().get(dataset.getSeriesKey(itr.next())); Iterator<Integer> rItr = rows.iterator(); while (rItr.hasNext()) { int row = rItr.next(); tModel.addRow(new Object[0]); rowIds.add(new String(row + ":")); for (int c = 0; c < columnCount; c++) { tModel.setValueAt(model.getValueAt(row, c), r, c); } r++; } } return getPanel(dialog, tModel, rowIds); }
From source file:org.squale.squalecommon.enterpriselayer.facade.quality.MeasureFacade.java
/** * Affichage des facteurs du Kiviat : tous les facteurs ou seulement ceux ayant une note * /*from ww w . j a v a2s. c o m*/ * @param pValues les donnes afficher : facteur + note * @param pNullValuesList la liste des facteurs dont la note est nulle * @param pAllFactors tous les facteurs (="true") ou seulement les facteurs ayant une note * @param pFactorsMin nombre de facteurs minimal que l'on doit afficher sur le Kiviat * @return values les donnes rellement afficher : facteur + note */ private static SortedMap deleteFactors(SortedMap pValues, ArrayList pNullValuesList, String pAllFactors, int pFactorsMin) { SortedMap values = new TreeMap(); // Seulement les facteurs ayant une note ? ==> suppression des facteurs ayant une note nulle. // Mais trois facteurs doivent au moins s'afficher (nuls ou pas !) if (pValues.size() > pFactorsMin && !pAllFactors.equals("true")) { // Nombre de suppressions possible int nbTotalDeletions = pValues.size() - pFactorsMin; // Nombre de suppressions effectu int nbCurrentDeletions = 0; // Parcours de la liste des facteurs avec une note nulle, pour les supprimer de l'affichage Iterator itList = pNullValuesList.iterator(); while (itList.hasNext() && nbCurrentDeletions < nbTotalDeletions) { String keyListe = (String) itList.next(); pValues.remove(keyListe); nbCurrentDeletions += 1; } } values.putAll(pValues); return values; }
From source file:com.linkedin.pinot.integration.tests.Pql2CompilerTest.java
private boolean filterQueryIsEquivalent(List<Integer> leftIds, List<Integer> rightIds, FilterQueryMap leftFilterQueries, FilterQueryMap rightFilterQueries) { ArrayList<Integer> leftIdsCopy = new ArrayList<>(leftIds); ArrayList<Integer> rightIdsCopy = new ArrayList<>(rightIds); if (leftIdsCopy.size() != rightIdsCopy.size()) { return false; }//from www . j a v a 2 s. co m Iterator<Integer> leftIterator = leftIdsCopy.iterator(); while (leftIterator.hasNext()) { Integer leftId = leftIterator.next(); FilterQuery leftQuery = leftFilterQueries.getFilterQueryMap().get(leftId); Iterator<Integer> rightIterator = rightIdsCopy.iterator(); while (rightIterator.hasNext()) { Integer rightId = rightIterator.next(); FilterQuery rightQuery = rightFilterQueries.getFilterQueryMap().get(rightId); boolean operatorsAreEqual = EqualityUtils.isEqual(leftQuery.getOperator(), rightQuery.getOperator()); boolean columnsAreEqual = EqualityUtils.isEqual(leftQuery.getColumn(), rightQuery.getColumn()); boolean valuesAreEqual = EqualityUtils.isEqual(leftQuery.getValue(), rightQuery.getValue()); boolean fieldsAreEqual = columnsAreEqual && operatorsAreEqual && valuesAreEqual; // Compare sets if the op is IN if (operatorsAreEqual && columnsAreEqual && leftQuery.getOperator() == FilterOperator.IN) { Set<String> leftValues = new HashSet<>( Arrays.asList(leftQuery.getValue().get(0).split("\t\t"))); Set<String> rightValues = new HashSet<>( Arrays.asList(rightQuery.getValue().get(0).split("\t\t"))); fieldsAreEqual = leftValues.equals(rightValues); if (!fieldsAreEqual) { System.out.println("in clause not the same?"); System.out.println("leftValues = " + leftValues); System.out.println("rightValues = " + rightValues); } } // NOT_IN and NOT are equivalent if (!operatorsAreEqual && columnsAreEqual && valuesAreEqual) { if ((leftQuery.getOperator() == FilterOperator.NOT || leftQuery.getOperator() == FilterOperator.NOT_IN) && (rightQuery.getOperator() == FilterOperator.NOT || rightQuery.getOperator() == FilterOperator.NOT_IN)) { fieldsAreEqual = true; } } if (fieldsAreEqual) { if (filterQueryIsEquivalent(leftQuery.getNestedFilterQueryIds(), rightQuery.getNestedFilterQueryIds(), leftFilterQueries, rightFilterQueries)) { leftIterator.remove(); rightIterator.remove(); break; } } } } return leftIdsCopy.isEmpty(); }
From source file:com.projity.pm.task.Portfolio.java
public Job getRemoveAllProjectsJob(JobRunnable exitRunnable, boolean calledFromSwing, boolean[] closeStatus) { boolean exitOnClose = true; if (closeStatus != null && closeStatus.length > 0) closeStatus[0] = true;/*from w w w . jav a 2s . c o m*/ final Job job = new Job(SessionFactory.getInstance().getLocalSession().getJobQueue(), "removeAllProjects", "Removing projects...", true); ArrayList toRemove = new ArrayList(); for (Iterator i = nodeModel.iterator(); i.hasNext();) { Node node = (Node) i.next(); if (!node.isRoot()) toRemove.add(node); } Project p; for (Iterator i = toRemove.iterator(); i.hasNext();) { p = (Project) ((Node) i.next()).getImpl(); if (p.isOpenedAsSubproject()) // subprojects are saved with their parents continue; Job rJob = getRemoveProjectJob(p, calledFromSwing); if (rJob == null) { if (calledFromSwing) exitOnClose = false; //close cancelled. if (closeStatus != null && closeStatus.length > 0) { System.out.println("Close cancelled"); closeStatus[0] = false; } } else job.addJob(rJob); } if (exitOnClose) job.addRunnable(exitRunnable, !calledFromSwing, false, calledFromSwing, false); return job; }
From source file:com.irccloud.android.data.ServersDataSource.java
public void deleteAllDataForServer(int cid) { Server s = getServer(cid);//from ww w.j a va2 s .c o m if (s != null) { ArrayList<BuffersDataSource.Buffer> buffersToRemove = new ArrayList<BuffersDataSource.Buffer>(); Iterator<BuffersDataSource.Buffer> i = BuffersDataSource.getInstance().getBuffersForServer(cid) .iterator(); while (i.hasNext()) { BuffersDataSource.Buffer b = i.next(); buffersToRemove.add(b); } i = buffersToRemove.iterator(); while (i.hasNext()) { BuffersDataSource.Buffer b = i.next(); BuffersDataSource.getInstance().deleteAllDataForBuffer(b.bid); Notifications.getInstance().deleteNotificationsForBid(b.bid); } servers.remove(cid); } }
From source file:ca.uhn.hl7v2.testpanel.util.compare.Hl7V2MessageCompare.java
private GroupComparison compareGroups(Group theStructure1, Group theStructure2) throws HL7Exception { List<String> originalNames1 = Arrays.asList(theStructure1.getNames()); ArrayList<String> names1 = new ArrayList<String>(originalNames1); for (Iterator<String> iter = names1.iterator(); iter.hasNext();) { String nextName = iter.next(); if (theStructure1.getAll(nextName).length == 0) { iter.remove();/*from ww w . j a v a 2 s .c o m*/ } } List<String> originalNames2 = Arrays.asList(theStructure2.getNames()); ArrayList<String> names2 = new ArrayList<String>(originalNames2); for (Iterator<String> iter = names2.iterator(); iter.hasNext();) { String nextName = iter.next(); if (theStructure2.getAll(nextName).length == 0) { iter.remove(); } } List<StructureComparison> structureComparisons = new ArrayList<StructureComparison>(); int nameIdx1 = 0; int nameIdx2 = 0; while ((nameIdx1 < names1.size()) || (nameIdx2 < names2.size())) { Pair<Integer> nextSameIdx = findNextSameIndex(names1, names2, nameIdx1, nameIdx2); // If we're at the end of the matching segments if (nextSameIdx == null) { addRemainingStructures(theStructure1, nameIdx1, names1.size(), structureComparisons, true); addRemainingStructures(theStructure2, nameIdx2, names2.size(), structureComparisons, false); break; } addRemainingStructures(theStructure1, nameIdx1, nextSameIdx.getValue1(), structureComparisons, true); addRemainingStructures(theStructure2, nameIdx2, nextSameIdx.getValue2(), structureComparisons, false); Structure[] children1 = theStructure1.getAll(names1.get(nextSameIdx.getValue1())); Structure[] children2 = theStructure2.getAll(names2.get(nextSameIdx.getValue2())); int lowerCommonIndex = (children1.length < children2.length) ? children1.length : children2.length; for (int i = 0; i < lowerCommonIndex; i++) { Structure child1 = children1[i]; Structure child2 = children2[i]; if (child1 instanceof Segment) { structureComparisons.add(compareSegments((Segment) child1, (Segment) child2)); } else { structureComparisons.add(compareGroups((Group) child1, (Group) child2)); } } for (int i = lowerCommonIndex; i < children1.length; i++) { if (children1[i] instanceof Segment) { structureComparisons .add(new SegmentComparison(children1[i].getName(), (Segment) children1[i], null)); } else { structureComparisons.add(new GroupComparison((Group) children1[i], null)); } } for (int i = lowerCommonIndex; i < children2.length; i++) { if (children2[i] instanceof Segment) { structureComparisons .add(new SegmentComparison(children2[i].getName(), null, (Segment) children2[i])); } else { structureComparisons.add(new GroupComparison(null, (Group) children2[i])); } } nameIdx1 = nextSameIdx.getValue1() + 1; nameIdx2 = nextSameIdx.getValue2() + 1; } return new GroupComparison(structureComparisons); }
From source file:com.concursive.connect.cms.portal.dao.DashboardPortletList.java
/** * Take page design and build portlet list in memory only, preferences cannot * be saved on these portlets// w w w .j a v a2 s .c o m * * @param page * @throws Exception */ public void buildTemporaryList(DashboardPage page) throws Exception { XMLUtils xml = new XMLUtils(page.getXmlDesign()); // Counter for number of instances on this page int falseIdCount = 0; // Pages have rows ArrayList rows = new ArrayList(); XMLUtils.getAllChildren(xml.getDocumentElement(), "row", rows); // ERROR if no rows found if (rows.isEmpty()) { LOG.error("buildTemporaryList-> rows is empty"); } Iterator i = rows.iterator(); while (i.hasNext()) { Element rowEl = (Element) i.next(); // Rows have columns ArrayList columns = new ArrayList(); XMLUtils.getAllChildren(rowEl, "column", columns); // ERROR if no columns found if (columns.isEmpty()) { LOG.error("buildTemporaryList-> columns is empty"); } Iterator j = columns.iterator(); while (j.hasNext()) { Element columnEl = (Element) j.next(); // Columns have portlets ArrayList portlets = new ArrayList(); XMLUtils.getAllChildren(columnEl, "portlet", portlets); Iterator k = portlets.iterator(); while (k.hasNext()) { Element portletEl = (Element) k.next(); // Give the portlet an instance reference ++falseIdCount; // Set the portlet information DashboardPortlet portlet = new DashboardPortlet(); portlet.setPageId(page.getId()); portlet.setName(portletEl.getAttribute("name")); if (portletEl.hasAttribute("viewer")) { portlet.setViewer(portletEl.getAttribute("viewer")); } if (portletEl.hasAttribute("class")) { portlet.setHtmlClass(portletEl.getAttribute("class")); } if (portletEl.hasAttribute("cache")) { portlet.setCacheTime(Integer.parseInt(portletEl.getAttribute("cache"))); } if (portletEl.hasAttribute("timeout")) { portlet.setTimeout(Integer.parseInt(portletEl.getAttribute("timeout"))); } if (portletEl.hasAttribute("isSensitive")) { portlet.setSensitive(portletEl.getAttribute("isSensitive")); } // This portlet can temporarily be used DashboardPortletItem portletItem = new DashboardPortletItem(); portletItem.setName(portlet.getName()); portletItem.setEnabled(true); // Portlets could have default preferences specified in the layout ArrayList<Element> preferences = new ArrayList<Element>(); XMLUtils.getAllChildren(portletEl, preferences); Iterator l = preferences.iterator(); while (l.hasNext()) { Element preferenceEl = (Element) l.next(); if ("portlet-events".equals(preferenceEl.getNodeName())) { // This is the registration of a generateDataEvent ArrayList<Element> generateDataEvents = new ArrayList<Element>(); XMLUtils.getAllChildren(preferenceEl, "generates-data", generateDataEvents); for (Element gde : generateDataEvents) { portlet.addGenerateDataEvent(XMLUtils.getNodeText(gde)); } // This is the registration of a consumeDataEvent ArrayList<Element> consumeDataEvents = new ArrayList<Element>(); XMLUtils.getAllChildren(preferenceEl, "consumes-data", consumeDataEvents); for (Element cde : consumeDataEvents) { portlet.addConsumeDataEvent(XMLUtils.getNodeText(cde)); } // This is the registration of generateSessionData ArrayList<Element> generateSessionData = new ArrayList<Element>(); XMLUtils.getAllChildren(preferenceEl, "generates-session-data", generateSessionData); for (Element cde : generateSessionData) { portlet.addGenerateSessionData(XMLUtils.getNodeText(cde)); } // This is the registration of consumeSessionData ArrayList<Element> consumeSessionData = new ArrayList<Element>(); XMLUtils.getAllChildren(preferenceEl, "consumes-session-data", consumeSessionData); for (Element cde : consumeSessionData) { portlet.addConsumeSessionDataEvent(XMLUtils.getNodeText(cde)); } // This is the registration of generateRequestData ArrayList<Element> generateRequestData = new ArrayList<Element>(); XMLUtils.getAllChildren(preferenceEl, "generates-request-data", generateRequestData); for (Element cde : generateRequestData) { portlet.addGenerateRequestData(XMLUtils.getNodeText(cde)); } // This is the registration of consumeRequestData ArrayList<Element> consumeRequestData = new ArrayList<Element>(); XMLUtils.getAllChildren(preferenceEl, "consumes-request-data", consumeRequestData); for (Element cde : consumeRequestData) { portlet.addConsumeRequestDataEvent(XMLUtils.getNodeText(cde)); } } else { // Provide the default preference DashboardPortletPrefs prefs = new DashboardPortletPrefs(); prefs.setName(preferenceEl.getNodeName()); // Check to see if the prefs are provided as an array ArrayList<String> valueList = new ArrayList<String>(); ArrayList valueElements = new ArrayList(); XMLUtils.getAllChildren(preferenceEl, "value", valueElements); if (valueElements.size() > 0) { // There are <value> nodes Iterator vi = valueElements.iterator(); while (vi.hasNext()) { valueList.add(XMLUtils.getNodeText((Element) vi.next())); } prefs.setValues(valueList.toArray(new String[valueList.size()])); } else { // There is a single value prefs.setValues(new String[] { XMLUtils.getNodeText(preferenceEl) }); } portlet.addDefaultPreference(prefs.getName(), prefs); } } portlet.setId(falseIdCount); this.add(portlet); } } } }