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.caju.uheer.app.services.infrastructure.ContactablesLoaderCallbacks.java

@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
    final ArrayList<String> infoAndName = new ArrayList<String>();
    try {//  ww w  . ja va  2s  . c o m
        for (int i = 0; i < usersFound.length(); i++) {
            infoAndName.add(usersFound.getJSONObject(i).getString("name"));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
    LocationListener locationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            Location geoPointLocation = new Location("geoPoint");
            try {
                infoAndName.clear();
                for (int i = 0; i < usersFound.length(); i++) {
                    String appendedText = "";
                    if (!usersFound.getJSONObject(i).has("channel")) {
                        geoPointLocation.setLongitude(usersFound.getJSONObject(i).getDouble("lon"));
                        geoPointLocation.setLatitude(usersFound.getJSONObject(i).getDouble("lat"));
                        float distance = location.distanceTo(geoPointLocation) / 1000;
                        appendedText = String.format("%.1f", distance) + "Km";
                    } else {
                        appendedText = usersFound.getJSONObject(i).getString("channel");
                    }
                    infoAndName.add(appendedText + usersFound.getJSONObject(i).getString("name"));
                    Log.e("infoandname", infoAndName.toString() + infoAndName.get(0) + infoAndName.get(1));
                    Toast.makeText(mContext, infoAndName.toString() + infoAndName.get(0) + infoAndName.get(1),
                            Toast.LENGTH_LONG).show();

                    // infoAndName tem a informacao de distancia ou canal e o nome. Precisa editar
                    //essa parte de baixo pra usar o infoAndName.
                    ArrayList<String> friendsEmails = new ArrayList<>();

                    friendsEmails.addAll(infoAndName);

                    friendsEmails = new ArrayList<>();
                    for (ArrayList<String> array : ServerInformation.getAllActiveListeners()) {
                        friendsEmails.addAll(array);
                        while (friendsEmails.contains(connectedEmail))
                            friendsEmails.remove(connectedEmail);
                    }
                    EmailListAdapter listAdapter = new EmailListAdapter(mContext, R.layout.adapter_email_list,
                            friendsEmails);
                    ListView emails = (ListView) ((Activity) mContext)
                            .findViewById(R.id.gps_friends_from_drawer);
                    emails.setAdapter(listAdapter);

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {

        }

        @Override
        public void onProviderEnabled(String provider) {

        }

        @Override
        public void onProviderDisabled(String provider) {

        }
    };

    // Minimum of 2 minutes between checks (120000 milisecs).
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 120000, 0, locationListener);
}

From source file:functionaltests.RestSchedulerTagTest.java

@Test
public void testTaskResultByTag() throws Exception {
    HttpResponse response = sendRequest("jobs/" + submittedJobId + "/tasks/tag/LOOP-T2-1/result");
    JSONArray jsonArray = toJsonArray(response);

    System.out.println(jsonArray.toJSONString());

    ArrayList<String> taskNames = new ArrayList<>(4);
    for (int i = 0; i < jsonArray.size(); i++) {
        JSONObject id = (JSONObject) ((JSONObject) jsonArray.get(i)).get("id");
        String name = (String) id.get("readableName");
        taskNames.add(name);/*from w ww. j a  v a  2 s  .  co  m*/
    }

    assertTrue(taskNames.contains("T1#1"));
    assertTrue(taskNames.contains("Print1#1"));
    assertTrue(taskNames.contains("Print2#1"));
    assertTrue(taskNames.contains("T2#1"));
    assertEquals(4, jsonArray.size());
}

From source file:com.yahoo.athenz.zts.store.impl.S3ChangeLogStoreTest.java

@Test
public void testListObjectsAllObjectsMultiplePagesModTime() {

    MockS3ChangeLogStore store = new MockS3ChangeLogStore(null);

    ArrayList<S3ObjectSummary> objectList1 = new ArrayList<>();
    S3ObjectSummary objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas");
    objectSummary.setLastModified(new Date(100));
    objectList1.add(objectSummary);//  w  w  w.j a v a 2s .c om
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas.athenz");
    objectSummary.setLastModified(new Date(100));
    objectList1.add(objectSummary);

    ArrayList<S3ObjectSummary> objectList2 = new ArrayList<>();
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("cd");
    objectSummary.setLastModified(new Date(100));
    objectList2.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("cd.docker");
    objectSummary.setLastModified(new Date(200));
    objectList2.add(objectSummary);

    ArrayList<S3ObjectSummary> objectList3 = new ArrayList<>();
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("platforms");
    objectSummary.setLastModified(new Date(200));
    objectList3.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("platforms.mh2");
    objectSummary.setLastModified(new Date(200));
    objectList3.add(objectSummary);

    ObjectListing objectListing = mock(ObjectListing.class);
    when(objectListing.getObjectSummaries()).thenReturn(objectList1).thenReturn(objectList2)
            .thenReturn(objectList3);
    when(objectListing.isTruncated()).thenReturn(true).thenReturn(true).thenReturn(false);
    when(store.s3.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
    when(store.s3.listNextBatchOfObjects(any(ObjectListing.class))).thenReturn(objectListing);

    ArrayList<String> domains = new ArrayList<>();
    store.listObjects(store.s3, domains, (new Date(150)).getTime());

    assertEquals(domains.size(), 3);
    assertTrue(domains.contains("cd.docker"));
    assertTrue(domains.contains("platforms"));
    assertTrue(domains.contains("platforms.mh2"));
}

From source file:com.yangtsaosoftware.pebblemessenger.activities.AppListPreference.java

@Override
protected void onDialogClosed(boolean positiveResult) {
    if (positiveResult) {
        String selectedPackages = "";
        ArrayList<String> tmpArray = new ArrayList<String>();
        if (lvPackageInfo == null || lvPackageInfo.getAdapter() == null) {
            return;
        }// w  w  w.j av a2 s.  c o m
        for (String strPackage : ((packageAdapter) lvPackageInfo.getAdapter()).selected) {
            if (!strPackage.isEmpty()) {
                if (!tmpArray.contains(strPackage)) {
                    tmpArray.add(strPackage);
                    selectedPackages += strPackage + ",";
                }
            }
        }
        SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(_context).edit();
        editor.putString(Constants.PREFERENCE_PACKAGE_LIST, selectedPackages);

        editor.apply();

        Intent intent = new Intent(NotificationService.class.getName());
        intent.putExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PREFER_CHANGED);
        LocalBroadcastManager.getInstance(_context).sendBroadcast(intent);

    }
    super.onDialogClosed(positiveResult);
}

From source file:com.stefensharkey.entityedit.command.CommandEnchant.java

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player player = (Player) sender;/*from   w  ww  . j  ava  2 s .c  om*/
    LivingEntity entity = Utils.getEntityInCrosshairs(player);
    ArrayList<String> argsList = new ArrayList<>();

    for (String arg : args) {
        argsList.add(arg.toUpperCase());
    }

    if (entity != null) {
        if (args.length < 3) {
            sender.sendMessage(ChatColor.RED + "At least one enchantment is required.");
            return false;
        } else {
            if (argsList.contains("-h") || argsList.contains("-c") || argsList.contains("-l")
                    || argsList.contains("-b")) {
                if (argsList.contains("-h")) {
                    ArrayList<String> helmEnchants;
                    String helmArgs = StringUtils.join(argsList, " ");

                    helmEnchants = new ArrayList<>(Arrays.asList(helmArgs
                            .substring(helmArgs.indexOf("-h", helmArgs.indexOf("-", helmArgs.indexOf("-h"))))
                            .split(" ")));

                    if (argsList.size() > argsList.indexOf("-h") + 1) {
                        Map<Enchantment, Integer> enchantMap = new HashMap<>();

                        for (String enchant : helmEnchants) {
                            enchantMap.put(Enchantment.getByName(enchant), 1);
                        }

                        entity.getEquipment().getHelmet().addEnchantments(enchantMap);
                    } else {
                        if (entity.getEquipment().getHelmet().hasItemMeta()) {
                            entity.getEquipment().getHelmet().getEnchantments().clear();
                        }
                    }
                }

                if (argsList.contains("-c")) {
                    ArrayList<String> chestplateEnchantments;
                    String chestplateArgs = StringUtils.join(argsList, " ");

                    chestplateEnchantments = new ArrayList<>(
                            Arrays.asList(chestplateArgs
                                    .substring(chestplateArgs.indexOf("-c",
                                            chestplateArgs.indexOf("-", chestplateArgs.indexOf("-c"))))
                                    .split(" ")));

                    if (argsList.size() > argsList.indexOf("-c") + 1) {
                        Map<Enchantment, Integer> enchantMap = new HashMap<>();

                        for (String enchant : chestplateEnchantments) {
                            enchantMap.put(Enchantment.getByName(enchant), 1);
                        }

                        entity.getEquipment().getChestplate().addEnchantments(enchantMap);
                    } else {
                        if (entity.getEquipment().getChestplate().hasItemMeta()) {
                            entity.getEquipment().getChestplate().getEnchantments().clear();
                        }
                    }
                }

                if (argsList.contains("-l")) {
                    ArrayList<String> leggingEnchantments;
                    String leggingArgs = StringUtils.join(argsList, " ");

                    leggingEnchantments = new ArrayList<>(
                            Arrays.asList(
                                    leggingArgs
                                            .substring(leggingArgs.indexOf("-l",
                                                    leggingArgs.indexOf("-", leggingArgs.indexOf("-l"))))
                                            .split(" ")));

                    if (argsList.size() > argsList.indexOf("-l") + 1) {
                        Map<Enchantment, Integer> enchantMap = new HashMap<>();

                        for (String enchant : leggingEnchantments) {
                            enchantMap.put(Enchantment.getByName(enchant), 1);
                        }

                        entity.getEquipment().getLeggings().addEnchantments(enchantMap);
                    } else {
                        if (entity.getEquipment().getLeggings().hasItemMeta()) {
                            entity.getEquipment().getLeggings().getEnchantments().clear();
                        }
                    }
                }

                if (argsList.contains("-b")) {
                    ArrayList<String> bootEnchantments;
                    String bootArgs = StringUtils.join(argsList, " ");

                    bootEnchantments = new ArrayList<>(Arrays.asList(bootArgs
                            .substring(bootArgs.indexOf("-b", bootArgs.indexOf("-", bootArgs.indexOf("-b"))))
                            .split(" ")));

                    if (argsList.size() > argsList.indexOf("-b") + 1) {
                        Map<Enchantment, Integer> enchantMap = new HashMap<>();

                        for (String enchant : bootEnchantments) {
                            enchantMap.put(Enchantment.getByName(enchant), 1);
                        }

                        entity.getEquipment().getBoots().addEnchantments(enchantMap);
                    } else {
                        if (entity.getEquipment().getBoots().hasItemMeta()) {
                            entity.getEquipment().getBoots().getEnchantments().clear();
                        }
                    }
                }
                return true;
            }

            sender.sendMessage(ChatColor.RED + "Syntax error.");
            sender.sendMessage(ChatColor.RED
                    + "/entityedit enchant <[-clear] [-h [enchantments]] [-c [enchantments]] [-l [enchantments]] [-b [enchantments]]>");
            return false;
        }
    }

    sender.sendMessage(ChatColor.RED + "No entities found.");
    return true;
}

From source file:fr.cirad.mgdb.exporting.markeroriented.HapMapExportHandler.java

@Override
public void exportData(OutputStream outputStream, String sModule, List<SampleId> sampleIDs,
        ProgressIndicator progress, DBCursor markerCursor, Map<Comparable, Comparable> markerSynonyms,
        int nMinimumGenotypeQuality, int nMinimumReadDepth, Map<String, InputStream> readyToExportFiles)
        throws Exception {
    MongoTemplate mongoTemplate = MongoTemplateManager.get(sModule);
    File warningFile = File.createTempFile("export_warnings_", "");
    FileWriter warningFileWriter = new FileWriter(warningFile);

    int markerCount = markerCursor.count();

    ZipOutputStream zos = new ZipOutputStream(outputStream);

    if (readyToExportFiles != null)
        for (String readyToExportFile : readyToExportFiles.keySet()) {
            zos.putNextEntry(new ZipEntry(readyToExportFile));
            InputStream inputStream = readyToExportFiles.get(readyToExportFile);
            byte[] dataBlock = new byte[1024];
            int count = inputStream.read(dataBlock, 0, 1024);
            while (count != -1) {
                zos.write(dataBlock, 0, count);
                count = inputStream.read(dataBlock, 0, 1024);
            }//from   w  w w . java2s  .c o m
        }

    List<Individual> individuals = getIndividualsFromSamples(sModule, sampleIDs);
    ArrayList<String> individualList = new ArrayList<String>();
    for (int i = 0; i < sampleIDs.size(); i++) {
        Individual individual = individuals.get(i);
        if (!individualList.contains(individual.getId())) {
            individualList.add(individual.getId());
        }
    }

    String exportName = sModule + "_" + markerCount + "variants_" + individualList.size() + "individuals";
    zos.putNextEntry(new ZipEntry(exportName + ".hapmap"));
    String header = "rs#" + "\t" + "alleles" + "\t" + "chrom" + "\t" + "pos" + "\t" + "strand" + "\t"
            + "assembly#" + "\t" + "center" + "\t" + "protLSID" + "\t" + "assayLSID" + "\t" + "panelLSID" + "\t"
            + "QCcode";
    zos.write(header.getBytes());
    for (int i = 0; i < individualList.size(); i++) {
        zos.write(("\t" + individualList.get(i)).getBytes());
    }
    zos.write((LINE_SEPARATOR).getBytes());

    int avgObjSize = (Integer) mongoTemplate
            .getCollection(mongoTemplate.getCollectionName(VariantRunData.class)).getStats().get("avgObjSize");
    int nChunkSize = nMaxChunkSizeInMb * 1024 * 1024 / avgObjSize;
    short nProgress = 0, nPreviousProgress = 0;
    long nLoadedMarkerCount = 0;

    while (markerCursor == null || markerCursor.hasNext()) {
        int nLoadedMarkerCountInLoop = 0;
        Map<Comparable, String> markerChromosomalPositions = new LinkedHashMap<Comparable, String>();
        boolean fStartingNewChunk = true;
        markerCursor.batchSize(nChunkSize);
        while (markerCursor.hasNext() && (fStartingNewChunk || nLoadedMarkerCountInLoop % nChunkSize != 0)) {
            DBObject exportVariant = markerCursor.next();
            DBObject refPos = (DBObject) exportVariant.get(VariantData.FIELDNAME_REFERENCE_POSITION);
            markerChromosomalPositions.put((Comparable) exportVariant.get("_id"),
                    refPos.get(ReferencePosition.FIELDNAME_SEQUENCE) + ":"
                            + refPos.get(ReferencePosition.FIELDNAME_START_SITE));
            nLoadedMarkerCountInLoop++;
            fStartingNewChunk = false;
        }

        List<Comparable> currentMarkers = new ArrayList<Comparable>(markerChromosomalPositions.keySet());
        LinkedHashMap<VariantData, Collection<VariantRunData>> variantsAndRuns = MgdbDao.getSampleGenotypes(
                mongoTemplate, sampleIDs, currentMarkers, true,
                null /*new Sort(VariantData.FIELDNAME_REFERENCE_POSITION + "." + ChromosomalPosition.FIELDNAME_SEQUENCE).and(new Sort(VariantData.FIELDNAME_REFERENCE_POSITION + "." + ChromosomalPosition.FIELDNAME_START_SITE))*/); // query mongo db for matching genotypes
        for (VariantData variant : variantsAndRuns.keySet()) // read data and write results into temporary files (one per sample)
        {
            Comparable variantId = variant.getId();
            if (markerSynonyms != null) {
                Comparable syn = markerSynonyms.get(variantId);
                if (syn != null)
                    variantId = syn;
            }

            boolean fIsSNP = variant.getType().equals(Type.SNP.toString());
            byte[] missingGenotype = ("\t" + "NN").getBytes();

            String[] chromAndPos = markerChromosomalPositions.get(variant.getId()).split(":");
            zos.write(((variantId == null ? variant.getId() : variantId) + "\t"
                    + StringUtils.join(variant.getKnownAlleleList(), "/") + "\t" + chromAndPos[0] + "\t"
                    + Long.parseLong(chromAndPos[1]) + "\t" + "+").getBytes());
            for (int j = 0; j < 6; j++)
                zos.write(("\t" + "NA").getBytes());

            Map<String, Integer> gqValueForSampleId = new LinkedHashMap<String, Integer>();
            Map<String, Integer> dpValueForSampleId = new LinkedHashMap<String, Integer>();
            Map<String, List<String>> individualGenotypes = new LinkedHashMap<String, List<String>>();
            Collection<VariantRunData> runs = variantsAndRuns.get(variant);
            if (runs != null)
                for (VariantRunData run : runs)
                    for (Integer sampleIndex : run.getSampleGenotypes().keySet()) {
                        SampleGenotype sampleGenotype = run.getSampleGenotypes().get(sampleIndex);
                        String gtCode = run.getSampleGenotypes().get(sampleIndex).getCode();
                        String individualId = individuals
                                .get(sampleIDs.indexOf(new SampleId(run.getId().getProjectId(), sampleIndex)))
                                .getId();
                        List<String> storedIndividualGenotypes = individualGenotypes.get(individualId);
                        if (storedIndividualGenotypes == null) {
                            storedIndividualGenotypes = new ArrayList<String>();
                            individualGenotypes.put(individualId, storedIndividualGenotypes);
                        }
                        storedIndividualGenotypes.add(gtCode);
                        gqValueForSampleId.put(individualId,
                                (Integer) sampleGenotype.getAdditionalInfo().get(VariantData.GT_FIELD_GQ));
                        dpValueForSampleId.put(individualId,
                                (Integer) sampleGenotype.getAdditionalInfo().get(VariantData.GT_FIELD_DP));
                    }

            int writtenGenotypeCount = 0;
            for (String individualId : individualList /* we use this list because it has the proper ordering */) {
                int individualIndex = individualList.indexOf(individualId);
                while (writtenGenotypeCount < individualIndex - 1) {
                    zos.write(missingGenotype);
                    writtenGenotypeCount++;
                }

                List<String> genotypes = individualGenotypes.get(individualId);
                HashMap<Object, Integer> genotypeCounts = new HashMap<Object, Integer>(); // will help us to keep track of missing genotypes
                int highestGenotypeCount = 0;
                String mostFrequentGenotype = null;
                if (genotypes != null)
                    for (String genotype : genotypes) {
                        if (genotype.length() == 0)
                            continue; /* skip missing genotypes */

                        Integer gqValue = gqValueForSampleId.get(individualId);
                        if (gqValue != null && gqValue < nMinimumGenotypeQuality)
                            continue; /* skip this sample because its GQ is under the threshold */

                        Integer dpValue = dpValueForSampleId.get(individualId);
                        if (dpValue != null && dpValue < nMinimumReadDepth)
                            continue; /* skip this sample because its DP is under the threshold */

                        int gtCount = 1 + MgdbDao.getCountForKey(genotypeCounts, genotype);
                        if (gtCount > highestGenotypeCount) {
                            highestGenotypeCount = gtCount;
                            mostFrequentGenotype = genotype;
                        }
                        genotypeCounts.put(genotype, gtCount);
                    }

                byte[] exportedGT = mostFrequentGenotype == null ? missingGenotype
                        : ("\t" + StringUtils.join(variant.getAllelesFromGenotypeCode(mostFrequentGenotype),
                                fIsSNP ? "" : "/")).getBytes();
                zos.write(exportedGT);
                writtenGenotypeCount++;

                if (genotypeCounts.size() > 1)
                    warningFileWriter.write("- Dissimilar genotypes found for variant "
                            + (variantId == null ? variant.getId() : variantId) + ", individual " + individualId
                            + ". Exporting most frequent: " + new String(exportedGT) + "\n");
            }

            while (writtenGenotypeCount < individualList.size()) {
                zos.write(missingGenotype);
                writtenGenotypeCount++;
            }
            zos.write((LINE_SEPARATOR).getBytes());
        }

        if (progress.hasAborted())
            return;

        nLoadedMarkerCount += nLoadedMarkerCountInLoop;
        nProgress = (short) (nLoadedMarkerCount * 100 / markerCount);
        if (nProgress > nPreviousProgress) {
            //            if (nProgress%5 == 0)
            //               LOG.info("========================= exportData: " + nProgress + "% =========================" + (System.currentTimeMillis() - before)/1000 + "s");
            progress.setCurrentStepProgress(nProgress);
            nPreviousProgress = nProgress;
        }
    }

    warningFileWriter.close();
    if (warningFile.length() > 0) {
        zos.putNextEntry(new ZipEntry(exportName + "-REMARKS.txt"));
        int nWarningCount = 0;
        BufferedReader in = new BufferedReader(new FileReader(warningFile));
        String sLine;
        while ((sLine = in.readLine()) != null) {
            zos.write((sLine + "\n").getBytes());
            in.readLine();
            nWarningCount++;
        }
        LOG.info("Number of Warnings for export (" + exportName + "): " + nWarningCount);
        in.close();
    }
    warningFile.delete();

    zos.close();
    progress.setCurrentStepProgress((short) 100);
}

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

public boolean isEmpty() {
    ArrayList<Integer> ords = mCol.getModels().availOrds(model(), Utils.joinFields(note().getFields()));
    return !ords.contains(mOrd);
}

From source file:com.mirth.connect.connectors.file.filesystems.test.FileConnectionTest.java

@Test
public void testListFiles() throws Exception {
    ArrayList<String> testFileNames = new ArrayList<String>();

    for (int i = 0; i < 10; i++) {
        File temp = File.createTempFile("ListFile", ".dat", someFolder);
        testFileNames.add(temp.getName());
    }/* w w w. ja v a2  s  .  co  m*/

    List<FileInfo> retFiles = fc.listFiles(someFolder.getAbsolutePath(), "ListFile.+", true, true);

    for (int i = 0; i < retFiles.size(); i++) {
        assertTrue(testFileNames.contains(retFiles.get(i).getName()));
    }
}

From source file:net.easysmarthouse.service.context.ProxiedResolverGenericXmlApplicationContext.java

@Override
public <T extends Object> T getBean(Class<T> requiredType) throws BeansException {
    Assert.notNull(requiredType, "Required type must not be null");
    String[] beanNames = getBeanNamesForType(requiredType);
    String primaryCandidate = null;

    if (beanNames.length > 1) {
        ArrayList<String> autowireCandidates = new ArrayList<String>();

        for (String beanName : beanNames) {
            BeanDefinition beanDefinition = getBeanDefinition(beanName);
            if (beanDefinition.isAutowireCandidate()) {
                autowireCandidates.add(beanName);
                if (beanDefinition.isPrimary()) {
                    primaryCandidate = beanName;
                }/*from w  w  w .  j  a v  a2 s  .  c  om*/
            }
        }

        for (String autowireCandidate : autowireCandidates) {
            if (autowireCandidates.contains(autowireCandidate + "Proxied")) {
                primaryCandidate = autowireCandidate;
            }
        }

        if (autowireCandidates.size() > 0) {
            beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
        }
    }

    if (beanNames.length == 1) {
        return getBean(beanNames[0], requiredType);

    } else if (beanNames.length > 1) {
        // more than one bean defined, lookup primary candidate
        if (primaryCandidate != null) {
            return getBean(primaryCandidate, requiredType);
        }
        throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found "
                + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames));

    } else if (beanNames.length == 0 && getParentBeanFactory() != null) {
        return getParentBeanFactory().getBean(requiredType);

    } else {
        throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found "
                + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames));

    }
}

From source file:administraScan.OrganizaDirectorios.java

public void copiarCompletos() throws IOException {
    FileUtils Files = new FileUtils();
    AdministraScan adm = new AdministraScan();
    File origen;//from  www . j ava2s.  c  o m
    File destino;
    File f = new File(conf.carpetaCT);
    ArrayList<String> cts = new ArrayList<>(Arrays.asList(f.list()));
    for (String ct : cts) {
        String dirCT = conf.carpetaCT + ct.trim();
        File dir_expedientes = new File(dirCT);
        ArrayList<String> curps = new ArrayList<>(Arrays.asList(dir_expedientes.list()));
        for (String curp : curps) {
            String dircurp = dirCT + "\\" + curp.trim();
            File doc = new File(dircurp);
            ArrayList<String> documentos = new ArrayList<>(Arrays.asList(doc.list()));
            ArrayList<String> claves = adm.RetornaCT(documentos);
            ArrayList<String> obli_cedula = new ArrayList<>(Arrays.asList(conf.DOC_R));
            obli_cedula.remove("CUGE");
            boolean completo_cedula = claves.containsAll(obli_cedula)
                    && (claves.contains("CPL") || claves.contains("CPM") || claves.contains("CPD"))
                    && !claves.contains("CUGE");
            if (claves.containsAll(conf.OBLIGATORIOS) || completo_cedula) {
                String clave = "";
                String nombre_ss = "";
                clave = ct.substring(3, 5);
                this.conectarbd();
                String consultaDescripcionSS = "Select descripcion from cg_nivel_educativo where nivel_educativo = ?";
                try {
                    PreparedStatement SPreparada;
                    SPreparada = connection.prepareStatement(consultaDescripcionSS);
                    SPreparada.setString(1, clave);
                    ResultSet resultadoDescripcion = SPreparada.executeQuery();
                    if (resultadoDescripcion.next()) {
                        nombre_ss = resultadoDescripcion.getString("descripcion").trim();
                    }
                    SPreparada.close();
                    connection.close();

                } catch (SQLException ex) {
                    Logger.getLogger(OrganizaDirectorios.class.getName()).log(Level.SEVERE, null, ex);
                }
                String ruta_destino = conf.carpetaRemota + "completos\\" + nombre_ss + "\\" + ct.trim();
                origen = new File(dircurp);
                destino = new File(ruta_destino);
                File destino_final = new File(ruta_destino + "\\" + curp.trim());
                if (!destino_final.exists()) {
                    Files.copyDirectoryToDirectory(doc, destino);
                    System.out.println(
                            "Movi carpeta: " + doc.getAbsolutePath() + " a " + destino_final.getAbsolutePath());
                }
            }
        }
    }
}