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:ml.arunreddy.research.sentiment.graphtransfer.ucross.GraphMatrixGenerator.java

private static List<String> getUniqueUsers(InstanceList posList, InstanceList negList) {
    TreeSet<String> uniqueUsersSet = new TreeSet<String>();
    ArrayList<String> uniqueUsersList = new ArrayList<String>();

    // Positive posts.
    for (Instance instance : posList) {
        String instanceName = (String) instance.getName();
        String user = instanceName.split("__")[1];
        uniqueUsersSet.add(user);/*  w  w w. jav a2s  .co m*/
    }

    // Negative posts.
    for (Instance instance : negList) {
        String instanceName = (String) instance.getName();
        String user = instanceName.split("__")[1];
        uniqueUsersSet.add(user);
    }

    uniqueUsersList.addAll(uniqueUsersSet);

    return uniqueUsersList;
}

From source file:com.opengamma.util.db.tool.DbTool.java

/**
 * Gets the selected database types./*from w w  w  .j  a va 2s  .c om*/
 * 
 * @return a singleton collection containing the String passed in, except if the type is ALL
 *  (case insensitive), in which case all supported database types are returned, not null
 */
private static Collection<String> initDatabaseTypes(String commandLineDbType) {
    ArrayList<String> dbTypes = new ArrayList<String>();
    if (commandLineDbType.trim().equalsIgnoreCase("all")) {
        dbTypes.addAll(DbDialectUtils.getSupportedDatabaseTypes());
    } else {
        dbTypes.add(commandLineDbType);
    }
    return dbTypes;
}

From source file:core.Utility.java

private static ArrayList<String> getSynonymsWordnet(String _word) {
    ArrayList<String> _list = new ArrayList();

    File f = new File("WordNet\\2.1\\dict");
    System.setProperty("wordnet.database.dir", f.toString());
    WordNetDatabase database = WordNetDatabase.getFileInstance();
    Synset[] synsets = database.getSynsets(_word);

    if (synsets.length > 0) {
        HashSet hs = new HashSet();
        for (Synset synset : synsets) {
            String[] wordForms = synset.getWordForms();
            _list.addAll(Arrays.asList(wordForms));
        }/*from   www . j  a va 2  s. c  o m*/

        hs.addAll(_list);
        _list.clear();
        _list.addAll(hs);
    }

    return _list;
}

From source file:Anaphora_Resolution.ParseAllXMLDocuments.java

public static ArrayList<Tree> findPronouns(Tree t) {
    ArrayList<Tree> pronouns = new ArrayList<Tree>();
    if (t.label().value().equals("PRP") && !t.children()[0].label().value().equals("I")
            && !t.children()[0].label().value().equals("you")
            && !t.children()[0].label().value().equals("You")) {
        pronouns.add(t);/*from   ww w .j a  va  2s .  c om*/
    } else
        for (Tree child : t.children())
            pronouns.addAll(findPronouns(child));
    return pronouns;
}

From source file:javadepchecker.Main.java

/**
 * Get jar names from the Gentoo package and store in a collection
 *
 * @param pkg Gentoo package name/* w  ww .  j  a  v a  2s  .com*/
 * @return a collection of jar names
 */
private static Collection<String> getPackageJars(String pkg) {
    ArrayList<String> jars = new ArrayList<>();
    try {
        Process p = Runtime.getRuntime().exec("java-config -p " + pkg);
        p.waitFor();
        BufferedReader in;
        in = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String output = in.readLine();
        if (output != null/* package somehow missing*/ && !output.trim().isEmpty()) {
            jars.addAll(Arrays.asList(output.split(":")));
        }
    } catch (InterruptedException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
    return jars;
}

From source file:com.twinsoft.convertigo.engine.util.CarUtils.java

public static ArrayList<File> deepListFiles(String sDir, String suffix) {
    final String _suffix = suffix;
    File[] all, files;/*from www  . j  a  v a  2 s. c o m*/
    File f, dir;

    dir = new File(sDir);

    all = dir.listFiles();

    files = dir.listFiles(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            File file = new File(dir, name);
            return (file.getName().endsWith(_suffix));
        }
    });

    ArrayList<File> list = null, deep = null;
    if (files != null) {
        list = new ArrayList<File>(Arrays.asList(files));
    }

    if ((list != null) && (all != null)) {
        for (int i = 0; i < all.length; i++) {
            f = all[i];
            if (f.isDirectory() && !list.contains(f)) {
                deep = deepListFiles(f.getAbsolutePath(), suffix);
                if (deep != null) {
                    list.addAll(deep);
                }
            }
        }
    }

    return list;
}

From source file:Main.java

public static ArrayList<File> getFileList(File dir, String... fileExtensions) {
    final ArrayList<File> files = new ArrayList<File>();
    final File[] fileList = dir.listFiles();
    if (fileList != null) {
        for (File file : fileList) {
            if (file.isFile()) {
                if (fileExtensions.length == 0) {
                    files.add(file);//  w  ww  .  j ava  2  s. co  m
                } else {
                    String fileName = file.getName().toLowerCase();
                    for (String ext : fileExtensions) {
                        if (fileName.endsWith(ext)) {
                            files.add(file);
                            break;
                        }
                    }
                }
            } else {
                files.addAll(getFileList(file, fileExtensions));
            }
        }
    }
    return files;
}

From source file:com.galactogolf.genericobjectmodel.levelloader.LevelSet.java

public static ArrayList<LevelSet> loadLevels(Context context) {
    ArrayList<LevelSet> levels = new ArrayList<LevelSet>();
    try {/*from  w  w  w . j  a  va2s.  c om*/
        levels.add(LevelSet.loadLevelSetFromRaw(context, R.raw.training));

        levels.add(LevelSet.loadLevelSetFromRaw(context, R.raw.amateur));
        levels.add(LevelSet.loadLevelSetFromRaw(context, R.raw.expert));
        levels.add(LevelSet.loadLevelSetFromRaw(context, R.raw.veteran));
        levels.addAll(LevelSet.loadAllLevelSetsFromInternalStorage(context));
    } catch (NotFoundException e) {
        Log.e("Not found", e.getMessage());
    } catch (LevelLoadingException e) {
        Log.e("Level loading issue", e.getMessage());
    }
    return levels;
}

From source file:eu.scape_project.pt.mapred.input.ControlFileInputFormat.java

/**
 * Finds input file references in the control line by looking 
 * into its toolspec.//  w  w w .j a v a  2  s .c  o m
 *
 * @param fs Hadoop filesystem handle
 * @param parser for parsing the control line
 * @param repo Toolspec repository
 * @return array of paths to input file references
 */
public static Path[] getInputFiles(FileSystem fs, CmdLineParser parser, Repository repo, String controlLine)
        throws IOException {
    parser.parse(controlLine);

    Command command = parser.getCommands()[0];
    String strStdinFile = parser.getStdinFile();
    // parse it, read input file parameters
    Tool tool = repo.getTool(command.getTool());

    ToolProcessor proc = new ToolProcessor(tool);
    Operation operation = proc.findOperation(command.getAction());
    if (operation == null)
        throw new IOException("operation " + command.getAction() + " not found");

    proc.setOperation(operation);
    proc.setParameters(command.getPairs());
    Map<String, String> mapInputFileParameters = proc.getInputFileParameters();
    ArrayList<Path> inFiles = new ArrayList<Path>();
    if (strStdinFile != null) {
        Path p = new Path(strStdinFile);
        if (fs.exists(p)) {
            inFiles.add(p);
        }
    }

    for (String fileRef : mapInputFileParameters.values()) {
        Path p = new Path(fileRef);
        if (fs.exists(p)) {
            if (fs.isDirectory(p)) {
                inFiles.addAll(getFilesInDir(fs, p));
            } else {
                inFiles.add(p);
            }
        }
    }
    return inFiles.toArray(new Path[0]);
}

From source file:edu.usc.squash.Main.java

private static HashMap<String, Module> parseQASMHF(Library library) {
    HFQParser hfqParser = null;/*  ww w  .j  a  v a  2 s.c  o  m*/
    /*
     * Pass 1: Getting module info
     */
    try {
        hfqParser = new HFQParser(new FileInputStream(hfqPath));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    HashMap<String, Module> moduleMap = hfqParser.parse(library, true, null);

    /* 
     * In order traversal of modules
     */

    ArrayList<CalledModule> modulesList = new ArrayList<CalledModule>();
    modulesList.add(new CalledModule(moduleMap.get("main"), new ArrayList<String>()));
    while (!modulesList.isEmpty()) {
        Module module = modulesList.get(0).getModule();

        if (!module.isVisited()) {
            module.setVisited();

            ArrayList<CalledModule> calledModules = module.getChildModules();
            modulesList.addAll(calledModules);
            for (CalledModule calledModule : calledModules) {
                Module childModule = calledModule.getModule();
                for (int i = 0; i < calledModule.getOps().size(); i++) {
                    Operand operand = childModule.getOperand(i);
                    if (operand.isArray() && operand.getLength() == -1) {
                        operand.setLength(module.getOperandLength(calledModule.getOps().get(i)));
                    }
                }
            }
        }
        modulesList.remove(0);
    }

    /*
     * Pass 2: Making hierarchical QMDG
     */
    try {
        hfqParser = new HFQParser(new FileInputStream(hfqPath));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    HashMap<String, Module> modules = hfqParser.parse(library, false, moduleMap);

    return modules;
}