List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ShowDegreesAction.java
private List buildDegreesList(List executionDegreesList) { if (executionDegreesList == null) { return null; }//from w w w. jav a 2 s .c o m List degreesList = new ArrayList(); ListIterator listIterator = executionDegreesList.listIterator(); while (listIterator.hasNext()) { InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) listIterator.next(); if (!degreesList.contains(infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree())) { degreesList.add(infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree()); } } // order list by alphabetic order of the code Collections.sort(degreesList, new BeanComparator("nome")); return degreesList; }
From source file:com.adaptris.core.ServiceList.java
@Override protected void applyServices(AdaptrisMessage msg) throws ServiceException { ListIterator<Service> itr = this.listIterator(); while (itr.hasNext()) { Service service = itr.next(); String serviceName = friendlyName(service); if (haltProcessing(msg)) { break; }//from w w w . j av a2 s . co m msg.setNextServiceId(""); log.debug("Executing doService on [{}]", serviceName); try { service.doService(msg); msg.addEvent(service, true); // Should we resolveNext *regardless of exception?* itr = resolveNext(itr, msg.getNextServiceId()); } catch (Exception e) { // add fail event msg.addEvent(service, false); handleException(service, msg, e); } } }
From source file:org.yamj.core.database.dao.PlayerDao.java
/** * Delete a path from a player// w w w. j a va2 s. co m * * @param playerId * @param pathId */ public void deletePlayerPath(Long playerId, Long pathId) { LOG.info("Attempting to delete path ID {} from player ID {}", pathId, playerId); PlayerInfo player = getById(PlayerInfo.class, playerId); ListIterator<PlayerPath> iter = player.getPaths().listIterator(); while (iter.hasNext()) { PlayerPath path = iter.next(); if (path.getId() == pathId) { LOG.info("Deleting path: {}", path.toString()); iter.remove(); break; } } // Update the Player record storePlayer(player); }
From source file:com.blauadvisors.pentaho.plugins.redirect.RedirectPluginContentGenerator.java
public void createContent() throws Exception { this.session = PentahoSessionHolder.getSession(); this.repository = PentahoSystem.get(IUnifiedRepository.class, session); RepositoryFile repositoryFile = (RepositoryFile) parameterProviders.get("path").getParameter("file"); SimpleRepositoryFileData data = repository.getDataForRead(repositoryFile.getId(), SimpleRepositoryFileData.class); RedirectPluginFileContectExtractor fileData = new RedirectPluginFileContectExtractor(data.getInputStream()); /*/* w ww .ja va 2s .c om*/ * Redirect to Specified URL */ 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() + ","; } // Build URL String redirectURL = fileData.getUrl(); String parameters = ""; parameters += (fileData.getIncludeRoles() ? "&" + fileData.getRolesParameterName() + "=" + roles : ""); parameters += (fileData.getIncludeUserName() ? "&" + fileData.getUserNameParameterName() + "=" + session.getName() : ""); parameters += (fileData.getIncludeTimeStamp() ? "&" + "timeStamp=" + (new Date()).toString() : ""); redirectURL += (!fileData.getUrlIncludesParameters() ? "?" : "") + parameters; // Redirect HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path") .getParameter("httpresponse"); response.sendRedirect(redirectURL); } catch (Exception e) { Logger.error(getClass().getName(), e.getMessage()); } }
From source file:com.swordlord.gozer.components.wicket.action.button.list.GWListActionToolbar.java
private GActionToolbar searchActionToolbar(GList list) { GActionToolbar actionToolbar = null; ListIterator<ObjectBase> iter = list.getChildren().listIterator(); while (iter.hasNext() && actionToolbar == null) { ObjectBase obj = iter.next();//from w w w .jav a 2s .c om if (obj instanceof GActionToolbar) { actionToolbar = (GActionToolbar) obj; } } return actionToolbar; }
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();//w ww.j av a2 s . c om } } } 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:edu.cornell.mannlib.vitro.webapp.controller.json.GetEntitiesByVClassContinuation.java
@Override protected JSONArray process() throws ServletException { log.debug("in getEntitiesByVClassContinuation()"); String resKey = vreq.getParameter("resultKey"); if (resKey == null) throw new ServletException("Could not get resultKey"); HttpSession session = vreq.getSession(); if (session == null) throw new ServletException("there is no session to get the pervious results from"); @SuppressWarnings("unchecked") List<Individual> entsInVClass = (List<Individual>) session.getAttribute(resKey); if (entsInVClass == null) throw new ServletException("Could not find List<Individual> for resultKey " + resKey); List<Individual> entsToReturn = new ArrayList<Individual>(REPLY_SIZE); boolean more = false; int count = 0; /* we have a large number of items to send back so we need to stash the list in the session scope */ if (entsInVClass.size() > REPLY_SIZE) { more = true;/*from ww w .ja va2 s.co m*/ ListIterator<Individual> entsFromVclass = entsInVClass.listIterator(); while (entsFromVclass.hasNext() && count <= REPLY_SIZE) { entsToReturn.add(entsFromVclass.next()); entsFromVclass.remove(); count++; } if (log.isDebugEnabled()) log.debug("getEntitiesByVClassContinuation(): Creating reply with continue token," + " sending in this reply: " + count + ", remaing to send: " + entsInVClass.size()); } else { //send out reply with no continuation entsToReturn = entsInVClass; count = entsToReturn.size(); session.removeAttribute(resKey); if (log.isDebugEnabled()) log.debug("getEntitiesByVClassContinuation(): sending " + count + " Ind without continue token"); } //put all the entities on the JSON array JSONArray ja = individualsToJson(entsToReturn); //put the responseGroup number on the end of the JSON array if (more) { try { JSONObject obj = new JSONObject(); obj.put("resultGroup", "true"); obj.put("size", count); StringBuffer nextUrlStr = vreq.getRequestURL(); nextUrlStr.append("?").append("getEntitiesByVClass").append("=1&").append("resultKey=") .append(resKey); obj.put("nextUrl", nextUrlStr.toString()); ja.put(obj); } catch (JSONException je) { throw new ServletException(je.getMessage()); } } log.debug("done with getEntitiesByVClassContinuation()"); return ja; }
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 {// w w w . ja v a 2s . co 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: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, ".", ""); }//from w w w . j av a 2 s . c o m iterator.set(extension.toLowerCase().trim()); } return tokenizedList; }
From source file:com.cloudera.sqoop.cli.SqoopParser.java
@Override /**/*from w ww. j av a 2 s .co m*/ * 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); } }