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:net.ripe.rpki.commons.validation.ValidationResult.java

public List<ValidationCheck> getAllValidationChecksForLocation(ValidationLocation location) {
    ArrayList<ValidationCheck> allChecks = new ArrayList<ValidationCheck>();
    if (results.containsKey(location)) {
        Map<ValidationStatus, List<ValidationCheck>> locationChecksMap = results.get(location);
        allChecks.addAll(locationChecksMap.get(ValidationStatus.ERROR));
        allChecks.addAll(locationChecksMap.get(ValidationStatus.WARNING));
        allChecks.addAll(locationChecksMap.get(ValidationStatus.PASSED));
    }//ww  w  .j  a v a2 s.c  o m

    return allChecks;
}

From source file:httpRequests.GetPost.java

public ArrayList<ArrayList<String>> getMatchesInformationsByMatchID(String matchID, float headersLevel,
        float dataLevel, ArrayList<String> filters) {
    try {//from  ww  w  . j  a v a2 s  .  c o  m
        String[] region = { "euw", "eune", "na", "br", "las", "lan", "oce", "kr", "jp", "ru", "tr" };
        int index = 0;
        boolean tryDifferentRegion = false;
        JSONObject obj;
        do {
            String url = "https://" + region[index] + ".api.pvp.net/api/lol/" + region[index] + "/v2.2/match/"
                    + matchID + "?api_key=";
            obj = sendGet(url);
            if (obj == null)
                return null;
            if (obj.has("status")) {
                if (String.valueOf(obj.getJSONObject("status").get("status_code")).equals("404")) {
                    tryDifferentRegion = true;
                }
            } else
                tryDifferentRegion = false;
            if (tryDifferentRegion) {
                index++;
            }
            if (index >= region.length) {
                System.exit(-1);
            }
        } while (tryDifferentRegion);
        ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
        ArrayList<String> headers = new ArrayList<String>();
        if (filters == null) {
            headers.addAll(asSortedList(getHeaders(headersLevel, obj)));
        } else
            headers = filters;
        result = getRows(obj, headers, dataLevel);
        result.add(0, headers);
        return result;
    } catch (Exception e) {
        System.out.println(e.getLocalizedMessage());
        return null;
    }
}

From source file:org.opendatakit.persistence.engine.pgres.QueryImpl.java

/**
 * Constructs the necessary filter clause to append to the Query filters to
 * support continuation cursors.//w w w .j  ava2  s  .co  m
 * 
 * @param queryContinuationBindBuilder
 * @param continuationValue
 * @return the updated bindArgs
 */
private ArrayList<Object> addContinuationFilter(StringBuilder queryContinuationBindBuilder,
        Object continuationValue) {
    if (dominantSortAttr == null) {
        throw new IllegalStateException("unexpected state");
    }
    if (continuationValue == null) {
        throw new IllegalStateException("unexpected state");
    }

    if (queryBindBuilder.length() == 0) {
        queryContinuationBindBuilder.append(K_WHERE);
    } else {
        queryContinuationBindBuilder.append(K_AND);
    }
    queryContinuationBindBuilder.append(K_BQ);
    queryContinuationBindBuilder.append(dominantSortAttr.getName());
    queryContinuationBindBuilder.append(K_BQ);
    queryContinuationBindBuilder.append(operationMap
            .get(dominantSortDirection.equals(Direction.ASCENDING) ? FilterOperation.GREATER_THAN_OR_EQUAL
                    : FilterOperation.LESS_THAN_OR_EQUAL));
    queryContinuationBindBuilder.append(K_BIND_VALUE);

    ArrayList<Object> values = new ArrayList<Object>();
    values.addAll(bindValues);
    values.add(DatastoreImpl.getBindValue(dominantSortAttr, continuationValue));

    return values;
}

From source file:ca.sfu.federation.model.Assembly.java

/**
 * Get List of Parent Contexts, inclusive of the current element.  The list
 * is ordered from root context to the current element.  An instance of
 * ParametricModel will always be the first element.
 * @return List of Parent contexts./*from  w w w. ja v  a  2  s . co m*/
 */
public List getParents() {
    ArrayList parents = new ArrayList();
    // add predecessors first
    if (this.context != null) {
        parents.addAll(this.context.getParents());
    }
    // add self
    parents.add(this);
    return (List) parents;
}

From source file:edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.OperatorDeepCopyVisitor.java

@Override
public ILogicalOperator visitScriptOperator(ScriptOperator op, Void arg) throws AlgebricksException {
    ArrayList<LogicalVariable> newInputList = new ArrayList<LogicalVariable>();
    ArrayList<LogicalVariable> newOutputList = new ArrayList<LogicalVariable>();
    newInputList.addAll(op.getInputVariables());
    newOutputList.addAll(op.getOutputVariables());
    return new ScriptOperator(op.getScriptDescription(), newInputList, newOutputList);
}

From source file:net.sf.housekeeper.domain.CategoryManager.java

/**
 * Returns a list of all categories excluding a category and its children.
 * //from w  w w.ja v  a 2s. c  o m
 * @return != null
 */
public List getAllCategoriesExcept(Category discardedCategory) {
    final ArrayList allCats = new ArrayList();
    final Iterator topLevelCats = getTopLevelCategoriesIterator();

    while (topLevelCats.hasNext()) {
        Category element = (Category) topLevelCats.next();

        final List c = element.getRecursiveCategories();
        allCats.addAll(c);
    }
    if (discardedCategory != null) {
        final List discCats = discardedCategory.getRecursiveCategories();
        allCats.removeAll(discCats);
    }

    return allCats;
}

From source file:com.exalttech.trex.util.PacketUtil.java

/**
 * Create vm instruction//from  w  w w  . j  av  a 2  s .  c om
 *
 * @param packetData
 * @return vm instruction
 */
public Map<String, Object> getVm(PacketData packetData) {
    VMInstructionBuilder vmInstructionBuilder = new VMInstructionBuilder(packetData.isTaggedVlan(),
            packetData.getUdpData().isEnable());
    ArrayList<Object> instructionsList = new ArrayList<>();

    // add VM instructions
    EthernetData ethernetData = packetData.getEthernetData();
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.MAC_DST,
            ethernetData.getDstAddress().getType(), ethernetData.getDstAddress().getCount(),
            ethernetData.getDstAddress().getStep(), ethernetData.getDstAddress().getAddress()));
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.MAC_SRC,
            ethernetData.getSrcAddress().getType(), ethernetData.getSrcAddress().getCount(),
            ethernetData.getSrcAddress().getStep(), ethernetData.getSrcAddress().getAddress()));

    IPV4Data ipv4Data = packetData.getIpv4Data();
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.IP_DST,
            ipv4Data.getDstAddress().getType(), ipv4Data.getDstAddress().getCount(), "1",
            ipv4Data.getDstAddress().getAddress()));
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.IP_SRC,
            ipv4Data.getSrcAddress().getType(), ipv4Data.getSrcAddress().getCount(), "1",
            ipv4Data.getSrcAddress().getAddress()));
    // add ipv4 checksum instructions
    instructionsList.addAll(vmInstructionBuilder.addChecksumInstruction());
    // add packet length instruction
    PacketLength packetLength = packetData.getPacketLength();
    instructionsList.addAll(vmInstructionBuilder.getPacketLenVMInstruction("pkt_len",
            packetLength.getLengthType(), String.valueOf(packetLength.getMinLength()),
            String.valueOf(packetLength.getMaxLength()), packetData.isTaggedVlan()));

    Map<String, Object> additionalProperties = new HashMap<>();

    LinkedHashMap<String, Object> vmBody = new LinkedHashMap<>();
    vmBody.put("split_by_var", vmInstructionBuilder.getSplitByVar());
    vmBody.put("instructions", instructionsList);

    // add cache size
    vmInstructionBuilder.addCacheSize(vmBody);

    additionalProperties.put("vm", vmBody);

    return additionalProperties;
}

From source file:com.ibm.bi.dml.hops.rewrite.ProgramRewriter.java

/**
 * //from   w w w .j  av  a 2s  .  c o  m
 * @param sbs
 * @return
 * @throws HopsException 
 */
public ArrayList<StatementBlock> rewriteStatementBlocks(ArrayList<StatementBlock> sbs,
        ProgramRewriteStatus state) throws HopsException {
    //ensure robustness for calls from outside
    if (state == null)
        state = new ProgramRewriteStatus();

    ArrayList<StatementBlock> tmp = new ArrayList<StatementBlock>();

    //rewrite statement blocks (with potential expansion)
    for (StatementBlock sb : sbs)
        tmp.addAll(rewriteStatementBlock(sb, state));

    //copy results into original collection
    sbs.clear();
    sbs.addAll(tmp);

    return sbs;
}

From source file:org.ambraproject.wombat.service.remote.SolrSearchApiImpl.java

/**
 * @inheritDoc//from www . j a  v a2  s.co m
 */
@Override
public List<String> getAllSubjects(String journalKey, Site site) throws IOException {
    ArticleSearchQuery.Builder query = ArticleSearchQuery.builder().setForRawResults(true)
            .setFacet("subject_hierarchy").setMaxFacetSize(MAX_FACET_SIZE)
            .setJournalKeys(Collections.singletonList(journalKey));

    ArrayList<String> categories = new ArrayList<>();
    FacetedQueryResponse response = executeFacetedQuery(query.build(), site);
    categories.addAll(
            response.getResultsMap().keySet().stream().map(Object::toString).collect(Collectors.toList()));

    return categories;
}

From source file:com.webpagebytes.cms.controllers.Controller.java

public <T> List<T> filterPagination(HttpServletRequest request, List<T> records,
        Map<String, Object> additionalInfo) {
    String paginationStart = request.getParameter(PAGINATION_START);
    String paginationCount = request.getParameter(PAGINATION_COUNT);
    ArrayList<T> result = new ArrayList<T>();

    if (paginationCount == null || paginationStart == null) {
        additionalInfo.put(PAGINATION_START, 0);
        additionalInfo.put(PAGINATION_COUNT, records.size());
        additionalInfo.put(PAGINATION_TOTAL_COUNT, records.size());
        result.addAll(records);
        return result;
    }//  w  w w.  jav  a 2  s . c om

    int start = 0;
    int count = 0;

    try {
        start = Integer.valueOf(paginationStart);
        count = Integer.valueOf(paginationCount);
    } catch (NumberFormatException e) {
        additionalInfo.put(PAGINATION_START, 0);
        additionalInfo.put(PAGINATION_COUNT, records.size());
        additionalInfo.put(PAGINATION_TOTAL_COUNT, records.size());
        result.addAll(records);
        return result;
    }

    if (count < 0 || start < 0) {
        result.addAll(records);
        return result;
    }

    int end = start + count;

    for (int i = start; i < end && i < records.size(); i++) {
        result.add(records.get(i));
    }

    additionalInfo.put(PAGINATION_START, start);
    additionalInfo.put(PAGINATION_COUNT, result.size());
    additionalInfo.put(PAGINATION_TOTAL_COUNT, records.size());

    return result;
}