List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.IntroJoinInsideSubplanRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op0 = (AbstractLogicalOperator) opRef.getValue(); if (op0.getOperatorTag() != LogicalOperatorTag.SUBPLAN) { return false; }// w w w .j av a 2 s . c o m SubplanOperator subplan = (SubplanOperator) op0; Mutable<ILogicalOperator> leftRef = subplan.getInputs().get(0); if (((AbstractLogicalOperator) leftRef.getValue()) .getOperatorTag() == LogicalOperatorTag.EMPTYTUPLESOURCE) { return false; } ListIterator<ILogicalPlan> plansIter = subplan.getNestedPlans().listIterator(); ILogicalPlan p = null; while (plansIter.hasNext()) { p = plansIter.next(); } if (p == null) { return false; } if (p.getRoots().size() != 1) { return false; } Mutable<ILogicalOperator> opRef1 = p.getRoots().get(0); while (true) { AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef1.getValue(); if (op1.getInputs().size() != 1) { return false; } if (op1.getOperatorTag() == LogicalOperatorTag.SELECT) { Mutable<ILogicalOperator> op2Ref = op1.getInputs().get(0); AbstractLogicalOperator op2 = (AbstractLogicalOperator) op2Ref.getValue(); if (op2.getOperatorTag() != LogicalOperatorTag.SELECT && descOrSelfIsScanOrJoin(op2)) { Set<LogicalVariable> free2 = new HashSet<LogicalVariable>(); OperatorPropertiesUtil.getFreeVariablesInSelfOrDesc(op2, free2); if (free2.isEmpty()) { Set<LogicalVariable> free1 = new HashSet<LogicalVariable>(); OperatorPropertiesUtil.getFreeVariablesInSelfOrDesc(op1, free1); if (!free1.isEmpty()) { OperatorManipulationUtil.ntsToEts(op2Ref, context); NestedTupleSourceOperator nts = new NestedTupleSourceOperator( new MutableObject<ILogicalOperator>(subplan)); Mutable<ILogicalOperator> ntsRef = new MutableObject<ILogicalOperator>(nts); Mutable<ILogicalOperator> innerRef = new MutableObject<ILogicalOperator>(op2); InnerJoinOperator join = new InnerJoinOperator( new MutableObject<ILogicalExpression>(ConstantExpression.TRUE), ntsRef, innerRef); op2Ref.setValue(join); context.computeAndSetTypeEnvironmentForOperator(nts); context.computeAndSetTypeEnvironmentForOperator(join); return true; } } } } opRef1 = op1.getInputs().get(0); } }
From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java
private String getNamedData(String name) { ListIterator<NameValuePair> itr = webData.listIterator(); while (itr.hasNext()) { NameValuePair t = itr.next(); if (t.getName() == name) { return t.getValue(); }//from w w w . ja v a2s . c o m } return new String(); }
From source file:edu.harvard.mcz.imagecapture.ConfiguredBarcodePositionTemplateDetector.java
protected String detectTemplateForImage(File anImageFile, CandidateImageFile scannableFile, boolean quickCheck) throws UnreadableFileException { // Set default response if no template is found. String result = PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS; // Read the image file, if possible, otherwise throw exception. if (!anImageFile.canRead()) { throw new UnreadableFileException("Unable to read " + anImageFile.getName()); }/*from w w w. j a va 2 s .c o m*/ BufferedImage image = null; try { image = ImageIO.read(anImageFile); } catch (IOException e) { throw new UnreadableFileException("IOException trying to read " + anImageFile.getName()); } // iterate through templates and check until the first template where a barcode is found List<String> templates = PositionTemplate.getTemplateIds(); ListIterator<String> i = templates.listIterator(); boolean found = false; while (i.hasNext() && !found) { try { // get the next template from the list PositionTemplate template = new PositionTemplate((String) i.next()); log.debug("Testing template: " + template.getTemplateId()); if (template.getTemplateId().equals(PositionTemplate.TEMPLATE_NO_COMPONENT_PARTS)) { // skip, this is the default result if no other is found. } else { if (image.getWidth() == template.getImageSize().getWidth()) { // Check to see if the barcode is in the part of the template // defined by getBarcodeULPosition and getBarcodeSize. String text; if (scannableFile == null) { text = CandidateImageFile.getBarcodeTextFromImage(image, template, quickCheck); } else { text = scannableFile.getBarcodeText(template); } log.debug("Found:[" + text + "] "); if (text.length() > 0) { // a barcode was scanned // Check to see if it matches the expected pattern. // Use the configured barcode matcher. if (Singleton.getSingletonInstance().getBarcodeMatcher().matchesPattern(text)) { found = true; log.debug("Match to:" + template.getTemplateId()); result = template.getTemplateId(); } } } else { log.debug("Skipping as template " + template.getTemplateId() + " is not same size as image. "); } } } catch (NoSuchTemplateException e) { // Ending up here means a serious error in PositionTemplate // as the list of position templates returned by getTemplates() includes // an entry that isn't recognized as a valid template. log.fatal( "Fatal error. PositionTemplate.getTemplates() includes an item that isn't a valid template."); log.trace(e); ImageCaptureApp.exit(ImageCaptureApp.EXIT_ERROR); } } return result; }
From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java
private void setNamedData(String name, String value) { ListIterator<NameValuePair> itr = webData.listIterator(); while (itr.hasNext()) { NameValuePair t = itr.next(); if (t.getName() == name) { itr.set(new BasicNameValuePair(name, value)); return; }//from w ww . j a v a 2 s.c o m } webData.add(new BasicNameValuePair(name, value)); }
From source file:com.bluelotussoftware.apache.commons.fileupload.example.FileUploadServlet.java
/** * Processes requests for both HTTP//from w ww .j av a 2 s. c om * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); boolean isMultiPart = ServletFileUpload.isMultipartContent(request); log("isMultipartContent: " + isMultiPart); log("Content-Type: " + request.getContentType()); if (isMultiPart) { // Create a factory for disk-based file items DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); /* * Set the file size limit in bytes. This should be set as an * initialization parameter */ diskFileItemFactory.setSizeThreshold(1024 * 1024 * 10); //10MB. // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(diskFileItemFactory); // Parse the request List items = null; try { items = upload.parseRequest(request); } catch (FileUploadException ex) { log("Could not parse request", ex); } PrintWriter out = response.getWriter(); out.print("<html><head><title>SUCCESS</title></head><body><h1>DONE!</h1>"); ListIterator li = items.listIterator(); while (li.hasNext()) { FileItem fileItem = (FileItem) li.next(); if (fileItem.isFormField()) { processFormField(fileItem); } else { out.append(processUploadedFile(fileItem)); } } out.print("</body></html>"); out.flush(); out.close(); } }
From source file:de.unisb.cs.st.javaslicer.tracer.instrumentation.PauseTracingInstrumenter.java
@SuppressWarnings("unchecked") public void transform(final ClassNode classNode) { final ListIterator<MethodNode> methodIt = classNode.methods.listIterator(); while (methodIt.hasNext()) { final MethodNode method = methodIt.next(); transformMethod(method, methodIt, Type.getObjectType(classNode.name).getClassName()); }/* w ww .j a va 2s . co m*/ }
From source file:edu.cornell.mannlib.vitro.webapp.controller.json.GetEntitiesByVClass.java
@Override protected JSONArray process() throws ServletException { log.debug("in getEntitiesByVClass()"); String vclassURI = vreq.getParameter("vclassURI"); WebappDaoFactory daos = vreq.getUnfilteredWebappDaoFactory(); if (vclassURI == null) { throw new ServletException("getEntitiesByVClass(): no value for 'vclassURI' found in the HTTP request"); }/* ww w. j a v a2s . c om*/ VClass vclass = daos.getVClassDao().getVClassByURI(vclassURI); if (vclass == null) { throw new ServletException("getEntitiesByVClass(): could not find vclass for uri '" + vclassURI + "'"); } List<Individual> entsInVClass = daos.getIndividualDao().getIndividualsByVClass(vclass); if (entsInVClass == null) { throw new ServletException( "getEntitiesByVClass(): null List<Individual> retruned by getIndividualsByVClass() for " + vclassURI); } int numberOfEntsInVClass = entsInVClass.size(); List<Individual> entsToReturn = new ArrayList<Individual>(REPLY_SIZE); String requestHash = null; int count = 0; boolean more = false; /* 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; HttpSession session = vreq.getSession(true); requestHash = Integer.toString((vclassURI + System.currentTimeMillis()).hashCode()); session.setAttribute(requestHash, entsInVClass); ListIterator<Individual> entsFromVclass = entsInVClass.listIterator(); while (entsFromVclass.hasNext() && count < REPLY_SIZE) { entsToReturn.add(entsFromVclass.next()); entsFromVclass.remove(); count++; } if (log.isDebugEnabled()) { log.debug("getEntitiesByVClass(): Creating reply with continue token, found " + numberOfEntsInVClass + " Individuals"); } } else { if (log.isDebugEnabled()) log.debug("getEntitiesByVClass(): sending " + numberOfEntsInVClass + " Individuals without continue token"); entsToReturn = entsInVClass; count = entsToReturn.size(); } //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); obj.put("total", numberOfEntsInVClass); StringBuffer nextUrlStr = vreq.getRequestURL(); nextUrlStr.append("?").append("getEntitiesByVClass").append("=1&").append("resultKey=") .append(requestHash); obj.put("nextUrl", nextUrlStr.toString()); ja.put(obj); } catch (JSONException je) { throw new ServletException("unable to create continuation as JSON: " + je.getMessage()); } } log.debug("done with getEntitiesByVClass()"); return ja; }
From source file:com.offbynull.voip.kademlia.model.NodeLeastRecentSet.java
public ActivityChangeSet remove(Node node) { Validate.notNull(node);/*ww w . j a va 2 s . c o m*/ Id nodeId = node.getId(); InternalValidate.matchesLength(baseId.getBitLength(), nodeId); ListIterator<Activity> it = entries.listIterator(); while (it.hasNext()) { Activity entry = it.next(); Id entryId = entry.getNode().getId(); if (entryId.equals(nodeId)) { InternalValidate.matchesLink(entry.getNode(), node); // remove it.remove(); return ActivityChangeSet.removed(entry); } } return ActivityChangeSet.NO_CHANGE; }
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AltQuestionText.java
private Question getQuestionFromList(String questionIdSeq, List questions) { ListIterator iterate = questions.listIterator(); while (iterate.hasNext()) { Question question = (Question) iterate.next(); if (question.getQuesIdseq().equals(questionIdSeq)) { return question; }//from www. ja v a 2 s . c o m } return null; }
From source file:de.fhg.iais.asc.ui.MyCortexStarter.java
/** * Configures this object according to a list of command line arguments.<br> * <br>/*from w ww. j a v a 2s .c o m*/ * The following arguments are recognized and processed from the left to the * right. Initially all servers are enabled.<br> * <br> * -conf <ConfigName> sets the name of the spring main configuration. * If there is more than one "-conf" argument, the rightmost one will be * used. If there is no "-conf" argument, the "default" spring main * configuration is used.<br> * <br> * +ALL enables all servers.<br> * -ALL disables all servers.<br> * +<servername> enables a single server.<br> * -<servername> disables a single server.<br> * <br> * Examples: to start all servers without the triplestore:<br> * +ALL -TRIPLESTORE<br> * Examples: to start only the triplestore server:<br> * -ALL +TRIPLESTORE<br> * Examples: to start the triplestore and the search server:<br> * -ALL +TRIPLESTORE +SEARCH<br> * Nonsense-examples: to start the search server:<br> * +ALL +TRIPLESTORE -ALL +SEARCH<br> */ private void configure(ListIterator<String> argIterator) { while (argIterator.hasNext()) { handleNextArgument(argIterator); } }