Example usage for java.util ArrayList remove

List of usage examples for java.util ArrayList remove

Introduction

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

Prototype

public boolean remove(Object o) 

Source Link

Document

Removes the first occurrence of the specified element from this list, if it is present.

Usage

From source file:ca.uhn.fhir.jpa.term.BaseHapiTerminologySvc.java

private int validateConceptForStorage(TermConcept theConcept, TermCodeSystemVersion theCodeSystem,
        ArrayList<String> theConceptsStack, IdentityHashMap<TermConcept, Object> theAllConcepts) {
    ValidateUtil.isTrueOrThrowInvalidRequest(theConcept.getCodeSystem() != null, "CodesystemValue is null");
    ValidateUtil.isTrueOrThrowInvalidRequest(theConcept.getCodeSystem() == theCodeSystem,
            "CodeSystems are not equal");
    ValidateUtil.isNotBlankOrThrowInvalidRequest(theConcept.getCode(),
            "Codesystem contains a code with no code value");

    if (theConceptsStack.contains(theConcept.getCode())) {
        throw new InvalidRequestException(
                "CodeSystem contains circular reference around code " + theConcept.getCode());
    }//  w  w  w . java2  s .c  o  m
    theConceptsStack.add(theConcept.getCode());

    int retVal = 0;
    if (theAllConcepts.put(theConcept, theAllConcepts) == null) {
        if (theAllConcepts.size() % 1000 == 0) {
            ourLog.info("Have validated {} concepts", theAllConcepts.size());
        }
        retVal = 1;
    }

    for (TermConceptParentChildLink next : theConcept.getChildren()) {
        next.setCodeSystem(theCodeSystem);
        retVal += validateConceptForStorage(next.getChild(), theCodeSystem, theConceptsStack, theAllConcepts);
    }

    theConceptsStack.remove(theConceptsStack.size() - 1);

    return retVal;
}

From source file:edu.isi.misd.tagfiler.download.FileDownloadImplementation.java

/**
 * Performs the dataset download./*from  w  w  w .  j  a  v a 2s . co m*/
 * 
 * @param destDir
 *            destination directory for the download
 * @param target
 *            resume or download all
 */
@SuppressWarnings("unchecked")
public boolean downloadFiles(String destDir, String target) {
    if (destDir == null || destDir.length() == 0 || target == null)
        throw new IllegalArgumentException(destDir + ", " + target);
    this.target = target;
    try {
        client.setBaseURL(DatasetUtils.getBaseDownloadUrl(dataset, tagFilerServerURL));
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    // the copy is done for performance reasons in the inner loop
    ArrayList<String> tempFiles = new ArrayList<String>(fileNames);

    List<FileWrapper> filesList = new ArrayList<FileWrapper>();
    if (target.equals(RESUME_TARGET)) {
        // resume download
        String filename = destDir + File.separator + TagFilerProperties.getProperty("tagfiler.checkpoint.file");
        File file = new File(filename);
        if (file.exists() && file.isFile() && file.canRead()) {
            // get the download check point status
            try {
                FileInputStream fis = new FileInputStream(filename);
                ObjectInputStream in = new ObjectInputStream(fis);
                Hashtable<String, Long> checkPoint = (Hashtable<String, Long>) in.readObject();
                HashMap<String, String> checksum = (HashMap<String, String>) in.readObject();
                in.close();
                fis.close();
                System.out.println("Check Points Read: " + checkPoint + "\n" + checksum);
                Set<String> keys = checkPoint.keySet();
                for (String key : keys) {
                    if (tempFiles.contains(key)) {
                        tempFiles.remove(key);
                        boolean complete = (long) bytesMap.get(key) == (long) checkPoint.get(key);
                        if (complete && enableChecksum) {
                            complete = checksum.get(key) != null && checksumMap.get(key) != null
                                    && checksum.get(key).equals(checksumMap.get(key));
                        }
                        if (complete) {
                            // file already downloaded
                            bytesMap.remove(key);
                            versionMap.remove(key);
                            checksumMap.remove(key);
                        } else {
                            // file partial downloaded
                            filesList.add(new FileWrapper(key, checkPoint.get(key), versionMap.get(key),
                                    bytesMap.get(key)));
                        }
                    }
                }
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    // add the rest of the files without check points
    for (String filename : tempFiles) {
        filesList.add(new FileWrapper(filename, 0, versionMap.get(filename), bytesMap.get(filename)));
    }

    System.out.println("" + filesList.size() + " file(s) will be downloaded");

    // get the total size of the files to be downloaded and checksum
    long totalSize = 0;
    long tb = 0;
    for (FileWrapper fileWrapper : filesList) {
        tb += fileWrapper.getFileLength() - fileWrapper.getOffset();
        totalSize += fileWrapper.getFileLength() - fileWrapper.getOffset();
        if (enableChecksum) {
            totalSize += fileWrapper.getFileLength();
        }
    }
    fileDownloadListener.notifyLogMessage(
            tb + " total bytes will be transferred\n" + totalSize + " total bytes in the progress bar");
    fileDownloadListener.notifyStart(dataset, totalSize);
    if (!((AbstractTagFilerApplet) applet).allowChunksTransfering()) {
        ClientUtils.disableExpirationWarning(applet);
    }
    start = System.currentTimeMillis();
    cancel = false;
    client.download(filesList, destDir, checksumMap, bytesMap, versionMap);

    return true;
}

From source file:com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet.java

@Override
public AnimatorSet clone() {
    final AnimatorSet anim = (AnimatorSet) super.clone();
    /*//from ww w .j a va2s. c  om
     * The basic clone() operation copies all items. This doesn't work very well for
     * AnimatorSet, because it will copy references that need to be recreated and state
     * that may not apply. What we need to do now is put the clone in an uninitialized
     * state, with fresh, empty data structures. Then we will build up the nodes list
     * manually, as we clone each Node (and its animation). The clone will then be sorted,
     * and will populate any appropriate lists, when it is started.
     */
    anim.mNeedsSort = true;
    anim.mTerminated = false;
    anim.mStarted = false;
    anim.mPlayingSet = new ArrayList<Animator>();
    anim.mNodeMap = new HashMap<Animator, Node>();
    anim.mNodes = new ArrayList<Node>();
    anim.mSortedNodes = new ArrayList<Node>();

    // Walk through the old nodes list, cloning each node and adding it to the new nodemap.
    // One problem is that the old node dependencies point to nodes in the old AnimatorSet.
    // We need to track the old/new nodes in order to reconstruct the dependencies in the clone.
    HashMap<Node, Node> nodeCloneMap = new HashMap<Node, Node>(); // <old, new>
    for (Node node : mNodes) {
        Node nodeClone = node.clone();
        nodeCloneMap.put(node, nodeClone);
        anim.mNodes.add(nodeClone);
        anim.mNodeMap.put(nodeClone.animation, nodeClone);
        // Clear out the dependencies in the clone; we'll set these up manually later
        nodeClone.dependencies = null;
        nodeClone.tmpDependencies = null;
        nodeClone.nodeDependents = null;
        nodeClone.nodeDependencies = null;
        // clear out any listeners that were set up by the AnimatorSet; these will
        // be set up when the clone's nodes are sorted
        ArrayList<AnimatorListener> cloneListeners = nodeClone.animation.getListeners();
        if (cloneListeners != null) {
            ArrayList<AnimatorListener> listenersToRemove = null;
            for (AnimatorListener listener : cloneListeners) {
                if (listener instanceof AnimatorSetListener) {
                    if (listenersToRemove == null) {
                        listenersToRemove = new ArrayList<AnimatorListener>();
                    }
                    listenersToRemove.add(listener);
                }
            }
            if (listenersToRemove != null) {
                for (AnimatorListener listener : listenersToRemove) {
                    cloneListeners.remove(listener);
                }
            }
        }
    }
    // Now that we've cloned all of the nodes, we're ready to walk through their
    // dependencies, mapping the old dependencies to the new nodes
    for (Node node : mNodes) {
        Node nodeClone = nodeCloneMap.get(node);
        if (node.dependencies != null) {
            for (Dependency dependency : node.dependencies) {
                Node clonedDependencyNode = nodeCloneMap.get(dependency.node);
                Dependency cloneDependency = new Dependency(clonedDependencyNode, dependency.rule);
                nodeClone.addDependency(cloneDependency);
            }
        }
    }

    return anim;
}

From source file:com.catify.processengine.core.nodes.NodeFactoryImpl.java

/**
 * Extracts the information of the embedding/parent sub process node's uniqueFlowNodeId. Used for Start and End Events which are logically connected to their
 * embedding sub process nodes./*from w  w w.ja v  a  2  s  .  com*/
 *
 * @param clientId the client id
 * @param processJaxb the process jaxb
 * @param subProcessesJaxb the sub processes jaxb
 * @param flowNodeJaxb the flow node jaxb
 * @return the unique flow node id of the parent sub process or null if there is none
 */
private String getParentSubProcessUniqueFlowNodeId(String clientId, TProcess processJaxb,
        List<TSubProcess> subProcessesJaxb, TFlowNode flowNodeJaxb) {
    ArrayList<TSubProcess> localSubProcessesJaxb = new ArrayList<TSubProcess>(subProcessesJaxb);

    // check if the current end event node is a embedded in a sub process
    if (localSubProcessesJaxb.size() > 0) {
        // we only check the last sub process, because this can only be the sub process we are looking for
        TSubProcess subProcessJaxb = localSubProcessesJaxb.get(localSubProcessesJaxb.size() - 1);
        for (JAXBElement<? extends TFlowElement> flowElementJaxb : subProcessJaxb.getFlowElement()) {
            // if the given end event node has been found in this sub process this is an embedded end event 
            if (flowElementJaxb.getValue().getId().equals(flowNodeJaxb.getId())) {
                // remove the current sub process from the list of sub processes to be able to get its actor reference
                localSubProcessesJaxb.remove(subProcessJaxb);
                return IdService.getUniqueFlowNodeId(clientId, processJaxb, localSubProcessesJaxb,
                        subProcessJaxb);
            }
        }
    }

    // return null if there is no embedding/parent sub process
    return null;
}

From source file:com.photon.phresco.framework.commons.QualityUtil.java

public ArrayList<String> getConnAndroidDevices(String command) throws Exception {
    S_LOGGER.debug("Entering Method QualityUtil.getConnAndroidDevices() for quality tab");
    ArrayList<String> output = new ArrayList<String>();
    try {//from  www  . j  av a  2  s. co  m
        String s = null;
        Process p = Runtime.getRuntime().exec(command);

        BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
        BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

        int cnt = 0;
        while ((s = stdInput.readLine()) != null) {
            if (cnt > 0) {
                s = s.substring(0, s.indexOf("\t") + 1);
                output.add(s.trim());
            }
            cnt++;
        }
        stdInput.close();
        cnt = 0;
        while ((s = stdError.readLine()) != null) {
            if (cnt > 0) {
                s = s.substring(0, s.indexOf("\t") + 1);
                output.add(s.trim());
            }
            cnt++;
        }
        stdError.close();
    } catch (Exception e) {
        S_LOGGER.error("Entered into catch block of Quality.getConnAndroidDevices()"
                + FrameworkUtil.getStackTraceAsString(e));
    }
    output.remove(output.size() - 1);
    return output;
}

From source file:com.ichi2.libanki.Models.java

public void moveField(JSONObject m, JSONObject field, int idx) throws ConfirmModSchemaException {
    mCol.modSchema(true);/*  ww  w .  j a  va  2 s  .  c  om*/
    try {
        JSONArray ja = m.getJSONArray("flds");
        ArrayList<JSONObject> l = new ArrayList<JSONObject>();
        int oldidx = -1;
        for (int i = 0; i < ja.length(); ++i) {
            l.add(ja.getJSONObject(i));
            if (field.equals(ja.getJSONObject(i))) {
                oldidx = i;
                if (idx == oldidx) {
                    return;
                }
            }
        }
        // remember old sort field
        String sortf = Utils.jsonToString(m.getJSONArray("flds").getJSONObject(m.getInt("sortf")));
        // move
        l.remove(oldidx);
        l.add(idx, field);
        m.put("flds", new JSONArray(l));
        // restore sort field
        ja = m.getJSONArray("flds");
        for (int i = 0; i < ja.length(); ++i) {
            if (Utils.jsonToString(ja.getJSONObject(i)).equals(sortf)) {
                m.put("sortf", i);
                break;
            }
        }
        _updateFieldOrds(m);
        save(m);
        _transformFields(m, new TransformFieldMove(idx, oldidx));
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }

}

From source file:com.krawler.spring.crm.accountModule.crmAccountDAOImpl.java

public KwlReturnObject getAccounts(HashMap<String, Object> requestParams) throws ServiceException {
    List ll = null;//from  w  w w .j a va 2  s. c om
    int dl = 0;
    try {
        ArrayList filter_names = new ArrayList();
        ArrayList filter_params = new ArrayList();

        if (requestParams.containsKey("filter_names")) {
            filter_names = (ArrayList) requestParams.get("filter_names");
        }
        if (requestParams.containsKey("filter_params")) {
            filter_params = (ArrayList) requestParams.get("filter_params");
        }

        String Hql = "select distinct c from CrmAccount c ";
        if (filter_names.contains("INp.productId.productid")) {
            Hql += " inner join c.crmProducts as p ";
        }
        String filterQuery = StringUtil.filterQuery(filter_names, "where");
        int ind = filterQuery.indexOf("(");
        if (ind > -1) {
            int index = Integer.valueOf(filterQuery.substring(ind + 1, ind + 2));
            filterQuery = filterQuery.replaceAll("(" + index + ")", filter_params.get(index).toString());
            filter_params.remove(index);
        }
        Hql += filterQuery;

        ll = executeQuery(Hql, filter_params.toArray());
        dl = ll.size();
    } catch (Exception e) {
        throw ServiceException.FAILURE("crmAccountDAOImpl.getActiveAccount : " + e.getMessage(), e);
    }
    return new KwlReturnObject(true, "002", "", ll, dl);
}

From source file:de.bangl.lm.LotManagerPlugin.java

public void removeSign(String lotName, Block block) {
    ArrayList<LotManagerSign> signs = this.Signs.getSigns(lotName);
    //How could this happen?
    if (signs == null) {
        logError("Unexpected Error 1.");
        return;//  www  .  j  a  va  2s.  c o  m
    }
    if (signs.size() - 1 < 1) {
        this.Signs.remove(lotName);
    } else {
        signs.remove(block);
        this.Signs.put(lotName, signs);
    }
    this.saveSigns();
}

From source file:com.amalto.workbench.utils.LocalTreeObjectRepository.java

private void checkUpAllCategoryForModel(TreeParent model) {
    if (model.getServerRoot() == null) {
        return;/*from   w  ww .  j a  v  a  2  s.  com*/
    }
    String xpath = "//" + model.getServerRoot().getUser().getUsername() + "/" //$NON-NLS-1$//$NON-NLS-2$
            + filterOutBlank(model.getDisplayName()) + "//child::*[text() = '" + TreeObject.CATEGORY_FOLDER + "' and @Url='" //$NON-NLS-1$//$NON-NLS-2$
            + getURLFromTreeObject(model) + "']";//$NON-NLS-1$
    Document doc = credentials.get(UnifyUrl(model.getServerRoot().getWsKey().toString())).doc;
    String xpathForModel = getXPathForTreeObject(model);
    List<Element> elems = doc.selectNodes(xpathForModel);
    Element modelElem = elems.get(0);
    elems = doc.selectNodes(xpath);
    for (Element elem : elems) {
        Element spec = elem;
        ArrayList<Element> hierarchicalList = new ArrayList<Element>();
        while (spec != modelElem) {
            hierarchicalList.add(spec);
            spec = spec.getParent();
        }
        Collections.reverse(hierarchicalList);
        TreeParent modelCpy = model;
        while (!hierarchicalList.isEmpty()) {
            spec = hierarchicalList.remove(0);
            String elemName = spec.getName();
            if (spec.attributeValue(REALNAME) != null) {
                elemName = spec.attributeValue(REALNAME);
            }
            TreeObject to = findObject(modelCpy, Integer.parseInt(spec.getText().trim()), elemName);
            if (to == null) {
                TreeParent catalog = new TreeParent(elemName, modelCpy.getServerRoot(),
                        TreeObject.CATEGORY_FOLDER, null, null);
                boolean cpyInternalCheck = internalCheck;
                internalCheck = true;
                modelCpy.addChild(catalog);
                internalCheck = cpyInternalCheck;
                modelCpy = catalog;
            } else {
                modelCpy = (TreeParent) to;
            }
        }
    }
}