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:com.digitalpebble.stormcrawler.Metadata.java

public void addValues(String key, Collection<String> values) {
    if (values == null || values.size() == 0)
        return;/*from   w w w.j  a v  a 2 s . com*/
    String[] existingvals = md.get(key);
    if (existingvals == null) {
        md.put(key, values.toArray(new String[values.size()]));
        return;
    }

    ArrayList<String> existing = new ArrayList<>(existingvals.length + values.size());
    for (String v : existingvals)
        existing.add(v);

    existing.addAll(values);
    md.put(key, existing.toArray(new String[existing.size()]));
}

From source file:it.larusba.integration.neo4j.jsonloader.transformer.DomainDrivenJsonTransformer.java

/**
 * The method gets all statements, ordering first the nodes statements e after
 * the relations./*from www  .  j a v  a 2  s .c om*/
 * 
 * @param nodes
 *          the node's list
 * @return the ordered statements list
 */
private List<String> getAllStatements(List<DocumentNode> nodes) {
    Set<String> nodesSet = getAllNodeStatements(nodes);
    Set<String> nodesRelationsSet = getAllRelationsStatements(nodes);
    ArrayList<String> result = new ArrayList<>(nodesSet);
    result.addAll(nodesRelationsSet);
    return result;
}

From source file:Game.Player.java

public int calculateVictoryPoints() {
    int cards;/*from   w ww  .j  a v  a2  s  . c o  m*/
    int points = 0;
    ArrayList<Card> total = new ArrayList<>();
    total.addAll(deck.used);
    total.addAll(deck.content);
    total.addAll(hand);
    cards = total.size();

    for (Card c : total) {
        if (c instanceof VictoryCard) {
            points += c.victorygain();
            if (c.hasSpecial()) {
                SpecialCase spec = c.special(this, this, null);
                if (spec instanceof RewardCase) {
                    RewardCase reward = (RewardCase) spec;
                    points += handleVictoryRewardCase(reward.reward_behaviour());
                }
            }
        }
    }
    return points;
}

From source file:com.thoughtworks.webanalyticsautomation.Engine.java

private ArrayList<String> verifyTagsForEachExpectedSection(ArrayList<Section> actualSectionList,
        Section expectedSection) {/* ww w.j  a v  a2s  . c o  m*/
    ArrayList<String> errorList = new ArrayList<String>();
    for (Section actualSection : actualSectionList) {
        errorList.addAll(getListOfMissingTagsFromEachActualSection(actualSection.getLoadedTagList(),
                expectedSection.getLoadedTagList()));
    }
    return errorList;
}

From source file:com.digitalpebble.storm.crawler.Metadata.java

public void addValues(String key, Collection<String> values) {
    if (values == null || values.size() == 0)
        return;/*from w w w.  j ava 2s  . com*/
    String[] existingvals = md.get(key);
    if (existingvals == null) {
        md.put(key, values.toArray(new String[values.size()]));
        return;
    }

    ArrayList<String> existing = new ArrayList<String>(existingvals.length + values.size());
    for (String v : existingvals)
        existing.add(v);

    existing.addAll(values);
    md.put(key, existing.toArray(new String[existing.size()]));
}

From source file:org.openmrs.module.openhmis.inventory.api.impl.ItemDataServiceImpl.java

@Override
protected Collection<? extends OpenmrsObject> getRelatedObjects(Item entity) {
    ArrayList<OpenmrsObject> results = new ArrayList<OpenmrsObject>();

    results.addAll(entity.getCodes());//from  w  ww.j  a  va 2  s.  co m
    results.addAll(entity.getPrices());
    results.addAll(entity.getAttributes());

    return results;
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation.java

/**
 * Check if a list of URIs has any XSS problems.
 * Return null if there are none and return an error message if there are problems.
 *//*from www .  j  a v a 2s.  c o m*/
private String uriHasXSS(List<String> uriList) throws ScanException, PolicyException {
    AntiSamy antiSamy = AntiScript.getAntiSamyScanner();
    ArrayList errorMsgs = new ArrayList();

    for (String uri : uriList) {
        CleanResults cr = antiSamy.scan(uri);
        errorMsgs.addAll(cr.getErrorMessages());
    }

    if (errorMsgs.isEmpty()) {
        return null;
    } else {
        return StringUtils.join(errorMsgs, ", ");
    }
}

From source file:com.cubeia.games.poker.admin.wicket.pages.wallet.TransactionInfo.java

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters/*from   w  w w  . j a  v a  2 s .  c  o m*/
*            Page parameters
*/
@SuppressWarnings("serial")
public TransactionInfo(PageParameters parameters) {
    super(parameters);
    transactionId = parameters.get("transactionId").toLongObject();
    Transaction tx = walletService.getTransactionById(transactionId);

    if (tx == null) {
        // TODO: create invalid tx page
        setInvalidTransactionResponsePage(transactionId);
        return;
    }

    add(new Label("txId", "" + transactionId));
    add(new Label("timestamp", "" + formatDate(tx.getTimestamp())));
    add(new Label("comment", "" + tx.getComment()));

    ArrayList<Map.Entry<String, String>> attribs;

    if (tx.getAttributes() != null) {
        attribs = new ArrayList<Map.Entry<String, String>>(tx.getAttributes().entrySet());
    } else {
        attribs = new ArrayList<Map.Entry<String, String>>();
    }

    ListView<Map.Entry<String, String>> attribList = new ListView<Map.Entry<String, String>>("attributeList",
            attribs) {
        @Override
        protected void populateItem(ListItem<Map.Entry<String, String>> item) {
            String key = item.getModelObject().getKey();
            String value = item.getModelObject().getValue();
            item.add(new Label("key", Model.of(key)));
            String url = getAttributeLinkUrl(key, value);
            if (url == null) {
                item.add(new Label("value", Model.of(value)));
            } else {
                item.add(new ExternalLinkPanel("value", value, url));
            }
        }

        private String getAttributeLinkUrl(String key, String value) {
            if (transactionLinkTemplates != null && transactionLinkTemplates.containsKey(key)) {
                String templ = transactionLinkTemplates.get(key);
                return templ.replace("${value}", value);
            } else {
                return null;
            }
        }
    };
    add(attribList);

    ArrayList<Entry> entryList = new ArrayList<Entry>();

    if (tx.getEntries() != null) {
        entryList.addAll(tx.getEntries());
    }

    Collections.sort(entryList, new Comparator<Entry>() {
        @Override
        public int compare(Entry o1, Entry o2) {
            return o1.getAccountId().compareTo(o2.getAccountId());
        }
    });

    ListView<Entry> entryListView = new ListView<Entry>("entryList", entryList) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Entry> item) {
            Entry e = (Entry) item.getModelObject();
            item.add(new Label("id", "" + e.getId()));

            LabelLinkPanel accountLink = new LabelLinkPanel("accountEntriesLink", "" + e.getAccountId(),
                    AccountDetails.class, params(AccountDetails.PARAM_ACCOUNT_ID, e.getAccountId()));
            item.add(accountLink);
            item.add(new Label("amount", "" + e.getAmount()));
            item.add(new Label("resultingBalance", "" + e.getResultingBalance()));
            item.add(new OddEvenRowsAttributeModifier(item.getIndex()));
        }
    };
    add(entryListView);
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.listing.ObjectPropertyHierarchyListingController.java

private void addChildren(ObjectProperty parent, ArrayList list, int position, String ontologyUri) {
    list.addAll(addObjectPropertyDataToResultsList(parent, position, ontologyUri));
    List childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
    if ((childURIstrs.size() > 0) && position < MAXDEPTH) {
        List childProps = new ArrayList();
        Iterator childURIstrIt = childURIstrs.iterator();
        while (childURIstrIt.hasNext()) {
            String URIstr = (String) childURIstrIt.next();
            ObjectProperty child = (ObjectProperty) opDao.getObjectPropertyByURI(URIstr);
            childProps.add(child);//from   w  ww  . j a  v a 2 s .c  om
        }
        Collections.sort(childProps);
        Iterator childPropIt = childProps.iterator();
        while (childPropIt.hasNext()) {
            ObjectProperty child = (ObjectProperty) childPropIt.next();
            addChildren(child, list, position + 1, ontologyUri);
        }

    }
}

From source file:org.red5.client.net.rtmp.RTMPConnManager.java

/** {@inheritDoc} */
@Override//from w  w  w.jav a 2  s.co m
public Collection<RTMPConnection> getAllConnections() {
    ArrayList<RTMPConnection> list = new ArrayList<RTMPConnection>(connMap.size());
    list.addAll(connMap.values());
    return list;
}