List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:io.lightlink.utils.ClasspathScanUtils.java
public static ArrayList<String> getAllResources(String packageName, ServletContext servletContext) throws IOException { ArrayList<String> res = new ArrayList<String>(); res.addAll(getResourcesFromPackage(packageName)); res.addAll(getResourcesFromWebInf(packageName, servletContext)); return res;//from ww w . jav a2s .c o m }
From source file:com.justgiving.raven.kissmetrics.utils.KissmetricsLocalSchemaExtractor.java
/*** * This function sorts the HashMap values by key and returns the key/value pairs as a string * @param hashMap the input hashMap/* w ww .j av a 2s. c om*/ * @return the return string of the sorted key/value pairs */ private static String sortOutputByKey(KeyValueCounter outputKetValueCounter) { Set<String> set = outputKetValueCounter.keyCounter.keySet(); ArrayList<String> list = new ArrayList<String>(); list.addAll(set); Collections.sort(list); StringBuilder sb = new StringBuilder(); for (String key : list) { sb.append(key).append("\t").append(outputKetValueCounter.keyCounter.get(key)).append("\t") .append(outputKetValueCounter.valueLength.get(key)).append("\n"); } return sb.toString(); }
From source file:Main.java
public static void uniqe(ArrayList<Integer> items) { // add elements to al, including duplicates HashSet<Integer> hs = new HashSet<Integer>(); hs.addAll(items);/* w w w.j a v a 2s. com*/ items.clear(); items.addAll(hs); }
From source file:ccm.pay2spawn.configurator.HTMLGenerator.java
public static void generate() throws IOException { ArrayList<Reward> sortedRewards = new ArrayList<>(); sortedRewards.addAll(Pay2Spawn.getRewardsDB().getRewards()); Collections.sort(sortedRewards, new Comparator<Reward>() { @Override// www. java 2 s . co m public int compare(Reward o1, Reward o2) { return (int) (o1.getAmount() - o2.getAmount()); } }); File output = new File(htmlFolder, "index.html"); String text = readFile(templateIndex); int begin = text.indexOf(LOOP_START); int end = text.indexOf(LOOP_END); FileUtils.writeStringToFile(output, replace(text.substring(0, begin)), false); String loop = text.substring(begin + LOOP_START.length(), end); for (Reward reward : sortedRewards) { Pay2Spawn.getLogger().info("Adding " + reward + " to html file."); FileUtils.writeStringToFile(output, replace(loop, reward), true); } FileUtils.writeStringToFile(output, text.substring(end + LOOP_END.length(), text.length()), true); }
From source file:Main.java
public static List<File> getListFiles(File parentDir) { ArrayList<File> inFiles = new ArrayList<File>(); File[] files = parentDir.listFiles(); for (File file : files) { if (file.isDirectory()) { inFiles.addAll(getListFiles(file)); } else {/*from w w w . j a v a2s . c o m*/ inFiles.add(file); } } return inFiles; }
From source file:com.bah.applefox.main.plugins.pageranking.utilities.PRtoFile.java
private static HashMap<String, Double> createMap(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { HashMap<String, Double> ret = new HashMap<String, Double>(); String readTable = args[13] + "Old"; Scanner scan = AccumuloUtils.connectRead(readTable); Iterator<Entry<Key, Value>> itr = scan.iterator(); while (itr.hasNext()) { Entry<Key, Value> temp = itr.next(); try {/*w ww . ja v a 2s . c o m*/ Double val = (Double) IngestUtils.deserialize(temp.getValue().get()); ret.put(temp.getKey().getRow().toString(), val); System.out.println("Adding to Map: " + temp.getKey().getRow().toString() + " with rank: " + val); } catch (IOException e) { if (e.getMessage() != null) { log.error(e.getMessage()); } else { log.error(e.getStackTrace()); } } catch (ClassNotFoundException e) { if (e.getMessage() != null) { log.error(e.getMessage()); } else { log.error(e.getStackTrace()); } } } Double max = 0.0; Collection<Double> values = ret.values(); ArrayList<Double> tempValues = new ArrayList<Double>(); tempValues.addAll(values); Collections.sort(tempValues); Collections.reverse(tempValues); max = tempValues.get(0); ret.put("[[MAX_PR]]", max); return ret; }
From source file:Main.java
public final static <T> void add(ArrayList<T> origin, ArrayList<T> list) { if (origin == null) { throw new IllegalArgumentException(""); }//from ww w . ja v a2 s.c o m if (list == null || list.size() == 0) { return; } origin.addAll(list); }
From source file:Main.java
public static <ValueType> ArrayList<ValueType> getArrayList(Hashtable<?, ValueType> hashTable) { // ///////////////////////////////////////// // Declarations: // ///////////////////////////////////////// ArrayList<ValueType> newList = null; // ///////////////////////////////////////// // Code:/*from w w w.j av a 2 s . com*/ // ///////////////////////////////////////// newList = new ArrayList<ValueType>(hashTable.size()); newList.addAll(hashTable.values()); return newList; }
From source file:it.iit.genomics.cru.simsearch.bundle.utils.PantherBridge.java
public static Collection<String[]> getEnrichment(String organism, String fileName, double threshold) { ArrayList<String[]> results = new ArrayList<>(); ArrayListMultimap<String, String> genes = ArrayListMultimap.create(); ArrayListMultimap<Double, String> pvalues = ArrayListMultimap.create(); HashSet<String> uniqueGenes = new HashSet<>(); try {//from www. j a v a 2 s. co m String[] enrichmentTypes = { "process", "pathway" }; for (String enrichmentType : enrichmentTypes) { HttpClient client = new HttpClient(); MultipartPostMethod method = new MultipartPostMethod( "http://pantherdb.org/webservices/garuda/tools/enrichment/VER_2/enrichment.jsp?"); // Define name-value pairs to set into the QueryString method.addParameter("organism", organism); method.addParameter("type", "enrichment"); method.addParameter("enrichmentType", enrichmentType); // "function", // "process", // "cellular_location", // "protein_class", // "pathway" File inputFile = new File(fileName); method.addPart(new FilePart("geneList", inputFile, "text/plain", "ISO-8859-1")); // PANTHER does not use the ID type // method.addParameter("IdType", "UniProt"); // Execute and print response client.executeMethod(method); String response = method.getResponseBodyAsString(); for (String line : response.split("\n")) { if (false == "".equals(line.trim())) { String[] row = line.split("\t"); // Id Name GeneId P-value if ("Id".equals(row[0])) { // header continue; } // if (row.length > 1) { String name = row[1]; String gene = row[2]; Double pvalue = Double.valueOf(row[3]); uniqueGenes.add(gene); if (pvalue < threshold) { if (false == genes.containsKey(name)) { pvalues.put(pvalue, name); } genes.put(name, gene); } // } else { // System.out.println("oups: " + row[0]); // } } } method.releaseConnection(); } ArrayList<Double> pvalueList = new ArrayList<>(); Collections.sort(pvalueList); pvalueList.addAll(pvalues.keySet()); Collections.sort(pvalueList); int numGenes = uniqueGenes.size(); for (Double pvalue : pvalueList) { for (String name : pvalues.get(pvalue)) { String geneList = String.join(",", genes.get(name)); String result[] = { name, "" + pvalue, genes.get(name).size() + "/" + numGenes, geneList }; results.add(result); } } } catch (IOException e) { e.printStackTrace(); } return results; }
From source file:edu.lafayette.metadb.model.dataman.DataExporter.java
/** * Export a project's attributes./*from w w w . j a v a 2s. com*/ * @param projectName The project name. * @param delimiter The delimiter to use. * @param encoder The character encoding to use. * @param technical A flag indicating whether to include technical attributes. * @return A String[] representing headers for the export file. */ public static String[] exportAttributes(String projectName, char delimiter, String encoder, boolean technical) { ArrayList attrList = null; attrList = AdminDescAttributesDAO.getAdminDescAttributes(projectName, Global.MD_TYPE_DESC); attrList.addAll(AdminDescAttributesDAO.getAdminDescAttributes(projectName, Global.MD_TYPE_ADMIN)); if (technical) attrList.addAll(TechAttributesDAO.getTechAttributes(projectName)); String[] out = new String[attrList.size()]; for (int i = 0; i < out.length; i++) try { String label = ((Attribute) attrList.get(i)).getLabel(); out[i] = StringUtils.trimToEmpty(new String( (((Attribute) attrList.get(i)).getElement() + (label.equals("") ? "" : "." + label)) .getBytes("UTF-8"), encoder).replace('\t', ' ')); } catch (UnsupportedEncodingException e) { MetaDbHelper.logEvent(e); out[i] = ((Attribute) attrList.get(i)).getElement() + "." + ((Attribute) attrList.get(i)).getLabel(); } return out; }