List of usage examples for java.util ListIterator next
E next();
From source file:com.xtivia.training.BookPortlet.java
@ProcessAction(name = "ajaxDelete") public void ajaxDelete(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { response.setContentType("text/html"); String isbn = request.getParameter("isbn"); ListIterator iterator = books.listIterator(); while (iterator.hasNext()) { Book book = (Book) iterator.next(); String isbns = book.getIsbnNumber() + ""; if (isbn.equals(isbns)) { iterator.remove();//from w w w . j a v a 2s .co m } } request.setAttribute("books", books); System.out.println("I am in ajax delete"); /*request.setAttribute("books", books); System.out.println("I am here whats up"); include(templateJSP, request, response, PortletRequest.RESOURCE_PHASE);*/ }
From source file:com.xtivia.training.BookPortlet.java
public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { response.setContentType("text/html"); String message = request.getParameter("message"); String isbn = message;// w w w .j av a 2 s . c om ListIterator iterator = books.listIterator(); while (iterator.hasNext()) { Book book = (Book) iterator.next(); String isbns = book.getIsbnNumber() + ""; if (isbn.equals(isbns)) { iterator.remove(); } } request.setAttribute("books", books); System.out.println("I am in ajax delete"); // this seems to be the page that was calling...? String resourceID = request.getResourceID(); System.out.println("resourceId was : " + resourceID); System.out.println("message was : " + message); }
From source file:edu.harvard.mcz.imagecapture.TemplatePickerDialog.java
protected boolean setupForImage(ICImage image) throws UnreadableFileException { boolean result = false; imageToTemplate = image;/*from w w w .j a v a 2 s . c om*/ StringBuffer heading = new StringBuffer(); heading.append("Current Template:"); heading.append(" ").append(image.getTemplateId()); StringBuffer filename = new StringBuffer(); filename.append(image.getPath()).append(File.pathSeparator).append(image.getFilename()); this.lblFileName.setText(filename.toString()); lblTemplate.setText(heading.toString()); comboBoxTemplatePicker.addItem(image.getTemplateId()); File imageFile = new File( ImageCaptureProperties.assemblePathWithBase(image.getPath(), image.getFilename())); BufferedImage bufImage = null; int imageWidth = 0; try { bufImage = ImageIO.read(imageFile); imageWidth = bufImage.getWidth(); } catch (IOException e) { throw new UnreadableFileException("IOException trying to read " + imageFile.getName()); } if (imageFile.exists()) { List<PositionTemplate> templates = PositionTemplate.getTemplates(); ListIterator<PositionTemplate> i = templates.listIterator(); while (i.hasNext()) { PositionTemplate template = i.next(); if (!template.getTemplateId().equals(PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS)) { int templateWidth = -1; try { templateWidth = (int) template.getImageSize().getWidth(); } catch (NullPointerException e) { log.debug(e.getMessage()); } if (imageWidth == templateWidth) { comboBoxTemplatePicker.addItem(template.getTemplateId()); } } } } return result; }
From source file:com.edgenius.wiki.render.macro.BaseMacro.java
/** * Move Iterator cursor backward or forward to given node. You must ensure then direction is correct! * This location will only following "forward inertia". <br> * "Inertia" means, if iterator goes previous, then next, the same cursor will return, likewise in next->previous. * (see {@link com.edgenius.wiki.gwt.client.html.TestHTMLNodeContainer#testIteratorAdd()}) <br> * /*from w w w . j a va 2 s. c om*/ * This method will if call next(), it already return next HTMNode from current cursor. But if call previous(), * it returns current cursor at first time. * * @param node * @param iter * @param forward */ protected void moveIteratorCursorTo(HTMLNode node, ListIterator<HTMLNode> iter, boolean forward) { if (forward) { if (iter.hasNext()) { HTMLNode cursor = iter.next(); if (cursor.previous() != node) { //this is just ensure, iter current position is not equals with given node while (cursor != node && iter.hasNext()) { cursor = iter.next(); } } } } else { //backward if (iter.hasPrevious()) { HTMLNode cursor = iter.previous(); if (cursor.next() != node) { //this is just ensure, iter current position is not equals with given node while (cursor != node && iter.hasPrevious()) { cursor = iter.previous(); } } //delete inertia iter.next(); } } }
From source file:br.com.ingenieux.mojo.beanstalk.version.RollbackVersionMojo.java
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { // TODO: Deal with withVersionLabels DescribeApplicationVersionsRequest describeApplicationVersionsRequest = new DescribeApplicationVersionsRequest() .withApplicationName(applicationName); DescribeApplicationVersionsResult appVersions = getService() .describeApplicationVersions(describeApplicationVersionsRequest); DescribeEnvironmentsRequest describeEnvironmentsRequest = new DescribeEnvironmentsRequest() .withApplicationName(applicationName).withEnvironmentIds(curEnv.getEnvironmentId()) .withEnvironmentNames(curEnv.getEnvironmentName()).withIncludeDeleted(false); DescribeEnvironmentsResult environments = getService().describeEnvironments(describeEnvironmentsRequest); List<ApplicationVersionDescription> appVersionList = new ArrayList<ApplicationVersionDescription>( appVersions.getApplicationVersions()); List<EnvironmentDescription> environmentList = environments.getEnvironments(); if (environmentList.isEmpty()) { throw new MojoFailureException("No environments were found"); }/*www. ja v a 2s .c om*/ EnvironmentDescription d = environmentList.get(0); Collections.sort(appVersionList, new Comparator<ApplicationVersionDescription>() { @Override public int compare(ApplicationVersionDescription o1, ApplicationVersionDescription o2) { return new CompareToBuilder().append(o1.getDateUpdated(), o2.getDateUpdated()).toComparison(); } }); Collections.reverse(appVersionList); if (latestVersionInstead) { ApplicationVersionDescription latestVersionDescription = appVersionList.get(0); return changeToVersion(d, latestVersionDescription); } ListIterator<ApplicationVersionDescription> versionIterator = appVersionList.listIterator(); String curVersionLabel = d.getVersionLabel(); while (versionIterator.hasNext()) { ApplicationVersionDescription versionDescription = versionIterator.next(); String versionLabel = versionDescription.getVersionLabel(); if (curVersionLabel.equals(versionLabel) && versionIterator.hasNext()) { return changeToVersion(d, versionIterator.next()); } } throw new MojoFailureException("No previous version was found (current version: " + curVersionLabel); }
From source file:org.socraticgrid.codeconversion.matchers.DescMatch.java
/** * Load the XML Document./* w ww . j a v a 2 s .c o m*/ * * @param is * * @throws InitializationException */ protected void load(InputStream is) throws InitializationException { try { JAXBContext jaxbContext = JAXBContext .newInstance(org.socraticgrid.codeconversion.matchers.xml.ObjectFactory.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); org.socraticgrid.codeconversion.matchers.xml.DescMatch xmlMap = (org.socraticgrid.codeconversion.matchers.xml.DescMatch) jaxbUnmarshaller .unmarshal(is); Iterator<TargetSystem> itr = xmlMap.getTargetSystem().iterator(); while (itr.hasNext()) { TargetSystem ts = itr.next(); // Update contract.addTargetSystem(ts.getTargetSystemCode()); TargetSystemCodeMap tsm = new TargetSystemCodeMap(); tsMap.put(ts.getTargetSystemCode(), tsm); ListIterator<SourceCoding> sItr = ts.getSourceCoding().listIterator(); while (sItr.hasNext()) { SourceCoding sc = sItr.next(); HashMap<String, SourceCoding> map; if (tsm.SrchMap.containsKey(sc.getSourceName())) { map = tsm.SrchMap.get(sc.getSourceName()); } else { map = new HashMap<>(); tsm.SrchMap.put(sc.getSourceName(), map); } map.put(sc.getSourceSystem(), sc); } } } catch (JAXBException exp) { throw new InitializationException("MapMap, Error parsing code map", exp); } }
From source file:vteaexploration.plotgatetools.gates.PolygonGate.java
@Override public Path2D createPath2D() { Point2D p;//from w ww. j av a 2s . c om Path2D.Double polygon = new Path2D.Double(); ListIterator<Point2D.Double> itr = vertices.listIterator(); p = (Point2D) vertices.get(0); polygon.moveTo(p.getX(), p.getY()); while (itr.hasNext()) { p = (Point2D) itr.next(); polygon.lineTo(p.getX(), p.getY()); } polygon.closePath(); return polygon; }
From source file:com.xtivia.training.BookPortlet.java
@ProcessAction(name = "editBookAction") public void editBookAction(ActionRequest actionRequest, ActionResponse actionResponse) { String isbn = actionRequest.getParameter("isbn"); ArrayList<String> errors = new ArrayList<String>(); Book bookEdit = ActionUtil.getFormRequest(actionRequest); boolean validate = ValidateBook.validateBook(bookEdit, errors); Book fromArray = null;// w ww. j a va 2 s . c om if (validate) { ListIterator iterator = books.listIterator(); while (iterator.hasNext()) { Book book = (Book) iterator.next(); String isbns = book.getIsbnNumber() + ""; if (isbn.equals(isbns)) { iterator.remove(); } } books.add(bookEdit); actionRequest.setAttribute("book", bookEdit); actionResponse.setRenderParameter(MYACTION_PARAM, bookJSP); } else { for (String error : errors) { SessionErrors.add(actionRequest, error); } SessionErrors.add(actionRequest, "error-saving-book"); actionResponse.setRenderParameter(MYACTION_PARAM, addJSP); actionRequest.setAttribute("book", bookEdit); actionRequest.setAttribute("edit", "edit"); } }
From source file:com.amazonaws.services.kinesis.clientlibrary.lib.worker.ProcessTask.java
/** * Scans a list of records to filter out records up to and including the most recent checkpoint value and to get * the greatest extended sequence number from the retained records. Also emits metrics about the records. * * @param scope metrics scope to emit metrics into * @param records list of records to scan and change in-place as needed * @param lastCheckpointValue the most recent checkpoint value * @param lastLargestPermittedCheckpointValue previous largest permitted checkpoint value * @return the largest extended sequence number among the retained records *///from w w w .j av a 2 s . c o m private ExtendedSequenceNumber filterAndGetMaxExtendedSequenceNumber(IMetricsScope scope, List<Record> records, final ExtendedSequenceNumber lastCheckpointValue, final ExtendedSequenceNumber lastLargestPermittedCheckpointValue) { ExtendedSequenceNumber largestExtendedSequenceNumber = lastLargestPermittedCheckpointValue; ListIterator<Record> recordIterator = records.listIterator(); while (recordIterator.hasNext()) { Record record = recordIterator.next(); ExtendedSequenceNumber extendedSequenceNumber = new ExtendedSequenceNumber(record.getSequenceNumber(), record instanceof UserRecord ? ((UserRecord) record).getSubSequenceNumber() : null); if (extendedSequenceNumber.compareTo(lastCheckpointValue) <= 0) { recordIterator.remove(); LOG.debug("removing record with ESN " + extendedSequenceNumber + " because the ESN is <= checkpoint (" + lastCheckpointValue + ")"); continue; } if (largestExtendedSequenceNumber == null || largestExtendedSequenceNumber.compareTo(extendedSequenceNumber) < 0) { largestExtendedSequenceNumber = extendedSequenceNumber; } scope.addData(DATA_BYTES_PROCESSED_METRIC, record.getData().limit(), StandardUnit.Bytes, MetricsLevel.SUMMARY); } return largestExtendedSequenceNumber; }
From source file:com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.java
@Override public Outcome handleRequest(Exchange exc) throws Exception { logMappings();//from w ww .ja v a2 s.co m ListIterator<String> it = exc.getDestinations().listIterator(); while (it.hasNext()) { String dest = it.next(); String pathQuery = URLUtil.getPathQuery(router.getUriFactory(), dest); int pathBegin = -1; int authorityBegin = dest.indexOf("//"); if (authorityBegin != -1) pathBegin = dest.indexOf("/", authorityBegin + 2); String schemaHostPort = pathBegin == -1 ? null : dest.substring(0, pathBegin); log.debug("pathQuery: " + pathQuery); log.debug("schemaHostPort: " + schemaHostPort); Mapping mapping = findFirstMatchingRegEx(pathQuery); if (mapping == null) continue; Type do_ = mapping.getDo(); log.debug("match found: " + mapping.from); log.debug("replacing with: " + mapping.to); log.debug("for type: " + do_); String newDest = replace(pathQuery, mapping); if (do_ == Type.REDIRECT_PERMANENT || do_ == Type.REDIRECT_TEMPORARY) { exc.setResponse(Response.redirect(newDest, do_ == Type.REDIRECT_PERMANENT).build()); return Outcome.RETURN; } if (!newDest.contains("://") && schemaHostPort != null) { // prepend schema, host and port from original uri newDest = schemaHostPort + newDest; } it.set(newDest); } Mapping mapping = findFirstMatchingRegEx(exc.getRequest().getUri()); if (mapping != null && mapping.do_ == Type.REWRITE) { String newDest = replace(exc.getRequest().getUri(), mapping); if (newDest.contains("://")) { newDest = URLUtil.getPathQuery(router.getUriFactory(), newDest); } exc.getRequest().setUri(newDest); } return Outcome.CONTINUE; }