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:com.aperigeek.dropvault.dav.DAVClient.java

protected List<Resource> getResources(Resource parent, String depth) throws DAVException {
    HttpPropfind propfind = new HttpPropfind(parent.getHref());
    propfind.addHeader("Depth", depth);

    try {/* w ww. ja v a 2s . c  o  m*/
        HttpResponse response = client.execute(propfind);

        InputStream in = response.getEntity().getContent();

        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(in);
        List<Element> elements = document.getRootElement().getChildren("response", DAV_NS);

        List<Resource> resources = buildResources(elements);
        resources.remove(parent);

        return resources;
    } catch (ParseException ex) {
        throw new DAVException("Error in XML returned by server", ex);
    } catch (JDOMException ex) {
        throw new DAVException("Error in XML returned by server", ex);
    } catch (IOException ex) {
        throw new DAVException(ex);
    }
}

From source file:io.hops.transaction.context.INodeAttributesContext.java

private void updateAttributes(INodeCandidatePrimaryKey trg_param,
        List<INodeCandidatePrimaryKey> toBeDeletedSrcs) throws TransactionContextException {
    toBeDeletedSrcs.remove(trg_param);
    for (INodeCandidatePrimaryKey src : toBeDeletedSrcs) {
        if (contains(src.getInodeId())) {
            INodeAttributes toBeDeleted = get(src.getInodeId());
            INodeAttributes toBeAdded = clone(toBeDeleted, trg_param.getInodeId());

            remove(toBeDeleted);/* w  w  w  . j  av a 2  s .c  o m*/
            if (isLogDebugEnabled()) {
                log("snapshot-maintenance-removed-inode-attribute", "inodeId", toBeDeleted.getInodeId());
            }

            add(toBeAdded);
            if (isLogDebugEnabled()) {
                log("snapshot-maintenance-added-inode-attribute", "inodeId", toBeAdded.getInodeId());
            }
        }
    }
}

From source file:edu.mayo.cts2.framework.plugin.service.umls.domain.codesystemversion.CodeSystemVersionRepository.java

public DirectoryResult<CodeSystemVersionCatalogEntrySummary> searchCodeSystemVersionDirectorySummaries(
        CodeSystemVersionMapper.SearchObject searchObject, int start, int end) {

    List<SourceDTO> dto = this.codeSystemVersionMapper.searchSourceDTOs(searchObject, start, end + 1);

    if (dto != null) {
        List<CodeSystemVersionCatalogEntrySummary> dtos = codeSystemVersionFactory.createCodeSystemVersion(dto);

        boolean atEnd = !(dtos.size() == (end + 1) - start);

        if (!atEnd) {
            dtos.remove(dto.size() - 1);
        }/*from   w ww  .j  av a 2s. c  om*/

        return new DirectoryResult<CodeSystemVersionCatalogEntrySummary>(dtos, atEnd);
    } else {
        return null;
    }

}

From source file:org.onebusaway.webapp.actions.admin.console.ServiceAlertAffectsAction.java

public String delete() {

    if (_id == null || _index == -1) {
        return INPUT;
    }//from ww  w. j  a  v a 2  s. co  m

    ServiceAlertBean alert = _transitDataService.getServiceAlertForId(_id);
    if (alert == null) {
        return INPUT;
    }

    List<SituationAffectsBean> allAffects = alert.getAllAffects();
    if (allAffects == null || _index >= allAffects.size()) {
        return INPUT;
    }

    allAffects.remove(_index);
    _transitDataService.updateServiceAlert(alert);

    return SUCCESS;
}

From source file:com.aurel.track.util.event.EventPublisher.java

/**
 * Detach a subscriber form an event/*  www.  j  a v  a2  s.co  m*/
 * @param subscriber
 */
public void detach(IEventSubscriber subscriber) {
    List<Integer> events = subscriber.getInterestedEvents();
    if (events != null) {
        for (Integer event : events) {
            List<IEventSubscriber> subscriberList = eventSubscribersMap.get(event);
            if (subscriberList != null) {
                subscriberList.remove(subscriber);
            }
        }
    }
}

From source file:it.unibas.spicy.model.algebra.NestedLoopProjectOperator.java

private void removeDuplicatedTuples(INode setNode) {
    int i = 0;/* ww  w. java 2 s  . co  m*/
    List<INode> tuples = setNode.getChildren();
    while (i < tuples.size()) {
        INode tuple = tuples.get(i);
        if (countOccurrences(tuple, tuples) > 1) {
            tuples.remove(i);
        } else {
            i++;
        }
    }
}

From source file:grails.plugin.searchable.internal.compass.mapping.CompassMappingUtils.java

/**
 * Resolve aliases between mappings//from  ww  w. j  av a 2s .c o m
 * Note this method is destructive in the sense that it modifies the passed in mappings
 */
public static void resolveAliases(List classMappings, Collection grailsDomainClasses) {
    // set defaults for those classes without explicit aliases and collect aliases
    Map mappingByClass = new HashMap();
    Map mappingsByAlias = new HashMap();
    for (Iterator iter = classMappings.iterator(); iter.hasNext();) {
        CompassClassMapping classMapping = (CompassClassMapping) iter.next();
        if (classMapping.getAlias() == null) {
            classMapping.setAlias(getDefaultAlias(classMapping.getMappedClass()));
        }
        mappingByClass.put(classMapping.getMappedClass(), classMapping);
        List mappings = (List) mappingsByAlias.get(classMapping.getAlias());
        if (mappings == null) {
            mappings = new ArrayList();
            mappingsByAlias.put(classMapping.getAlias(), mappings);
        }
        mappings.add(classMapping);
    }

    // override duplicate inherited aliases
    for (Iterator iter = mappingsByAlias.keySet().iterator(); iter.hasNext();) {
        List mappings = (List) mappingsByAlias.get(iter.next());
        if (mappings.size() == 1) {
            continue;
        }
        CompassClassMapping parentMapping = null;
        for (Iterator miter = mappings.iterator(); miter.hasNext();) {
            CompassClassMapping classMapping = (CompassClassMapping) miter.next();
            if (classMapping.getMappedClassSuperClass() == null) {
                parentMapping = classMapping;
                break;
            }
        }
        mappings.remove(parentMapping);
        for (Iterator miter = mappings.iterator(); miter.hasNext();) {
            CompassClassMapping classMapping = (CompassClassMapping) miter.next();
            LOG.debug("Overriding duplicated alias [" + classMapping.getAlias() + "] for class ["
                    + classMapping.getMappedClass().getName()
                    + "] with default alias. (Aliases must be unique - maybe this was inherited from a superclass?)");
            classMapping.setAlias(getDefaultAlias(classMapping.getMappedClass()));
        }
    }

    // resolve property ref aliases
    for (Iterator iter = classMappings.iterator(); iter.hasNext();) {
        CompassClassMapping classMapping = (CompassClassMapping) iter.next();
        Class mappedClass = classMapping.getMappedClass();
        for (Iterator piter = classMapping.getPropertyMappings().iterator(); piter.hasNext();) {
            CompassClassPropertyMapping propertyMapping = (CompassClassPropertyMapping) piter.next();
            if ((propertyMapping.isComponent() || propertyMapping.isReference())
                    && !propertyMapping.hasAttribute("refAlias")) {
                Set aliases = new HashSet();
                Class clazz = propertyMapping.getPropertyType();
                aliases.add(((CompassClassMapping) mappingByClass.get(clazz)).getAlias());
                GrailsDomainClassProperty domainClassProperty = GrailsDomainClassUtils
                        .getGrailsDomainClassProperty(grailsDomainClasses, mappedClass,
                                propertyMapping.getPropertyName());

                GrailsDomainClass dc = domainClassProperty.getReferencedDomainClass();
                if (dc == null) {
                    Class elementClass = SearchableUtils.getElementClass(domainClassProperty);
                    dc = GrailsDomainClassUtils.getGrailsDomainClass(elementClass, grailsDomainClasses);

                    if (dc == null) {
                        LOG.warn("Cannot find domain class for property '" + domainClassProperty.getName()
                                + "' of class '" + domainClassProperty.getDomainClass().getFullName());
                        continue;
                    }
                }
                Collection clazzes = GrailsDomainClassUtils.getClazzes(dc.getSubClasses());
                for (Iterator citer = clazzes.iterator(); citer.hasNext();) {
                    CompassClassMapping mapping = (CompassClassMapping) mappingByClass.get(citer.next());
                    if (mapping != null) {
                        aliases.add(mapping.getAlias());
                    }
                }
                propertyMapping.setAttribute("refAlias", DefaultGroovyMethods.join(aliases, ", "));
            }
        }
    }

    // resolve extend aliases
    for (Iterator iter = classMappings.iterator(); iter.hasNext();) {
        CompassClassMapping classMapping = (CompassClassMapping) iter.next();
        Class mappedClassSuperClass = classMapping.getMappedClassSuperClass();
        if (mappedClassSuperClass != null && classMapping.getExtend() == null) {
            CompassClassMapping mapping = (CompassClassMapping) mappingByClass.get(mappedClassSuperClass);
            classMapping.setExtend(mapping.getAlias());
        }
    }
}

From source file:sys.core.util.MenuBarHelper.java

public Menubar getMenuBar(List<OpcionSistemaDto> listaOpcionMenu, List<PermisoDto> listaPermisos)
        throws Exception {
    listaOpcionMenu.remove(new OpcionSistemaDto(0L));
    Menubar menuBar = new Menubar();
    Submenu subMenu = null;/*from   w  w w. j  a  v  a 2 s  .c  om*/
    MenuItem menuItem = null;

    ApplicationMBean applicationMBean = (ApplicationMBean) WebServletContextListener.getApplicationContext()
            .getBean("applicationMBean");

    for (OpcionSistemaDto opcionMenuDto : listaOpcionMenu) {
        opcionMenuDto.setPermiso(obtenerPermiso(listaPermisos, opcionMenuDto).getEstado());
        if (opcionMenuDto.getPadreDto() == null || opcionMenuDto.getPadreDto().getId().equals(0L)) {
            List<OpcionSistemaDto> hijos = opcionSistemaManager.obtenerHijosMenu(opcionMenuDto);
            if (hijos.size() > 0) {
                if (opcionMenuDto.getPermiso()) {
                    subMenu = new Submenu();
                    subMenu.setId(
                            ConstantesCore.VARIABLE_ID_MENU + String.valueOf(opcionMenuDto.getId().intValue()));
                    subMenu.setLabel(UtilCore.Internacionalizacion
                            .getMensajeInternacional(opcionMenuDto.getValue()).toUpperCase());
                    subMenu.setIcon(opcionMenuDto.getIcon());
                    subMenu.setStyle(applicationMBean.getEstiloMenu());
                    cargarHijos3(opcionMenuDto, subMenu, listaPermisos);
                    menuBar.getChildren().add(subMenu);
                }

            } else {
                if (opcionMenuDto.getPermiso()) {
                    menuItem = new MenuItem();
                    menuItem.setId(ConstantesCore.VARIABLE_ID_MENU_ITEM
                            + String.valueOf(opcionMenuDto.getId().intValue()));
                    menuItem.setValue(UtilCore.Internacionalizacion
                            .getMensajeInternacional(opcionMenuDto.getValue()).toUpperCase());

                    menuItem.setIcon(opcionMenuDto.getIcon());
                    menuItem.setOnclick(opcionMenuDto.getOnClick());
                    if (opcionMenuDto.getAction() != null && opcionMenuDto.getAction().length() > 0) {
                        menuItem.setAction(FacesContext.getCurrentInstance().getApplication()
                                .createMethodBinding(opcionMenuDto.getAction(), new Class[] {}));
                    } else {
                        menuItem.setUrl(opcionMenuDto.getUrl());
                    }

                    menuItem.setInView(true);
                    menuItem.setStyle(applicationMBean.getEstiloMenu());
                    menuItem.setAjax(false);
                    menuBar.getChildren().add(menuItem);
                }

            }
        }
    }
    return menuBar;
}

From source file:com.cip.crane.zookeeper.common.heartbeat.PollingAgentMonitor.java

private List<String> getConnectedHosts() {
    List<String> ips = zkClient.getChildren(WATCH_PATH);
    for (int i = 0; i < ips.size(); i++) {
        if (!isConnected(ips.get(i))) {
            ips.remove(i);
            i--;//  w  w  w .  j  a  va  2 s. c om
        }
    }
    return ips;
}

From source file:it.unibas.spicy.persistence.xml.operators.TransformFilePaths.java

private String mergePathLists(List<String> basePathSteps, List<String> filePathSteps) {
    Collections.reverse(basePathSteps);
    Collections.reverse(filePathSteps);
    List<String> result = new ArrayList<String>(basePathSteps);
    int i = 0;/*from   ww  w  .j  a  v a  2s .  c  om*/
    while (i < filePathSteps.size() && filePathSteps.get(i).equals("..")) {
        result.remove(result.size() - 1);
        i++;
    }
    for (int j = i; j < filePathSteps.size(); j++) {
        result.add(filePathSteps.get(j));
    }
    StringBuilder resultPath = new StringBuilder();
    for (int k = 0; k < result.size(); k++) {
        resultPath.append(result.get(k));
        if (k != result.size() - 1) {
            resultPath.append(File.separator);
        }
    }
    String resultString = resultPath.toString();
    if (!resultString.startsWith("/")) {
        resultString = "/" + resultString;
    }
    return resultString;
}