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:Main.java

/**
 * Get the node set from parent node by the specified  name
 *
 * @param parent//from w ww  .  ja  v a  2 s .  c om
 * @param name
 * @return
 */
public static Element[] getElementsByName(Element parent, String name) {
    ArrayList resList = new ArrayList();
    NodeList nl = getNodeList(parent);
    for (int i = 0; i < nl.getLength(); i++) {
        Node nd = nl.item(i);
        if (nd.getNodeName().equals(name)) {
            resList.add(nd);
        }
    }
    Element[] res = new Element[resList.size()];
    for (int i = 0; i < resList.size(); i++) {
        res[0] = (Element) resList.get(i);
    }
    return res;
}

From source file:Main.java

public static List<Node> getNodes(Node node, String path) {
    ArrayList nodeList = new ArrayList();

    ArrayList pathList = new ArrayList();
    String[] pathArray = path.split("/");
    for (int i = 0; i < pathArray.length; i++) {
        if (pathArray[i].equals(""))
            continue;
        pathList.add(pathArray[i]);/*w w  w.ja  v a2s  .  co  m*/
    }

    for (int i = 0; i < pathList.size(); i++) {
        StringBuffer restPath = new StringBuffer();
        for (int k = i + 1; k < pathList.size(); k++) {
            restPath.append("/").append((String) pathList.get(k));
        }

        for (int j = 0; j < node.getChildNodes().getLength(); j++) {
            if (!node.getChildNodes().item(j).getNodeName().equals(pathList.get(i)))
                continue;
            if (restPath.length() == 0) {
                nodeList.add(node.getChildNodes().item(j));
            } else {
                nodeList.addAll(getNodes(node.getChildNodes().item(j), restPath.toString()));
            }
        }

    }

    return nodeList;
}

From source file:com.acme.spring.jms.Deployments.java

/**
 * <p>Retrieves the dependencies.</p>
 *
 * @return the array of the dependencies
 *///from ww w  .ja v a  2s .  c o m
public static File[] springDependencies() {

    ArrayList<File> files = new ArrayList<File>();

    files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE"));
    files.addAll(resolveDependencies("org.springframework:spring-jms:3.1.1.RELEASE"));

    return files.toArray(new File[files.size()]);
}

From source file:com.hanuor.sapphire.utils.Client.java

public static void updateJson(final ArrayList<String> tags, String docID) {

    storageService.findDocumentById(LibraryDatabase.DBNAME, LibraryDatabase.collectionName, docID,
            new App42CallBack() {
                public void onSuccess(Object response) {
                    String jsonD = null;
                    HashMap<String, String> hMap = new HashMap<String, String>();
                    ArrayList<String> arrayList = new ArrayList<String>();
                    Storage storage = (Storage) response;
                    System.out.println("dbName is " + storage.getDbName());
                    System.out.println("collection Name is " + storage.getCollectionName());
                    ArrayList<Storage.JSONDocument> jsonDocList = storage.getJsonDocList();
                    for (int i = 0; i < jsonDocList.size(); i++) {
                        jsonD = jsonDocList.get(i).getJsonDoc();
                    }//from   ww  w.j  a  v a  2  s .  c  o  m
                    try {
                        if (jsonD != null) {
                            JSONObject jObj = new JSONObject(jsonD);
                            for (int i = 0; i < tags.size(); i++) {
                                String entityValue = null;
                                entityValue = jObj.getString(tags.get(i));
                                if (entityValue.length() != 0) {
                                    hMap.put(tags.get(i), entityValue);
                                } else {
                                    arrayList.add(tags.get(i));
                                }
                                //add to hashmap here
                                for (int j = 0; j < arrayList.size(); j++) {
                                    hMap.put(arrayList.get(j), "0.1");
                                }
                            }
                            updateJsonDoc(hMap);
                        }
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

                public void onException(Exception ex) {
                    System.out.println("Exception Message" + ex.getMessage());
                }
            });

}

From source file:edu.uci.ics.jung.algorithms.transformation.FoldingTransformer.java

/**
 * @param target//from  www  .  ja  v  a2 s .  c  om
 * @param e
 * @param incident
 */
private static <S, T> void populateTarget(Graph<S, Collection<T>> target, T e, ArrayList<S> incident) {
    for (int i = 0; i < incident.size(); i++) {
        S v1 = incident.get(i);
        for (int j = i + 1; j < incident.size(); j++) {
            S v2 = incident.get(j);
            Collection<T> e_coll = target.findEdge(v1, v2);
            if (e_coll == null) {
                e_coll = new ArrayList<T>();
                target.addEdge(e_coll, v1, v2);
            }
            e_coll.add(e);
        }
    }
}

From source file:Main.java

/**
 * Reads a sentence from the a reader and returns a string array with tokens.
 * /*from ww  w  .  j a v  a 2s.c  o m*/
 * The method expect that each line contains a token and empty line is equal to end of sentence.
 * 
 * There are no check for particular data format so if the input is garbage then the output will also be garbage. 
 * 
 * @param reader a buffered reader
 * @return a string array with tokens
 * @throws IOException
 */
public static String[] readSentence(BufferedReader reader) throws IOException {
    ArrayList<String> tokens = new ArrayList<String>();
    String line;
    while ((line = reader.readLine()) != null) {
        if (line.trim().length() == 0) {
            break;
        } else {
            tokens.add(line.trim());
        }

    }
    return tokens.toArray(new String[tokens.size()]);
}

From source file:grafici.PazientiBarChart.java

/**
 * Returns a sample dataset.//w  w  w .  j av  a 2s  . c o  m
 * 
 * @return The dataset.
 */
private static CategoryDataset createDataset(int tipo) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if (tipo == 0) {
        // Tipologia visita
        ArrayList<Tipologiavisita> tipiVisite = VisitaDAO.getTipologVisita();
        String[] righe = new String[tipiVisite.size()];
        int i = 0;
        for (Tipologiavisita item : tipiVisite) {
            righe[i] = item.getTipologia();
            i++;
        }

        // Data
        String category1 = "Category 1";
        String category2 = "Category 2";
        String category3 = "Category 3";
        String category4 = "Category 4";
        String category5 = "Category 5";

        // prenotazioni

        for (String tipologia : righe) {
            dataset.addValue(1.0, tipologia, category1);
            dataset.addValue(4.0, tipologia, category2);
            dataset.addValue(3.0, tipologia, category3);
            dataset.addValue(5.0, tipologia, category4);
            dataset.addValue(5.0, tipologia, category5);
        }
    }
    return dataset;

}

From source file:RMOS.PieChartCash.java

/**
 * Creates a sample dataset.//from w w w  . j av  a 2 s  .co m
 * 
 * Source: http://www.bbc.co.uk/news/business-15489523
 *
 * @return A sample dataset.
 */
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    ArrayList<String> s1 = new ArrayList<String>();
    s1 = f1.getStationInGroup();

    for (int i = 0; i < s1.size(); i++) {
        //System.out.println(f1.getStationInGroup().get(i));
        //System.out.println(u.getInCapacity().get(i));
        dataset.setValue(f1.getStationInGroup().get(i),
                new Double(f2.getCashDispatched(f1.getStationInGroup().get(i).toString())));

    }

    /* dataset.setValue("Samsung", new Double(27.8));
     dataset.setValue("Others", new Double(55.3));
     dataset.setValue("Nokia", new Double(16.8));
     dataset.setValue("Apple", new Double(17.1));*/
    return dataset;
}

From source file:com.mapviewer.business.UserRequestManager.java

/**
 * Generate links for the default entry layers
 *
 * @param layers ArrayList<Layer> contains the layers
 * @return String[] array with kml link of layers
 *//*from w ww  . j  av  a2s  .  c o  m*/
public static String[] getCheckboxKmlLinks(ArrayList<Layer> layers) {
    String[] kmlLinks = new String[layers.size()];//this array will have the links of the kml of each layer requested. 

    String layerName = null;
    String serverLayer = null;
    for (int i = 0; i < kmlLinks.length; i++) {
        kmlLinks[i] = UserRequestManager.buildKmlLink(layers.get(i), layers.get(i).getPalette());
    }
    return kmlLinks;
}

From source file:filterviewplugin.FilterViewSettings.java

static String[] getAvailableFilterNames() {
    ArrayList<String> names = new ArrayList<String>();
    for (ProgramFilter filter : getAvailableFilters()) {
        names.add(filter.getName());/*from w w w  .  j  a  va 2s . c  o  m*/
    }
    return names.toArray(new String[names.size()]);
}