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.brightcove.com.uploader.verifier.RetrieveJSONResponseforVideo.java

public ArrayList<Object> getMetaData(String metaDataName) {
    ArrayList<Object> property = new ArrayList<Object>();
    property = jsonResponse.retrieveArrayPropertyFromJSONResponse(metaDataName);
    if (property.size() == 0) {
        property = jsonResponse.retrieveJSONObjectFromJSONResponse(metaDataName);
        if (property.isEmpty() && !property.contains("renditions") && !property.contains("IOSRenditions")) {
            property.add(jsonResponse.retrievePropertyFromJSONResponse(metaDataName));
        }/*from w w w  . ja v  a 2s. c  o m*/
    }
    return property;
}

From source file:com.grossbart.forbiddenfunction.FFRunner.java

/**
 * Add files for compilation./*w  w w  . j a  v  a  2 s . c  o  m*/
 * 
 * @param slim   the compiler instance
 * @param files  the files to add
 * 
 * @return true if the files were properly validated or false otherwise
 * @exception IOException
 *                   if there is an error reading the files
 */
private boolean addFiles(ForbiddenFunction slim, List<String> files) throws IOException {
    ArrayList<File> readFiles = new ArrayList<File>();

    for (String file : files) {
        File f = new File(file);
        if (readFiles.contains(f)) {
            continue;
        }

        String contents = FileUtils.readFileToString(f, m_charset);

        if (m_preparse) {
            ErrorManager mgr = slim.validate(f.getAbsolutePath(), contents);
            if (mgr.getErrorCount() != 0) {
                mgr.generateReport();
                return false;
            }
        }

        m_mainFiles.append(contents + "\n");

        ForbiddenFunction.getLogger().log(Level.INFO, "Adding main file: " + f.getAbsoluteFile());

        slim.addSourceFile(new JSFile(f.getAbsolutePath(), contents));
    }

    return true;
}

From source file:fr.gouv.vitam.mdbes.MongoDbAccess.java

/**
 * Add a one way relation (n) from Obj1 to Obj2
 *
 * @param obj1/*from  w  w  w. ja  v a2s .c om*/
 * @param obj1ToObj2
 * @param obj2
 * @param toUpdate
 *            True if this element will be updated through $addToSet only
 * @return a {@link DBObject} for update
 */
private static final DBObject addAsymmetricLinkset(final VitamType obj1, final String obj1ToObj2,
        final VitamType obj2, final boolean toUpdate) {
    @SuppressWarnings("unchecked")
    ArrayList<String> relation12 = (ArrayList<String>) obj1.get(obj1ToObj2);
    final String oid2 = (String) obj2.get(VitamType.ID);
    if (relation12 == null) {
        if (toUpdate) {
            return new BasicDBObject("$addToSet", new BasicDBObject(obj1ToObj2, oid2));
        }
        relation12 = new ArrayList<String>();
    }
    if (relation12.contains(oid2)) {
        return null;
    }
    if (toUpdate) {
        return new BasicDBObject("$addToSet", new BasicDBObject(obj1ToObj2, oid2));
    } else {
        relation12.add(oid2);
        obj1.put(obj1ToObj2, relation12);
        return null;
    }
}

From source file:blue.mixer.ChannelList.java

public void clearChannelsNotInList(ArrayList ids) {
    Iterator iter = channels.iterator();

    while (iter.hasNext()) {
        Channel channel = (Channel) iter.next();

        if (!ids.contains(channel.getName())) {
            iter.remove();//from w  ww.ja v  a2s  .  c  o  m
        }
    }
}

From source file:vocab.VocabUtils.java

/**
 * The reason why the model is not returned is because I want to be able to close it later.
 * @param model//from  w  w  w  . j  a  va2s  .  c o m
 * @param ontoPath
 * @param ontoURL 
 */
private static void readOnlineModel(OntModel model, Vocabulary v) {
    ArrayList<String> s = v.getSupportedSerializations();
    if (s.isEmpty()) {
        System.err.println("Error: no serializations available!!");
        Report.getInstance().addErrorForVocab(v.getUri(), TextConstants.Error.NO_SERIALIZATIONS_FOR_VOCAB);
        //try the application/rdf+xml anyways. It is the most typical, 
        //and sometimes it may not have been recognized because they 
        //don't add a content header
        try {
            model.read(v.getUri(), null, "RDF/XML");
            v.getSupportedSerializations().add("application/rdf+xml");
        } catch (Exception e) {
            System.err.println("Error: no serializations available!!");
            Report.getInstance().addErrorForVocab(v.getUri(), TextConstants.Error.NO_SERIALIZATIONS_FOR_VOCAB);
        }
    } else {
        if (s.contains("application/rdf+xml")) {
            doContentNegotiation(model, v, "application/rdf+xml", "RDF/XML");
        } else if (s.contains("text/turtle")) {
            doContentNegotiation(model, v, "text/turtle", "TURTLE");
        } else if (s.contains("text/n3")) {
            doContentNegotiation(model, v, "text/n3", "N3");
        }
        //            System.out.println("Vocab "+v.getUri()+" loaded successfully!");
    }
}

From source file:com.marketcloud.marketcloud.Json.java

/**
 * Parses a JSONObject, looking for the given structure. <br />
 * <br />// w ww .  j av a  2 s  .  co m
 * It differs from the other parseData because the user should provide a pre-prepared Hashmap that will be
 * filled by the method. The keys of the map will be used as the string array of the other parseData.
 * <br />
 * In order to avoid override of data that you need to keep, and to use the method without getting an
 * exception, you could pass an "ignore" list containing the keys that you want the method to ignore,
 * simply adding all the keys you want to ignore to the method call. <br />
 * Example: parseData(map, jsonObject, "price", "source"); <br />
 * If the map contains the keys "price" and "source", then the method will ignore them. <br />
 * The normal method call remains: parseData(map, jsonObject) .
 * <br />
 * Note: if the structure is not correct, the method will throw an exception and fail. If the JSONObject
 * contains a JSONArray, only the first argument of the array (the first object) will be parsed.
 *
 * @param map pre-prepared Hashmap
 * @return an Hashmap with the parsed data
 */
@SuppressWarnings("unused")
public HashMap<String, Object> parseData(HashMap<String, Object> map, JSONObject jsonObject, String... ignore)
        throws JSONException {
    if (jsonObject.has("data"))
        jsonObject = getData(jsonObject)[0];

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

    Collections.addAll(ignorelist, ignore);

    for (String key : map.keySet()) {
        if (!ignorelist.contains(key))
            map.put(key, jsonObject.get(key));
    }

    return map;
}

From source file:fusion.Fusion.java

private static boolean isSynonym(Value val1, Value val2) throws IOException {
    boolean isSyn = false;
    String thesaurusUrl = "http://words.bighugelabs.com/api/2/92eae7f933f0f63404b3438ca46861e5/"
            + val1.getValue() + "/xml";

    Document doc = Jsoup.connect(thesaurusUrl).get();
    Elements synonyms = doc.select("w");

    String syn = synonyms.html();
    String[] synonymsArray = syn.split("\n");
    ArrayList<String> synonymsList = new ArrayList<String>(Arrays.asList(synonymsArray));
    if (synonymsList.contains(val2.getValue())) {
        val1.addToSynonyms(val2);
        val2.addToSynonyms(val1);
        isSyn = true;/*from   w ww .j  ava 2 s  .  c o m*/

    }
    return isSyn;
}

From source file:fr.inria.atlanmod.neoemf.map.datastore.MapPersistenceBackendFactory.java

@Override
protected SearcheableResourceEStore internalCreatePersistentEStore(PersistentResource resource,
        PersistenceBackend backend, Map<?, ?> options) throws InvalidDataStoreException {
    assert backend instanceof DB : "Trying to create a Map-based EStore with an invalid backend";
    @SuppressWarnings("unchecked")
    ArrayList<PersistentResourceOptions.StoreOption> storeOptions = (ArrayList<PersistentResourceOptions.StoreOption>) options
            .get(PersistentResourceOptions.STORE_OPTIONS);
    if (storeOptions == null || storeOptions.isEmpty()
            || storeOptions.contains(MapResourceOptions.EStoreMapOption.DIRECT_WRITE)) {
        // Default store
        return new DirectWriteMapResourceEStoreImpl(resource, (MapPersistenceBackend) backend);
    } else {//from   w w w .j a va 2s  .  c o  m
        if (storeOptions.contains(MapResourceOptions.EStoreMapOption.AUTOCOMMIT)) {
            return new AutocommitMapResourceEStoreImpl(resource, (MapPersistenceBackend) backend);
        } else if (storeOptions.contains(MapResourceOptions.EStoreMapOption.CACHED_MANY)) {
            return new CachedManyDirectWriteMapResourceEStoreImpl(resource, (MapPersistenceBackend) backend);
        } else if (storeOptions.contains(MapResourceOptions.EStoreMapOption.DIRECT_WRITE_WITH_LISTS)) {
            return new DirectWriteMapResourceWithListsEStoreImpl(resource, (MapPersistenceBackend) backend);
        } else if (storeOptions.contains(MapResourceOptions.EStoreMapOption.DIRECT_WRITE_WITH_INDEXES)) {
            return new DirectWriteMapWithIndexesResourceEStoreImpl(resource, (MapPersistenceBackend) backend);
        } else {
            throw new InvalidDataStoreException();
        }
    }
}

From source file:Data.c_CardDB.java

public boolean isInLegal(c_Deck deck, Legals leg) {
    boolean isDeckInLegal = true;
    c_Card card;//from   www. ja va2s . c  o  m
    if (m_expansionDB.doesLegalContainLegals(leg)) {
        HashMap<Integer, Keyword> list = m_expansionDB.getOtherLegals(leg);
        for (int mid : deck.getAllCards().keySet()) {
            card = getCard(mid);
            HashMap<c_Expansion, Integer> expList = getExpansionList(card.Name);
            ArrayList<Integer> legalExpansions = m_expansionDB.getLegalExpansions(leg);
            for (c_Expansion exp : expList.keySet()) {
                if (!legalExpansions.contains(m_expansionDB.getEID(exp))) {
                    isDeckInLegal = false;
                    expList = null;
                    legalExpansions = null;
                    break;
                }
            }

            int nameHash = card.Name.hashCode();
            if (list.containsKey(nameHash)) {
                if (list.get(nameHash) == Keyword.Banned
                        || deck.getAmountOfCard(mid, c_Deck.WhichHalf.BOTH) > 1) {
                    isDeckInLegal = false;
                    list = null;
                    break;
                }
            }
        }
    }
    card = null;
    return isDeckInLegal;
}

From source file:freightKt.KTFreight_v3.java

/**
 * Prft ob alle Services auch in den geplanten Touren vorkommen, d.h., ob sie auhc tatschslcih geplant wurden.
 * Falls nicht: log.Error und Ausgabe einer Datei: "#UnassignedServices.txt" mit den Service-Ids.
 * @param carriers//w  ww  . j  av  a  2s. c o m
 */

//TODO: Ausgabe der Anassigned Services in Run-Verzeichnis und dafrin der bersicht nur eine Nennung der Anzahl unassignedServices je Run 
//TODO: multiassigned analog.
private static void checkServiceAssignment(Carriers carriers) {
    for (Carrier c : carriers.getCarriers().values()) {
        ArrayList<CarrierService> assignedServices = new ArrayList<CarrierService>();
        ArrayList<CarrierService> multiassignedServices = new ArrayList<CarrierService>();
        ArrayList<CarrierService> unassignedServices = new ArrayList<CarrierService>();

        System.out.println("### Carrier: " + c.getId());
        //Erfasse alle einer Tour zugehrigen (-> stattfindenden) Services 
        for (ScheduledTour tour : c.getSelectedPlan().getScheduledTours()) {
            for (TourElement te : tour.getTour().getTourElements()) {
                if (te instanceof ServiceActivity) {
                    CarrierService assigService = ((ServiceActivity) te).getService();
                    if (!assignedServices.contains(assigService)) {
                        assignedServices.add(assigService);
                        System.out.println("Assigned Service: " + assignedServices.toString());
                    } else {
                        multiassignedServices.add(assigService);
                        log.error("Service wurde von dem Carrier " + c.getId().toString()
                                + " bereits angefahren: " + assigService.getId().toString());
                    }
                }
            }
        }

        //Nun prfe, ob alle definierten Service zugeordnet wurden
        for (CarrierService service : c.getServices()) {
            System.out.println("Service to Check: " + service.toString());
            if (!assignedServices.contains(service)) {
                System.out.println("Service not assigned: " + service.toString());
                unassignedServices.add(service);
                log.error("Service wird von Carrier " + c.getId().toString() + " NICHT bedient: "
                        + service.getId().toString());
            } else {
                System.out.println("Service was assigned: " + service.toString());
            }
        }

        //Schreibe die mehrfach eingeplanten Services in Datei
        if (!multiassignedServices.isEmpty()) {
            try {
                FileWriter writer = new FileWriter(new File(TEMP_DIR + "#MultiAssignedServices.txt"), true);
                writer.write("#### Multi-assigned Services of Carrier: " + c.getId().toString()
                        + System.getProperty("line.separator"));
                for (CarrierService s : multiassignedServices) {
                    writer.write(s.getId().toString() + System.getProperty("line.separator"));
                }
                writer.flush();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        //Schreibe die nicht eingeplanten Services in Datei
        if (!unassignedServices.isEmpty()) {
            try {
                FileWriter writer = new FileWriter(new File(TEMP_DIR + "#UnassignedServices.txt"), true);
                writer.write("#### Unassigned Services of Carrier: " + c.getId().toString()
                        + System.getProperty("line.separator"));
                for (CarrierService s : unassignedServices) {
                    writer.write(s.getId().toString() + System.getProperty("line.separator"));
                }
                writer.flush();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    } //for(carriers)

}