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.alkacon.opencms.v8.documentcenter.CmsXmlDocumentContent.java

/**
 * Returns a list with all paths to look for a default file. The order is to first
 * look in the folder specified in the property and then in the given startRoot and all
 * parent folder up to the root folder of the document center.<p>
 * //from  ww  w.  jav a  2  s  . c  o m
 * @param property the name of the property where the name of the folder to search in is defined
 * @param search flag if to search in parent folders too
 * @param searchRoot the directory where to start the search for the default file
 * @return a list with all found paths to look for a default file
 */
private List<String> getFolderList(String property, boolean search, String searchRoot) {

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

    // look for the path defined in the property
    String path = m_cms.property(property, "search", null);
    if (path != null) {
        ret.add(path);
    }

    // if value is not going to be searched return only folder of property
    if (!search) {
        return ret;
    }

    // check if searchRoot ends with slash
    if ((searchRoot != null) && (!searchRoot.endsWith("/"))) {
        searchRoot += "/";
    }

    try {

        // add actual path and all parent paths up to the document center
        boolean next = true;
        String currentPath = searchRoot;
        while ((next) && (currentPath != null)) {
            if (!ret.contains(currentPath)) {
                ret.add(currentPath);
            }

            // check if current folder is already root folder of document center
            CmsResource currentRes = m_cms.getCmsObject().readResource(currentPath);
            if (currentRes.getTypeId() == 260) {
                next = false;
            }

            currentPath = CmsResource.getParentFolder(currentPath);
        }

        // if current resource is not inside a document center only add folder from property
        if (next) {
            ret = new ArrayList<String>();
            if (path != null) {
                ret.add(path);
            }
        }
    } catch (CmsException ex) {
        // do nothing
    }

    return ret;
}

From source file:io.siddhi.extension.io.file.FileSinkTestCase.java

@Test
public void fileSinkTest7() throws InterruptedException {
    log.info("test SiddhiIoFile Sink 7");

    String streams = "" + "@App:name('TestSiddhiApp')"
            + "define stream FooStream (symbol string, price float, volume long); "
            + "@sink(type='file', @map(type='json'), append='true', " + "file.uri='" + sinkUri
            + "/{{symbol}}.json') " + "define stream BarStream (symbol string, price float, volume long); ";

    String query = "" + "from FooStream " + "select * " + "insert into BarStream; ";

    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream");

    siddhiAppRuntime.start();//from  w w  w . j ava 2 s .  c o  m

    stockStream.send(new Object[] { "WSO2", 55.6f, 100L });
    stockStream.send(new Object[] { "IBM", 57.678f, 100L });
    stockStream.send(new Object[] { "GOOGLE", 50f, 100L });
    stockStream.send(new Object[] { "REDHAT", 50f, 100L });
    stockStream.send(new Object[] { "WSO2", 56.6f, 200L });
    stockStream.send(new Object[] { "IBM", 58.678f, 200L });

    Thread.sleep(100);

    ArrayList<String> symbolNames = new ArrayList<>();
    symbolNames.add("WSO2.json");
    symbolNames.add("IBM.json");
    symbolNames.add("GOOGLE.json");
    symbolNames.add("REDHAT.json");

    File sink = new File(sinkUri);
    if (sink.isDirectory()) {
        for (File file : sink.listFiles()) {
            if (symbolNames.contains(file.getName())) {
                count.incrementAndGet();
            }
        }
        AssertJUnit.assertEquals(4, count.intValue());
    } else {
        AssertJUnit.fail(sinkUri + " is not a directory.");
    }

    File wso2File = new File(sinkUri + "/WSO2.json");
    File ibmFile = new File(sinkUri + "/IBM.json");

    try {
        BufferedReader bufferedReader1 = new BufferedReader(new FileReader(wso2File));
        BufferedReader bufferedReader2 = new BufferedReader(new FileReader(ibmFile));

        int n = 0;
        String line = null;
        while ((line = bufferedReader1.readLine()) != null) {
            switch (n) {
            case 0:
                AssertJUnit.assertEquals("{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}",
                        line);
                break;
            case 1:
                AssertJUnit.assertEquals("{\"event\":{\"symbol\":\"WSO2\",\"price\":56.6,\"volume\":200}}",
                        line);
                break;
            }
            n++;
        }

        AssertJUnit.assertEquals(2, n);

        n = 0;
        while ((line = bufferedReader2.readLine()) != null) {
            switch (n) {
            case 0:
                AssertJUnit.assertEquals("{\"event\":{\"symbol\":\"IBM\",\"price\":57.678,\"volume\":100}}",
                        line);
                break;
            case 1:
                AssertJUnit.assertEquals("{\"event\":{\"symbol\":\"IBM\",\"price\":58.678,\"volume\":200}}",
                        line);
                break;
            }
            n++;
        }

        AssertJUnit.assertEquals(2, n);

    } catch (FileNotFoundException e) {
        AssertJUnit.fail(e.getMessage());
    } catch (IOException e) {
        AssertJUnit.fail(e.getMessage());
    }

    Thread.sleep(1000);
    siddhiAppRuntime.shutdown();
}

From source file:com.voidsearch.voidbase.config.VoidBaseConfig.java

public List<String> getList(String key) {
    Iterator iterator;//from w ww .  j a v  a2 s. c  o m
    ArrayList<String> list = new ArrayList<String>();

    if (key == null)
        return null;

    iterator = config.getKeys(key);

    while (iterator.hasNext()) {
        Integer rpos = 0;
        String newKey = null;
        String subKey = (String) iterator.next();

        // sanity check
        if (!subKey.startsWith(key)) {
            logger.error("Bad key: " + key);
            continue;
        } else if (subKey.length() <= key.length()) {
            continue;
        }

        // get key cutoff
        rpos = subKey.indexOf(".", key.length() + 1);
        rpos = rpos < 0 ? subKey.length() : rpos;

        newKey = subKey.substring(key.length() + 1, rpos);

        if (!list.contains(newKey)) {
            list.add(newKey);
        }
    }

    return list;
}

From source file:com.annahid.libs.artenus.internal.unified.IabHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);/*from w ww  .j a  v a 2 s . c o  m*/
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        IabSkuDetails d = new IabSkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.harvester.FileHarvestController.java

/**
 * Parse an additions file (RDF/XML) to get the URIs of newly-harvested data, which will be sent to the browser and
 * displayed to the user as links.//from  w  w w .  j a v  a  2 s  .c o  m
 * @param additionsFile the file containing the newly-added RDF/XML
 * @param newlyAddedUris a list in which to place the newly added URIs
 */
private void extractNewlyAddedUris(File additionsFile, List<String> newlyAddedUris, FileHarvestJob job) {

    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        Document document = factory.newDocumentBuilder().parse(additionsFile);
        //Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(additionsFile);
        NodeList descriptionNodes = document
                .getElementsByTagNameNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "Description");

        int numNodes = descriptionNodes.getLength();
        for (int i = 0; i < numNodes; i++) {
            Node node = descriptionNodes.item(i);

            ArrayList<String> types = getRdfTypes(node);

            boolean match = false;
            String[] validRdfTypesForJob = job.getRdfTypesForLinks();
            for (String rdfType : validRdfTypesForJob) {
                if (types.contains(rdfType))
                    match = true;
                break;
            }

            if (match) {

                NamedNodeMap attributes = node.getAttributes();
                Node aboutAttribute = attributes.getNamedItemNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                        "about");
                if (aboutAttribute != null) {
                    String value = aboutAttribute.getNodeValue();
                    newlyAddedUris.add(value);
                }
            }
        }

    } catch (Exception e) {
        log.error(e, e);
    }
}

From source file:net.sourceforge.mipa.predicatedetection.lattice.sequence.SequenceWindowedLatticeChecker.java

private void updateReachableState(SequenceLatticeIDNode minCGS, AbstractLatticeIDNode maxCGS, int id) {
    // TODO Auto-generated method stub
    if (minCGS == null) {
        return;//from ww  w  .  ja va2  s  . co m
    }

    /*
     * minCGS.getReachedStates().clear();
     * 
     * String[] string = minCGS.getSatisfiedPredicates().split(" "); for
     * (int i = 0; i < string.length; i++) { State state =
     * automaton.getInitialState().step(string[i].charAt(0));
     * minCGS.addReachedStates(state); } //
     * minCGS.addReachedStates(automaton.getInitialState()); if (DEBUG) {
     * long time_t = (new Date()).getTime(); out.print("[ "); for (int i =
     * 0; i < minCGS.getID().length; i++) { out.print(minCGS.getID()[i] +
     * " "); } out.print("]: satisfied predicates: " +
     * minCGS.getSatisfiedPredicates()); out.print(" reachable states: ");
     * Iterator<State> it = minCGS.getReachedStates().iterator(); while
     * (it.hasNext()) { State state = it.next(); out.print(state.getName() +
     * " "); } out.println(); out.flush(); wastedTime += (new
     * Date()).getTime() - time_t; } long time = (new Date()).getTime();
     * ArrayList<SequenceLatticeIDNode> set = new
     * ArrayList<SequenceLatticeIDNode>(); ArrayList<String> setID = new
     * ArrayList<String>(); set.add(minCGS);
     * setID.add(StringUtils.join(minCGS.getID(), ' ')); while
     * (!set.isEmpty()) { SequenceLatticeIDNode node = set.remove(0); for
     * (int i = 0; i < children.length; i++) { String[] index = new
     * String[children.length]; for (int j = 0; j < children.length; j++) {
     * index[j] = node.getID()[j]; } index[i] =
     * Integer.toString(Integer.valueOf(index[i]) + 1); String ID =
     * StringUtils.join(index, ' '); if (!setID.contains(ID) &&
     * getMappedLattice().get(ID) != null) { SequenceLatticeIDNode newNode =
     * (SequenceLatticeIDNode) getMappedLattice() .get(ID); if
     * (newNode.getGlobalState()[id].getID().equals(
     * minCGS.getGlobalState()[id].getID())) {
     * newNode.getReachedStates().clear(); computeReachableStates(newNode);
     * set.add(newNode); setID.add(StringUtils.join(newNode.getID(), ' '));
     * } else { HashSet<State> oriState = new HashSet<State>();
     * Iterator<State> iterator = newNode.getReachedStates() .iterator();
     * while (iterator.hasNext()) { oriState.add(iterator.next()); }
     * newNode.getReachedStates().clear(); computeReachableStates(newNode);
     * 
     * boolean flag = true; if (oriState.size() ==
     * newNode.getReachedStates() .size()) { String ori = ""; iterator =
     * oriState.iterator(); while (iterator.hasNext()) { State state =
     * iterator.next(); ori += state.getName() + " ";
     * 
     * } String news = ""; iterator = newNode.getReachedStates().iterator();
     * while (iterator.hasNext()) { State state = iterator.next(); news +=
     * state.getName() + " "; }
     * 
     * String[] oriStates = ori.trim().split(" "); String[] newStates =
     * news.trim().split(" "); for (int j = 0; j < oriStates.length; j++) {
     * String s = oriStates[j]; boolean f = false; for (int k = 0; k <
     * newStates.length; k++) { if (s.equals(newStates[k])) { f = true;
     * break; } } if (f == false) { flag = false; break; } } } else { flag =
     * false; } if (flag == false) { set.add(newNode);
     * setID.add(StringUtils.join(newNode.getID(), ' ')); } } } } } for (int
     * i = 0; i < children.length; i++) { String[] index = new
     * String[children.length]; for (int j = 0; j < children.length; j++) {
     * index[j] = node.getID()[j]; } index[i] =
     * Integer.toString(Integer.valueOf(index[i]) + 1); String ID =
     * StringUtils.join(index, ' '); if (!setID.contains(ID) &&
     * getMappedLattice().get(ID) != null) { SequenceLatticeIDNode newNode =
     * (SequenceLatticeIDNode) getMappedLattice() .get(ID); if
     * (newNode.getGlobalState()[id].getID().equals(
     * minCGS.getGlobalState()[id].getID())) {
     * newNode.getReachedStates().clear(); computeReachableStates(newNode);
     * set.add(newNode); setID.add(StringUtils.join(newNode.getID(), ' '));
     * } else { HashSet<State> oriState = new HashSet<State>();
     * Iterator<State> iterator = newNode.getReachedStates() .iterator();
     * while (iterator.hasNext()) { oriState.add(iterator.next()); }
     * newNode.getReachedStates().clear(); computeReachableStates(newNode);
     * 
     * boolean flag = true; if (oriState.size() ==
     * newNode.getReachedStates() .size()) { String ori = ""; iterator =
     * oriState.iterator(); while (iterator.hasNext()) { State state =
     * iterator.next(); ori += state.getName() + " ";
     * 
     * } String news = ""; iterator = newNode.getReachedStates().iterator();
     * while (iterator.hasNext()) { State state = iterator.next(); news +=
     * state.getName() + " "; }
     * 
     * String[] oriStates = ori.trim().split(" "); String[] newStates =
     * news.trim().split(" "); for (int j = 0; j < oriStates.length; j++) {
     * String s = oriStates[j]; boolean f = false; for (int k = 0; k <
     * newStates.length; k++) { if (s.equals(newStates[k])) { f = true;
     * break; } } if (f == false) { flag = false; break; } } } else { flag =
     * false; } if (flag == false) { set.add(newNode);
     * setID.add(StringUtils.join(newNode.getID(), ' ')); } } } }
     */

    long time = (new Date()).getTime();
    ArrayList<SequenceLatticeIDNode> set = new ArrayList<SequenceLatticeIDNode>();
    ArrayList<String> setID = new ArrayList<String>();
    set.add(minCGS);
    while (!set.isEmpty()) {
        SequenceLatticeIDNode node = set.remove(0);
        if (!setID.contains(StringUtils.join(node.getID(), ' '))) {
            setID.add(StringUtils.join(node.getID(), ' '));
            HashSet<State> oriState = new HashSet<State>();
            Iterator<State> iterator = node.getReachedStates().iterator();
            while (iterator.hasNext()) {
                oriState.add(iterator.next());
            }
            if (node.equals(minCGS)) {
                node.getReachedStates().clear();
                String[] string = node.getSatisfiedPredicates().split(" ");
                for (int i = 0; i < string.length; i++) {
                    State state = automaton.getInitialState().step(string[i].charAt(0));
                    node.addReachedStates(state);
                }
                if (DEBUG) {
                    long time_t = (new Date()).getTime();
                    out.print("[ ");
                    for (int i = 0; i < node.getID().length; i++) {
                        out.print(node.getID()[i] + " ");
                    }
                    out.print("]: satisfied predicates: " + node.getSatisfiedPredicates());
                    out.print(" reachable states: ");
                    Iterator<State> it = node.getReachedStates().iterator();
                    while (it.hasNext()) {
                        State state = it.next();
                        out.print(state.getName() + " ");
                    }
                    out.println();
                    out.flush();
                    wastedTime += (new Date()).getTime() - time_t;
                }
            } else {
                node.getReachedStates().clear();
                computeReachableStates(node);
            }

            boolean flag = true;
            if (oriState.size() == node.getReachedStates().size()) {
                String ori = "";
                iterator = oriState.iterator();
                while (iterator.hasNext()) {
                    State state = iterator.next();
                    ori += state.getName() + " ";

                }
                String news = "";
                iterator = node.getReachedStates().iterator();
                while (iterator.hasNext()) {
                    State state = iterator.next();
                    news += state.getName() + " ";
                }

                String[] oriStates = ori.trim().split(" ");
                String[] newStates = news.trim().split(" ");
                for (int j = 0; j < oriStates.length; j++) {
                    String s = oriStates[j];
                    boolean f = false;
                    for (int k = 0; k < newStates.length; k++) {
                        if (s.equals(newStates[k])) {
                            f = true;
                            break;
                        }
                    }
                    if (f == false) {
                        flag = false;
                        break;
                    }
                }
            } else {
                flag = false;
            }
            if (flag == false) {
                for (int i = 0; i < children.length; i++) {
                    String[] index = new String[children.length];
                    for (int j = 0; j < children.length; j++) {
                        index[j] = node.getID()[j];
                    }
                    index[i] = Integer.toString(Integer.valueOf(index[i]) + 1);
                    String ID = StringUtils.join(index, ' ');
                    if (getMappedLattice().get(ID) != null) {
                        set.add((SequenceLatticeIDNode) getMappedLattice().get(ID));
                    }
                }
            } else {
                // [id] not change
                if (node.getID()[id].equals(windowedLocalStateSet.get(id).get(0).getID())) {
                    for (int i = 0; i < children.length; i++) {
                        if (i == id) {
                            continue;
                        }
                        String[] index = new String[children.length];
                        for (int j = 0; j < children.length; j++) {
                            index[j] = node.getID()[j];
                        }
                        index[i] = Integer.toString(Integer.valueOf(index[i]) + 1);
                        String ID = StringUtils.join(index, ' ');
                        if (getMappedLattice().get(ID) != null) {
                            set.add((SequenceLatticeIDNode) getMappedLattice().get(ID));
                        }
                    }
                }
            }
        }
    }
    updateNumber = setID.size();
    updateTime = (new Date()).getTime() - time;
}

From source file:acceptable_risk.nik.uniobuda.hu.andrawid.util.IabHelper.java

int querySkuDetails(String 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  w  w w  .  j  a v a2 s . c om
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:com.achep.acdisplay.iab.utils.IabHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);//from w ww  . ja  va  2  s. co m
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:it.giacomos.android.osmer.purhcase.iabHelper.IabHelper.java

int querySkuDetails(String 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);//w  ww.j  ava2  s.c om
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mPackageName, itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:com.baroq.pico.google.iab.IabHelper.java

int querySkuDetails(String 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 . c  o  m*/
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> skuDetailsList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
    inv.jsonSkuDetailsList.addAll(skuDetailsList);
    logDebug("inv.jsonSkuDetailsList size: " + inv.jsonSkuDetailsList.size());

    for (String thisResponse : inv.jsonSkuDetailsList) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}