List of usage examples for java.util ListIterator next
E next();
From source file:application.BrokersMouseListener.java
@Override public void graphClicked(Object arg0, MouseEvent arg1) { //Reset the selected variable for all the broker ListIterator<Broker> it = state.getBrokersList(); while (it.hasNext()) { it.next().resetSelected(); }/*from ww w.jav a2s.c om*/ Broker broker = (Broker) arg0; //SET the selected variable for THE SPECIFIC broker broker.setSelected(); Transformer<Broker, Paint> vertexPaint = new Transformer<Broker, Paint>() { public Paint transform(Broker b) { if (b.selected()) { return Color.GREEN; } return Color.GRAY; } }; //Reset the selected variable for all the link it = state.getBrokersList(); while (it.hasNext()) { Broker b = it.next(); ListIterator<Interface> intit = b.getInterfaces(); while (intit.hasNext()) { Interface ix = intit.next(); ix.getLink().resetSelected(); } } //SET the selected variable for THE SPECIFIC links it = state.getBrokersList(); while (it.hasNext()) { Broker b = it.next(); ListIterator<Interface> intit = b.getInterfaces(); if (b.equals(broker)) { while (intit.hasNext()) { Interface ix = intit.next(); ix.getLink().setSelected(); } } else { while (intit.hasNext()) { Interface ix = intit.next(); ix.getLink().setSelectedBcastFunction(state.getBrokerPosition(broker)); } } } Transformer<Link, Stroke> edgeStrokeTransformer = new Transformer<Link, Stroke>() { public Stroke transform(Link link) { if (link.selected()) { final Stroke edgeStroke = new BasicStroke(2); return edgeStroke; } else { float[] dot = { 1.0f, 3.0f }; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dot, 0f); return edgeStroke; } } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); //((FRLayout)layout).initialize(); //((FRLayout)layout).step(); vv.repaint(); }
From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java
private List<Individual> removeIndividualsAlreadyInRange(List<Individual> indiviuals, List<ObjectPropertyStatement> stmts) { log.trace(// w ww .j a v a 2s .co m "starting to check for duplicate range individuals in OptionsForPropertyTag.removeIndividualsAlreadyInRange() ..."); HashSet<String> range = new HashSet<String>(); for (ObjectPropertyStatement ops : stmts) { if (ops.getPropertyURI().equals(getPredicateUri())) range.add(ops.getObjectURI()); } int removeCount = 0; ListIterator<Individual> it = indiviuals.listIterator(); while (it.hasNext()) { Individual ind = it.next(); if (range.contains(ind.getURI())) { it.remove(); ++removeCount; } } log.trace("removed " + removeCount + " duplicate range individuals"); return indiviuals; }
From source file:net.relet.freimap.NodeInfo.java
public void setLinkCountProfile(LinkedList<LinkCount> lcp) { if (lcp.size() == 0) { minLinks = 0;//from w ww . j a v a 2s . com maxLinks = 0; return; } XYSeries data = new XYSeries("links"); XYSeries avail = new XYSeries("avail"); XYSeriesCollection datac = new XYSeriesCollection(data); datac.addSeries(avail); linkCountChart = ChartFactory.createXYLineChart("average incoming link count\r\nincoming link availability", "time", "count", datac, PlotOrientation.VERTICAL, false, false, false); sexupLayout(linkCountChart); long first = lcp.getFirst().time, last = lcp.getLast().time, lastClock = first, count = 0, maxCount = 0; long aggregate = (last - first) / CHART_WIDTH; double sum = 0; /* ok, this ain't effective, we do it just to pre-calculate maxCount */ ListIterator<LinkCount> li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); count++; if (lc.time - lastClock > aggregate) { if (maxCount < count) maxCount = count; lastClock = lc.time; count = 0; } } //reset for second iteration count = 0; lastClock = first; //iterate again li = lcp.listIterator(); while (li.hasNext()) { LinkCount lc = li.next(); if (minLinks > lc.count) minLinks = lc.count; if (maxLinks < lc.count) maxLinks = lc.count; sum += lc.count; count++; if (aggregate == 0) aggregate = 1000;//dirty hack if (lc.time - lastClock > aggregate) { for (long i = lastClock; i < lc.time - aggregate; i += aggregate) { data.add(i * 1000, (i == lastClock) ? sum / count : Double.NaN); avail.add(i * 1000, (i == lastClock) ? ((double) count / maxCount) : 0); } count = 0; sum = 0; lastClock = lc.time; } } status = STATUS_AVAILABLE; }
From source file:com.digitalgeneralists.assurance.model.entities.ApplicationConfiguration.java
private List<String> transformStringPropertyToListProperty(String property, boolean removeExtensionPatterns) { StrTokenizer tokenizer = new StrTokenizer(property, ','); List<String> tokenizedList = tokenizer.getTokenList(); // NOTE: May want to reconsider the toLowercase conversion. ListIterator<String> iterator = tokenizedList.listIterator(); while (iterator.hasNext()) { String extension = iterator.next(); // NOTE: This is probably a bit overly-aggressive and less-sophisticated than it could be, // but it should handle 99% of the input that will be entered. if (removeExtensionPatterns) { extension = StringUtils.replace(extension, "*.", ""); extension = StringUtils.replace(extension, "*", ""); extension = StringUtils.replace(extension, ".", ""); }// ww w.ja v a 2s . c o m iterator.set(extension.toLowerCase().trim()); } return tokenizedList; }
From source file:com.cloudera.sqoop.cli.SqoopParser.java
@Override /**//from w w w. j a va 2s . com * Processes arguments to options but only strips matched quotes. */ public void processArgs(Option opt, ListIterator iter) throws ParseException { // Loop until an option is found. while (iter.hasNext()) { String str = (String) iter.next(); if (getOptions().hasOption(str) && str.startsWith("-")) { // found an Option, not an argument. iter.previous(); break; } // Otherwise, this is a value. try { // Note that we only strip matched quotes here. addValForProcessing.invoke(opt, stripMatchedQuotes(str)); } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (java.lang.reflect.InvocationTargetException ite) { // Any runtime exception thrown within addValForProcessing() // will be wrapped in an InvocationTargetException. iter.previous(); break; } catch (RuntimeException re) { iter.previous(); break; } } if (opt.getValues() == null && !opt.hasOptionalArg()) { throw new MissingArgumentException(opt); } }
From source file:com.exalead.io.failover.HostState.java
void killStaleConnections() { int closed = 0; ListIterator<MonitoredConnection> it = freeConnections.listIterator(); while (it.hasNext()) { MonitoredConnection free = it.next(); boolean wasStale; try {/*from w w w . j ava 2 s .c o m*/ wasStale = free.conn.closeIfStale(); } catch (IOException e) { wasStale = true; free.conn.close(); } if (wasStale) { closed++; it.remove(); } } logger.info("Closed " + closed + " stale connections, " + freeConnections.size() + " remaining"); }
From source file:vteaexploration.plottools.panels.DefaultExplorationPanel.java
protected int keyLookUp(int x, int y, int l) { ListIterator<ArrayList> itr = ExplorationItems.listIterator(); Object test;//from w ww . j av a2s .c om String key = x + "_" + y + "_" + l; while (itr.hasNext()) { //test = itr.next().get(0); ArrayList list = itr.next(); test = list.get(0); if (key.equals(test.toString())) { return ExplorationItems.indexOf(list); } } return 0; }
From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java
private void trimStackTraceAtEnd(List<StackTraceElement> list) { ListIterator<StackTraceElement> iter = list.listIterator(); boolean trimming = false; while (iter.hasNext()) { StackTraceElement ste = iter.next(); if (trimming) { iter.remove();/*from w ww .ja va 2 s. co m*/ } else if (ste.getClassName().contains("ApplicationFilterChain")) { trimming = true; } } }
From source file:org.cleverbus.admin.web.log.LogController.java
@RequestMapping("/") public String getLogSearch(@RequestParam(value = "fromDate", required = false) DateTime fromDate, @RequestParam MultiValueMap<String, String> params, Model model) throws UnsupportedEncodingException { if (fromDate != null) { params.remove("fromDate"); // remove empty values: for (List<String> valueList : params.values()) { ListIterator<String> values = valueList.listIterator(); while (values.hasNext()) { if (!StringUtils.hasText(values.next())) { values.remove();/*ww w .j av a 2 s .com*/ } } } model.mergeAttributes(params); return "redirect:" + UriUtils.encodePath(LogParserConstants.LOGBACK_ISO8601_FORMAT.print(fromDate), "UTF-8"); } model.addAttribute("fromDate", LogParserConstants.LOGBACK_ISO8601_FORMAT.print( DateTime.now().minusHours(2).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0))); LogParserConfig logParserConfig = new LogParserConfig(); logParserConfig.setGroupBy(LogParserConstants.DEFAULT_GROUP_BY_PROPERTY); logParserConfig.setGroupLimit(LogParserConstants.DEFAULT_GROUP_SIZE); model.addAttribute("config", logParserConfig); return "logSearch"; }
From source file:com.smile.pentaho.birtplugin.BIRTContentGenerator.java
public void createContent() throws Exception { this.session = PentahoSessionHolder.getSession(); this.repository = PentahoSystem.get(IUnifiedRepository.class, session); RepositoryFile BIRTfile = (RepositoryFile) parameterProviders.get("path").getParameter("file"); String ExecBIRTFilePath = "../../pentaho-solutions/" + BIRTfile.getId() + ".rptdesign"; /*//from w ww .jav a 2 s .c om * Get BIRT report design from repository */ File ExecBIRTFile = new File(ExecBIRTFilePath); if (!ExecBIRTFile.exists()) { Writer writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(ExecBIRTFilePath), "UTF-8")); try { SimpleRepositoryFileData data = repository.getDataForRead(BIRTfile.getId(), SimpleRepositoryFileData.class); Reader reader = new InputStreamReader(data.getInputStream(), "UTF8"); int c; while ((c = reader.read()) != -1) { writer.write(c); } } catch (Exception e) { Logger.error(getClass().getName(), e.getMessage()); } finally { writer.close(); } } /* * Redirect to BIRT Viewer */ try { //Get informations about user context IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class); String roles = ""; ListIterator li = service.getRolesForUser(null, session.getName()).listIterator(); while (li.hasNext()) { roles = roles + li.next().toString() + ","; } //Redirect HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path") .getParameter("httpresponse"); response.sendRedirect("/WebViewerExample/frameset?__report=" + BIRTfile.getId() + ".rptdesign&__showtitle=false&username=" + session.getName() + "&userroles=" + roles + "&reportname=" + BIRTfile.getTitle()); } catch (Exception e) { Logger.error(getClass().getName(), e.getMessage()); } }