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:VisitorExample.java

public void visit(Element node) {
    Namespace ns = node.getNamespace();

    if (ns.getURI().equals(from.getURI())) {
        QName newQName = new QName(node.getName(), to);
        node.setQName(newQName);//from  w w w.  j a v  a2  s.c om
    }

    ListIterator namespaces = node.additionalNamespaces().listIterator();
    while (namespaces.hasNext()) {
        Namespace additionalNamespace = (Namespace) namespaces.next();
        if (additionalNamespace.getURI().equals(from.getURI())) {
            namespaces.remove();
        }
    }
}

From source file:org.smartfrog.services.deployapi.notifications.EventSubscriberManager.java

/**
 * Do a clean up of old/expired/disconnected entries
 * @return number of purged elements/*  w w w . jav  a 2s  .  c o m*/
 */
public synchronized int purge() {
    int purged = 0;
    ListIterator<EventSubscription> it = subscriptions.listIterator();
    while (it.hasNext()) {
        EventSubscription sub = it.next();
        if (!sub.probe()) {
            it.remove();
            purged++;
        }
    }
    return purged;
}

From source file:net.alchemiestick.katana.winehqappdb.Metrics.java

private void removeNamedData(String name) {
    ListIterator<NameValuePair> itr = webData.listIterator();
    while (itr.hasNext()) {
        NameValuePair t = itr.next();
        if (t.getName() == name) {
            itr.remove();
            return;
        }//  w  w w.j a  v a 2  s. co  m
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaSearchQueryOptions.java

private List<Individual> removeSubjectUri(List<Individual> individuals, String subjectUri) {
    ListIterator<Individual> it = individuals.listIterator();
    while (it.hasNext()) {
        Individual ind = it.next();/*from w w  w  .  ja v  a 2 s. c o m*/
        if (ind.getURI().equals(subjectUri)) {
            it.remove();
        }
    }
    return individuals;
}

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();
                }//from w ww . j av  a  2  s  . co m
            }
        }
        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:org.jactr.core.event.ACTREventDispatcher.java

synchronized public void removeListener(L listener) {
    if (_actualListeners == null)
        return;/*from w  w w  . j a  v a  2  s.co m*/

    ListIterator<Pair> itr = _actualListeners.listIterator();
    while (itr.hasNext()) {
        Pair pair = itr.next();
        if (pair.hasListener(listener))
            itr.remove();
    }

    if (_actualListeners.size() == 0) {
        FastList.recycle(_actualListeners);
        _actualListeners = null;
    }
}

From source file:org.jcodec.movtool.Cut.java

private void selectInner(List<Edit> edits, Slice cut, MovieBox movie, TrakBox trakBox) {
    long inMv = (long) (movie.getTimescale() * cut.inSec);
    long outMv = (long) (movie.getTimescale() * cut.outSec);

    long editStart = 0;
    ListIterator<Edit> lit = edits.listIterator();
    while (lit.hasNext()) {
        Edit edit = lit.next();//from  w w w . j av a2s.  c  o m
        if (editStart + edit.getDuration() <= inMv || editStart >= outMv)
            lit.remove();
        editStart += edit.getDuration();
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java

private void trimStackTraceAtEnd(List<StackTraceElement> list) {
    ListIterator<StackTraceElement> iter = list.listIterator();
    boolean trimming = false;
    while (iter.hasNext()) {
        StackTraceElement ste = iter.next();
        if (trimming) {
            iter.remove();
        } else if (ste.getClassName().contains("ApplicationFilterChain")) {
            trimming = true;//from   w  w  w .j a va 2  s  .com
        }
    }
}

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   w  w w . 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.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java

private void removeJenaClassesFromStackTrace(List<StackTraceElement> list) {
    ListIterator<StackTraceElement> iter = list.listIterator();
    while (iter.hasNext()) {
        StackTraceElement ste = iter.next();
        if (ste.getClassName().startsWith("com.hp.hpl.jena.")) {
            iter.remove();
        }//from   w  w  w . j  a  v  a2  s  . c  o m
    }
}