Example usage for java.util ArrayList addAll

List of usage examples for java.util ArrayList addAll

Introduction

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

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.

Usage

From source file:Model.Picture.java

public static ArrayList<String> upload(HttpServletRequest request, int type) {
    ArrayList<String> errors = new ArrayList<String>();
    ArrayList<String> pictureNames = new ArrayList<String>();

    DiskFileItemFactory factory = new DiskFileItemFactory();
    factory.setSizeThreshold(Constants.UPLOAD_SIZE_THRESHOLD);
    new File(Constants.TEMP_DIR).mkdirs();
    factory.setRepository(new File(Constants.TEMP_DIR));

    ServletFileUpload upload = new ServletFileUpload(factory);
    upload.setSizeMax(Constants.MAX_UPLOAD_SIZE);

    try {/*from   w w w  . jav  a2 s  .  co  m*/
        List fileItems = upload.parseRequest(request);
        Iterator i = fileItems.iterator();

        while (i.hasNext()) {
            FileItem fileItem = (FileItem) i.next();
            String fileName = fileItem.getName();

            if (type == EXCEL_UPLOAD)
                errors.addAll(upload_excel(fileName, fileItem));
            else if (type == PICTURE_UPLOAD)
                errors.addAll(upload_picture(fileName, fileItem, pictureNames));
        }
    } catch (org.apache.commons.fileupload.FileUploadException e) {
        e.printStackTrace(System.out);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }

    if (type == PICTURE_UPLOAD)
        DataBaseTools.insertAndUpdateRecords(pictureNames);

    return errors;
}

From source file:cross.io.AFragmentCommandServiceLoader.java

/**
 * Creates a sorted list of fragment commands, given the provided comparator.
 *
 * @param s    the set of fragment commands
 * @param comp the comparator/*w  ww . j  av  a  2 s  .c o  m*/
 * @return a sorted list of fragment commands
 */
public List<AFragmentCommand> createSortedListFromSet(Set<AFragmentCommand> s,
        Comparator<AFragmentCommand> comp) {
    ArrayList<AFragmentCommand> al = new ArrayList<>();
    al.addAll(s);
    Collections.sort(al, comp);
    return al;
}

From source file:com.orchestra.portale.external.services.manager.CiRoService.java

private String createPoi(int item, JsonArray puntiCiro) {
    CompletePOI newPoi = new CompletePOI();
    newPoi.setName(puntiCiro.get(item).getAsJsonObject().get("nome").getAsString());
    newPoi.setAddress(puntiCiro.get(item).getAsJsonObject().get("indirizzo").getAsString());
    double[] location = { puntiCiro.get(item).getAsJsonObject().get("latitudine").getAsDouble(),
            puntiCiro.get(item).getAsJsonObject().get("longitudine").getAsDouble() };
    newPoi.setLocation(location);/*from w w  w  .  j a  v  a 2 s  . c o  m*/
    ArrayList<AbstractPoiComponent> newlistComponent = new ArrayList<AbstractPoiComponent>();
    ExternalServiceComponent externalServiceComponent = new ExternalServiceComponent();
    Map<String, String[]> map = new HashMap<String, String[]>();
    String[] id = { puntiCiro.get(item).getAsJsonObject().get("id").getAsString() };
    map.put("id", id);
    externalServiceComponent.setURL(getUrl);
    externalServiceComponent.setMapParams(map);
    newlistComponent.add(externalServiceComponent);
    ArrayList<String> categories = new ArrayList<String>();
    categories.addAll(Arrays.asList(categoriesName));
    newPoi.setCategories(categories);
    newPoi.setComponents(newlistComponent);

    pm.savePoi(newPoi);

    return gson.toJson(newPoi);
}

From source file:cachedataanalysis.FlowCacheGroup.java

public ArrayList<XYSeries> exportHitRateData() {

    ArrayList<XYSeries> result = new ArrayList<>();

    for (FlowCache fc : caches) {
        result.addAll(fc.exportHitRateData());
    }//from  w  w  w  . j  ava  2s.  co m
    return result;
}

From source file:com.thoughtworks.go.server.service.lookups.CommandSnippets.java

public List<CommandSnippet> filterBy(String prefix) {
    String prefixToCheckAgainst = prefix.toLowerCase();

    ArrayList<CommandSnippet> exactNameMatchingSnippets = new ArrayList<>();
    ArrayList<CommandSnippet> partialNameMatchingSnippets = new ArrayList<>();
    ArrayList<CommandSnippet> exactKeywordMatchingSnippets = new ArrayList<>();
    for (CommandSnippet snippet : snippets) {
        if (!snippet.isValid()) {
            continue;
        }/*from w ww  .  jav a 2  s . c om*/
        if (snippet.isExactMatchOfName(prefixToCheckAgainst)) {
            exactNameMatchingSnippets.add(snippet);
            continue;
        }
        if (snippet.hasNameWhichStartsWith(prefixToCheckAgainst)) {
            partialNameMatchingSnippets.add(snippet);
            continue;
        }
        if (snippet.containsKeyword(prefixToCheckAgainst)) {
            exactKeywordMatchingSnippets.add(snippet);
        }
    }
    ArrayList<CommandSnippet> matchedSnippets = new ArrayList<>();
    matchedSnippets.addAll(exactNameMatchingSnippets);
    matchedSnippets.addAll(partialNameMatchingSnippets);
    matchedSnippets.addAll(exactKeywordMatchingSnippets);
    return matchedSnippets;
}

From source file:com.thoughtworks.go.domain.ConfigErrors.java

public List<String> getAll() {
    ArrayList<String> allErrors = new ArrayList<>();
    for (List<String> errorOnAnAttribute : values()) {
        allErrors.addAll(errorOnAnAttribute);
    }/*  ww w  .  j a  v a2 s.co m*/
    return allErrors;
}

From source file:it.iit.genomics.cru.structures.bridges.bridges.UniprotkbUtilsTest.java

@Test
public void testGetUniprotAcFromGene() throws BridgesRemoteAccessException {

    String[] genes = { "kefC", "yliI" };

    ArrayList<String> geneCollection = new ArrayList<>();
    geneCollection.addAll(Arrays.asList(genes));

    MapOfMap<String, MoleculeEntry> entries = UniprotkbUtils.getInstance("83333")
            .getUniprotEntriesFromGenes(geneCollection);

    Assert.assertEquals(genes.length, entries.keySet().size());

    for (String gene : genes) {
        System.out.println("organism: " + entries.get(gene).iterator().next().getOrganism());
        Assert.assertEquals(1, entries.get(gene).size());
    }//www .j  a va 2s .  co m
}

From source file:it.iit.genomics.cru.structures.bridges.bridges.UniprotkbUtilsTest.java

public void testGetGenesFromUniprotAcs() throws BridgesRemoteAccessException {

    String[] uniprotAcs = { "Q9NUR3", "P52803", "P02765", "Q9BX66", "P29074", "Q9ULD4" };

    ArrayList<String> uniprotAcsCollection = new ArrayList<>();
    uniprotAcsCollection.addAll(Arrays.asList(uniprotAcs));

    HashMap<String, MoleculeEntry> entries = UniprotkbUtils.getInstance("9606")
            .getUniprotEntriesFromUniprotAccessions(uniprotAcsCollection);

    Assert.assertEquals(uniprotAcs.length, entries.keySet().size());
}

From source file:com.parse.ParseAddOperation.java

@Override
public ParseFieldOperation mergeWithPrevious(ParseFieldOperation previous) {
    if (previous == null) {
        return this;
    } else if (previous instanceof ParseDeleteOperation) {
        return new ParseSetOperation(objects);
    } else if (previous instanceof ParseSetOperation) {
        Object value = ((ParseSetOperation) previous).getValue();
        if (value instanceof JSONArray) {
            ArrayList<Object> result = ParseFieldOperations.jsonArrayAsArrayList((JSONArray) value);
            result.addAll(objects);
            return new ParseSetOperation(new JSONArray(result));
        } else if (value instanceof List) {
            ArrayList<Object> result = new ArrayList<>((List<?>) value);
            result.addAll(objects);//from w  w  w. ja  va2 s  .c  o m
            return new ParseSetOperation(result);
        } else {
            throw new IllegalArgumentException("You can only add an item to a List or JSONArray.");
        }
    } else if (previous instanceof ParseAddOperation) {
        ArrayList<Object> result = new ArrayList<>(((ParseAddOperation) previous).objects);
        result.addAll(objects);
        return new ParseAddOperation(result);
    } else {
        throw new IllegalArgumentException("Operation is invalid after previous operation.");
    }
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.MaturityWithOutISASpiderChart.java

protected List<Entry<String, Double>> sort(Set<Entry<String, Double>> entrySet) {
    ArrayList<Entry<String, Double>> list = new ArrayList<Entry<String, Double>>();
    list.addAll(entrySet);
    Collections.sort(list, new Comparator<Entry<String, Double>>() {
        public int compare(Entry<String, Double> o1, Entry<String, Double> o2) {
            return o1.getKey().compareTo(o2.getKey());
        }//from   w w  w  .  j a v  a 2  s. c  o m
    });
    return list;
}