Example usage for java.util ListIterator next

List of usage examples for java.util ListIterator next

Introduction

In this page you can find the example usage for java.util ListIterator next.

Prototype

E next();

Source Link

Document

Returns the next element in the list and advances the cursor position.

Usage

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 ww  w  .j  a  v  a 2 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: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();
        if (obj instanceof GActionToolbar) {
            actionToolbar = (GActionToolbar) obj;
        }/*w w w .  j  a  va  2  s  . c om*/
    }
    return actionToolbar;
}

From source file:de.fhg.iais.asc.ui.MyCortexStarter.java

private void handleNextArgument(ListIterator<String> argIterator) {
    String arg = argIterator.next();
    if (StringUtils.isEmpty(arg)) {
        return;// w  ww . ja  v  a2  s .  c o  m
    }

    if (arg.equals("-conf")) {
        if (!argIterator.hasNext()) {
            LOG.warn("Found option \"-conf\" without [name of configuration] as next argument - ignored");
        } else {
            this.config = argIterator.next();
        }
    } else if (!handleServerArgument(arg)) {
        LOG.warn("Found unknown argument \"{}\" - ignored", arg);
    }
}

From source file:com.innoventsolutions.pentaho.birtrptdocplugin.BIRTContentGenerator.java

@Override
public void createContent() throws Exception {
    this.session = PentahoSessionHolder.getSession();
    this.repository = PentahoSystem.get(IUnifiedRepository.class, session);
    final RepositoryFile BIRTfile = (RepositoryFile) parameterProviders.get("path").getParameter("file");
    final String ExecBIRTFilePath = "../webapps/birt/" + BIRTfile.getId() + ".rptdocument";
    /*//  ww w .j av  a2s  .c  o  m
     * Get BIRT report design from repository
     */
    final File ExecBIRTFile = new File(ExecBIRTFilePath);
    if (!ExecBIRTFile.exists()) {
        final FileOutputStream fos = new FileOutputStream(ExecBIRTFilePath);
        try {
            final SimpleRepositoryFileData data = repository.getDataForRead(BIRTfile.getId(),
                    SimpleRepositoryFileData.class);
            final InputStream inputStream = data.getInputStream();
            final byte[] buffer = new byte[0x1000];
            int bytesRead = inputStream.read(buffer);
            while (bytesRead >= 0) {
                fos.write(buffer, 0, bytesRead);
                bytesRead = inputStream.read(buffer);
            }
        } catch (final Exception e) {
            Logger.error(getClass().getName(), e.getMessage());
        } finally {
            fos.close();
        }
    }
    /*
     * Redirect to BIRT Viewer
     */
    try {
        // Get informations about user context
        final IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class);
        String roles = "";
        final ListIterator<String> li = service.getRolesForUser(null, session.getName()).listIterator();
        while (li.hasNext()) {
            roles = roles + li.next().toString() + ",";
        }
        // Redirect
        final HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path")
                .getParameter("httpresponse");
        response.sendRedirect(
                "/birt/frameset?__document=" + BIRTfile.getId() + ".rptdocument&__showtitle=false&username="
                        + session.getName() + "&userroles=" + roles + "&reportname=" + BIRTfile.getTitle());
    } catch (final Exception e) {
        Logger.error(getClass().getName(), e.getMessage());
    }
}

From source file:mimir.ControlChart.java

public void printSignals() {
    ListIterator<String> flagChecker = this.signals.listIterator(0);
    while (flagChecker.hasNext()) {
        System.out.println(flagChecker.next());
    }//  ww w  .jav  a2s  . c  o  m
}

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;//w  ww. jav a 2 s  . c o  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: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:org.zilverline.core.TestFileSystemCollection.java

public void testAllCollections() throws Exception {
    CollectionManager c = (CollectionManager) applicationContext.getBean("collectionMan");
    assertNotNull(c);// ww w  .j a va  2s .com

    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.liferay.maven.arquillian.internal.tasks.ToolsClasspathTask.java

@Override
public URLClassLoader execute(MavenWorkingSession session) {

    final Logger log = LoggerFactory.getLogger(ToolsClasspathTask.class);

    final ParsedPomFile pomFile = session.getParsedPomFile();

    LiferayPluginConfiguration configuration = new LiferayPluginConfiguration(pomFile);

    System.setProperty("liferayVersion", configuration.getLiferayVersion());

    File appServerLibGlobalDir = new File(configuration.getAppServerLibGlobalDir());

    File appServerLibPortalDir = new File(configuration.getAppServerLibPortalDir());

    List<URI> liferayToolArchives = new ArrayList<URI>();

    if (appServerLibGlobalDir != null && appServerLibGlobalDir.exists()) {

        // app server global libraries
        Collection<File> appServerLibs = FileUtils.listFiles(appServerLibGlobalDir, new String[] { "jar" },
                true);/*from   w  w  w . j a  va 2 s  .co  m*/

        for (File file : appServerLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // All Liferay Portal Lib jars
        Collection<File> liferayPortalLibs = FileUtils.listFiles(appServerLibPortalDir, new String[] { "jar" },
                true);

        for (File file : liferayPortalLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // Util jars
        File[] utilJars = Maven.resolver().loadPomFromClassLoaderResource("liferay-tool-deps.xml")
                .importCompileAndRuntimeDependencies().resolve().using(AcceptAllStrategy.INSTANCE).asFile();

        for (int i = 0; i < utilJars.length; i++) {
            liferayToolArchives.add(utilJars[i].toURI());
        }

    }

    log.trace("Jars count in Tools classpath Archive:" + liferayToolArchives.size());

    List<URL> classpathUrls = new ArrayList<URL>();

    try {
        if (!liferayToolArchives.isEmpty()) {

            ListIterator<URI> toolsJarItr = liferayToolArchives.listIterator();
            while (toolsJarItr.hasNext()) {
                URI jarURI = toolsJarItr.next();
                classpathUrls.add(jarURI.toURL());
            }

        }
    } catch (MalformedURLException e) {
        log.error("Error building Tools classpath", e);
    }

    return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), null);
}

From source file:com.nuodb.migrator.cli.parse.parser.ParserImpl.java

/**
 * Parse the withConnection.arguments according to the specified options and properties.
 *
 * @param arguments to parse.//from  w w w.  j a v  a  2  s  .  c o m
 * @param option    sets the option to parse against.
 * @return the option setValue object.
 */
public OptionSet parse(String[] arguments, Option option) throws OptionException {
    if (logger.isTraceEnabled()) {
        logger.trace(format("Parsing options %s", join(asList(arguments), " ")));
    }
    List<String> list = Lists.newArrayList(arguments);

    CommandLine commandLine = new CommandLineImpl(option, list);
    // pick up any defaults from the meta
    option.defaults(commandLine);
    // withConnection the options as far as possible
    ListIterator<String> iterator = list.listIterator();
    Object previous = null;
    while (option.canProcess(commandLine, iterator)) {
        // peek at the next item and backtrack
        String current = iterator.next();
        iterator.previous();
        // if we have just tried to process this instance
        if (current == previous) {
            // abort
            break;
        }
        previous = current;
        option.preProcess(commandLine, iterator);
        option.process(commandLine, iterator);
    }
    if (iterator.hasNext()) {
        throw new OptionException(format("Unexpected argument %s", iterator.next()), option);
    }
    option.postProcess(commandLine);
    return commandLine;
}