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:blusunrize.immersiveengineering.api.ApiUtils.java

public static IngredientStack createIngredientStack(Object input, boolean preferWildcard) {
    if (input instanceof IngredientStack)
        return (IngredientStack) input;
    else if (input instanceof ItemStack)
        return new IngredientStack((ItemStack) input);
    else if (input instanceof Item) {
        if (preferWildcard)
            return new IngredientStack(new ItemStack((Item) input, 1, OreDictionary.WILDCARD_VALUE));
        return new IngredientStack(new ItemStack((Item) input));
    } else if (input instanceof Block) {
        if (preferWildcard)
            return new IngredientStack(new ItemStack((Block) input, 1, OreDictionary.WILDCARD_VALUE));
        return new IngredientStack(new ItemStack((Block) input));
    } else if (input instanceof Ingredient)
        return new IngredientStack(Arrays.asList(((Ingredient) input).getMatchingStacks()));
    else if (input instanceof List) {
        if (!((List) input).isEmpty()) {
            if (((List) input).get(0) instanceof ItemStack)
                return new IngredientStack(((List<ItemStack>) input));
            else if (((List) input).get(0) instanceof String) {
                ArrayList<ItemStack> itemList = new ArrayList();
                for (String s : ((List<String>) input))
                    itemList.addAll(OreDictionary.getOres(s));
                return new IngredientStack(itemList);
            }//ww  w. j a  va  2 s.c  o  m
        } else
            return new IngredientStack(ItemStack.EMPTY);
    } else if (input instanceof ItemStack[])
        return new IngredientStack(Arrays.asList((ItemStack[]) input));
    else if (input instanceof String[]) {
        ArrayList<ItemStack> itemList = new ArrayList();
        for (String s : ((String[]) input))
            itemList.addAll(OreDictionary.getOres(s));
        return new IngredientStack(itemList);
    } else if (input instanceof String)
        return new IngredientStack((String) input);
    else if (input instanceof FluidStack)
        return new IngredientStack((FluidStack) input);
    throw new RuntimeException(
            "Recipe Ingredients must always be ItemStack, Item, Block, List<ItemStack>, String (OreDictionary name) or FluidStack; "
                    + input + " is invalid");
}

From source file:de.kp.ames.web.core.json.DateCollector.java

/**
 * A method to return a sorted list of JSON objects
 * //www.  j  a v  a2s .c om
 * @return
 */
public ArrayList<JSONObject> values() {

    ArrayList<JSONObject> values = new ArrayList<JSONObject>();

    Iterator<ArrayList<JSONObject>> iterator = collector.values().iterator();
    while (iterator.hasNext()) {
        values.addAll(iterator.next());
    }

    return values;

}

From source file:ca.uhn.fhir.model.api.BaseElement.java

@Override
public List<ExtensionDt> getAllUndeclaredExtensions() {
    ArrayList<ExtensionDt> retVal = new ArrayList<ExtensionDt>();
    if (myUndeclaredExtensions != null) {
        retVal.addAll(myUndeclaredExtensions);
    }/*from  w  ww.  j a  v  a 2 s. com*/
    if (myUndeclaredModifierExtensions != null) {
        retVal.addAll(myUndeclaredModifierExtensions);
    }
    return Collections.unmodifiableList(retVal);
}

From source file:org.jasig.springframework.web.client.ExtendedRestTemplate.java

@Override
public final void setInterceptors(List<ClientHttpRequestInterceptor> interceptors) {
    //Make sure that the interceptors list always includes HeaderSettingClientHttpRequestInterceptor
    if (!interceptors.contains(HeaderSettingClientHttpRequestInterceptor.INSTANCE)) {
        final ArrayList<ClientHttpRequestInterceptor> newInterceptors = new ArrayList<ClientHttpRequestInterceptor>(
                interceptors.size() + 1);
        newInterceptors.addAll(newInterceptors);
        newInterceptors.add(HeaderSettingClientHttpRequestInterceptor.INSTANCE);
        interceptors = newInterceptors;/*from   w  w w .  j  a va 2  s. c o m*/
    }

    super.setInterceptors(interceptors);
}

From source file:generate.ShowArticlesAction.java

public String execute() throws ClassNotFoundException, SQLException, IOException {
    List<DBObject> documents = new ArrayList<>();
    System.out.println("Mark 0");
    try {/*from   w w w.  jav  a2  s  .  c  om*/
        MongoClient mongo = new MongoClient();
        DB db = mongo.getDB("Major");
        DBCollection collection = db.getCollection("ConceptMap");
        DBCursor cursor = collection.find();
        documents = cursor.toArray();
        cursor.close();
    } catch (MongoException e) {
        System.out.println("ERRRRRORRR: " + e.getMessage());
        return ERROR;
    } catch (UnknownHostException ex) {
        Logger.getLogger(MapGenerateAction.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println("Mark 1");
    Map<String, ArrayList<String>> chap_to_section = new HashMap<>();
    Map<String, String> id_to_section = new HashMap<>();
    for (DBObject document : documents) {
        String c_name = document.get("ChapterName").toString();
        boolean has_key = chap_to_section.containsKey(c_name);
        ArrayList<String> sections = new ArrayList<>();
        sections.add(document.get("SectionName").toString());
        if (has_key) {
            sections.addAll(chap_to_section.get(c_name));
            chap_to_section.put(c_name, sections);
        } else {
            chap_to_section.put(c_name, sections);
        }
        id_to_section.put(document.get("SectionName").toString(), document.get("UniqueID").toString());
    }
    FileWriter file = null;
    try {
        file = new FileWriter("/home/chanakya/NetBeansProjects/Concepto/web/Chapters_Sections.json");
    } catch (IOException ex) {
        Logger.getLogger(ShowArticlesAction.class.getName()).log(Level.SEVERE, null, ex);
    }
    JSONArray jarr = new JSONArray();

    for (String key : chap_to_section.keySet()) {
        JSONObject jobj = new JSONObject();
        JSONArray arr = new JSONArray();

        for (String val : chap_to_section.get(key)) {
            JSONObject temp = new JSONObject();
            temp.put("name", val);
            temp.put("id", id_to_section.get(val).toString());
            arr.add(temp);
        }
        jobj.put("sname", arr);
        jobj.put("cname", key);
        jarr.add(jobj);
    }
    System.out.println("Mark 2");
    //JSONObject obj = new JSONObject();
    //obj.put("cmap", jarr);
    file.write(jarr.toJSONString());
    file.flush();
    file.close();
    System.out.println("Mark 3");
    return SUCCESS;
}

From source file:com.tremolosecurity.embedd.EmbPostProc.java

protected HashMap<String, Attribute> setHeadersCookiesEmb(HttpFilterRequest req) throws Exception {
    Iterator<String> names;

    names = req.getHeaderNames();/*  w  w  w . j  a  va 2s.  co m*/

    HashMap<String, Attribute> reqHeaders = new HashMap<String, Attribute>();

    while (names.hasNext()) {
        String name = names.next();
        if (name.equalsIgnoreCase("Cookie")) {

            continue;
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Header : " + name);
        }

        Attribute attrib = req.getHeader(name);
        ArrayList<String> vals = new ArrayList<String>();

        vals.addAll(attrib.getValues());
        //logger.info("Header : '" + name + "'='" + vals + "'");

        if (name.equalsIgnoreCase("Content-Type")) {
            continue;
        } else if (name.equalsIgnoreCase("If-Range")) {
            continue;
        } else if (name.equalsIgnoreCase("Range")) {
            continue;
        } else if (name.equalsIgnoreCase("If-None-Match")) {
            continue;
        }

        if (this.addHeader(name)) {
            Attribute header = reqHeaders.get(name);
            if (header == null) {
                header = new Attribute(name);
                reqHeaders.put(name, header);
            }

            header.getValues().addAll(vals);
        }

    }

    HashMap<String, Attribute> fromResults = (HashMap<String, Attribute>) req
            .getAttribute(AzSys.AUTO_IDM_HTTP_HEADERS);
    if (fromResults != null) {
        names = fromResults.keySet().iterator();

        while (names.hasNext()) {
            String name = names.next();
            reqHeaders.remove(name);

            Attribute attrib = fromResults.get(name);

            Attribute header = reqHeaders.get(name);
            if (header == null) {
                header = new Attribute(name);
                reqHeaders.put(name, header);
            }

            header.getValues().addAll(attrib.getValues());

            //logger.info("Header2 : '" + name + "'='" + header.getValues() + "'");
        }
    }

    return reqHeaders;

}

From source file:Game.Player.java

public int numberOfTotalCards() {
    ArrayList<Card> total = new ArrayList<>();
    total.addAll(deck.used);
    total.addAll(deck.content);/* w  w  w.  j a v a 2s .c  o  m*/
    total.addAll(hand);
    return total.size();
}

From source file:net.antidot.sql.model.db.StdTable.java

public ArrayList<Key> getKeys() {
    ArrayList<Key> keys = new ArrayList<Key>();
    keys.addAll(getCandidateKeys());
    keys.addAll(getForeignKeys());/*from   w ww .j av  a  2 s . c om*/
    return keys;
}

From source file:classif.ahc.AHCSymbolicSequence.java

double getDistanceClusters(ArrayList<Integer> cluster1, ArrayList<Integer> cluster2) {
    double ESS1 = calcESS(cluster1);
    double ESS2 = calcESS(cluster2);
    ArrayList<Integer> merged = new ArrayList<Integer>();
    merged.addAll(cluster1);
    merged.addAll(cluster2);//from   w ww  . j a  v a 2  s .  co m
    double ESS = calcESS(merged);
    return ESS * merged.size() - ESS1 * cluster1.size() - ESS2 * cluster2.size();
}