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:in.flipbrain.controllers.Trail.java

private ArrayList<CommentDto> getChildren(Long root, HashMap<Long, ArrayList<CommentDto>> tree) {
    ArrayList<CommentDto> children = new ArrayList<CommentDto>();
    if (tree.containsKey(root)) {
        children.addAll(tree.get(root));
        for (CommentDto n : tree.get(root)) {
            children.addAll(getChildren(n.commentId, tree));
        }//w  w  w.  j  a  v a2  s .  c  o m
    }
    return children;
}

From source file:net.leegorous.jsc.JavaScriptDocument.java

protected ArrayList getImportedFiles() {
    ArrayList list = new ArrayList();
    for (int i = 0, j = importedDocs.size(); i < j; i++) {
        list.addAll(((JavaScriptDocument) importedDocs.get(i)).getImportedFiles());
    }//from   w  w  w .j a v a  2  s  . co m
    list.add(doc);
    return list;
}

From source file:de.thejeterlp.bukkit.updater.Updater.java

/**
 * Check if the remote version is higher than the current version.
 *
 * @param data/* w ww  .  ja  va 2  s  . c om*/
 * @return
 */
protected boolean versionCheck(String[] data) {
    debug("Method: versionCheck(String[])");
    String title = data[1];
    if (this.rType != ReleaseType.ALL) {
        ReleaseType releaseType = ReleaseType.valueOf(data[2].toUpperCase());
        if (releaseType != this.rType) {
            debug("Releasetype of the new file does not match the one which we search for! Ignoring the file...");
            return false;
        }
    }
    String remote;
    if (title.contains(" v")) {
        remote = title.split(" v")[1];
    } else {
        remote = title;
    }
    ArrayList<String> rNumbers = new ArrayList<String>();
    ArrayList<String> numbers = new ArrayList<String>();
    rNumbers.addAll(Arrays.asList(remote.split("\\.")));

    if (main.getDescription().getVersion().contains("-")) {
        numbers.addAll(Arrays.asList(main.getDescription().getVersion().split("-")[0].split("\\.")));
        debug("numbers: " + Arrays.toString(numbers.toArray()));
    } else {
        numbers.addAll(Arrays.asList(main.getDescription().getVersion().split("\\.")));
        debug("numbers: " + Arrays.toString(numbers.toArray()));
    }

    if (rNumbers.size() > numbers.size()) {
        int missing = rNumbers.size() - numbers.size();
        for (int i = 0; i < missing; i++) {
            numbers.add("0");
        }
        debug("numbers: " + Arrays.toString(numbers.toArray()));
    } else if (numbers.size() > rNumbers.size()) {
        int missing = numbers.size() - rNumbers.size();
        for (int i = 0; i < missing; i++) {
            rNumbers.add("0");
        }
        debug("rNumbers: " + Arrays.toString(rNumbers.toArray()));
    }

    for (int i = 0; i < rNumbers.size(); i++) {
        int rNumber = Integer.valueOf(rNumbers.get(i));
        int number = Integer.valueOf(numbers.get(i));
        if (rNumber > number) {
            debug(rNumber + " is bigger than " + number
                    + ". This means there is a new version. Returnign true...");
            return true;
        } else if (number > rNumber) {
            main.getLogger().info(
                    "It seems that your version is newer than the one on BukkitDev. Maybe you are using a development build?");
            return false;
        }
    }
    main.getLogger().info("There is no new version available. You are up-to-date!");
    return false;
}

From source file:at.gv.egiz.bku.local.stal.LocalSecureViewer.java

@Override
public void displayDataToBeSigned(List<SignatureInfo> signedInfo, ActionListener okListener, String okCommand)
        throws DigestException, Exception {
    log.warn("Called displayDataToBeSigned");
    ArrayList<HashDataInput> selectedHashDataInputs = new ArrayList<HashDataInput>();

    for (SignatureInfo nextSignedInfo : signedInfo) {
        selectedHashDataInputs.addAll(addEmptyHashDataInputs(nextSignedInfo));
    }/*from   ww  w .j a v  a  2  s .  c om*/

    gui.showSecureViewer(selectedHashDataInputs, okListener, okCommand, this);

}

From source file:com.ciphertool.sentencebuilder.dao.IndexedWordMapDao.java

/**
 * Constructor with autowired dependency.
 * /*w  w  w  . j a  v  a  2 s  . co  m*/
 * @param wordDao
 *            the WordDao to use for populating the internal Maps
 */
@Autowired
public IndexedWordMapDao(WordDao wordDao) {
    if (wordDao == null) {
        throw new IllegalArgumentException("Error constructing IndexedWordMapDao.  WordDao cannot be null.");
    }

    ArrayList<Word> allWords = new ArrayList<Word>();

    log.info("Beginning fetching of words from database.");

    long start = System.currentTimeMillis();

    allWords.addAll(wordDao.findAll());

    log.info("Finished fetching words from database in " + (System.currentTimeMillis() - start) + "ms.");

    partOfSpeechWordMap = mapByPartOfSpeech(allWords);

    partOfSpeechFrequencyMap = buildIndexedFrequencyMapByPartOfSpeech(partOfSpeechWordMap);

    lengthWordMap = mapByWordLength(allWords);

    lengthFrequencyMap = buildIndexedFrequencyMapByLength(lengthWordMap);
}

From source file:Main.java

/**
 * Sarches for ressources that have to be downloaded and creates a list with all download links.
 *
 * @param node to check for download links
 * @return list with all found download links
 *//*  w w  w  .  ja  va  2  s  .c o m*/
private static ArrayList<String> findUrls(Node node) {

    int type = node.getNodeType();
    ArrayList<String> result = new ArrayList<>();
    String temp = null;
    NamedNodeMap atts = node.getAttributes();
    Log.i(TAG, "parsing for ressources.  node: " + node.getNodeName() + " value: " + node.getNodeValue()
            + " atts length: " + atts.getLength() + "type: " + type);
    switch (type) {
    //Element
    case Node.ELEMENT_NODE:
        //TODO: This method is stupid. It just looks for
        // attributes named ressourcepath. What if we have to download several ressources?

        for (int j = 0; j < atts.getLength(); j++) {
            Log.i(TAG, "atts: " + atts.item(j).getNodeName() + " value: " + atts.item(j).getNodeValue());
            temp = atts.item(j).getNodeValue();

            if (temp != null) {
                result.add(temp);
                Log.i(TAG, "added path: " + temp);
            }

            Log.i(TAG, "parent node:" + node.getParentNode().getNodeName());
            Element parent = (Element) node.getParentNode();
            parent.setAttribute("TESTITEST", "dllink");

        }
        // get the pages, means the children
        for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
            ArrayList<String> childres = findUrls(child);
            if (childres.size() > 0) {
                result.addAll(childres);
            }
        }
        break;
    }
    return result;
}

From source file:com.cognifide.slice.cq.impl.PageChildrenProviderImpl.java

private List<String> getChildren(final Page page, final Filter<Page> filter, final RecursiveMode recurseMode) {
    ArrayList<String> result = new ArrayList<String>();
    if (null == page) {
        return result;
    }//from   ww w  .j a v a 2  s .  com

    final Iterator<Page> children = page.listChildren(filter);
    while (children.hasNext()) {
        final Page child = children.next();
        result.add(child.getPath());

        if (recurseMode == RecursiveMode.RECURSIVE) {
            result.addAll(getChildren(child, filter, recurseMode));
        }
    }

    return result;
}

From source file:com._17od.upm.gui.MainWindow.java

/**
 * Convenience method to iterate over all graphics configurations.
 *//*from w w w . ja  v  a  2s .  co  m*/
private static ArrayList getConfigs() {
    ArrayList result = new ArrayList();
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = env.getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
        GraphicsConfiguration[] configs = devices[i].getConfigurations();
        result.addAll(Arrays.asList(configs));
    }
    return result;
}

From source file:org.dspace.servicemanager.spring.SpringServiceManager.java

@SuppressWarnings("unchecked")
public <T> List<T> getServicesByType(Class<T> type) {
    ArrayList<T> l = new ArrayList<T>();
    Map<String, T> beans;
    try {/*  w  w w .ja v a2  s .  co  m*/
        beans = applicationContext.getBeansOfType(type, true, true);
        l.addAll((Collection<? extends T>) beans.values());
    } catch (BeansException e) {
        throw new RuntimeException("Failed to get beans of type (" + type + "): " + e.getMessage(), e);
    }
    return l;
}

From source file:lt.flickrfeed.jzplius.feed_items_list.FlickrFeedXmlParser.java

/**
 * In subclasses override this method to provide specific
 * actions based on each tag/* w  w w  .  ja  va2s. com*/
 *
 * @param parser - XMLPullParser
 * @param tag - tag to be handled
 */
@Override
protected ArrayList<NameValuePair> handleTag(XmlPullParser parser, String tag)
        throws IOException, XmlPullParserException {
    ArrayList<NameValuePair> list = new ArrayList<>();
    String tagName = parser.getName();

    switch (tag) {
    // Handles "feed" tag and his inner nodes.
    case "feed":
        // Handle "entry" tag
        switch (tagName) {
        case "entry":
            list.addAll(parseTag(parser, "entry"));
            break;
        default:
            skip(parser);
            break;
        }
        break;

    // Handles "entry" tag and it's inner nodes. Receives "title", "link", "name",
    // "buddyicon" string representations packed in ArrayList<NameValuePair>
    case "entry":
        // Handle "title", "link", "name", "buddyicon" tags
        switch (tagName) {
        case "author":
            list.addAll(parseTag(parser, "author"));
            break;
        case "title":
            list.add(new BasicNameValuePair("title", readTag(parser, "title")));
            break;
        case "link":
            String link = readLink(parser, "link", "enclosure", "image/jpeg");
            if (!link.equals("")) {
                list.add(new BasicNameValuePair("photo", link));
            }
            break;
        default:
            skip(parser);
            break;
        }
        break;

    // Handles "author" tag and it's inner nodes, thus receiving and returning
    // "name", "buddyicon" string representations packed in ArrayList<NameValuePair>
    case "author":
        // Handle "name", "buddyicon" tags and pack them into ArrayList<NameValuePair>
        switch (tagName) {
        case "name":
            list.add(new BasicNameValuePair("name", readTag(parser, "name")));
            break;
        case "buddyicon":
            list.add(new BasicNameValuePair("buddyicon", readTag(parser, "buddyicon")));
            break;
        default:
            skip(parser);
            break;
        }
        break;
    }

    return list;
}