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.vk.sdk.payments.VKIInAppBillingService.java

private static String getPurchaseData(@NonNull final Object iInAppBillingService, final int apiVersion,
        @NonNull final String packageName, @NonNull final String purchaseToken) throws RemoteException {
    Bundle ownedItems = getPurchases(iInAppBillingService, apiVersion, packageName, "inapp", purchaseToken);
    ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
    if (purchaseDataList != null) {
        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseDataLocal = purchaseDataList.get(i);
            try {
                JSONObject o = new JSONObject(purchaseDataLocal);
                String token = o.optString(PURCHASE_DETAIL_TOKEN, o.optString(PURCHASE_DETAIL_PURCHASE_TOKEN));
                if (TextUtils.equals(purchaseToken, token)) {
                    return getReceipt(iInAppBillingService, apiVersion, packageName, purchaseDataLocal)
                            .toJson();//from   w  ww  .j av  a2  s.  com
                }
            } catch (JSONException e) {
                // nothing
            }
        }
    }
    return null;
}

From source file:com.sec.ose.osi.sdk.protexsdk.component.ComponentAPIWrapper.java

public static ComponentVersion getComponentVersionByName(String componentName, String versionName) {
    if (componentName == null || componentName.length() <= 0)
        return null;
    if (versionName == null || versionName.equals("Unspecified"))
        versionName = "";

    ComponentVersion cv = new ComponentVersion();
    cv.setComponentName(componentName);/*w ww. j ava2s .  c o m*/
    cv.setVersionName(versionName);

    // 1. cache
    ArrayList<ComponentInfo> componentInfoList = globalComponentManager
            .getComponentVersionIdFromName(componentName, versionName);
    if (componentInfoList.size() == 1) {
        cv.setComponentId(componentInfoList.get(0).getComponentId());
        cv.setVersionId(componentInfoList.get(0).getVersionId());
        return cv;
    } else if (componentInfoList.size() == 0) {
        try {
            String componentId = getGlobalComponentId(componentName);
            if (componentId != null) {
                List<ComponentVersionInfo> componentVersionInfoList = ProtexSDKAPIManager
                        .getComponentVersionAPI().getComponentVersions(componentId);
                for (ComponentVersionInfo cvInfo : componentVersionInfoList) {
                    ComponentInfo info = new ComponentInfo(cvInfo.getComponentId(), cvInfo.getComponentName(),
                            cvInfo.getVersionId(), cvInfo.getVersionName());
                    List<LicenseInfo> licenseInfo = cvInfo.getLicenses();
                    if (licenseInfo.size() > 0) {
                        info.setLicenseId(licenseInfo.get(0).getLicenseId());
                        info.setLicenseName(licenseInfo.get(0).getName());
                    }
                    globalComponentManager.addComponent(info);
                    if (componentName.equals(info.getComponentName())
                            && versionName.equals(info.getVersionName())) {
                        componentInfoList.add(info);
                    }
                }
                if (componentInfoList.size() == 0) {
                    // There is no component info in ComponentVersionAPI , There is info in StandardComponentAPI.
                    ComponentInfo info = new ComponentInfo(componentId, componentName);
                    globalComponentManager.addComponent(info);
                    componentInfoList.add(info);
                }
            }
        } catch (SdkFault e) {
            e.printStackTrace();
        }
    }

    if (componentInfoList.size() == 1) {
        cv.setComponentId(componentInfoList.get(0).getComponentId());
        cv.setVersionId(componentInfoList.get(0).getVersionId());
        return cv;
    } else if (componentInfoList.size() > 1) {
        // Need matched file info
        return null;
    }

    return null;
}

From source file:eu.fbk.dh.tint.tokenizer.ItalianTokenizer.java

public static String getString(TokenGroup tokenGroup) {
        StringBuilder buffer = new StringBuilder();
        ArrayList<Token> tokens = tokenGroup.getSupport();

        // todo: check this
        if (tokens.size() > 0) {
            for (int i = 0; i < tokens.size() - 1; i++) {
                Token token = tokens.get(i);
                buffer.append(token.getForm()).append(CharacterTable.SPACE);
            }//from w w  w . j  a v  a2s  .  c o m
            buffer.append(tokens.get(tokens.size() - 1).getForm());
        }
        return buffer.toString();
    }

From source file:com.hpe.nv.samples.advanced.AdvRealtimeUpdate.java

public static void printNetworkTime(ExportableResult analyzeResult) throws InterruptedException {
    ArrayList<ExportableSummary> transactionSummaries = analyzeResult.getTransactionSummaries();

    ExportableSummary firstTransactionSummary = transactionSummaries.get(0);
    DocumentProperties firstTransactionProperties = firstTransactionSummary.getProperties();
    ExportableSummary secondTransactionSummary = transactionSummaries.get(1);
    DocumentProperties secondTransactionProperties = secondTransactionSummary.getProperties();

    if (!debug) {
        SpinnerStatus.getInstance().pauseThread();
        System.out.print("\b ");
    }/*  w w  w  . j  a  v  a 2s  .com*/

    System.out.println("");
    System.out.println("Network times for all transaction runs in seconds:");

    double busyTime = firstTransactionProperties.getNetworkTime() / 1000;
    double goodTime = secondTransactionProperties.getNetworkTime() / 1000;

    System.out.println(
            "--- Time to navigate to the site with the NV \"3G Busy\" network scenario: " + busyTime + "s");
    System.out.println(
            "--- Time to navigate to the site with the NV \"3G Good\" network scenario: " + goodTime + "s");
    System.out.println(
            "--------- (Running this transaction with network scenario \"3G Busy\" increased the time by: "
                    + (busyTime - goodTime) + "s)");

    if (!debug) {
        SpinnerStatus.getInstance().resumeThread();
    }
}

From source file:com.taobao.android.apatch.ApkPatch.java

private static Set<String> buildPrepareClass(File smaliDir, List<File> newFiles, DexDiffInfo info)
        throws PatchException {
    Set<DexBackedClassDef> classes = Sets.newHashSet();
    classes = SmaliDiffUtils.scanClasses(smaliDir, newFiles);
    ArrayList<String> methods = new ArrayList<String>();
    {//from   w  ww. j  ava  2 s .c o m
        Set<DexBackedMethod> tempSet = info.getModifiedMethods();
        for (DexBackedMethod methodRef : tempSet) {
            String template = methodRef.getDefiningClass() + "->" + methodRef.getName();
            methods.add(template);
            System.out.println("template: " + template);
            if (superClasses.containsKey(methodRef.getDefiningClass())) {
                ArrayList<String> derivedClasses = superClasses.get(methodRef.getDefiningClass());
                for (int i = 0; i < derivedClasses.size(); i++) {
                    template = derivedClasses.get(i) + "->" + methodRef.getName();
                    System.out.println("template: " + template);
                    methods.add(template);
                }
            }
        }
    }

    Set<String> prepareClasses = new HashSet<String>();
    try {
        final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
        for (DexBackedClassDef classDef : classes) {
            currentClassType = null;
            String className = TypeGenUtil.newType(classDef.getType());
            // baksmali.disassembleClass(classDef, outFileNameHandler, options);
            File smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
            if (!smaliFile.exists()) {
                continue;
            }
            //classprepare
            getClassAnnotaionPrepareClasses(classDef, prepareClasses, info);

            BufferedReader br = new BufferedReader(new FileReader(smaliFile));
            String data = br.readLine();// null?
            while (data != null) {
                boolean find = false;
                for (String m : methods) {
                    if (data.contains(m)) {
                        find = true;
                        break;
                    }
                }
                if (find) {
                    prepareClasses.add(className.substring(1, className.length() - 1).replace('/', '.'));
                    System.out.println("prepare class: " + className);
                    break;
                }
                data = br.readLine(); // ?
            }
            br.close();

        }
    } catch (Exception e) {
        throw new PatchException(e);
    }
    for (DexBackedMethod method : info.getModifiedMethods()) {
        prepareClasses.add(method.getDefiningClass().substring(1, method.getDefiningClass().length() - 1)
                .replace("/", "."));
    }
    //modifyanatationprepare
    //        getMethodAnnotaionPrepareClasses(info,prepareClasses);
    return prepareClasses;
}

From source file:org.apache.taverna.activities.rest.HTTPRequestHandler.java

/**
 * TODO - REDIRECTION output:: if there was no redirection, should just show
 * the actual initial URL?//from w ww  .ja v  a2 s.co  m
 *
 * @param httpRequest
 * @param acceptHeaderValue
 */
private static HTTPRequestResponse performHTTPRequest(ClientConnectionManager connectionManager,
        HttpRequestBase httpRequest, RESTActivityConfigurationBean configBean,
        Map<String, String> urlParameters, CredentialsProvider credentialsProvider) {
    // headers are set identically for all HTTP methods, therefore can do
    // centrally - here

    // If the user wants to set MIME type for the 'Accepts' header
    String acceptsHeaderValue = configBean.getAcceptsHeaderValue();
    if ((acceptsHeaderValue != null) && !acceptsHeaderValue.isEmpty()) {
        httpRequest.setHeader(ACCEPT_HEADER_NAME, URISignatureHandler.generateCompleteURI(acceptsHeaderValue,
                urlParameters, configBean.getEscapeParameters()));
    }

    // See if user wanted to set any other HTTP headers
    ArrayList<ArrayList<String>> otherHTTPHeaders = configBean.getOtherHTTPHeaders();
    if (!otherHTTPHeaders.isEmpty())
        for (ArrayList<String> httpHeaderNameValuePair : otherHTTPHeaders)
            if (httpHeaderNameValuePair.get(0) != null && !httpHeaderNameValuePair.get(0).isEmpty()) {
                String headerParameterizedValue = httpHeaderNameValuePair.get(1);
                String headerValue = URISignatureHandler.generateCompleteURI(headerParameterizedValue,
                        urlParameters, configBean.getEscapeParameters());
                httpRequest.setHeader(httpHeaderNameValuePair.get(0), headerValue);
            }

    try {
        HTTPRequestResponse requestResponse = new HTTPRequestResponse();
        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, null);
        ((DefaultHttpClient) httpClient).setCredentialsProvider(credentialsProvider);
        HttpContext localContext = new BasicHttpContext();

        // Set the proxy settings, if any
        if (System.getProperty(PROXY_HOST) != null && !System.getProperty(PROXY_HOST).isEmpty()) {
            // Instruct HttpClient to use the standard
            // JRE proxy selector to obtain proxy information
            ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
                    httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault());
            httpClient.setRoutePlanner(routePlanner);
            // Do we need to authenticate the user to the proxy?
            if (System.getProperty(PROXY_USERNAME) != null && !System.getProperty(PROXY_USERNAME).isEmpty())
                // Add the proxy username and password to the list of
                // credentials
                httpClient.getCredentialsProvider().setCredentials(
                        new AuthScope(System.getProperty(PROXY_HOST),
                                Integer.parseInt(System.getProperty(PROXY_PORT))),
                        new UsernamePasswordCredentials(System.getProperty(PROXY_USERNAME),
                                System.getProperty(PROXY_PASSWORD)));
        }

        // execute the request
        HttpResponse response = httpClient.execute(httpRequest, localContext);

        // record response code
        requestResponse.setStatusCode(response.getStatusLine().getStatusCode());
        requestResponse.setReasonPhrase(response.getStatusLine().getReasonPhrase());

        // record header values for Content-Type of the response
        requestResponse.setResponseContentTypes(response.getHeaders(CONTENT_TYPE_HEADER_NAME));

        // track where did the final redirect go to (if there was any)
        HttpHost targetHost = (HttpHost) localContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        HttpUriRequest targetRequest = (HttpUriRequest) localContext
                .getAttribute(ExecutionContext.HTTP_REQUEST);
        requestResponse.setRedirectionURL("" + targetHost + targetRequest.getURI());
        requestResponse.setRedirectionHTTPMethod(targetRequest.getMethod());
        requestResponse.setHeaders(response.getAllHeaders());

        /* read and store response body
         (check there is some content - negative length of content means
         unknown length;
         zero definitely means no content...)*/
        // TODO - make sure that this test is sufficient to determine if
        // there is no response entity
        if (response.getEntity() != null && response.getEntity().getContentLength() != 0)
            requestResponse.setResponseBody(readResponseBody(response.getEntity()));

        // release resources (e.g. connection pool, etc)
        httpClient.getConnectionManager().shutdown();
        return requestResponse;
    } catch (Exception ex) {
        return new HTTPRequestResponse(ex);
    }
}

From source file:com.alcatel_lucent.nz.wnmsextract.reader.CSVReader.java

/**
 * String tokeniser method will split up a CSV file by row and column 
 * returning a List<List<String>>
 * @param in// w  w  w.j a  va2  s .co  m
 * @param struct
 * @return
 */
public static ArrayList<ArrayList<String>> read(BufferedReader in, ArrayList<ColumnStructure> struct) {
    ArrayList<ArrayList<String>> dmap = new ArrayList<ArrayList<String>>();
    CSVParser parser = new CSVParser(in, CSVReader.strategy);

    //if header
    try {
        //[consume header]
        //String[] header = 
        parser.getLine();

        //and body
        String[] line = null;

        while ((line = parser.getLine()) != null) {
            ArrayList<String> list = new ArrayList<String>();

            for (int i = 0; i < line.length; i++) {
                ColumnStructure cs = struct.get(i);
                switch (cs) {
                case VC:
                    list.add(line[i]);
                    break;
                case TS:
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(DATA_DF.parse(line[i]));
                    list.add(ALUDBUtilities.ALUDB_DF.format(cal.getTime()));
                    break;
                case FL:
                    list.add(String.valueOf(validateFloat(Float.parseFloat(line[i]))));
                    break;
                case IT:
                    list.add(String.valueOf(validateInt(Integer.parseInt(line[i]))));
                    break;
                default:
                    list.add(line[i]);
                }
            }

            dmap.add(list);
        }
    } catch (IOException ioe) {
        // TODO Auto-generated catch block
        ioe.printStackTrace();
    } catch (ParseException pe) {
        // TODO Auto-generated catch block
        pe.printStackTrace();
    }

    return dmap;
}

From source file:com.hp.test.framework.Utlis.java

public static Map<String, List<String>> GetCountsrunsWise(ArrayList runs, String path) {
    String string = "";

    Map<String, List<String>> Run_counts = new HashMap<String, List<String>>();
    for (int count = 0; count < runs.size(); count++) {
        Boolean runhasData = false;
        String file = path + "\\" + runs.get(count) + "\\pieChart.js";

        //reading   
        try {//from   w ww  .  j  a  v  a2 s .  c o  m
            InputStream ips = new FileInputStream(file);
            InputStreamReader ipsr = new InputStreamReader(ips);
            BufferedReader br = new BufferedReader(ipsr);
            String line;
            ArrayList<String> ar = new ArrayList<String>();
            while ((line = br.readLine()) != null) {
                runhasData = true;
                if (line.contains("var data")) {
                    // System.out.println(line);
                    String tem_ar[] = line.split("=");
                    //System.out.println(tem_ar[1]);
                    String temp_ar1[] = tem_ar[1].split(",");
                    String counts = "";
                    for (int i = 0; i < temp_ar1.length; i++) {
                        temp_ar1[i] = temp_ar1[i].replace("[", "");
                        temp_ar1[i] = temp_ar1[i].replace("]", "");
                        temp_ar1[i] = temp_ar1[i].replace("'", "");
                        String temp = temp_ar1[i];
                        ar.add(temp);
                        counts = counts + temp;
                        // System.out.println(temp_ar1[i]);

                    }
                    string += line + "\n";
                    Run_counts.put(runs.get(count).toString(), ar);
                    log.info("counts run wise-->" + runs.get(count) + "***" + ar.toString());
                    break;
                }
            }
            br.close();
        } catch (Exception e) {
            log.error(e.toString());

        }
        if (!runhasData) {
            ArrayList<String> ar = new ArrayList<String>();
            ar.add("Passed");
            ar.add("0");
            ar.add("Failed");
            ar.add("0");
            ar.add("Skipped");
            ar.add("0;");

            Run_counts.put(runs.get(count).toString(), ar);
            log.info("has NO*******  data for " + runs.get(count));
        }
    }
    return Run_counts;

}

From source file:GenAppStoreSales.java

/**
 * Creates a dataset./* w ww. j av  a  2s.co m*/
 *
 * @return A dataset.
 */
public static CategoryDataset createDataset1(ArrayList<String> cLabels, ArrayList<ArrayList<Integer>> cUnits) {

    DefaultCategoryDataset result = new DefaultCategoryDataset();

    for (int country = 0; country < cUnits.size(); country++)
        for (int d = cUnits.get(country).size() - 1; d >= 0; d--)
            result.addValue(cUnits.get(country).get(d), cLabels.get(country),
                    String.valueOf(cUnits.get(country).size() - d));

    return result;
}