Example usage for java.util ArrayList size

List of usage examples for java.util ArrayList size

Introduction

In this page you can find the example usage for java.util ArrayList size.

Prototype

int size

To view the source code for java.util ArrayList size.

Click Source Link

Document

The size of the ArrayList (the number of elements it contains).

Usage

From source file:edu.lafayette.metadb.model.dataman.DataImporter.java

/**
 * Import a list of data into a project for one item.
 * @param projectName The destination project.
 * @param data Array of data strings.//w  ww .j  av  a 2s .  c o m
 * @param attrList A list of attributes associated with the data. The entries in the data array should be ordered in the same way as this list.
 * @param itemNumber The item number which is being updated.
 * @param replaceEntity Flag indicating whether HTML entity codes should be unescaped on import.
 * @return true if the import completed, false otherwise.
 */
private static boolean importData(String projectName, String[] data, ArrayList<AdminDescAttribute> attrList,
        int itemNumber, boolean replaceEntity) {
    if (data == null)
        return false;

    try {
        for (int i = 0; i < attrList.size(); i++) {
            AdminDescAttribute attribute = attrList.get(i);
            String filteredData = (replaceEntity ? StringEscapeUtils.unescapeHtml(data[i]) : data[i]);
            if (!AdminDescDataDAO.updateAdminDescData(projectName, itemNumber, attribute.getElement(),
                    attribute.getLabel(), filteredData))
                throw new Exception("Cannot update data: " + projectName + " " + itemNumber + " "
                        + attribute.getElement() + " " + attribute.getLabel() + " " + filteredData);

        }
    } catch (Exception e) {
        MetaDbHelper.logEvent(e);
        return false;
    }

    return true;

}

From source file:com.lucidtechnics.blackboard.util.Utility.java

public static Class[] getAllTypes(Class _class) {
    ArrayList allTypesList = new ArrayList();
    ArrayList searchDomainList = new ArrayList();
    searchDomainList.add(_class);
    allTypesList.add(_class);

    allTypesList = getAllTypes(searchDomainList, allTypesList);

    return (Class[]) allTypesList.toArray(new Class[allTypesList.size()]);
}

From source file:filterviewplugin.FilterViewSettings.java

private static ProgramFilter[] getAvailableFilters() {
    ProgramFilter[] allFilters = Plugin.getPluginManager().getFilterManager().getAvailableFilters().clone();
    Arrays.sort(allFilters, new Comparator<ProgramFilter>() {

        public int compare(ProgramFilter f1, ProgramFilter f2) {
            return f1.getName().compareToIgnoreCase(f2.getName());
        }/*from  ww  w.  j av a  2 s  .  c  o m*/
    });
    ArrayList<ProgramFilter> filters = new ArrayList<ProgramFilter>(Arrays.asList(allFilters));
    filters.remove(Plugin.getPluginManager().getFilterManager().getAllFilter());
    return filters.toArray(new ProgramFilter[filters.size()]);
}

From source file:mlflex.helper.MathUtilities.java

/** Rounds each of a list of numeric values to the specified number of decimal places.
 *
 * @param numbers List of numeric values to round
 * @param decimalPlaces Number of decimal places to use
 * @return List of rounded values//from  w  w w  .  j  a  va2  s . co  m
 */
public static ArrayList<Double> Round(ArrayList<Double> numbers, int decimalPlaces) {
    for (int i = 0; i < numbers.size(); i++)
        numbers.set(i, Round(numbers.get(i), decimalPlaces));
    return numbers;
}

From source file:ReflectUtils.java

/**
 * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
 *
 * @param packageName The base package// w  w w  .  j av a2 s .  c  o m
 * @return The classes
 * @throws ClassNotFoundException
 * @throws IOException
 */
private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException {
    //        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    assert classLoader != null;
    String path = packageName.replace('.', '/');
    Enumeration<URL> resources = classLoader.getResources(path);
    List<File> dirs = new ArrayList<File>();
    while (resources.hasMoreElements()) {
        URL resource = resources.nextElement();
        dirs.add(new File(resource.getFile()));
    }
    ArrayList<Class> classes = new ArrayList<Class>();
    for (File directory : dirs) {
        classes.addAll(findClasses(directory, packageName));
    }
    return classes.toArray(new Class[classes.size()]);
}

From source file:com.uniteddev.Unity.Downloader.java

public static void recursiveFileListing(ArrayList<String> extracted_links, String folder) throws IOException {
    for (int i = 0; i < extracted_links.size(); i++) {
        String target = extracted_links.get(i).toString();
        String new_folder = folder + target;
        while (target.endsWith("/")) {
            folders.add(new_folder);
            String foldername[] = new_folder.split("/");
            folder((Minecraft.getWorkingDirectory() + File.separator + new_folder),
                    foldername[foldername.length - 1]);
            recursiveFileListing(getDirectoryListing(new_folder), new_folder);
            break;
        }//from w  w w .  j  av a2s  .c o  m
        if (!new_folder.endsWith("/")) {
            files.add(new_folder);
            rename_files.add(new_folder);
        }
    }
}

From source file:com.clustercontrol.jobmanagement.util.JobUtil.java

/**
 * ?/*from www . jav  a  2 s  .  c o m*/
 * @param item
 */
public static void sort(JobTreeItem item) {
    ArrayList<JobTreeItem> children = item.getChildren();
    if (children == null || children.size() == 0) {
        return;
    }
    Collections.sort(item.getChildren(), new DataComparator());
    for (JobTreeItem child : children) {
        sort(child);
    }
}

From source file:com.feedzai.fos.server.remote.impl.RemoteInterfacesTest.java

/**
 * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
 *
 * @param packageName The base package//  w w  w  . j  a  v  a  2  s.c  om
 * @return The classes
 * @throws ClassNotFoundException
 * @throws java.io.IOException
 */
private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    assert classLoader != null;
    String path = packageName.replace('.', '/');
    Enumeration<URL> resources = classLoader.getResources(path);
    List<File> dirs = new ArrayList<>();
    while (resources.hasMoreElements()) {
        URL resource = resources.nextElement();
        dirs.add(new File(resource.getFile()));
    }
    ArrayList<Class> classes = new ArrayList<>();
    for (File directory : dirs) {
        classes.addAll(findClasses(directory, packageName));
    }
    return classes.toArray(new Class[classes.size()]);
}

From source file:com.milaboratory.core.io.sequence.fastq.RandomAccessFastqReaderTest.java

private static SingleRead[] allReads(File sample) throws IOException {
    ArrayList<SingleRead> reads = new ArrayList<>();
    SingleFastqReader reader = new SingleFastqReader(sample);
    SingleRead read;//from w  ww.  j av a  2  s .c  om
    while ((read = reader.take()) != null)
        reads.add(read);
    return reads.toArray(new SingleRead[reads.size()]);
}

From source file:eu.smartfp7.terrier.sensor.ParserUtility.java

public static EdgeNodeSnapShot parseHashMap(HashMap hashMap) throws Exception {

    /*/*from w  w w . j a  v  a 2s  . com*/
     * ((HashMap)((java.util.HashMap)v.getValue()).get("crowd")).get("time");
            
    (java.lang.String) 2012-07-26T06:29:51.947Z
    (java.lang.String) #lab_visits    (java.util.ArrayList<E>) [07:00, 08:00]
            
            
    (java.util.HashMap<K,V>) {motion_spread=-1.000000, time=2012-07-26T06:29:51.947Z, motion_horizontal=-1, density=0.000000, motion_vertical=-1}
    (java.util.HashMap<K,V>) {isActive=false, temporalHint=[07:00, 08:00], name=#lab_visits, date=26-07-2012}
    (java.util.HashMap<K,V>) {motion_spread=-1.000000, time=2012-07-26T06:29:51.947Z, motion_horizontal=-1, density=0.000000, motion_vertical=-1}
    Evaluation failed. Reason(s):
    ClassCastException: Cannot cast java.util.HashMap (id=185) to java.util.Hashtable
     * */

    HashMap crowdHashMap = (HashMap) hashMap.get("crowd");
    double density = (Double) crowdHashMap.get("density");

    String time = (String) crowdHashMap.get("time");

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    Calendar c = Calendar.getInstance();
    ;
    c.setTime(df.parse(time));

    double[] colors = null;

    if (crowdHashMap.containsKey("color")) {
        ArrayList colorList = (ArrayList) crowdHashMap.get("color");
        colors = new double[colorList.size()];
        for (int i = 0; i < colorList.size(); i++) {
            colors[i] = (Double) colorList.get(i);
        }
    }

    CrowdReport crowdReport = new CrowdReport(null, new Double(density), 0.0, colors);
    EdgeNodeSnapShot snapShot = new EdgeNodeSnapShot(null, null, c, crowdReport);

    return snapShot;
}