Example usage for java.util ArrayList contains

List of usage examples for java.util ArrayList contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:com.novartis.opensource.yada.format.ResultSetResultDelimitedConverter.java

/**
 * Parses global harmony map for duplicate values, and removes key/value pairs that
 * are not present in local harmony map.
 * @return the parsed global harmony map
 * @since 6.1.0/*from  w ww.j  a v a 2  s.c om*/
 */
@Override
public Object getHarmonyMap() {
    JSONObject globMap = (JSONObject) this.harmonyMap;
    JSONObject local = new JSONObject(getYADAQueryResult().getYADAQueryParamValue(YADARequest.PS_HARMONYMAP));
    JSONArray vals = local.toJSONArray(new JSONArray(JSONObject.getNames(local)));
    ArrayList<String> locVals = new ArrayList<>();
    for (int i = 0; i < vals.length(); i++) {
        locVals.add(vals.getString(i));
    }
    for (Object globalKey : globMap.keySet()) {
        String gk = (String) globalKey;
        String gv = globMap.getString(gk);
        if (locVals.contains(gv) && !local.has(gk)) // the value is associated to a different key in the local map
        {
            globMap.remove(gk);
        }
    }
    return globMap;
}

From source file:gov.nih.nci.ispy.web.ajax.DynamicReportGenerator.java

public Map saveTmpGeneric(String type, String elem) {
    Map results = new HashMap();

    HttpSession session = ExecutionContext.get().getSession(false);
    //put the element into an arraylist in the session...doesnt exist? create it
    ArrayList al = new ArrayList();
    if (session.getAttribute(type) != null) {
        al = (ArrayList) session.getAttribute(type);
    }//from ww w .j  a v  a 2s  .c  o  m

    if (!elem.equals("") && !al.contains(elem)) {
        al.add(elem); // add it
        session.setAttribute(type, al); //put back in session
    }
    String tmpElems = "";
    for (int i = 0; i < al.size(); i++)
        tmpElems += al.get(i) + "<br/>";

    results.put("count", al.size());
    results.put("elements", tmpElems);

    return results;
}

From source file:eu.morfeoproject.fast.catalogue.recommender.BuildingBlockRecommender.java

public List<URI> getSuggestionList(List<URI> uriList) {
    ArrayList<URI> resultList = new ArrayList<URI>();
    TopKStringPatterns pattern = getTopKStringPatterns(uriList);
    for (Pair<List<String>, Long> pair : pattern.getPatterns()) {
        long weight = pair.getSecond();
        for (String element : pair.getFirst()) {
            URI uri = new URIImpl(element);
            if (!uriList.contains(uri) && !resultList.contains(uri)) {
                resultList.add(uri);// w w w  .  j av a 2  s  . c om
                if (log.isInfoEnabled())
                    log.info(uri + ", weight: " + weight);
            }
        }
    }
    return resultList;
}

From source file:com.nadmm.airports.library.LibraryService.java

private void cleanupBooks(String category, ArrayList<String> books) {
    // Delete all books that are no longer in the library list for a category
    File categoryDir = getCategoryDir(category);
    File[] list = categoryDir.listFiles();
    if (list != null) {
        for (File pdfFile : list) {
            if (!books.contains(pdfFile.getName())) {
                pdfFile.delete();/*from www  .j  a  v  a  2s  .co  m*/
            }
        }
    }
}

From source file:MSUmpire.PSMDataStructure.FragmentSelection.java

public void GenerateTopPepMap(int topNPep) {
    for (String ProteinKey : ProtPepScore.keySet()) {
        HashMap<String, Float> Peptides = ProtPepScore.get(ProteinKey);
        ArrayList<String> peps = new ArrayList<>();
        for (int i = 0; i < topNPep; i++) {
            float bestscore = 0f;
            String bestpep = "";
            for (String pep : Peptides.keySet()) {
                if (!peps.contains(pep) && Peptides.get(pep) > bestscore) {
                    bestscore = Peptides.get(pep);
                    bestpep = pep;/*from ww  w  .j  av a2 s.  c o m*/
                }
            }
            if (!"".equals(bestpep)) {
                peps.add(bestpep);
            }
        }
        TopPeps.put(ProteinKey, peps);
    }
}

From source file:edu.brandeis.cs.nlp.mae.model.LinkTag.java

private Set<String> checkRequiredArgs() {
    Set<String> underspec = new TreeSet<>();
    ArrayList<ArgumentType> existingArgs = new ArrayList<>();
    for (Argument arg : getArguments()) {
        if (arg.isComplete()) {
            existingArgs.add(arg.getArgumentType());
        }/*from  w w w  .  j  av  a  2s . c om*/
    }
    for (ArgumentType argType : getTagtype().getArgumentTypes()) {
        if (argType.isRequired() && !existingArgs.contains(argType)) {
            underspec.add(argType.getName());
        }
    }
    return underspec;

}

From source file:org.cfr.capsicum.test.AbstractCayenneJUnit4DbUnitSpringContextTests.java

private void addTableName(ArrayList<String> tables, DbEntity dbEntity) {
    if (tables.contains(dbEntity.getFullyQualifiedName())) {
        return;//  w  ww  .  jav a  2 s. c o m
    }
    Collection<DbRelationship> relationships = dbEntity.getRelationships();
    if (relationships.size() > 0) {
        for (DbRelationship relationship : relationships) {
            if (relationship.isToMany() && !dbEntity.equals(relationship.getTargetEntity())) {
                addTableName(tables, (DbEntity) relationship.getTargetEntity());
            }
        }
    }
    tables.add(dbEntity.getFullyQualifiedName());
}

From source file:com.android.launcher4.InstallShortcutReceiver.java

public static void removeFromInstallQueue(SharedPreferences sharedPrefs, ArrayList<String> packageNames) {
    if (packageNames.isEmpty()) {
        return;// w  w  w.  j av  a2s.c  o  m
    }
    synchronized (sLock) {
        Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
        if (DBG) {
            Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames);
        }
        if (strings != null) {
            Set<String> newStrings = new HashSet<String>(strings);
            Iterator<String> newStringsIter = newStrings.iterator();
            while (newStringsIter.hasNext()) {
                String json = newStringsIter.next();
                try {
                    JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
                    Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
                    String pn = launchIntent.getPackage();
                    if (pn == null) {
                        pn = launchIntent.getComponent().getPackageName();
                    }
                    if (packageNames.contains(pn)) {
                        newStringsIter.remove();
                    }
                } catch (org.json.JSONException e) {
                    Log.d(TAG, "Exception reading shortcut to remove: " + e);
                } catch (java.net.URISyntaxException e) {
                    Log.d(TAG, "Exception reading shortcut to remove: " + e);
                }
            }
            sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>(newStrings)).commit();
        }
    }
}

From source file:com.shanet.relayremote.Main.java

public void getRelayStates() {
    Toast.makeText(this, R.string.refreshingRelays, Toast.LENGTH_SHORT).show();

    // If no relays exist, call the set relays function directly so
    // the list adapters in the fragments are still created
    if (relays.size() == 0) {
        setRelaysAndGroupsStates(null);/*w  ww  .j ava  2 s  . c o m*/
    }

    // For each unique server, start a thread to get the state of the relays on that server
    ArrayList<String> servers = new ArrayList<String>();
    Relay relay;
    for (int i = 0; i < relays.size(); i++) {
        relay = relays.get(i);
        if (!servers.contains(relay.getServer())) {
            Bundle bgInfo = new Bundle();
            bgInfo.putChar("op", Constants.OP_GET);
            bgInfo.putString("server", relay.getServer());
            bgInfo.putInt("port", relay.getPort());

            // Add this server to the server list so we don't check it again
            servers.add(relay.getServer());

            new Background(this, Constants.OP_GET, false).execute(bgInfo);
        }
    }
}

From source file:com.thoughtworks.go.domain.materials.mercurial.HgCommandTest.java

@Test
public void shouldCloneOnlyTheSpecifiedBranchAndPointToIt() {
    String branchName = "second";
    HgCommand hg = new HgCommand(null, secondBranchWorkingCopy, branchName, serverRepo.getAbsolutePath(), null);
    hg.clone(outputStreamConsumer, new UrlArgument(serverRepo.getAbsolutePath() + "#" + branchName));

    String currentBranch = hg(secondBranchWorkingCopy, "branch").runOrBomb(null).outputAsString();
    assertThat(currentBranch, is(branchName));

    List<String> branches = hg(secondBranchWorkingCopy, "branches").runOrBomb(null).output();
    ArrayList<String> branchNames = new ArrayList<>();
    for (String branchDetails : branches) {
        branchNames.add(StringUtils.split(branchDetails, " ")[0]);
    }/*from   w  ww  .j a v  a2  s.  c  o m*/
    assertThat(branchNames.size(), is(2));
    assertThat(branchNames.contains(branchName), is(true));
    assertThat(branchNames.contains("default"), is(true));
}