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:jeplus.INSELWinTools.java

/**
 * Test if any of the given files in jEPlus format is available in the given  
 * directory as an indicator of successful run.
 * @return boolean True if the file is present at the specified location
 *///w ww  .j a  v a  2s  .com
public static boolean isAnyFileAvailable(String FileNames, String workdir) {
    ArrayList<String> filename = getPrintersFunc(FileNames);
    for (int i = 0; i < filename.size(); i++) {
        if (new File(workdir + filename.get(i)).exists()) {
            return true;
        }
    }
    return false;
}

From source file:ded.model.Entity.java

/** Return the value to which 'index' is mapped in 'integerToEntity'. */
public static Entity fromJSONRef(ArrayList<Entity> integerToEntity, long index) throws JSONException {
    if (0 <= index && index < integerToEntity.size()) {
        return integerToEntity.get((int) index);
    } else {// w w  w.  j  ava 2  s. c o  m
        throw new JSONException("invalid entity ref " + index);
    }
}

From source file:CB_Core.GCVote.GCVote.java

public static ArrayList<RatingData> GetRating(String User, String password, ArrayList<String> Waypoints) {
    ArrayList<RatingData> result = new ArrayList<RatingData>();

    String data = "userName=" + User + "&password=" + password + "&waypoints=";
    for (int i = 0; i < Waypoints.size(); i++) {
        data += Waypoints.get(i);
        if (i < (Waypoints.size() - 1))
            data += ",";
    }/*from  ww w  . j ava2 s.c  o m*/

    try {
        HttpPost httppost = new HttpPost("http://gcvote.de/getVotes.php");

        httppost.setEntity(new ByteArrayEntity(data.getBytes("UTF8")));

        // Log.info(log, "GCVOTE-Post" + data);

        // Execute HTTP Post Request
        String responseString = Execute(httppost);

        // Log.info(log, "GCVOTE-Response" + responseString);

        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(responseString));

        Document doc = db.parse(is);

        NodeList nodelist = doc.getElementsByTagName("vote");

        for (Integer i = 0; i < nodelist.getLength(); i++) {
            Node node = nodelist.item(i);

            RatingData ratingData = new RatingData();
            ratingData.Rating = Float.valueOf(node.getAttributes().getNamedItem("voteAvg").getNodeValue());
            String userVote = node.getAttributes().getNamedItem("voteUser").getNodeValue();
            ratingData.Vote = (userVote == "") ? 0 : Float.valueOf(userVote);
            ratingData.Waypoint = node.getAttributes().getNamedItem("waypoint").getNodeValue();
            result.add(ratingData);

        }

    } catch (Exception e) {
        String Ex = "";
        if (e != null) {
            if (e != null && e.getMessage() != null)
                Ex = "Ex = [" + e.getMessage() + "]";
            else if (e != null && e.getLocalizedMessage() != null)
                Ex = "Ex = [" + e.getLocalizedMessage() + "]";
            else
                Ex = "Ex = [" + e.toString() + "]";
        }
        Log.err(log, "GcVote-Error" + Ex);
        return null;
    }
    return result;

}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java

protected static void eliminarTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlAdmin.eliminarTaller(Integer.parseInt(request.getParameter("1"))); // id

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);//from w  w  w  .ja v a2 s . c  om
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else
        Util.errordeRespuesta(r, out);
}

From source file:net.gcompris.GComprisActivity.java

public static void checkPayment() {
    if (m_instance.m_service == null) {
        Log.e(QtApplication.QtTAG, "Check full version is bought failed: No billing service");
        return;/* w w  w. j  a v a  2 s . c  om*/
    }

    try {
        Bundle ownedItems = m_instance.m_service.getPurchases(3, m_instance.getPackageName(), "inapp", null);
        int responseCode = ownedItems.getInt("RESPONSE_CODE");
        if (responseCode == 0) {
            ArrayList ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
            ArrayList purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
            for (int i = 0; i < purchaseDataList.size(); ++i) {
                String purchaseData = (String) purchaseDataList.get(i);
                String sku = (String) ownedSkus.get(i);

                if (sku.equals(SKU_NAME)) {
                    bought(true);
                    return;
                } else {
                    Log.e(QtApplication.QtTAG, "Unknown item bought " + sku);
                }
            }
            bought(false);
            return;
        } else {
            bought(false);
            Log.e(QtApplication.QtTAG, "Item not owed " + responseCode);
        }
    } catch (Exception e) {
        Log.e(QtApplication.QtTAG, "Exception caught when checking if full version is bought!", e);
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java

protected static void eliminarConvocatoria(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlAdmin.eliminarConvocatoria(Integer.parseInt(request.getParameter("1"))); // id

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);//from ww w. j a va  2s .co m
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else
        Util.errordeRespuesta(r, out);
}

From source file:edu.umn.cs.spatialHadoop.temporal.RepartitionTemporal.java

private static void bulkLoadSpatioTemporalIndexesLevel(Path indexLevelHomePath, Path[] inputPathDirs,
        String indexLevel, OperationsParams params) throws IOException, InterruptedException {
    LOG.info("Needs to index/re-index " + inputPathDirs.length + " " + indexLevel);

    for (Path inputPathDir : inputPathDirs) {
        FileSystem currFileSystem = inputPathDir.getFileSystem(params);

        if (currFileSystem.exists(inputPathDir)) {
            currFileSystem.delete(inputPathDir, true);
        }/*from w  w w.j a v  a  2s . co  m*/
        currFileSystem.mkdirs(inputPathDir);

        ArrayList<Path[]> pathsArrList = NASADatasetUtil.getSortedTuplesInPath(indexLevelHomePath,
                NASADatasetUtil.extractDateStringFromPath(inputPathDir));

        Path indexPath = generateIndexPath(pathsArrList.get(0)[0], inputPathDir);

        for (Path[] currInputFiles : pathsArrList) {
            repartitionMapReduce(currInputFiles, indexPath, params);
        }

    }

}

From source file:com.pros.jsontransform.sort.ArraySortAbstract.java

static void doSort(final ArrayNode arrayNode, final JsonNode sortNode, final ObjectTransformer transformer) {
    // move array nodes to sorted array
    int size = arrayNode.size();
    ArrayList<JsonNode> sortedArray = new ArrayList<JsonNode>(arrayNode.size());
    for (int i = 0; i < size; i++) {
        sortedArray.add(arrayNode.remove(0));
    }//w  w  w . ja  v  a 2 s  .co m

    // sort array
    sortedArray.sort(new NodeComparator(sortNode, transformer));

    // move nodes back to targetArray
    for (int i = 0; i < sortedArray.size(); i++) {
        arrayNode.add(sortedArray.get(i));
    }
}

From source file:gov.nih.nci.eagle.web.ajax.DynamicListHelper.java

public static String createGenericList(String listType, List<String> list, String name)
        throws OperationNotSupportedException {
    try {/*w  w  w  .j a va  2 s . c  o m*/
        String[] tps = CommonListFunctions.parseListType(listType);
        //tps[0] = ListType
        //tps[1] = ListSubType (if not null)
        ListType lt = ListType.valueOf(tps[0]);
        if (tps.length > 1 && tps[1] != null) {
            //create a list out of [1]
            ArrayList<ListSubType> lst = new ArrayList();
            lst.add(ListSubType.valueOf(tps[1]));
            EAGLEListValidator lv = new EAGLEListValidator(ListType.valueOf(tps[0]),
                    ListSubType.valueOf(tps[1]), list);
            return CommonListFunctions.createGenericList(lt, lst.get(0), list, name, lv);
        } else if (tps.length > 0 && tps[0] != null) {
            //no subtype, only a primary type - typically a PatientDID then
            EAGLEListValidator lv = new EAGLEListValidator(ListType.valueOf(tps[0]), list);
            return CommonListFunctions.createGenericList(lt, list, name, lv);
        } else {
            //no type or subtype, not good, force to clinical in catch                
            throw new Exception();
        }
    } catch (Exception e) {
        //try as a patient list as default, will fail validation if its not accepted
        return CommonListFunctions.createGenericList(ListType.PatientDID, list, name,
                new EAGLEListValidator(ListType.PatientDID, list));
    }
}

From source file:org.neo4j.nlp.examples.wikipedia.main.java

private static List<Map<String, Object>> getWikipediaArticles() throws IOException {
    final String txUri = "http://localhost:7474/db/data/" + "transaction/commit";
    WebResource resource = Client.create().resource(txUri);

    String query = "MATCH (n:Page) WITH n, rand() as sortOrder " + "ORDER BY sortOrder " + "LIMIT 1000 "
            + "RETURN n.title as title";

    String payload = "{\"statements\" : [ {\"statement\" : \"" + query + "\"} ]}";
    ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON)
            .entity(payload).post(ClientResponse.class);

    ObjectMapper objectMapper = new ObjectMapper();
    HashMap<String, Object> result;
    try {//  www . ja v  a  2 s  .  c om
        result = objectMapper.readValue(response.getEntity(String.class), HashMap.class);
    } catch (Exception e) {
        throw e;
    }
    response.close();

    List<Map<String, Object>> results = new ArrayList<>();

    ArrayList resultSet = ((ArrayList) result.get("results"));
    List<LinkedHashMap<String, Object>> dataSet = (List<LinkedHashMap<String, Object>>) resultSet.stream()
            .map(a -> (LinkedHashMap<String, Object>) a).collect(Collectors.toList());

    List<LinkedHashMap> rows = (List<LinkedHashMap>) ((ArrayList) (dataSet.get(0).get("data"))).stream()
            .map(m -> (LinkedHashMap) m).collect(Collectors.toList());
    ArrayList cols = (ArrayList) (dataSet.get(0).get("columns"));

    for (LinkedHashMap row : rows) {
        ArrayList values = (ArrayList) row.get("row");
        Map<String, Object> resultRecord = new HashMap<>();
        for (int i = 0; i < values.size(); i++) {
            resultRecord.put(cols.get(i).toString(), values.get(i));
        }
        results.add(resultRecord);
    }
    return results;
}