Example usage for java.util ListIterator remove

List of usage examples for java.util ListIterator remove

Introduction

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

Prototype

void remove();

Source Link

Document

Removes from the list the last element that was returned by #next or #previous (optional operation).

Usage

From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java

private List<Individual> removeIndividualsAlreadyInRange(List<Individual> indiviuals,
        List<ObjectPropertyStatement> stmts) {
    log.trace(/*from  w  w w. j  a  va  2  s .c om*/
            "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:org.zkoss.ganttz.util.WeakReferencedListeners.java

private List<T> getActiveListeners() {
    ListIterator<WeakReference<T>> listIterator = listeners.listIterator();
    List<T> result = new ArrayList<>();

    while (listIterator.hasNext()) {
        T listener = listIterator.next().get();
        if (listener == null) {
            listIterator.remove();
        } else {//from  w ww .  j  a va  2  s .  c  om
            result.add(listener);
        }
    }

    return result;
}

From source file:org.openecomp.sdnc.sli.SliPluginUtils.SvcLogicContextList.java

public void remove(String key, String value) {
    if (value == null) {
        throw new IllegalArgumentException("value cannot be null");
    }//  w w  w .jav  a 2s .  c  o  m

    ListIterator<HashMap<String, String>> itr = this.list.listIterator();
    while (itr.hasNext()) {
        if (value.equals(itr.next().get(key))) {
            itr.remove();
        }
    }
}

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 w  w w.j av a 2 s .  co 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:net.erdfelt.android.sdkfido.project.SourceCopier.java

public void identifyCopiedFiles(Dir sourceDir) throws IOException {
    if (javalisting == null) {
        return; // nothing to do here
    }/* w w  w  .  j  a  v  a  2 s. c  o  m*/
    File searchFile;
    String javafilename;
    ListIterator<String> iterlisting = javalisting.listIterator();
    while (iterlisting.hasNext()) {
        javafilename = iterlisting.next();
        searchFile = sourceDir.getFile(javafilename);
        if (searchFile.exists()) {
            iterlisting.remove();
            out.println("[FOUND] " + javafilename);
        }
    }
}

From source file:org.openvpms.archetype.rules.workflow.FreeSlotIterators.java

/**
 * Gets the next iterator./*  ww w.  ja va2  s .  co m*/
 */
private void getNext() {
    next = null;
    ListIterator<PeekingIterator<Slot>> listIterator = iterators.listIterator();
    Date minDate = null;
    while (listIterator.hasNext()) {
        PeekingIterator<Slot> iterator = listIterator.next();
        if (!iterator.hasNext()) {
            listIterator.remove();
        } else {
            Slot slot = iterator.peek();
            if (minDate == null || DateRules.compareTo(minDate, slot.getStartTime()) > 0) {
                minDate = slot.getStartTime();
                next = iterator;
            }
        }
    }
}

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");
    }/*from   w  w w.j a v  a 2  s  .  c  o  m*/

    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:org.jspringbot.keyword.csv.CSVState.java

public void setFirstLineAsHeader() {
    ListIterator<String[]> itr = lines.listIterator();

    setHeaders(itr.next());
    itr.remove();
}

From source file:org.yamj.core.database.dao.PlayerDao.java

/**
 * Delete a path from a player//  w w w. j a  v a  2s . c om
 *
 * @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:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java

private void trimStackTraceAtBeginning(List<StackTraceElement> list) {
    ListIterator<StackTraceElement> iter = list.listIterator();
    while (iter.hasNext()) {
        StackTraceElement ste = iter.next();
        if (ste.getClassName().equals(lowestClassInStackTrace.getName())) {
            break;
        } else {//from   ww w . j a  v  a2 s.  c o  m
            iter.remove();
        }
    }
}