Example usage for org.json JSONArray toString

List of usage examples for org.json JSONArray toString

Introduction

In this page you can find the example usage for org.json JSONArray toString.

Prototype

public String toString() 

Source Link

Document

Make a JSON text of this JSONArray.

Usage

From source file:fr.natoine.model_annotation.AnnotationStatus.java

/**
 * Sets a JSONArray as a decriptor of the Annotation Form
 * The JSONArry is made of JSONObjects composed of :
 * a string equals ANNOTATED or ADDED// w ww  .j  a v a  2 s  . c om
 * a string that indicates the ClassName of the resource
 * a string that indicates a status for this resource (comment for example)
 * a String[] to give the possible values if there are
 * a string infinite or a number to indicate if you con add an infinity of this resource or a specified number, if the number is surrounded by |, it means you must add exactly this number of resources
 * @param descripteur
 */
public void setDescripteur(JSONArray descripteur) {
    this.descripteur = descripteur.toString();
}

From source file:com.telefonica.iot.perseo.test.Help.java

/**
 * Creates a big rule set as a JSON array.
 * /*from   w w w .  ja  va 2  s  .c o m*/
 * @return String representing the JSON for the rule set
 */
public static String longRuleSet() {
    final int ruleNumber = 100000; // ~45MB
    JSONArray ja = new JSONArray();
    JSONObject rule = new JSONObject();
    for (int i = 0; i < ruleNumber; i++) {
        rule.put("name", "manyrules_a_" + i);
        rule.put("text", ExampleRules[0]);
        ja.put(rule);
        rule.put("name", "manyrules_b_" + i);
        rule.put("text", ExampleRules[1]);
        ja.put(rule);
    }
    return ja.toString();
}

From source file:com.abeo.tia.noordin.ProcessCaseVendor.java

private void confirm_allvalues_btn() throws JSONException {
    // TODO Auto-generated method stub
    String spinnertype1 = getSelectedItem(
            ((Spinner) findViewById(R.id.spinner_VendorType)).getSelectedItem().toString());
    String spinnertype2 = getSelectedItem(
            ((Spinner) findViewById(R.id.spinner_VendorType2)).getSelectedItem().toString());
    String spinnertype3 = getSelectedItem(
            ((Spinner) findViewById(R.id.spinner_VendorType3)).getSelectedItem().toString());
    String spinnertype4 = getSelectedItem(
            ((Spinner) findViewById(R.id.spinner_VendorType4)).getSelectedItem().toString());

    if (rep_firm.isChecked()) {
        f_yes = "Y";
    } else if (!rep_firm.isChecked()) {
        f_yes = "N";
    }//w  ww  .  ja  v a  2s.  c  o  m
    if (lawer_rep.isChecked()) {
        l_yes = "Y";
    } else if (!lawer_rep.isChecked()) {
        l_yes = "N";
    }
    contact_no1.getText().toString();
    //      String json_element = "[{\"Case\":\"1500000001\",\"CaseType\":\"SPA-BUY-DEV-APT-C\",\"CaseStatus\":\"OPEN\",\"FileOpenDate\":\"10/10/2015 12:00:00 AM\",\"CaseFileNo\":\"JJ/1500000001/\",\"KIV\":\"\",\"TabId\":\"2\",\"Details\":{\"LA\":\"\",\"MANAGER\":\"\",\"InCharge\":\"\",\"CustomerService\":\"\",\"CaseType\":\"SPA-BUY-DEV-APT-C\",\"FileLocation\":\"\",\"FileClosedDate\":\"\",\"VendAcqDt\":\"\",\"CompanyBuisnessSearch\":\"\",\"BankWindingSearch\":\"\"},\"Purchaser\":{\"PurRepresentedByFirm\":\"N\",\"PurlawyerRepresented\":\"N\",\"PurSPADate\":\"1/1/1900 12:00:00 AM\",\"PurEntryOfPrivateCaveat\":\"Chase\",\"PurWithOfPrivateCaveat\":\"Rane\",\"PurFirstName\":\"Name1\",\"PurFirstID\":\"Id1\",\"PurFirstTaxNo\":\"Tax1\",\"PurFirstContactNo\":\"9784561233\",\"PurFirstType\":\"CORPORATE\",\"PurSecName\":\"Name2\",\"PurSecID\":\"Id2\",\"PurSecTaxNo\":\"Tax2\",\"PurSecContactNo\":\"9784561234\",\"PurSecType\":\"INDIVIDUAL\",\"PurThirdName\":\"Name3\",\"PurThirdID\":\"Id3\",\"PurThirdTaxNo\":\"Tax3\",\"PurThirdContactNo\":\"9784561234\",\"PurThirdType\":\"INDIVIDUAL\",\"PurFourthName\":\"Name4\",\"PurFourthID\":\"Id4\",\"PurFourthTaxNo\":\"Tax4\",\"PurFourthContactNo\":\"9784561235\",\"PurFourthType\":\"INDIVIDUAL\"},\"Vendor\":{\"VndrRepresentedByFirm\":\"N\",\"VndrlawyerRepresented\":\"Y\",\"VndrReqDevConsent\":\"Name\",\"VndrReceiveDevConsent\":\"Sam\",\"VndrFirstName\":\"Name1\",\"VndrFirstID\":\"Id1\",\"VndrFirstTaxNo\":\"Tax1\",\"VndrFirstContactNo\":\"9784561233\",\"VndrFirstType\":\"CORPORATE\",\"VndrSecName\":\"Name2\",\"VndrSecID\":\"Id2\",\"VndrSecTaxNo\":\"Tax2\",\"VndrSecContactNo\":\"9784561234\",\"VndrSecType\":\"INDIVIDUAL\",\"VndrThirdName\":\"Name3\",\"VndrThirdID\":\"Id3\",\"VndrThirdTaxNo\":\"Tax3\",\"VndrThirdContactNo\":\"9784561234\",\"VndrThirdType\":\"INDIVIDUAL\",\"VndrFourthName\":\"Name4\",\"VndrFourthID\":\"Id4\",\"VndrFourthTaxNo\":\"Tax4\",\"VndrFourthContactNo\":\"9784561235\",\"VndrFourthType\":\"INDIVIDUAL\"},\"Property\":{\"TitleType\":\"KEKAL\",\"CertifiedPlanNo\":\"\",\"LotNo\":\"\",\"PreviouslyKnownAs\":\"\",\"State\":\"\",\"Area\":\"\",\"BPM\":\"\",\"GovSurvyPlan\":\"\",\"LotArea\":\"12345\",\"Developer\":\"\",\"Project\":\"\",\"DevLicenseNo\":\"\",\"DevSolicitor\":\"\",\"DevSoliLoc\":\"\",\"TitleSearchDate\":\"\",\"DSCTransfer\":\"\",\"DRCTransfer\":\"\",\"FourteenADate\":\"\",\"DRTLRegistry\":\"\",\"PropertyCharged\":\"\",\"BankName\":\"\",\"Branch\":\"\",\"PAName\":\"\",\"PresentationNo\":\"\",\"ExistChargeRef\":\"\",\"ReceiptType\":\"\",\"ReceiptNo\":\"\",\"ReceiptDate\":\"\",\"PurchasePrice\":\"1452\",\"AdjValue\":\"\",\"VndrPrevSPAValue\":\"\",\"Deposit\":\"\",\"BalPurPrice\":\"\",\"LoanAmount\":\"\",\"LoanCaseNo\":\"1234\",\"DiffSum\":\"\",\"RedAmt\":\"\",\"RedDate\":\"\",\"DefRdmptSum\":\"\"},\"LoanPrinciple\":{\"ReqRedStatement\":\"\",\"RedStmtDate\":\"\",\"RedPayDate\":\"\",\"RepByFirm\":\"\",\"LoanCaseNo\":\"1234\",\"Project\":\"\",\"MasterBankName\":\"\",\"BranchName\":\"\",\"Address\":\"\",\"PAName\":\"\",\"BankRef\":\"\",\"BankInsDate\":\"2015/10/11\",\"LOFDate\":\"\",\"BankSolicitor\":\"\",\"SoliLoc\":\"\",\"SoliRef\":\"\",\"TypeofLoan\":\"\",\"TypeofFacility\":\"\",\"FacilityAmt\":\"\",\"Repaymt\":\"\",\"IntrstRate\":\"\",\"MonthlyInstmt\":\"\",\"TermLoanAmt\":\"\",\"Interest\":\"\",\"ODLoan\":\"\",\"MRTA\":\"\",\"BankGuarantee\":\"\",\"LetterofCredit\":\"\",\"TrustReceipt\":\"\",\"Others\":\"\",\"LoanDet1\":\"\",\"LoanDet2\":\"\",\"LoanDet3\":\"\",\"LoanDet4\":\"\",\"LoanDet5\":\"\"},\"LoanSubsidary\":{\"LoanDocForBankExe\":\"Exe 1\",\"FaciAgreeDate\":\"\",\"LoanDocRetFromBank\":\"\",\"DischargeofCharge\":\"\",\"FirstTypeofFacility\":\"\",\"FirstFacilityAmt\":\"\",\"FirstRepaymt\":\"\",\"FirstIntrstRate\":\"\",\"FirstMonthlyInstmt\":\"1500\",\"FirstTermLoanAmt\":\"\",\"FirstInterest\":\"\",\"FirstODLoan\":\"\",\"FirstMRTA\":\"\",\"FirstBankGuarantee\":\"\",\"FirstLetterofCredit\":\"\",\"FirstTrustReceipt\":\"\",\"FirstOthers\":\"Sample\",\"SecTypeofFacility\":\"\",\"SecFacilityAmt\":\"\",\"SecRepaymt\":\"\",\"SecIntrstRate\":\"12%\",\"SecMonthlyInstmt\":\"\",\"SecTermLoanAmt\":\"\",\"SecInterest\":\"\",\"SecODLoan\":\"\",\"SecMRTA\":\"\",\"SecBankGuarantee\":\"\",\"SecLetterofCredit\":\"\",\"SecTrustReceipt\":\"45A\",\"SecOthers\":\"\",\"ThirdTypeofFacility\":\"Sample_Data\",\"ThirdFacilityAmt\":\"\",\"ThirdRepaymt\":\"\",\"ThirdIntrstRate\":\"\",\"ThirdMonthlyInstmt\":\"\",\"ThirdTermLoanAmt\":\"587.15\",\"ThirdInterest\":\"\",\"ThirdODLoan\":\"\",\"ThirdMRTA\":\"\",\"ThirdBankGuarantee\":\"\",\"ThirdLetterofCredit\":\"\",\"ThirdTrustReceipt\":\"\",\"ThirdOthers\":\"\",\"FourthTypeofFacility\":\"Sample4\",\"FourthFacilityAmt\":\"\",\"FourthRepaymt\":\"15\",\"FourthIntrstRate\":\"\",\"FourthMonthlyInstmt\":\"\",\"FourthTermLoanAmt\":\"\",\"FourthInterest\":\"21\",\"FourthODLoan\":\"\",\"FourthMRTA\":\"\",\"FourthBankGuarantee\":\"\",\"FourthLetterofCredit\":\"\",\"FourthTrustReceipt\":\"\",\"FourthOthers\":\"\",\"FifthTypeofFacility\":\"Sample 5\",\"FifthFacilityAmt\":\"\",\"FifthRepaymt\":\"\",\"FifthIntrstRate\":\"\",\"FifthMonthlyInstmt\":\"\",\"FifthTermLoanAmt\":\"\",\"FifthInterest\":\"10\",\"FifthODLoan\":\"\",\"FifthMRTA\":\"\",\"FifthBankGuarantee\":\"\",\"FifthLetterofCredit\":\"\",\"FifthTrustReceipt\":\"Test\",\"FifthOthers\":\"\"}}]";
    String json_element = "[{\"Case\":" + "\"" + jsonResponseconfirm.get("Case").toString() + "\",\"CaseType\":"
            + "\"" + jsonResponseconfirm.get("CaseType").toString()
            + "\",\"CaseStatus\":\"OPEN\",\"FileOpenDate\":\"10/10/2015 12:00:00 AM\",\"CaseFileNo\":\"JJ/1500000001/\",\"KIV\":\"\",\"TabId\":\"3\",\"Details\":{\"LA\":\"\",\"MANAGER\":\"\",\"InCharge\":\"\",\"CustomerService\":\"\",\"CaseType\":\"SPA-BUY-DEV-APT-C\",\"FileLocation\":\"\",\"FileClosedDate\":\"\",\"VendAcqDt\":\"\",\"CompanyBuisnessSearch\":\"\",\"BankWindingSearch\":\"\"},\"Purchaser\":{\"PurRepresentedByFirm\":\"N\",\"PurlawyerRepresented\":\"N\",\"PurSPADate\":\"1/1/1900 12:00:00 AM\",\"PurEntryOfPrivateCaveat\":\"Chase\",\"PurWithOfPrivateCaveat\":\"Rane\",\"PurFirstName\":\"Name1\",\"PurFirstID\":\"Id1\",\"PurFirstTaxNo\":\"Tax1\",\"PurFirstContactNo\":\"9784561233\",\"PurFirstType\":\"CORPORATE\",\"PurSecName\":\"Name2\",\"PurSecID\":\"Id2\",\"PurSecTaxNo\":\"Tax2\",\"PurSecContactNo\":\"9784561234\",\"PurSecType\":\"INDIVIDUAL\",\"PurThirdName\":\"Name3\",\"PurThirdID\":\"Id3\",\"PurThirdTaxNo\":\"Tax3\",\"PurThirdContactNo\":\"9784561234\",\"PurThirdType\":\"INDIVIDUAL\",\"PurFourthName\":\"Name4\",\"PurFourthID\":\"Id4\",\"PurFourthTaxNo\":\"Tax4\",\"PurFourthContactNo\":\"9784561235\",\"PurFourthType\":\"INDIVIDUAL\"},\"Vendor\":{\""
            + "VndrRepresentedByFirm" + "\":" + "\"" + f_yes + "\",\"" + "VndrlawyerRepresented" + "\":" + "\""
            + l_yes + "\",\"" + "VndrReqDevConsent" + "\":" + "\"" + request_developer.getText().toString()
            + "\",\"" + "VndrReceiveDevConsent" + "\":" + "\"" + receive_developer.getText().toString()
            + "\",\"" + "VndrFirstName" + "\":" + "\"" + name1.getText().toString() + "\",\"" + "VndrFirstID"
            + "\":" + "\"" + brn_no1.getText().toString() + "\",\"" + "VndrFirstTaxNo" + "\":" + "\""
            + tax_no1.getText().toString() + "\",\"" + "VndrFirstContactNo" + "\":" + "\""
            + contact_no1.getText().toString() + "\",\"" + "VndrFirstType" + "\":" + "\"" + spinnertype1
            + "\",\"" + "VndrSecName" + "\":" + "\"" + name2.getText().toString() + "\",\"" + "VndrSecID"
            + "\":" + "\"" + brn_no2.getText().toString() + "\",\"" + "VndrSecTaxNo" + "\":" + "\""
            + tax_no2.getText().toString() + "\",\"" + "VndrSecContactNo" + "\":" + "\""
            + contact_no2.getText().toString() + "\",\"" + "VndrSecType" + "\":" + "\"" + spinnertype2 + "\",\""
            + "VndrThirdName" + "\":" + "\"" + name3.getText().toString() + "\",\"" + "VndrThirdID" + "\":"
            + "\"" + brn_no3.getText().toString() + "\",\"" + "VndrThirdTaxNo" + "\":" + "\""
            + tax_no3.getText().toString() + "\",\"" + "VndrThirdContactNo" + "\":" + "\""
            + contact_no3.getText().toString() + "\",\"" + "VndrThirdType" + "\":" + "\"" + spinnertype3
            + "\",\"" + "VndrFourthName" + "\":" + "\"" + name4.getText().toString() + "\",\"" + "VndrFourthID"
            + "\":" + "\"" + brn_no4.getText().toString() + "\",\"" + "VndrFourthTaxNo" + "\":" + "\""
            + tax_no4.getText().toString() + "\",\"" + "VndrFourthContactNo" + "\":" + "\""
            + contact_no4.getText().toString() + "\",\"" + "VndrFourthType" + "\":" + "\"" + spinnertype4
            + "\"},\"Property\":{\"TitleType\":\"KEKAL\",\"CertifiedPlanNo\":\"\",\"LotNo\":\"\",\"PreviouslyKnownAs\":\"\",\"State\":\"\",\"Area\":\"\",\"BPM\":\"\",\"GovSurvyPlan\":\"\",\"LotArea\":\"12345\",\"Developer\":\"\",\"Project\":\"\",\"DevLicenseNo\":\"\",\"DevSolicitor\":\"\",\"DevSoliLoc\":\"\",\"TitleSearchDate\":\"\",\"DSCTransfer\":\"\",\"DRCTransfer\":\"\",\"FourteenADate\":\"\",\"DRTLRegistry\":\"\",\"PropertyCharged\":\"\",\"BankName\":\"\",\"Branch\":\"\",\"PAName\":\"\",\"PresentationNo\":\"\",\"ExistChargeRef\":\"\",\"ReceiptType\":\"\",\"ReceiptNo\":\"\",\"ReceiptDate\":\"\",\"PurchasePrice\":\"1452\",\"AdjValue\":\"\",\"VndrPrevSPAValue\":\"\",\"Deposit\":\"\",\"BalPurPrice\":\"\",\"LoanAmount\":\"\",\"LoanCaseNo\":\"1234\",\"DiffSum\":\"\",\"RedAmt\":\"\",\"RedDate\":\"\",\"DefRdmptSum\":\"\"},\"LoanPrinciple\":{\"ReqRedStatement\":\"\",\"RedStmtDate\":\"\",\"RedPayDate\":\"\",\"RepByFirm\":\"\",\"LoanCaseNo\":\"1234\",\"Project\":\"\",\"MasterBankName\":\"\",\"BranchName\":\"\",\"Address\":\"\",\"PAName\":\"\",\"BankRef\":\"\",\"BankInsDate\":\"2015/10/11\",\"LOFDate\":\"\",\"BankSolicitor\":\"\",\"SoliLoc\":\"\",\"SoliRef\":\"\",\"TypeofLoan\":\"\",\"TypeofFacility\":\"\",\"FacilityAmt\":\"\",\"Repaymt\":\"\",\"IntrstRate\":\"\",\"MonthlyInstmt\":\"\",\"TermLoanAmt\":\"\",\"Interest\":\"\",\"ODLoan\":\"\",\"MRTA\":\"\",\"BankGuarantee\":\"\",\"LetterofCredit\":\"\",\"TrustReceipt\":\"\",\"Others\":\"\",\"LoanDet1\":\"\",\"LoanDet2\":\"\",\"LoanDet3\":\"\",\"LoanDet4\":\"\",\"LoanDet5\":\"\"},\"LoanSubsidary\":{\"LoanDocForBankExe\":\"Exe 1\",\"FaciAgreeDate\":\"\",\"LoanDocRetFromBank\":\"\",\"DischargeofCharge\":\"\",\"FirstTypeofFacility\":\"\",\"FirstFacilityAmt\":\"\",\"FirstRepaymt\":\"\",\"FirstIntrstRate\":\"\",\"FirstMonthlyInstmt\":\"1500\",\"FirstTermLoanAmt\":\"\",\"FirstInterest\":\"\",\"FirstODLoan\":\"\",\"FirstMRTA\":\"\",\"FirstBankGuarantee\":\"\",\"FirstLetterofCredit\":\"\",\"FirstTrustReceipt\":\"\",\"FirstOthers\":\"Sample\",\"SecTypeofFacility\":\"\",\"SecFacilityAmt\":\"\",\"SecRepaymt\":\"\",\"SecIntrstRate\":\"12%\",\"SecMonthlyInstmt\":\"\",\"SecTermLoanAmt\":\"\",\"SecInterest\":\"\",\"SecODLoan\":\"\",\"SecMRTA\":\"\",\"SecBankGuarantee\":\"\",\"SecLetterofCredit\":\"\",\"SecTrustReceipt\":\"45A\",\"SecOthers\":\"\",\"ThirdTypeofFacility\":\"Sample_Data\",\"ThirdFacilityAmt\":\"\",\"ThirdRepaymt\":\"\",\"ThirdIntrstRate\":\"\",\"ThirdMonthlyInstmt\":\"\",\"ThirdTermLoanAmt\":\"587.15\",\"ThirdInterest\":\"\",\"ThirdODLoan\":\"\",\"ThirdMRTA\":\"\",\"ThirdBankGuarantee\":\"\",\"ThirdLetterofCredit\":\"\",\"ThirdTrustReceipt\":\"\",\"ThirdOthers\":\"\",\"FourthTypeofFacility\":\"Sample4\",\"FourthFacilityAmt\":\"\",\"FourthRepaymt\":\"15\",\"FourthIntrstRate\":\"\",\"FourthMonthlyInstmt\":\"\",\"FourthTermLoanAmt\":\"\",\"FourthInterest\":\"21\",\"FourthODLoan\":\"\",\"FourthMRTA\":\"\",\"FourthBankGuarantee\":\"\",\"FourthLetterofCredit\":\"\",\"FourthTrustReceipt\":\"\",\"FourthOthers\":\"\",\"FifthTypeofFacility\":\"Sample 5\",\"FifthFacilityAmt\":\"\",\"FifthRepaymt\":\"\",\"FifthIntrstRate\":\"\",\"FifthMonthlyInstmt\":\"\",\"FifthTermLoanAmt\":\"\",\"FifthInterest\":\"10\",\"FifthODLoan\":\"\",\"FifthMRTA\":\"\",\"FifthBankGuarantee\":\"\",\"FifthLetterofCredit\":\"\",\"FifthTrustReceipt\":\"Test\",\"FifthOthers\":\"\"}}]";

    Log.e("pur_string", json_element);

    JSONObject valuesObject = null;
    JSONArray list = null;
    try {
        list = new JSONArray(json_element);
        valuesObject = list.getJSONObject(0);

        /*valuesObject.put("PurSPADate",spa_date.getText().toString());
        valuesObject.put("PurEntryOfPrivateCaveat", entry_private_caveat.getText().toString());
        valuesObject.put("PurWithOfPrivateCaveat", withdrawal_private_caveat.getText().toString());
        valuesObject.put("PurFirstName", name1.getText().toString());
        valuesObject.put("PurFirstID", brn_no1.getText().toString());
        valuesObject.put("PurFirstTaxNo", tax_no1.getText().toString());
        valuesObject.put("PurFirstContactNo", contact_no1.getText().toString());*/

        list.put(valuesObject);

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    RequestParams params = new RequestParams();
    params.put("sJsonInput", list.toString());
    System.out.println("params");

    RestService.post(CONFIRM_BTN_REQUEST, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);
            System.out.println("onFailure process case purchaser");
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Add purchaser Confirmed");
            System.out.println(arg2);

            // Find status Response
            try {
                StatusResult = jsonResponse.getString("Result").toString();
                messageDisplay = jsonResponse.getString("DisplayMessage").toString();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (StatusResult.equals("SUCCESS")) {
                Intent iAddBack = new Intent(ProcessCaseVendor.this, ProcessCaseProperty.class);
                startActivity(iAddBack);
                Toast.makeText(ProcessCaseVendor.this, messageDisplay, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(ProcessCaseVendor.this, messageDisplay, Toast.LENGTH_SHORT).show();

            }
        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Purchaser Add Response");
            System.out.println(arg0);
            return null;
        }
    });
}

From source file:com.twitterdev.rdio.app.RdioApp.java

/**
 * Get the current user, and load their collection to start playback with.
 * Requires authorization and the Rdio app to be installed.
 *//*from   w w  w .  java2s.c om*/

private void LoadMoreTracks() {
    if (accessToken == null || accessTokenSecret == null) {
        Log.i(TAG, "Anonymous user! No more tracks to play.");

        // Notify the user we're out of tracks
        //Toast.makeText(this, getString(R.string.no_more_tracks), Toast.LENGTH_LONG).show();

        // Then helpfully point them to the market to go install Rdio ;)
        accessToken = accessTokenSecret = null;
        Intent myIntent = new Intent(RdioApp.this, OAuth1WebViewActivity.class);
        myIntent.putExtra(OAuth1WebViewActivity.EXTRA_CONSUMER_KEY, Constants.appKey);
        myIntent.putExtra(OAuth1WebViewActivity.EXTRA_CONSUMER_SECRET, Constants.appSecret);
        RdioApp.this.startActivityForResult(myIntent, 1);

        //finish();
        return;
    }

    showGetCollectionDialog();
    List<NameValuePair> args = new LinkedList<NameValuePair>();

    //

    //args.add(new BasicNameValuePair("query", where.get(1)));
    args.add(new BasicNameValuePair("type", "Track"));
    //Log.v("args", args.toString());
    rdio.apiCall("getTopCharts", args, new RdioApiCallback() {
        @Override
        public void onApiFailure(String methodName, Exception e) {
            dismissGetCollectionDialog();
            Log.e(TAG, methodName + " failed: ", e);
        }

        @Override
        public void onApiSuccess(JSONObject result) {
            try {
                Log.v("result", result.toString());
                //result = result.getJSONObject("result");

                //                    result = result.getJSONObject(collectionKey);
                List<Track> trackKeys = new LinkedList<Track>();
                JSONArray tracks = result.getJSONArray("result");
                Log.v("results", tracks.toString());
                for (int i = 0; i < tracks.length(); i++) {
                    JSONObject trackObject = tracks.getJSONObject(i);
                    String key = trackObject.getString("key");
                    final String name = trackObject.getString("name");
                    final String artist = trackObject.getString("artist");
                    String album = trackObject.getString("album");
                    String albumArt = trackObject.getString("icon");
                    Log.d(TAG, "Found track: " + key + " => " + trackObject.getString("name"));

                    trackKeys.add(new Track(key, artist, album, name, albumArt));
                }
                if (trackKeys.size() > 1)
                    trackQueue.addAll(trackKeys);
                dismissGetCollectionDialog();

                next(true);

            } catch (Exception e) {
                dismissGetCollectionDialog();
                Log.e(TAG, "Failed to handle JSONObject: ");
            }
        }
    });
}

From source file:com.redip.servlet.GetLinkToDoc.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    String id = policy.sanitize(request.getParameter("idNC"));
    String idName = ParameterParserUtil.parseStringParam(id, "");

    ApplicationContext appContext = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext());
    IQualityNonconformitiesDocService docService = appContext.getBean(IQualityNonconformitiesDocService.class);
    List<QualityNonconformitiesDoc> myDocs = docService.getDocLink(Integer.valueOf(id));

    try {/*from w ww. j  ava 2s  .co m*/
        JSONArray docList = new JSONArray();

        try {
            for (QualityNonconformitiesDoc myDoc : myDocs) {
                JSONObject doc = new JSONObject();
                doc.put("link", myDoc.getLinkToDoc());
                doc.put("id", myDoc.getIdQualityNonconformitiesDoc());
                docList.put(doc);
            }
        } catch (Exception ex) {
            response.setContentType("text/html");
            response.getWriter().print(ex);

        }
        response.setContentType("application/json");
        response.getWriter().print(docList.toString());
    } catch (Exception e) {
        Logger.log(GetInvariantList.class.getName(), Level.FATAL, "" + e);
        response.setContentType("text/html");
        response.getWriter().print(e.getMessage());
    }
}

From source file:gr.cti.android.experimentation.controller.api.RestApiDataController.java

private JSONArray getExperimentData(final String experiment, final int deviceId, final String after,
        final String to, final int accuracy) {
    final String format = getFormat(accuracy);
    final DecimalFormat df = new DecimalFormat(format);
    LOGGER.info("format:" + format);
    final long start = parseDateMillis(after);
    final long end = parseDateMillis(to);

    final Set<Result> results;
    if (deviceId == 0) {
        results = resultRepository.findByExperimentIdAndTimestampAfter(Integer.parseInt(experiment), start);
    } else {//from ww w .j ava2 s  .  com
        results = resultRepository.findByExperimentIdAndDeviceIdAndTimestampAfterOrderByTimestampAsc(
                Integer.parseInt(experiment), deviceId, start);
    }

    final JSONArray addressPoints = doCalculations(results, end, df);
    LOGGER.info(addressPoints.toString());
    return addressPoints;
}

From source file:gr.cti.android.experimentation.controller.api.RestApiDataController.java

private JSONArray getAllData(final int deviceId, final String after, final String to, final int accuracy) {
    final String format = getFormat(accuracy);

    DecimalFormat df = new DecimalFormat(format);
    long start = parseDateMillis(after);
    long end = parseDateMillis(to);

    final Set<Result> results;
    if (deviceId == 0) {
        results = new HashSet<>();
    } else {//  w  w  w . j  a  va2s.  c o  m
        results = resultRepository.findByDeviceIdAndTimestampAfterOrderByTimestampAsc(deviceId, start);
    }

    final JSONArray addressPoints = doCalculations(results, end, df);
    LOGGER.info(addressPoints.toString());
    return addressPoints;
}

From source file:com.kakao.kakaolink.KakaoTalkLinkMessageBuilder.java

/**
 *  ?   ?  ?  ./*from  www.  j  av a 2  s .  c o m*/
 * @return  ?  
 * @throws KakaoParameterException ?     ?.
 */
public String build() throws KakaoParameterException {
    try {
        if (linkObjList.isEmpty())
            throw new KakaoParameterException(KakaoParameterException.ERROR_CODE.CORE_PARAMETER_MISSING,
                    "call addAppLink or addWebLink or addAppButton or addWebButton or addText or addImage before calling build().");

        final StringBuilder talkLinkURL = new StringBuilder(KakaoTalkLinkProtocol.KAKAO_TALK_LINK_URL)
                .append("?");
        talkLinkURL.append(KakaoTalkLinkProtocol.LINK_VER).append("=")
                .append(URLEncoder.encode(KakaoTalkLinkProtocol.LINK_VERSION, KakaoTalkLinkProtocol.ENCODING))
                .append("&");
        talkLinkURL.append(KakaoTalkLinkProtocol.API_VER).append("=")
                .append(URLEncoder.encode(KakaoTalkLinkProtocol.API_VERSION, KakaoTalkLinkProtocol.ENCODING))
                .append("&");
        talkLinkURL.append(KakaoTalkLinkProtocol.APP_KEY).append("=")
                .append(URLEncoder.encode(appKey, KakaoTalkLinkProtocol.ENCODING)).append("&");
        talkLinkURL.append(KakaoTalkLinkProtocol.APP_VER).append("=")
                .append(URLEncoder.encode(appVer, KakaoTalkLinkProtocol.ENCODING)).append("&");
        talkLinkURL.append(KakaoTalkLinkProtocol.FORWARDABLE).append("=")
                .append(URLEncoder.encode(String.valueOf(forwardable), KakaoTalkLinkProtocol.ENCODING))
                .append("&");
        talkLinkURL.append(KakaoTalkLinkProtocol.EXTRAS).append("=")
                .append(URLEncoder.encode(extra.toString(), KakaoTalkLinkProtocol.ENCODING)).append("&");

        talkLinkURL.append(KakaoTalkLinkProtocol.OBJS).append("=");
        final JSONArray jsonArray = new JSONArray();
        for (LinkObject linkObject : linkObjList) {
            jsonArray.put(linkObject.createJSONObject());
        }

        Logger.d("====================================================================================");
        Logger.d("++ LINK_VERSION : " + KakaoTalkLinkProtocol.LINK_VERSION);
        Logger.d("++ API_VERSION : " + KakaoTalkLinkProtocol.API_VERSION);
        Logger.d("++ appKey : " + appKey);
        Logger.d("++ appVer : " + appVer);
        Logger.d("++  : " + extra);
        Logger.d("++ linkObjList = %s", jsonArray.toString());
        Logger.d("====================================================================================");
        final String encodedValue = URLEncoder.encode(jsonArray.toString(), KakaoTalkLinkProtocol.ENCODING);
        return talkLinkURL.append(encodedValue).toString();

    } catch (UnsupportedEncodingException e) {
        throw new KakaoParameterException(KakaoParameterException.ERROR_CODE.UNSUPPORTED_ENCODING, e);
    } catch (JSONException e) {
        throw new KakaoParameterException(KakaoParameterException.ERROR_CODE.JSON_PARSING_ERROR, e);
    }
}

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

private void addComments() {
    try {/*from   w w  w .  ja  v  a2s .  c  o  m*/
        if (getActivity() == null)
            return;
        JSONArray commentJSONArray = commentData.getJSONObject().getJSONArray("data");
        if (commentJSONArray.length() > 0) {
            imageUpvote.setVisibility(View.VISIBLE);
            imageDownvote.setVisibility(View.VISIBLE);
            imageComment.setVisibility(View.VISIBLE);
        }
        commentArray = new ArrayList<JSONParcelable>();
        Log.d("calling indent function", commentJSONArray.toString());
        ArrayList<JSONObject> childrenArray = new ArrayList<JSONObject>();
        for (int i = 0; i < commentJSONArray.length(); i++) {
            childrenArray.add(commentJSONArray.getJSONObject(i));
        }
        if (sort.equals("New"))
            Collections.sort(childrenArray, new JSONNewestComparator());
        else if (sort.equals("Top"))
            Collections.sort(childrenArray, new JSONTopComparator());
        for (JSONObject aChildrenArray : childrenArray) {
            getIndents(aChildrenArray, 0);
        }
        commentAdapter.addAll(commentArray);
    } catch (JSONException e) {
        Log.e("Error1!", e.toString());
    }
}

From source file:edu.mbl.jif.imaging.mmtiff.MultipageTiffReader.java

public void rewriteDisplaySettings(JSONArray settings) throws IOException, JSONException {
    if (writingFinished_) {
        long offset = readOffsetHeaderAndOffset(MultipageTiffWriter.DISPLAY_SETTINGS_OFFSET_HEADER, 16);
        int numReservedBytes = readIntoBuffer(offset + 4, 4).getInt(0);
        byte[] blank = new byte[numReservedBytes];
        for (int i = 0; i < blank.length; i++) {
            blank[i] = 0;//from   w  w w . j  a  v  a  2s. c  o m
        }
        fileChannel_.write(ByteBuffer.wrap(blank), offset + 8);
        byte[] bytes = getBytesFromString(settings.toString());
        ByteBuffer buffer = ByteBuffer.wrap(bytes);
        fileChannel_.write(buffer, offset + 8);
    }
    displayAndComments_.put("Channels", settings);
}