List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java
private List<Individual> removeIndividualsAlreadyInRange(List<Individual> indiviuals, List<ObjectPropertyStatement> stmts) { log.trace(// www . j av a2 s . c o 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:com.itesm.test.servlets.TasksServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String[] description = request.getParameterValues("description"); String[] priority = request.getParameterValues("priority"); String[] task_time = request.getParameterValues("task_time"); String[] end_time = request.getParameterValues("end_time"); PersonaVO personavo = (PersonaVO) request.getSession().getAttribute("persona"); TaskManager taskManager = new TaskManager(); for (int i = 0; i < priority.length; i++) { TaskVO wh = new TaskVO(); SimpleDateFormat sdf = new SimpleDateFormat("hh:mm"); SimpleDateFormat sdfTimeStamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); Date durationDate = null; Date end_date = null;/*from www. j a v a2 s . c o m*/ try { durationDate = sdf.parse(task_time[i]); end_date = sdfTimeStamp.parse(end_time[i]); } catch (ParseException e) { e.printStackTrace(); } wh.setDuration(new Time(durationDate.getTime())); wh.setEnd_date(new Timestamp(end_date.getTime())); wh.setDescription(description[i]); wh.setPriority(Integer.parseInt(priority[i])); wh.setAgenda_id(personavo.getAgenda_id()); System.out.println(wh.toString()); taskManager.agregar(wh); } CreateSchedule createSchedule = new CreateSchedule(personavo); createSchedule.createSchedule(); TaskDAO taskDAO = new TaskDAO(); List<TaskVO> task_list = taskDAO.findByAgenda(personavo.getAgenda_id()); ListIterator listIterator = task_list.listIterator(); while (listIterator.hasNext()) { TaskVO task = (TaskVO) listIterator.next(); if (task.getWork_hours_id() == null) { listIterator.remove(); } } WorkHoursManager workHoursManager = new WorkHoursManager(); List<WorkHoursVO> worksHours_list = workHoursManager.consultarPorAgenda(personavo.getAgenda_id()); request.setAttribute("tasks", task_list); request.setAttribute("works", worksHours_list); RequestDispatcher rd = getServletContext().getRequestDispatcher("/schedule.jsp"); rd.forward(request, response); }
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();/* ww w . ja v a 2 s . c o m*/ } else if (ste.getClassName().contains("ApplicationFilterChain")) { trimming = true; } } }
From source file:net.relet.freimap.NodeInfo.java
public void setLinkCountProfile(LinkedList<LinkCount> lcp) { if (lcp.size() == 0) { minLinks = 0;/*from ww w. j a v a 2 s .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:org.zilverline.core.TestFileSystemCollection.java
public void testAllCollections() throws Exception { CollectionManager c = (CollectionManager) applicationContext.getBean("collectionMan"); assertNotNull(c);/*ww w .j av a 2s .co m*/ ListIterator li = c.getCollections().listIterator(); while (li.hasNext()) { DocumentCollection col = (DocumentCollection) li.next(); log.debug("Collection " + col.getName()); if (col instanceof FileSystemCollection) { assertTrue(col.getName(), ((FileSystemCollection) col).getContentDir().isDirectory()); log.debug(((FileSystemCollection) col).getContentDir() + ", " + col.getIndexDirWithManagerDefaults() + ", " + col.getCacheDirWithManagerDefaults()); log.debug(((FileSystemCollection) col).getContentDir().getAbsoluteFile()); } log.debug(col.getName() + " has %%% " + col.getNumberOfDocs() + " documents."); } }
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"; /*/* w w w . j a va 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()); } }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.FactorRedundantGroupAndDecorVarsRule.java
private boolean factorRedundantRhsVars(List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> veList, Mutable<ILogicalOperator> opRef, Map<LogicalVariable, LogicalVariable> varRhsToLhs, IOptimizationContext context) throws AlgebricksException { varRhsToLhs.clear();//from w w w .ja v a2 s . c o m ListIterator<Pair<LogicalVariable, Mutable<ILogicalExpression>>> iter = veList.listIterator(); boolean changed = false; while (iter.hasNext()) { Pair<LogicalVariable, Mutable<ILogicalExpression>> p = iter.next(); if (p.second.getValue().getExpressionTag() != LogicalExpressionTag.VARIABLE) { continue; } LogicalVariable v = GroupByOperator.getDecorVariable(p); LogicalVariable lhs = varRhsToLhs.get(v); if (lhs != null) { if (p.first != null) { AssignOperator assign = new AssignOperator(p.first, new MutableObject<ILogicalExpression>(new VariableReferenceExpression(lhs))); ILogicalOperator op = opRef.getValue(); assign.getInputs().add(new MutableObject<ILogicalOperator>(op)); opRef.setValue(assign); context.computeAndSetTypeEnvironmentForOperator(assign); } iter.remove(); changed = true; } else { varRhsToLhs.put(v, p.first); } } return changed; }
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AvailableValidValue.java
public String generateHtml(List nonListedVVs, List availableValidVaues, String questionIdSeq) { StringBuffer selectHtml = new StringBuffer( "<select class=\"" + selectClassName + "\" name=\"" + selectName + "\"> \n"); StringBuffer optionHtml = (StringBuffer) pageContext.getAttribute(questionIdSeq + "validValueOptionBuffer"); ////from w ww.j ava 2 s. c o m //The options are cached since they dont change for the same question // if (optionHtml != null) { return selectHtml.toString() + optionHtml.toString(); } optionHtml = new StringBuffer(); ListIterator avalilableVVsListIterate = nonListedVVs.listIterator(); while (avalilableVVsListIterate.hasNext()) { FormValidValue fvv = (FormValidValue) avalilableVVsListIterate.next(); int index = availableValidVaues.indexOf(fvv); optionHtml.append("<option value=\"" + index + "\">" + fvv.getLongName() + "</option> \n"); } optionHtml.append("</select>"); pageContext.setAttribute(questionIdSeq + "validValueOptionBuffer", optionHtml); return selectHtml.toString() + optionHtml.toString(); }
From source file:mimir.ControlChart.java
public void printSignals() { ListIterator<String> flagChecker = this.signals.listIterator(0); while (flagChecker.hasNext()) { System.out.println(flagChecker.next()); }//from www . java2s. co m }
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 w ww .j a v a 2 s.c o m } 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(); }