Example usage for java.util List remove

List of usage examples for java.util List remove

Introduction

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

Prototype

E remove(int index);

Source Link

Document

Removes the element at the specified position in this list (optional operation).

Usage

From source file:cn.com.sinosoft.util.exception.ExceptionUtils.java

/**
 * <p>//  w  w  w  .j  ava 2  s . c  o m
 * Removes from the list of method names used in the search for
 * <code>Throwable</code> objects.
 * </p>
 * 
 * @param methodName
 *            the methodName to remove from the list, <code>null</code> and
 *            empty strings are ignored
 * @since 2.1
 */
public static void removeCauseMethodName(String methodName) {
    if (StringUtils.isNotEmpty(methodName)) {
        List list = getCauseMethodNameList();
        if (list.remove(methodName)) {
            synchronized (CAUSE_METHOD_NAMES_LOCK) {
                CAUSE_METHOD_NAMES = toArray(list);
            }
        }
    }
}

From source file:hudson.util.CopyOnWriteList.java

/**
 * Removes an item from the list./*from   w w w  . ja v a2s  .co m*/
 *
 * @return
 *      true if the list contained the item. False if it didn't,
 *      in which case there's no change.
 */
public synchronized boolean remove(E e) {
    List<E> n = new ArrayList<E>(core);
    boolean r = n.remove(e);
    core = n;
    return r;
}

From source file:com.liferay.portal.spring.context.PortalApplicationContext.java

protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
    try {/*from  w  w  w  .  ja  v  a 2  s.c  o  m*/
        super.loadBeanDefinitions(reader);
    } catch (Exception e) {
        if (_log.isWarnEnabled()) {
            _log.warn(e, e);
        }
    }

    reader.setResourceLoader(new DefaultResourceLoader());

    if (PropsValues.SPRING_CONFIGS == null) {
        return;
    }

    List<String> configLocations = ListUtil.fromArray(PropsValues.SPRING_CONFIGS);

    if (PropsValues.PERSISTENCE_PROVIDER.equalsIgnoreCase("jpa")) {
        configLocations.remove("META-INF/hibernate-spring.xml");
    } else {
        configLocations.remove("META-INF/jpa-spring.xml");
    }

    reader.setResourceLoader(new PathMatchingResourcePatternResolver());
    for (String configLocation : configLocations) {
        try {
            reader.loadBeanDefinitions(configLocation);
        } catch (Exception e) {
            Throwable cause = e.getCause();

            if (cause instanceof FileNotFoundException) {
                if (_log.isWarnEnabled()) {
                    _log.warn(cause.getMessage());
                }
            } else {
                _log.error(e, e);
            }
        }
    }
}

From source file:com.o19s.solr.swan.nodes.SwanXOrOperationNode.java

@Override
public SpanQuery getSpanQuery(String field) {
    SpanOrQuery query = new SpanOrQuery();

    List<SwanNode> inc;
    for (int x = 0; x < _nodes.size(); x++) {
        inc = new ArrayList<SwanNode>();
        inc.addAll(_nodes);/*w w  w .j  a va2 s .co m*/
        inc.remove(x);

        SpanOrQuery or = new SpanOrQuery();
        for (SwanNode n : inc) {
            or.addClause(n.getSpanQuery(field));
        }
        if (or.getClauses().length > 0) {
            SpanNotQuery not = new SpanNotQuery(_nodes.get(x).getSpanQuery(field), or);
            query.addClause(not);
        }
    }

    return query;
}

From source file:com.inmobi.grill.server.EventServiceImpl.java

@Override
public void removeListener(GrillEventListener listener) {
    synchronized (eventListeners) {
        for (List<GrillEventListener> listeners : eventListeners.values()) {
            if (listeners.remove(listener)) {
                LOG.info("Removed listener " + listener);
            }//from   www.  j a v a  2s .  c om
        }
    }
}

From source file:com.transcend.loadbalancer.worker.DeregisterInstancesFromLoadBalancerWorker.java

@Override
protected DeregisterInstancesFromLoadBalancerResponse doWork0(DeregisterInstancesFromLoadBalancerRequest r,
        ServiceRequestContext context) throws Exception {
    final DeregisterInstancesFromLoadBalancerResponse.Builder ret = DeregisterInstancesFromLoadBalancerResponse
            .newBuilder();/*from   ww  w.  ja v a 2 s . com*/
    final Session session = getSession();

    final String name = r.getLoadBalancerName();
    logger.debug("Operation DeregisterInstancesFromLoadBalancer " + name);

    // find out if load balancer exists
    final AccountBean ac = context.getAccountBean();
    final LoadBalancerBean lbean = LoadBalancerUtil.read(session, ac.getId(), name);
    if (lbean == null) {
        throw LoadBalancerQueryFaults.loadBalancerNotFound();
    }

    final LoadBalancerType lbtype = LoadBalancerUtil.toLoadBalancerType(session, lbean);
    final List<String> instances = lbtype.getInstances();
    for (final String in : r.getInstanceList()) {
        if (instances.contains(in)) {
            instances.remove(in);
        } else {
            throw LoadBalancerQueryFaults.invalidInstance();
        }
    }

    for (String in : instances) {
        ret.addInstance(in);
    }
    ret.setLoadBalancerName(name);
    DeregisterInstancesFromLoadBalancerResponse result = ret.buildPartial();
    logger.debug("Response " + result.toString());
    return result;
}

From source file:edu.sjsu.cmpe275.lab2.service.ManageFriendshipController.java

/** Remove a friendship object
 (10) Remove a friend//from   w w  w . j  a v  a2s.  c  om
 Path:friends/{id1}/{id2}
 Method: DELETE
        
 This request removes the friendship relation between the two persons.
 If either person does not exist, return 404.
 If the two persons are not friends, return 404. Otherwise,
 Remove this friendship relation. Return HTTP code 200 and a meaningful text message if all is successful.
        
 * @param a         Description of a
 * @param b         Description of b
 * @return         Description of c
 */

@RequestMapping(value = "/{id1}/{id2}", method = RequestMethod.DELETE)
public ResponseEntity deleteFriendship(@PathVariable("id1") long id1, @PathVariable("id2") long id2) {
    Session session = null;
    Transaction transaction = null;
    Person person1 = null, person2 = null;
    try {
        session = sessionFactory.openSession();
        transaction = session.beginTransaction();
        person1 = (Person) session.get(Person.class, id1);
        person2 = (Person) session.get(Person.class, id2);
        if (person1 == null || person2 == null) {
            throw new HibernateException("can't find person records with id1 = " + id1 + " and id2 = " + id2);
        }
        List<Person> l = person1.getFriends();
        if (l.contains(person2)) {
            l.remove(person2);
        }

        l = person2.getFriends();
        if (l.contains(person1)) {
            l.remove(person1);
        }

        session.update(person1);
        session.update(person2);
        transaction.commit();
    } catch (HibernateException e) {
        if (transaction != null) {
            transaction.rollback();
        }
        return new ResponseEntity("can't find person records with id1 = " + id1 + " and id2 = " + id2,
                HttpStatus.NOT_FOUND);

    } finally {
        if (session != null) {
            session.close();
        }
    }
    return new ResponseEntity("you have deleted a friendship.", HttpStatus.OK);
}

From source file:com.adito.tunnels.agent.DefaultRemoteTunnelManager.java

public void removeRemoteTunnel(RemoteTunnel tunnel) {
    synchronized (tunnels) {
        String tunnelId = tunnel.getTunnel().getSourcePort() + "-"
                + (tunnel.getTunnel().getSourceInterface() == null
                        || tunnel.getTunnel().getSourceInterface().equals("") ? ""
                                : tunnel.getTunnel().getSourceInterface());
        if (log.isInfoEnabled())
            log.info("Removing remote tunnel with id of " + tunnelId);
        tunnels.remove(tunnelId);//from w ww.  j a  v a2 s  . c o m
        List<RemoteTunnel> sessionTunnels = tunnelsBySession.get(tunnel.getAgent().getSession().getId());
        sessionTunnels.remove(tunnel);
        if (sessionTunnels.size() == 0) {
            tunnelsBySession.remove(tunnel.getAgent().getSession().getId());
        }
    }

}

From source file:com.museum_web.controller.ChallengeController.java

@RequestMapping("actions/removeAnswer/{Answer}")
public void removeAnswer(@PathVariable("Answer") Long answer, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    List<Answer> aux = c.getAnswers();

    for (Answer x : aux) {
        if (x.getId().compareTo(answer) == 0) {
            aux.remove(x);
            break;
        }//from   ww w  . j  a  v  a 2 s .co m
    }
    c.setAnswers(aux);

    new ChallengeService().editChallenge(c);

    response.sendRedirect("../../challengeCreate?id=" + c.getChallengeId());

}

From source file:it.tidalwave.northernwind.core.impl.model.DefaultRequestLocaleManager.java

/*******************************************************************************************************************
 *
 * {@inheritDoc}/*from w  w  w.ja  v  a  2s. c  om*/
 *
 ******************************************************************************************************************/
@Override
@Nonnull
public List<Locale> getLocales() {
    final Locale requestLocale = localeHolder.get();
    final List<Locale> locales = new ArrayList<>(siteProvider.get().getSite().getConfiguredLocales());

    if (requestLocale != null) {
        locales.remove(requestLocale);
        locales.add(0, requestLocale);
    }

    log.debug(">>>> locales: {}", locales);

    return locales;
}