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:org.dklisiaris.downtown.helper.XMLParser.java

public ArrayList<String> getAllValuesWithTag(Document doc, String itemTag) {
    ArrayList<String> items = new ArrayList<String>();
    //Document doc = getDomElement(xml); // getting DOM element
    NodeList nl = doc.getElementsByTagName(itemTag);
    // looping through all item nodes <category>
    for (int k = 0; k < nl.getLength(); k++) {
        Element e = (Element) nl.item(k);
        String value = getElementValue(e);
        if (!items.contains(value) && value != null && !TextUtils.isEmpty(value)) {
            items.add(value);/*from   w  w  w  . j a v  a2  s .  c  o  m*/
            //Log.d("Item added:",value);
        }
    }

    return items;
}

From source file:de.kp.ames.office.xml.ImpressBuilder.java

/**
 * A private method to compute the content of the outline
 * page from the title elements of all other pages of this
 * briefing; the first three pages are ignored
 * /*from   ww  w . j ava  2  s .c o m*/
 * @param pages
 * @throws Exception
 */
private void extractOutline(NodeList pages) throws Exception {

    ArrayList<String> titles = new ArrayList<String>();

    for (int i = 3; i < pages.getLength(); i++) {

        Element ePage = (Element) pages.item(i);
        String title = ImpressHelper.getTitle(ePage);

        if ((title == null) || titles.contains(title))
            continue;

        titles.add(title);

    }

    StringBuffer buffer = new StringBuffer();

    buffer.append("<ul>");
    for (int s = 0; s < titles.size(); s++) {
        buffer.append("<li>" + titles.get(s) + "</li>");

    }
    buffer.append("</ul>");
    outline = buffer.toString();

}

From source file:amp.lib.io.db.Database.java

public ArrayList<String> getScenarioNames() throws SQLException {
    SQLFactory sqlm = SQLFactory.getSQLFactory();
    ArrayList<String> scen = new ArrayList<String>();
    for (String tbl : getDatabaseTableNames()) {
        ResultSet rs = query(sqlm.getScenarioNames(tbl));

        while (rs.next()) {
            String thisScen = rs.getString(1);
            if (!scen.contains(thisScen)) {
                scen.add(rs.getString(1));
            }/*w  w  w.ja  v  a2  s  .  co m*/
        }
    }
    return scen;
}

From source file:edu.cornell.kfs.vnd.document.validation.impl.CuVendorRule.java

protected boolean checkMerchantNameUniqueness(MaintenanceDocument document) {
    boolean success = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    List<CuVendorCreditCardMerchant> vendorCreditCardMerchants = ((VendorDetailExtension) vendorDetail
            .getExtension()).getVendorCreditCardMerchants();
    ArrayList<String> merchantNames = new ArrayList<String>();
    int i = 0;/*from w ww .  ja va 2s.c  o  m*/
    for (CuVendorCreditCardMerchant vendorCreditCardMerchant : vendorCreditCardMerchants) {
        if (merchantNames.contains(vendorCreditCardMerchant.getCreditMerchantName())) {
            putFieldError("vendorCreditCardMerchants[" + i + "].creditMerchantName",
                    CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_DUPLICATE);
            //can't have duplicate merchant names, part of the primary key for the table in the db
            success = false;
        }
        if (vendorCreditCardMerchant.getCreditMerchantName() == null
                || vendorCreditCardMerchant.getCreditMerchantName().equals("")) {
            //can't have a null or blank name, it's part of the primary key for this table in the db
            putFieldError("vendorCreditCardMerchants[" + i + "].creditMerchantName",
                    CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_BLANK);
            success = false;
        }
        merchantNames.add(vendorCreditCardMerchant.getCreditMerchantName());
        i++;
    }

    return success;
}

From source file:com.github.jberkel.pay.me.IabHelper.java

private int querySkuDetails(ItemType itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);//from  www. j a v a2s . com
            }
        }
    }
    if (skuList.isEmpty()) {
        logDebug("querySkuDetails: nothing to do because there are no SKUs.");
        return OK.code;
    }

    // TODO: check for 20 SKU limit + add batching ?
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(API_VERSION, mContext.getPackageName(), itemType.toString(),
            querySkus);
    if (skuDetails == null)
        return IABHELPER_BAD_RESPONSE.code;

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != OK.code) {
            logWarn("getSkuDetails() failed: " + getDescription(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE.code;
        }
    }
    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
    for (String json : responseList) {
        inv.addSkuDetails(new SkuDetails(json));
    }
    return OK.code;
}

From source file:be.fedict.dcat.datagovbe.Drupal.java

/**
 * Get list of contact email addresses/*from   w  w w. ja v  a  2s.  c  om*/
 * 
 * @param dataset
 * @return list of email addresses
 * @throws RepositoryException 
 */
private List<String> getDatasetMails(Map<IRI, ListMultimap<String, String>> dataset)
        throws RepositoryException {
    ArrayList<String> arr = new ArrayList<>();
    List<String> orgs = getMany(dataset, DCAT.CONTACT_POINT, "");
    for (String org : orgs) {
        String email = getOrgEmail(org);
        if (!email.isEmpty() && !arr.contains(email)) {
            arr.add(email);
        }
    }
    return arr;
}

From source file:com.dev.pygmy.game.GameHomePageActivity.java

private void onReportClick() {
    final ArrayList<String> selectedItems = new ArrayList<String>();
    final String[] reasons = getResources().getStringArray(R.array.report_reasons);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Report: " + ((TextView) findViewById(R.id.name_game)).getText());
    builder.setMultiChoiceItems(reasons, null, new DialogInterface.OnMultiChoiceClickListener() {

        @Override/*from  w w  w.  ja  v  a 2s.  c om*/
        public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
            String reason = reasons[indexSelected];
            if (isChecked) {
                selectedItems.add(reason);
            } else if (selectedItems.contains(reason)) {
                selectedItems.remove(reason);
            }

            Button positiveButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setEnabled((selectedItems.size() != 0));
        }
    })
            // Assign action buttons
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    new GameReportTask(GameHomePageActivity.this, selectedItems).execute(mGame.name);
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    Toast.makeText(GameHomePageActivity.this, "Report canceled", Toast.LENGTH_SHORT).show();
                }
            });

    reportDialog = builder.create();
    reportDialog.show();
    reportDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
}

From source file:be.fedict.dcat.datagovbe.Drupal.java

/**
 * Get list of organization names//from  w  ww  .java2 s.co  m
 * 
 * @param dataset
 * @param lang language code
 * @return list of email addresses
 * @throws RepositoryException 
 */
private List<String> getDatasetOrgs(Map<IRI, ListMultimap<String, String>> dataset, String lang)
        throws RepositoryException {
    ArrayList<String> arr = new ArrayList<>();
    List<String> orgs = getMany(dataset, DCAT.CONTACT_POINT, "");
    for (String org : orgs) {
        String name = getOrgName(org, lang);
        if (!name.isEmpty() && !arr.contains(name)) {
            arr.add(name);
        }
    }
    return arr;
}

From source file:edu.isi.wings.portal.controllers.PlanController.java

private HashMap<String, Integer> getRegressionVariableValues(Template t, ArrayList<String> usermetrics,
        ArrayList<String> userparams) {
    // FIXME: Assuming value is Integer
    HashMap<String, Integer> regressionVariables = new HashMap<String, Integer>();
    for (Variable v : t.getInputVariables()) {
        if (v.isDataVariable() && v.getBinding() != null) {
            Metrics metrics = v.getBinding().getMetrics();
            for (String key : metrics.getMetrics().keySet()) {
                if (usermetrics.contains(key)) {
                    for (Metric m : metrics.getMetrics().get(key)) {
                        // FIXME: Assuming value is Integer
                        Integer val = Integer.valueOf(m.getValue().toString());
                        regressionVariables.put(key, val);
                    }//  w  w w. ja va2s  . co  m
                }
            }
        } else if (v.isParameterVariable() && v.getBinding() != null) {
            if (userparams.contains(v.getID())) {
                // FIXME: Assuming value is Integer
                regressionVariables.put(v.getID(), Integer.valueOf(v.getBinding().getValue().toString()));
            }
        }
    }
    return regressionVariables;
}

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

private void dropCircularRefs(TermConcept theConcept, ArrayList<String> theChain,
        Map<String, TermConcept> theCode2concept, Counter theCircularCounter) {

    theChain.add(theConcept.getCode());//  w w w.  ja  v a  2  s.  co m
    for (Iterator<TermConceptParentChildLink> childIter = theConcept.getChildren().iterator(); childIter
            .hasNext();) {
        TermConceptParentChildLink next = childIter.next();
        TermConcept nextChild = next.getChild();
        if (theChain.contains(nextChild.getCode())) {

            StringBuilder b = new StringBuilder();
            b.append("Removing circular reference code ");
            b.append(nextChild.getCode());
            b.append(" from parent ");
            b.append(next.getParent().getCode());
            b.append(". Chain was: ");
            for (String nextInChain : theChain) {
                TermConcept nextCode = theCode2concept.get(nextInChain);
                b.append(nextCode.getCode());
                b.append('[');
                b.append(StringUtils.substring(nextCode.getDisplay(), 0, 20).replace("[", "").replace("]", "")
                        .trim());
                b.append("] ");
            }
            ourLog.info(b.toString(), theConcept.getCode());
            childIter.remove();
            nextChild.getParents().remove(next);

        } else {
            dropCircularRefs(nextChild, theChain, theCode2concept, theCircularCounter);
        }
    }
    theChain.remove(theChain.size() - 1);

}