Example usage for java.util ArrayList get

List of usage examples for java.util ArrayList get

Introduction

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

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:com.tmobile.TMobileParsing.java

protected static List<Subscription> parseSubscriptions(JsonObject jsonSubscriptions) {
    List<Subscription> subscriptions = new ArrayList<>();

    Set<Map.Entry<String, JsonElement>> keys = jsonSubscriptions.entrySet();
    ArrayList<Map.Entry<String, JsonElement>> subscriptionIds = new ArrayList<>(keys);

    for (int i = 0; i < subscriptionIds.size(); i++) {
        String subscriptionId = subscriptionIds.get(0).getKey();

        JsonObject jsonSubscription = jsonSubscriptions.get(subscriptionId).getAsJsonObject();

        Subscription subscription = new Subscription();
        subscription.setPhoneNumber(subscriptionId);
        subscription.setCallUsageLink(jsonSubscription.get("callUsageLink").getAsString());
        subscription.setContractEndDate(jsonSubscription.get("contractEndDate").getAsString());
        subscription.setDataUsageLink(jsonSubscription.get("dataUsageLink").getAsString());
        subscription.setInfoLink(jsonSubscription.get("infoLink").getAsString());
        subscription.setPaymentType(jsonSubscription.get("paymentType").getAsString());
        subscription.setTariffName(jsonSubscription.get("tariffName").getAsString());
        subscription.setTrafficSOC(jsonSubscription.get("tariffSOC").getAsString());
        subscription.setThirdPartyUsageLink(jsonSubscription.get("thirdPartyUsageLink").getAsString());

        subscriptions.add(subscription);
    }//from w  ww  . ja v  a 2 s. c o  m

    return subscriptions;
}

From source file:biblioteca.reportes.ChartCreator.java

public static DefaultCategoryDataset asignarBarDataset(ArrayList<String> Valores) {
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    int size = Valores.size();
    size = (size <= 32) ? size : 32;//from   w w w.j  a v  a 2s  .  c  o m
    for (int i = 2; i < size; i += 2) {
        dataSet.setValue(Double.parseDouble(Valores.get(i + 1)), "Grafica", Valores.get(i));
    }
    return dataSet;
}

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 {//from  w w  w .  j  a  va  2 s  . c  om
            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:fr.bmartel.android.tictactoe.request.ResponseParser.java

public static String parseUsernameEvent(Intent intent) {

    ArrayList<String> actionsStr = intent.getStringArrayListExtra("");

    if (actionsStr.size() > 0) {
        try {//from   ww  w  .jav a  2  s  .c o m
            JSONObject mainObject = new JSONObject(actionsStr.get(0));
            if (mainObject.has(RequestConstants.DEVICE_NAME)) {

                return mainObject.get(RequestConstants.DEVICE_NAME).toString();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return "";
}

From source file:CB_Core.GCVote.GCVote.java

public static RatingData GetRating(String User, String password, String Waypoint) {
    ArrayList<String> waypoint = new ArrayList<String>();
    waypoint.add(Waypoint);/* www  .j a v  a2  s.  co  m*/
    ArrayList<RatingData> result = GetRating(User, password, waypoint);

    if (result == null || result.size() == 0) {
        return new RatingData();
    } else {
        return result.get(0);
    }

}

From source file:Main.java

public static Element getElementByTagName(Element n, String elementName) {
    int sz = n.getChildNodes().getLength();
    ArrayList<Element> elements = new ArrayList<Element>(sz);
    for (int idx = 0; idx < sz; idx++) {
        Node node = n.getChildNodes().item(idx);
        if (node instanceof Element && node.getLocalName().equals(elementName))
            elements.add((Element) node);
    }/* w  w w  .  j a va  2  s.  co  m*/
    if (elements.size() > 0)
        return elements.get(0);
    return null;
}

From source file:automaticdatabaseupdate.FileHandler.java

/**
 *
 * @param strFilePath    - path of given file          e.g. "D:\\EGYETEM\\Szakdolgozat\\Mernoki_tervezes\\update files\\sr28upd\\ADD_NUTR.txt"
 * @param strFileType    - type of the given file      e.g. AddFood
 * @param TList          - list to fill with data      e.g. List<FileFoodStruct> ListFFS
 *//*w  w w . j ava2 s  . c  o  m*/
public static <T> void readFile(String strFilePath, List<T> TList, String strFileType) {
    TList.clear();

    try {

        File file = FileUtils.getFile(strFilePath);
        LineIterator iter = FileUtils.lineIterator(file);

        while (iter.hasNext()) {
            String strLine = iter.next();

            switch (strFileType) {
            case "ADD_FOOD": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileFoodStruct Object = new FileFoodStruct(Integer.valueOf(strList.get(0)), strList.get(2),
                        strList.get(3), Integer.valueOf(strList.get(8)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "ADD_NUTR": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileNutrientStruct Object = new FileNutrientStruct(Integer.valueOf(strList.get(0)),
                        Integer.valueOf(strList.get(1)), Double.valueOf(strList.get(2)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "ADD_WGT": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileWeightStruct Object = new FileWeightStruct(Integer.valueOf(strList.get(0)),
                        Double.valueOf(strList.get(2)), strList.get(3), Double.valueOf(strList.get(4)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "CHG_FOOD": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileFoodStruct Object = new FileFoodStruct(Integer.valueOf(strList.get(0)), strList.get(2),
                        strList.get(3), Integer.valueOf(strList.get(8)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "CHG_NUTR": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileNutrientStruct Object = new FileNutrientStruct(Integer.valueOf(strList.get(0)),
                        Integer.valueOf(strList.get(1)), Double.valueOf(strList.get(2)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "CHG_WGT": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileWeightStruct Object = new FileWeightStruct(Integer.valueOf(strList.get(0)),
                        Double.valueOf(strList.get(2)), strList.get(3), Double.valueOf(strList.get(4)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "DEL_FOOD": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileFoodStruct Object = new FileFoodStruct(Integer.valueOf(strList.get(0)), strList.get(1));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "DEL_NUTR": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileNutrientStruct Object = new FileNutrientStruct(Integer.valueOf(strList.get(0)),
                        Integer.valueOf(strList.get(1)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "DEL_WGT": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileWeightStruct Object = new FileWeightStruct(Integer.valueOf(strList.get(0)),
                        Double.valueOf(strList.get(2)), strList.get(3), Double.valueOf(strList.get(4)));
                TList.add((T) Object);
                System.out.println(Object.toString());
                break;
            }
            case "LOG_FILE": {
                ArrayList<String> strList = ParseLogFile(strLine);
                TraceMessage Object = new TraceMessage(strList.get(0), strList.get(1));
                TList.add((T) Object);
                break;
            }
            }
        }
        //System.out.println( "Total line: " + moduleCounter );
        iter.close();

    } catch (IOException ex) {
        Logger.getLogger(FileHandler.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:k_means.Plot.java

public static XYDataset createDataset(ArrayList<Data> dataSet, int k) {

    final XYSeriesCollection dataset = new XYSeriesCollection();

    for (int i = 0; i < k; i++) {
        String str = "Cluster " + (i + 1);
        XYSeries cluster = new XYSeries(str);
        for (int j = 0; j < dataSet.size(); j++) {

            if (dataSet.get(j).getCluster() == i) {
                cluster.add(dataSet.get(j).getX(), dataSet.get(j).getY());
            }//www. j  a  v  a  2  s . c  o m

        }
        dataset.addSeries(cluster);
    }

    return dataset;

}

From source file:Main.java

@SuppressWarnings("rawtypes")
private static void mapToXml(Map map, StringBuffer sb) {
    Set set = map.keySet();//from   w  w w  . java2s  . com
    for (Iterator it = set.iterator(); it.hasNext();) {
        String key = (String) it.next();
        Object value = map.get(key);
        if (null == value)
            value = "";
        if (value instanceof List) {
            ArrayList list = (ArrayList) map.get(key);
            // sb.append("<" + key + ">");
            for (int i = 0; i < list.size(); i++) {
                sb.append("<" + key + ">");
                // Object listi = list.get(i);
                if (list.get(i) instanceof HashMap) {
                    HashMap hm = (HashMap) list.get(i);
                    // sb.append("<" + key + ">");
                    mapToXml(hm, sb);
                    // sb.append("</" + key + ">");
                } else {
                    // sb.append("<" + key + ">" + list.get(i) + "</" + key
                    // + ">");
                    sb.append(list.get(i));
                }
                // else
                // if(listi.getClass().getName().equals("java.util.ArrayList")){
                // sb.append("<" + key + ">" + "??" + "</" + key + ">");}

                sb.append("</" + key + ">");
            }
            // sb.append("</" + key + ">");

        } else {
            if (value instanceof HashMap) {
                sb.append("<" + key + ">");
                mapToXml((HashMap) value, sb);
                sb.append("</" + key + ">");
            } else {
                sb.append("<" + key + ">" + value + "</" + key + ">");
            }

        }

    }
}

From source file:test.GanttDemo1.java

/**
 * Creates a sample dataset for a Gantt chart.
 *
 * @return The dataset./*from w w  w . j a va2s.co  m*/
 */
public static IntervalCategoryDataset createDataset(ArrayList<proceso> lista_imprimir) {

    String nameProcess;
    TimePeriod periodProcess;

    final TaskSeries s1 = new TaskSeries("Scheduled");

    for (int i = 0; i < lista_imprimir.size(); i++) {
        nameProcess = "Proceso " + lista_imprimir.get(i).getId_proceso();
        s1.add(new Task(nameProcess,
                new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001))));
    }

    //        s1.add(new Task("Proceso 1",
    //               new SimpleTimePeriod(date(1, Calendar.APRIL, 2001),
    //                                    date(5, Calendar.APRIL, 2001))));
    //        s1.add(new Task("Proceso 2",
    //               new SimpleTimePeriod(date(5, Calendar.APRIL, 2001),
    //                                    date(9, Calendar.APRIL, 2001))));
    //        s1.add(new Task("Proceso 3",
    //               new SimpleTimePeriod(date(9, Calendar.APRIL, 2001),
    //                                    date(15, Calendar.MAY, 2001))));

    final TaskSeriesCollection collection = new TaskSeriesCollection();
    collection.add(s1);

    return collection;
}