Example usage for java.lang CharSequence toString

List of usage examples for java.lang CharSequence toString

Introduction

In this page you can find the example usage for java.lang CharSequence toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:de.schildbach.pte.AbstractHafasMobileProvider.java

protected final QueryTripsResult jsonTripSearch(Location from, @Nullable Location via, Location to,
        final Date time, final boolean dep, final @Nullable Set<Product> products, final String moreContext)
        throws IOException {
    if (!from.hasId()) {
        from = jsonTripSearchIdentify(from);
        if (from == null)
            return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT),
                    QueryTripsResult.Status.UNKNOWN_FROM);
    }//w  ww  . j ava  2s.co  m

    if (via != null && !via.hasId()) {
        via = jsonTripSearchIdentify(via);
        if (via == null)
            return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT),
                    QueryTripsResult.Status.UNKNOWN_VIA);
    }

    if (!to.hasId()) {
        to = jsonTripSearchIdentify(to);
        if (to == null)
            return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT),
                    QueryTripsResult.Status.UNKNOWN_TO);
    }

    final Calendar c = new GregorianCalendar(timeZone);
    c.setTime(time);
    final CharSequence outDate = jsonDate(c);
    final CharSequence outTime = jsonTime(c);
    final CharSequence outFrwdKey = "1.11".equals(apiVersion) ? "outFrwd" : "frwd";
    final CharSequence outFrwd = Boolean.toString(dep);
    final CharSequence jnyFltr = productsString(products);
    final CharSequence jsonContext = moreContext != null ? "\"ctxScr\":" + JSONObject.quote(moreContext) + ","
            : "";
    final String request = wrapJsonApiRequest("TripSearch", "{" //
            + jsonContext //
            + "\"depLocL\":[" + jsonLocation(from) + "]," //
            + "\"arrLocL\":[" + jsonLocation(to) + "]," //
            + (via != null ? "\"viaLocL\":[{\"loc\":" + jsonLocation(via) + "}]," : "") //
            + "\"outDate\":\"" + outDate + "\"," //
            + "\"outTime\":\"" + outTime + "\"," //
            + "\"" + outFrwdKey + "\":" + outFrwd + "," //
            + "\"jnyFltrL\":[{\"value\":\"" + jnyFltr + "\",\"mode\":\"BIT\",\"type\":\"PROD\"}]," //
            + "\"gisFltrL\":[{\"mode\":\"FB\",\"profile\":{\"type\":\"F\",\"linDistRouting\":false,\"maxdist\":2000},\"type\":\"P\"}]," //
            + "\"getPolyline\":false,\"getPasslist\":true,\"getIST\":false,\"getEco\":false,\"extChgTime\":-1}", //
            false);

    final HttpUrl url = checkNotNull(mgateEndpoint);
    final CharSequence page = httpClient.get(url, request, "application/json");

    try {
        final JSONObject head = new JSONObject(page.toString());
        final String headErr = head.optString("err", null);
        if (headErr != null)
            throw new RuntimeException(headErr);
        final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT, head.getString("ver"), null, 0,
                null);

        final JSONArray svcResList = head.getJSONArray("svcResL");
        checkState(svcResList.length() == 1);
        final JSONObject svcRes = svcResList.optJSONObject(0);
        checkState("TripSearch".equals(svcRes.getString("meth")));
        final String err = svcRes.getString("err");
        if (!"OK".equals(err)) {
            final String errTxt = svcRes.getString("errTxt");
            log.debug("Hafas error: {} {}", err, errTxt);
            if ("H890".equals(err)) // No connections found.
                return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
            if ("H891".equals(err)) // No route found (try entering an intermediate station).
                return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
            if ("H895".equals(err)) // Departure/Arrival are too near.
                return new QueryTripsResult(header, QueryTripsResult.Status.TOO_CLOSE);
            if ("H9220".equals(err)) // Nearby to the given address stations could not be found.
                return new QueryTripsResult(header, QueryTripsResult.Status.UNRESOLVABLE_ADDRESS);
            if ("H9240".equals(err)) // HAFAS Kernel: Internal error.
                return new QueryTripsResult(header, QueryTripsResult.Status.SERVICE_DOWN);
            if ("H9360".equals(err)) // Date outside of the timetable period.
                return new QueryTripsResult(header, QueryTripsResult.Status.INVALID_DATE);
            if ("H9380".equals(err)) // Departure/Arrival/Intermediate or equivalent stations def'd more
                                     // than once.
                return new QueryTripsResult(header, QueryTripsResult.Status.TOO_CLOSE);
            if ("FAIL".equals(err) && "HCI Service: request failed".equals(errTxt))
                return new QueryTripsResult(header, QueryTripsResult.Status.SERVICE_DOWN);
            throw new RuntimeException(err + " " + errTxt);
        }
        final JSONObject res = svcRes.getJSONObject("res");

        final JSONObject common = res.getJSONObject("common");
        /* final List<String[]> remarks = */ parseRemList(common.getJSONArray("remL"));
        final List<Location> locations = parseLocList(common.getJSONArray("locL"));
        final List<String> operators = parseOpList(common.getJSONArray("opL"));
        final List<Line> lines = parseProdList(common.getJSONArray("prodL"), operators);

        final JSONArray outConList = res.optJSONArray("outConL");
        final List<Trip> trips = new ArrayList<>(outConList.length());
        for (int iOutCon = 0; iOutCon < outConList.length(); iOutCon++) {
            final JSONObject outCon = outConList.getJSONObject(iOutCon);
            final Location tripFrom = locations.get(outCon.getJSONObject("dep").getInt("locX"));
            final Location tripTo = locations.get(outCon.getJSONObject("arr").getInt("locX"));

            c.clear();
            ParserUtils.parseIsoDate(c, outCon.getString("date"));
            final Date baseDate = c.getTime();

            final JSONArray secList = outCon.optJSONArray("secL");
            final List<Trip.Leg> legs = new ArrayList<>(secList.length());
            for (int iSec = 0; iSec < secList.length(); iSec++) {
                final JSONObject sec = secList.getJSONObject(iSec);
                final String secType = sec.getString("type");

                final JSONObject secDep = sec.getJSONObject("dep");
                final Stop departureStop = parseJsonStop(secDep, locations, c, baseDate);

                final JSONObject secArr = sec.getJSONObject("arr");
                final Stop arrivalStop = parseJsonStop(secArr, locations, c, baseDate);

                final Trip.Leg leg;
                if ("JNY".equals(secType)) {
                    final JSONObject jny = sec.getJSONObject("jny");
                    final Line line = lines.get(jny.getInt("prodX"));
                    final String dirTxt = jny.optString("dirTxt", null);
                    final Location destination = dirTxt != null
                            ? new Location(LocationType.ANY, null, null, dirTxt)
                            : null;

                    final JSONArray stopList = jny.getJSONArray("stopL");
                    checkState(stopList.length() >= 2);
                    final List<Stop> intermediateStops = new ArrayList<>(stopList.length());
                    for (int iStop = 1; iStop < stopList.length() - 1; iStop++) {
                        final JSONObject stop = stopList.getJSONObject(iStop);
                        final Stop intermediateStop = parseJsonStop(stop, locations, c, baseDate);
                        intermediateStops.add(intermediateStop);
                    }

                    leg = new Trip.Public(line, destination, departureStop, arrivalStop, intermediateStops,
                            null, null);
                } else if ("WALK".equals(secType) || "TRSF".equals(secType)) {
                    final JSONObject gis = sec.getJSONObject("gis");
                    final int distance = gis.optInt("dist", 0);
                    leg = new Trip.Individual(Trip.Individual.Type.WALK, departureStop.location,
                            departureStop.getDepartureTime(), arrivalStop.location,
                            arrivalStop.getArrivalTime(), null, distance);
                } else {
                    throw new IllegalStateException("cannot handle type: " + secType);
                }

                legs.add(leg);
            }

            final JSONObject trfRes = outCon.optJSONObject("trfRes");
            final List<Fare> fares = new LinkedList<>();
            if (trfRes != null) {
                final JSONArray fareSetList = trfRes.getJSONArray("fareSetL");
                for (int iFareSet = 0; iFareSet < fareSetList.length(); iFareSet++) {
                    final JSONObject fareSet = fareSetList.getJSONObject(iFareSet);
                    final String fareSetName = fareSet.optString("name", null);
                    final String fareSetDescription = fareSet.optString("desc", null);
                    if (fareSetName != null || fareSetDescription != null) {
                        final JSONArray fareList = fareSet.getJSONArray("fareL");
                        for (int iFare = 0; iFare < fareList.length(); iFare++) {
                            final JSONObject jsonFare = fareList.getJSONObject(iFare);
                            final String name = jsonFare.getString("name");
                            final JSONArray ticketList = jsonFare.optJSONArray("ticketL");
                            if (ticketList != null) {
                                for (int iTicket = 0; iTicket < ticketList.length(); iTicket++) {
                                    final JSONObject jsonTicket = ticketList.getJSONObject(iTicket);
                                    final String ticketName = jsonTicket.getString("name");
                                    final Currency currency = Currency.getInstance(jsonTicket.getString("cur"));
                                    final float price = jsonTicket.getInt("prc") / 100f;
                                    final Fare fare = parseJsonTripFare(name, fareSetDescription, ticketName,
                                            currency, price);
                                    if (fare != null)
                                        fares.add(fare);
                                }
                            } else {
                                final Currency currency = Currency.getInstance(jsonFare.getString("cur"));
                                final float price = jsonFare.getInt("prc") / 100f;
                                final Fare fare = parseJsonTripFare(fareSetName, fareSetDescription, name,
                                        currency, price);
                                if (fare != null)
                                    fares.add(fare);
                            }
                        }
                    }
                }
            }

            final Trip trip = new Trip(null, tripFrom, tripTo, legs, fares, null, null);
            trips.add(trip);
        }

        final JsonContext context = new JsonContext(from, via, to, time, dep, products,
                res.optString("outCtxScrF"), res.optString("outCtxScrB"));
        return new QueryTripsResult(header, null, from, null, to, context, trips);
    } catch (final JSONException x) {
        throw new ParserException("cannot parse json: '" + page + "' on " + url, x);
    }
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

private void testNotificationExtenderServiceOverridePropertiesWithSummary() throws Exception {
    Bundle bundle = getBaseNotifBundle("UUID1");
    bundle.putString("grp", "test1");

    startNotificationExtender(createInternalPayloadBundle(bundle),
            NotificationExtenderServiceOverrideProperties.class);

    bundle = getBaseNotifBundle("UUID2");
    bundle.putString("grp", "test1");

    startNotificationExtender(createInternalPayloadBundle(bundle),
            NotificationExtenderServiceOverrideProperties.class);

    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();

    // Test - First notification should be the summary
    PostedNotification postedSummaryNotification = postedNotifsIterator.next().getValue();
    Assert.assertEquals("2 new messages", postedSummaryNotification.getShadow().getContentText());
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
        Assert.assertEquals(Notification.FLAG_GROUP_SUMMARY,
                postedSummaryNotification.notif.flags & Notification.FLAG_GROUP_SUMMARY);

    // Test - Make sure summary build saved and used the developer's extender settings for the body and title
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
        CharSequence[] lines = postedSummaryNotification.notif.extras
                .getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
        for (CharSequence line : lines)
            Assert.assertEquals("[Modified Tile] [Modified Body(ContentText)]", line.toString());
    }/* w  ww .j a  v a  2s .c  o  m*/
}

From source file:com.appolis.receiving.AcReceiveOptionMove.java

/**
 * function to initial layout/*from w  w w  . j a va 2s  .  co m*/
 */
private void initLayout() {
    linBack = (ImageView) findViewById(R.id.imgHome);
    linBack.setVisibility(View.GONE);
    linScan = (ImageView) findViewById(R.id.img_main_menu_scan_barcode);
    linScan.setOnClickListener(this);
    linScan.setVisibility(View.GONE);
    tvHeader = (TextView) findViewById(R.id.tvHeader);
    tvHeader.setText(
            languagePrefs.getPreferencesString(GlobalParams.RID_LBL_MOVE_KEY, GlobalParams.RID_LBL_MOVE_VALUE));

    tvMoveFunctionTitle = (TextView) findViewById(R.id.textView_move);
    tvMoveFunctionTitle.setText(languagePrefs.getPreferencesString(GlobalParams.MV_MSG_SELECTORSCAN_KEY,
            GlobalParams.MV_MSG_SELECTORSCAN_VALUE));
    tvTitleTransfer = (TextView) findViewById(R.id.tvTitleTransfer);
    tvTitleTransfer.setText(languagePrefs.getPreferencesString(GlobalParams.TRANSFER, GlobalParams.TRANSFER)
            + GlobalParams.VERTICAL_TWO_DOT);
    tvTitleMaxQty = (TextView) findViewById(R.id.tvTitleMaxQty);
    tvTitleMaxQty.setText(
            languagePrefs.getPreferencesString(GlobalParams.MV_LBL_MAXQTY, GlobalParams.DMG_LBL_MAXQTY_VALUE)
                    + ": ");
    tvUOM = (TextView) findViewById(R.id.tvUOM);
    tvUOM.setText(
            languagePrefs.getPreferencesString(GlobalParams.MV_LBL_UOM, GlobalParams.UNIT_OF_MEASURE_VALUE)
                    + GlobalParams.VERTICAL_TWO_DOT);
    tvLot = (TextView) findViewById(R.id.tvLot);
    tvLot.setText(languagePrefs.getPreferencesString(GlobalParams.REST_GRD_LOT_KEY, GlobalParams.LOT)
            + GlobalParams.VERTICAL_TWO_DOT);
    tvFrom = (TextView) findViewById(R.id.tvFrom);
    tvFrom.setText(languagePrefs.getPreferencesString(GlobalParams.MV_LBL_FROM, GlobalParams.FROM)
            + GlobalParams.VERTICAL_TWO_DOT);
    tvQtyView = (TextView) findViewById(R.id.tvQtyView);
    tvQtyView.setText(languagePrefs.getPreferencesString(GlobalParams.RID_GRD_QTY_KEY, GlobalParams.QTY));
    tvTo = (TextView) findViewById(R.id.tvTo);
    tvTo.setText(languagePrefs.getPreferencesString(GlobalParams.MV_LBL_TO, GlobalParams.TO)
            + GlobalParams.VERTICAL_TWO_DOT);

    tvmaxQty = (TextView) findViewById(R.id.tvmaxQty);
    tvItemDescription = (TextView) findViewById(R.id.tvItemDescription);
    tvTransfer = (TextView) findViewById(R.id.tvTransfer);
    spnMoveUOM = (Spinner) findViewById(R.id.spn_Move_UOM);
    edtLotValue = (EditText) findViewById(R.id.edtLotValue);
    edtMoveFrom = (EditText) findViewById(R.id.edt_move_from);

    edtMoveQty = (EditText) findViewById(R.id.et_move_qty);
    edtMoveQty.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (null != s && s.length() == 1 && s.toString().equalsIgnoreCase(".")) {
                edtMoveQty.setText("");
                s = "";
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    edtMoveQty.setFilters(
            new InputFilter[] { new DecimalDigitsInputFilter(enPurchaseOrderItemInfo.get_significantDigits()),
                    new InputFilter.LengthFilter(14) });

    edtMoveTo = (EditText) findViewById(R.id.et_move_to);
    btMoveOk = (Button) findViewById(R.id.btnOK);
    btMoveOk.setText(languagePrefs.getPreferencesString(GlobalParams.OK, GlobalParams.OK));
    btMoveOk.setOnClickListener(this);
    btMoveOk.setEnabled(true);
    btMoveCancel = (Button) findViewById(R.id.btnCancel);
    btMoveCancel.setText(languagePrefs.getPreferencesString(GlobalParams.CANCEL, GlobalParams.CANCEL));
    btMoveCancel.setOnClickListener(this);

    edtMoveTo.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                linScan.setVisibility(View.VISIBLE);
                scanFlag = GlobalParams.FLAG_ACTIVE;
            } else {
                linScan.setVisibility(View.GONE);
                scanFlag = GlobalParams.FLAG_INACTIVE;
            }
        }
    });

    if (null != enPurchaseOrderItemInfo) {
        tvTransfer.setText(enPurchaseOrderItemInfo.get_itemNumber());
        tvItemDescription.setText(enPurchaseOrderItemInfo.get_itemDesc());
    }

    if (null != enPurchaseOrderInfo) {
        if (StringUtils.isNotBlank(enPurchaseOrderInfo.get_receivingBinNumber())) {
            edtMoveFrom.setText(enPurchaseOrderInfo.get_receivingBinNumber());
        } else {
            edtMoveFrom.setText("");
        }
        edtMoveFrom.setEnabled(false);
    }

    if (null != listReceiptInfos) {
        if (listReceiptInfos.size() == 1) {
            Log.e("Appolis", "single record was selected from the previous screen");
            EnPurchaseOrderReceiptInfo recipt = listReceiptInfos.get(0);
            maxQty = recipt.get_quantityReceived();
            tvmaxQty.setText(BuManagement.formatDecimal(recipt.get_quantityReceived()).trim());
            edtLotValue.setText(recipt.get_lotNumber());
            edtLotValue.setEnabled(false);
            edtMoveQty.setText(BuManagement.formatDecimal(recipt.get_quantityReceived()).trim());
            edtMoveQty.setEnabled(true);
            spnMoveUOM.setEnabled(true);
            edtMoveTo.requestFocus();

            GetDataAsyncTask getDataAsyncTask = new GetDataAsyncTask(this,
                    enPurchaseOrderItemInfo.get_itemNumber());
            getDataAsyncTask.execute();
        } else {
            Logger.error("Appolis: multiple records have been selected on the previous screen");
            String strlot = "";
            int index = 0;

            for (EnPurchaseOrderReceiptInfo item : listReceiptInfos) {
                maxQty += item.get_quantityReceived();

                if (StringUtils.isNotBlank(item.get_lotNumber())) {
                    if (index == 0) {
                        strlot = strlot + item.get_lotNumber();
                    } else {
                        strlot = strlot + ", " + item.get_lotNumber();
                    }
                    index++;
                }
            }

            tvmaxQty.setText(BuManagement.formatDecimal(maxQty).trim());
            edtMoveTo.requestFocus();
            edtLotValue.setText(strlot);
            edtLotValue.setEnabled(false);
            edtMoveQty.setText(BuManagement.formatDecimal(maxQty).trim());
            edtMoveQty.setEnabled(false);
            spnMoveUOM.setEnabled(false);
            uom = enPurchaseOrderItemInfo.get_uomDesc();
            ArrayList<String> listUom = new ArrayList<String>();
            listUom.add(uom);
            ArrayAdapter<String> uomAdapter = new ArrayAdapter<String>(this, R.layout.custom_spinner_item,
                    listUom);
            spnMoveUOM.setAdapter(uomAdapter);
        }
    }
}

From source file:com.cryart.sabbathschool.viewmodel.SSReadingViewModel.java

public void promptForEditSuggestion() {
    if (ssReads.size() > 0) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        final String name = prefs.getString(SSConstants.SS_USER_NAME_INDEX,
                context.getString(R.string.ss_menu_anonymous_name));
        final String email = prefs.getString(SSConstants.SS_USER_EMAIL_INDEX,
                context.getString(R.string.ss_menu_anonymous_email));

        new MaterialDialog.Builder(context).title(context.getString(R.string.ss_reading_suggest_edit))
                .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)
                .input(context.getString(R.string.ss_reading_suggest_edit_hint), "",
                        new MaterialDialog.InputCallback() {
                            @Override
                            public void onInput(MaterialDialog dialog, CharSequence input) {

                                mDatabase.child(SSConstants.SS_FIREBASE_SUGGESTIONS_DATABASE)
                                        .child(ssFirebaseAuth.getCurrentUser().getUid())
                                        .child(ssReads.get(ssReadingActivityBinding.ssReadingViewPager
                                                .getCurrentItem()).index)
                                        .setValue(new SSSuggestion(name, email, input.toString()));

                                Toast.makeText(context,
                                        context.getString(R.string.ss_reading_suggest_edit_done),
                                        Toast.LENGTH_LONG).show();
                            }//from w  w  w .  j  a v  a2 s.c  o m
                        })
                .show();
    }
}

From source file:edu.cornell.med.icb.goby.readers.vcf.VCFParser.java

/**
 * Returns the value of a field./*from  w  w  w .j a v  a  2 s. c om*/
 * The field is identified by a global index that runs from zero (inclusive) to countAllFields() (exclusive).
 *
 * @param globalFieldIndex a global index that runs from zero to countAllFields()
 * @return Value of this field.
 */
public String getStringFieldValue(final int globalFieldIndex) {

    final CharSequence value = getFieldValue(globalFieldIndex);
    return value == null ? null : value.toString();
}

From source file:org.archive.modules.extractor.ExtractorHTML.java

protected void processEmbed(CrawlURI curi, final CharSequence value, CharSequence context, Hop hop) {
    if (logger.isLoggable(Level.FINEST)) {
        logger.finest("embed (" + hop.getHopChar() + "): " + value.toString() + " from " + curi);
    }//from w  ww . j  ava2s. co  m
    addLinkFromString(curi, (value instanceof String) ? (String) value : value.toString(), context, hop);
    numberOfLinksExtracted.incrementAndGet();
}

From source file:com.taobao.android.repatch.InsTructionsReIClassDef.java

@Override
protected Iterable<? extends Instruction> reInstructions(Iterable<? extends Instruction> instructions) {
    final List<Instruction> reinstructions = new ArrayList<Instruction>();
    for (final Instruction instruction : instructions) {
        if (instruction instanceof ReferenceInstruction) {
            Opcode opcode = instruction.getOpcode();
            if (opcode.referenceType == ReferenceType.METHOD) {
                boolean isBasic = false;
                MethodReference methodReference = null;
                try {
                    methodReference = (MethodReference) ((ReferenceInstruction) instruction).getReference();
                    if (methodReference.getDefiningClass().contains("Ljava/lang")
                            || methodReference.getDefiningClass().startsWith("Ljava/util/")
                            || methodReference.getDefiningClass().startsWith("[Ljava/lang")) {
                        reinstructions.add(ImmutableInstruction.of(instruction));
                        continue;
                    }/*from w  w w.j  a v  a 2 s.  co  m*/
                    String returnType = methodReference.getReturnType();
                    boolean isArray = false;
                    if (returnType.startsWith("[")) {
                        isArray = true;
                    }
                    String methodName = methodReference.getName();
                    if (methodName.equals("InitBundleInfoByVersionIfNeed")) {
                        System.out.println("InitBundleInfoByVersionIfNeed");
                    }
                    if (basicType.containsKey(returnType)) {
                        isBasic = true;
                    }
                    List<? extends CharSequence> paramTypes = methodReference.getParameterTypes();
                    List<CharSequence> dalvikParamTypes = new ArrayList<CharSequence>();

                    List<CharSequence> newParamTypes = new ArrayList<CharSequence>();

                    for (CharSequence charSequence : paramTypes) {
                        if (basicType.containsKey(charSequence.toString())) {
                            newParamTypes.add(charSequence);
                            dalvikParamTypes.add(basicType.get(charSequence.toString()));
                            continue;
                        }
                        boolean isArray1 = charSequence.toString().startsWith("[");
                        dalvikParamTypes.add(DefineUtils.getDalvikClassName(charSequence.toString())
                                + (isArray ? "[]" : ""));
                        newParamTypes.add(DefineUtils.getDefineClassName(
                                classProcessor.classProcess(
                                        DefineUtils.getDalvikClassName(charSequence.toString())).className,
                                isArray1));
                    }
                    final ImmutableMethodReference immutableReference = new ImmutableMethodReference(
                            DefineUtils.getDefineClassName(
                                    classProcessor.classProcess(DefineUtils
                                            .getDalvikClassName(methodReference.getDefiningClass())).className,
                                    false),

                            classProcessor.methodProcess(
                                    DefineUtils.getDalvikClassName(methodReference.getDefiningClass()),
                                    methodReference.getName(),
                                    isBasic ? basicType.get(methodReference.getReturnType())
                                            : DefineUtils.getDalvikClassName(methodReference.getReturnType())
                                                    + (isArray ? "[]" : ""),
                                    StringUtils.join(dalvikParamTypes.toArray(), ",")).methodName,
                            newParamTypes,

                            isBasic ? returnType
                                    : DefineUtils.getDefineClassName(
                                            classProcessor.classProcess(DefineUtils.getDalvikClassName(
                                                    methodReference.getReturnType())).className,
                                            methodReference.getReturnType().startsWith("[")));
                    if (instruction instanceof Instruction3rc) {

                        reinstructions.add(new ImmutableInstruction3rc(instruction.getOpcode(),
                                ((Instruction3rc) instruction).getStartRegister(),
                                ((Instruction3rc) instruction).getRegisterCount(), immutableReference));

                    } else if (instruction instanceof Instruction20bc) {
                        reinstructions.add(new ImmutableInstruction20bc(instruction.getOpcode(),
                                ((Instruction20bc) instruction).getVerificationError(), immutableReference));

                    } else if (instruction instanceof Instruction21c) {
                        reinstructions.add(new ImmutableInstruction21c(instruction.getOpcode(),
                                ((Instruction21c) instruction).getRegisterA(), immutableReference));

                    } else if (instruction instanceof Instruction22c) {
                        reinstructions.add(new ImmutableInstruction22c(instruction.getOpcode(),
                                ((Instruction22c) instruction).getRegisterA(),
                                ((Instruction22c) instruction).getRegisterB(), immutableReference));

                    } else if (instruction instanceof Instruction31c) {
                        reinstructions.add(new ImmutableInstruction31c(instruction.getOpcode(),
                                ((Instruction31c) instruction).getRegisterA(), immutableReference));

                    } else if (instruction instanceof Instruction35c) {
                        reinstructions.add(new ImmutableInstruction35c(instruction.getOpcode(),
                                ((Instruction35c) instruction).getRegisterCount(),
                                ((Instruction35c) instruction).getRegisterC(),
                                ((Instruction35c) instruction).getRegisterD(),
                                ((Instruction35c) instruction).getRegisterE(),
                                ((Instruction35c) instruction).getRegisterF(),
                                ((Instruction35c) instruction).getRegisterG(), immutableReference));

                    }

                } catch (Exception e) {

                }
            } else if (opcode.referenceType == ReferenceType.FIELD) {
                FieldReference fieldReference = null;
                boolean isBasic = false;
                boolean isBasicArray = false;
                fieldReference = (FieldReference) ((ReferenceInstruction) instruction).getReference();
                if (fieldReference.getDefiningClass().startsWith("Ljava/lang/")
                        || fieldReference.getDefiningClass().startsWith("Ljava/util/")
                        || fieldReference.getDefiningClass().startsWith("[Ljava/lang/")) {
                    reinstructions.add(ImmutableInstruction.of(instruction));
                    continue;
                }
                if (basicType.containsKey(fieldReference.getType())) {
                    isBasic = true;
                }

                final ImmutableFieldReference immutableFieldReference = new ImmutableFieldReference(

                        DefineUtils.getDefineClassName(
                                classProcessor.classProcess(DefineUtils
                                        .getDalvikClassName(fieldReference.getDefiningClass())).className,
                                false),
                        classProcessor.filedProcess(
                                DefineUtils.getDalvikClassName(fieldReference.getDefiningClass()),
                                isBasic ? basicType.get(fieldReference.getType())
                                        : DefineUtils.getDalvikClassName(fieldReference.getType()),
                                fieldReference.getName()).fieldName,
                        isBasic ? fieldReference.getType()
                                : DefineUtils.getDefineClassName(
                                        classProcessor.classProcess(DefineUtils
                                                .getDalvikClassName(fieldReference.getType())).className,
                                        fieldReference.getType().startsWith("[")));

                if (instruction instanceof Instruction3rc) {

                    reinstructions.add(new ImmutableInstruction3rc(instruction.getOpcode(),
                            ((Instruction3rc) instruction).getStartRegister(),
                            ((Instruction3rc) instruction).getRegisterCount(), immutableFieldReference));

                } else if (instruction instanceof Instruction20bc) {
                    reinstructions.add(new ImmutableInstruction20bc(instruction.getOpcode(),
                            ((Instruction20bc) instruction).getVerificationError(), immutableFieldReference));

                } else if (instruction instanceof Instruction21c) {
                    reinstructions.add(new ImmutableInstruction21c(instruction.getOpcode(),
                            ((Instruction21c) instruction).getRegisterA(), immutableFieldReference));

                } else if (instruction instanceof Instruction22c) {
                    reinstructions.add(new ImmutableInstruction22c(instruction.getOpcode(),
                            ((Instruction22c) instruction).getRegisterA(),
                            ((Instruction22c) instruction).getRegisterB(), immutableFieldReference));

                } else if (instruction instanceof Instruction31c) {
                    reinstructions.add(new ImmutableInstruction31c(instruction.getOpcode(),
                            ((Instruction31c) instruction).getRegisterA(), immutableFieldReference));

                } else if (instruction instanceof Instruction35c) {
                    reinstructions.add(new ImmutableInstruction35c(instruction.getOpcode(),
                            ((Instruction35c) instruction).getRegisterCount(),
                            ((Instruction35c) instruction).getRegisterC(),
                            ((Instruction35c) instruction).getRegisterD(),
                            ((Instruction35c) instruction).getRegisterE(),
                            ((Instruction35c) instruction).getRegisterF(),
                            ((Instruction35c) instruction).getRegisterG(), immutableFieldReference));

                }

            } else if (opcode.referenceType == ReferenceType.TYPE) {
                TypeReference typeReference = (TypeReference) ((ReferenceInstruction) instruction)
                        .getReference();
                String type = typeReference.getType();
                if (!basicType.containsKey(type) && !type.startsWith("Ljava/lang")
                        && !type.startsWith("Ljava/util/") && !type.startsWith("[Ljava/lang")) {
                    type = DefineUtils.getDefineClassName(
                            classProcessor.classProcess(DefineUtils.getDalvikClassName(type)).className,
                            type.startsWith("["));
                }
                ImmutableTypeReference immutableTypeReference = new ImmutableTypeReference(type);
                if (instruction instanceof Instruction3rc) {

                    reinstructions.add(new ImmutableInstruction3rc(instruction.getOpcode(),
                            ((Instruction3rc) instruction).getStartRegister(),
                            ((Instruction3rc) instruction).getRegisterCount(), immutableTypeReference));

                } else if (instruction instanceof Instruction20bc) {
                    reinstructions.add(new ImmutableInstruction20bc(instruction.getOpcode(),
                            ((Instruction20bc) instruction).getVerificationError(), immutableTypeReference));

                } else if (instruction instanceof Instruction21c) {
                    reinstructions.add(new ImmutableInstruction21c(instruction.getOpcode(),
                            ((Instruction21c) instruction).getRegisterA(), immutableTypeReference));

                } else if (instruction instanceof Instruction22c) {
                    reinstructions.add(new ImmutableInstruction22c(instruction.getOpcode(),
                            ((Instruction22c) instruction).getRegisterA(),
                            ((Instruction22c) instruction).getRegisterB(), immutableTypeReference));

                } else if (instruction instanceof Instruction31c) {
                    reinstructions.add(new ImmutableInstruction31c(instruction.getOpcode(),
                            ((Instruction31c) instruction).getRegisterA(), immutableTypeReference));

                } else if (instruction instanceof Instruction35c) {
                    reinstructions.add(new ImmutableInstruction35c(instruction.getOpcode(),
                            ((Instruction35c) instruction).getRegisterCount(),
                            ((Instruction35c) instruction).getRegisterC(),
                            ((Instruction35c) instruction).getRegisterD(),
                            ((Instruction35c) instruction).getRegisterE(),
                            ((Instruction35c) instruction).getRegisterF(),
                            ((Instruction35c) instruction).getRegisterG(), immutableTypeReference));

                }

            } else if (opcode.referenceType == ReferenceType.STRING) {
                StringReference stringReference = (StringReference) ((ReferenceInstruction) instruction)
                        .getReference();
                String type = stringReference.getString();
                //                    if (!basicType.contains(type) && !type.startsWith("[Ljava/lang")) {
                //                        type = DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(type)).className);
                //                    }
                ImmutableStringReference immutableStringReference = new ImmutableStringReference(type);
                if (instruction instanceof Instruction3rc) {

                    reinstructions.add(new ImmutableInstruction3rc(instruction.getOpcode(),
                            ((Instruction3rc) instruction).getStartRegister(),
                            ((Instruction3rc) instruction).getRegisterCount(), immutableStringReference));

                } else if (instruction instanceof Instruction20bc) {
                    reinstructions.add(new ImmutableInstruction20bc(instruction.getOpcode(),
                            ((Instruction20bc) instruction).getVerificationError(), immutableStringReference));

                } else if (instruction instanceof Instruction21c) {
                    reinstructions.add(new ImmutableInstruction21c(instruction.getOpcode(),
                            ((Instruction21c) instruction).getRegisterA(), immutableStringReference));

                } else if (instruction instanceof Instruction22c) {
                    reinstructions.add(new ImmutableInstruction22c(instruction.getOpcode(),
                            ((Instruction22c) instruction).getRegisterA(),
                            ((Instruction22c) instruction).getRegisterB(), immutableStringReference));

                } else if (instruction instanceof Instruction31c) {
                    reinstructions.add(new ImmutableInstruction31c(instruction.getOpcode(),
                            ((Instruction31c) instruction).getRegisterA(), immutableStringReference));

                } else if (instruction instanceof Instruction35c) {
                    reinstructions.add(new ImmutableInstruction35c(instruction.getOpcode(),
                            ((Instruction35c) instruction).getRegisterCount(),
                            ((Instruction35c) instruction).getRegisterC(),
                            ((Instruction35c) instruction).getRegisterD(),
                            ((Instruction35c) instruction).getRegisterE(),
                            ((Instruction35c) instruction).getRegisterF(),
                            ((Instruction35c) instruction).getRegisterG(), immutableStringReference));

                }

            } else {
                reinstructions.add(ImmutableInstruction.of(instruction));

            }
        } else {
            reinstructions.add(ImmutableInstruction.of(instruction));
        }
    }

    return new Iterable<Instruction>() {
        @Override
        public Iterator<Instruction> iterator() {
            return reinstructions.iterator();

        }

    };
}

From source file:brooklyn.util.internal.ssh.SshjTool.java

/**
 * Merges the commands and env, into a single set of commands. Also escapes the commands as required.
 * //w  w w . j a va 2  s. c  o m
 * Not all ssh servers handle "env", so instead convert env into exported variables
 */
private List<String> toCommandSequence(List<String> commands, Map<String, ?> env) {
    List<String> result = new ArrayList<String>(env.size() + commands.size());

    for (Entry<String, ?> entry : env.entrySet()) {
        if (entry.getKey() == null || entry.getValue() == null) {
            LOG.warn("env key-values must not be null; ignoring: key=" + entry.getKey() + "; value="
                    + entry.getValue());
            continue;
        }
        String escapedVal = BashStringEscapes.escapeLiteralForDoubleQuotedBash(entry.getValue().toString());
        result.add("export " + entry.getKey() + "=\"" + escapedVal + "\"");
    }

    for (CharSequence cmd : commands) { // objects in commands can be groovy GString so can't treat as String here
        result.add(cmd.toString());
    }

    return result;
}

From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.BuyAndSellFragment.java

@Nullable
@Override/*from ww w  . j a  v  a 2s . co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_actualtransactionbuyandsell, container, false);

    mButton = (Button) view.findViewById(R.id.fragment_ats_buy_button);
    mSpinner = (Spinner) view.findViewById(R.id.fragment_actualtransactionbuy_mode);
    mCountEdit = (TextInputEditText) view.findViewById(R.id.fragment_actualtransactionbuy_count);
    mUnivalentEdit = (TextInputEditText) view.findViewById(R.id.fragment_actualtransactionbuy_univalent);
    mCNYTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_cnycount);
    mBTCTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_btccount);
    mFreezedCNYTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_freezed_cnycount);
    mFreezedBTCTextView = (TextView) view.findViewById(R.id.fragment_ats_buy_account_freezed_btccount);

    //?
    if (isSell) {
        //?
        mButton.setText(R.string.fragment_actualtransactionbuy_sell);

    } else {
        //
        mButton.setText(R.string.fragment_actualtransactionbuy_buy);

    }
    mUnivalentEdit.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            Log.e(TAG, "afterTextChanged" + s);
            if (s.toString().trim().length() == 0 || s.toString().equals("?"))
                return;
            if (!isDecimal(s.toString())) {
                mUnivalentEdit.setError("???");
            } else {
                double d = Double.parseDouble(s.toString());
                if (d < 0.01) {
                    mUnivalentEdit.setError("?0.01");
                }
            }
        }
    });
    mCountEdit.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().trim().length() == 0 || s.toString().equals("?"))
                return;
            if (!isDecimal(s.toString())) {
                mCountEdit.setError("???");
            } else {
                double d = Double.parseDouble(s.toString());
                if (d < 0.01) {
                    mCountEdit.setError("?0.01");
                }
            }
        }
    });

    isLimit = true;
    mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            if (position == 0) {
                //?
                isLimit = true;
                if (isSell) {
                    mUnivalentEdit.setText("");
                    mUnivalentEdit.setEnabled(true);
                } else {
                    mCountEdit.setText("");
                    mCountEdit.setEnabled(true);
                }
            } else if (position == 1) {
                //?
                isLimit = false;
                if (isSell) {
                    mUnivalentEdit.setText("?");
                    mUnivalentEdit.setEnabled(false);
                } else {
                    mCountEdit.setText("?");
                    mCountEdit.setEnabled(false);
                }

            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }

    });

    mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //???
            double count = 0;
            double univalent = 0;

            /*
             * 3?,
             * 1?? 
             * 2,??
             * 3?,??
             */
            Log.e(TAG, "isLimit" + isLimit + "isSell" + isSell);
            try {
                if (isLimit) {
                    count = Double.parseDouble(mCountEdit.getText().toString());
                    univalent = Double.parseDouble(mUnivalentEdit.getText().toString());
                    if (count < 0.01 || univalent < 0.01) {
                        Toast.makeText(getActivity(), "?0.01", Toast.LENGTH_SHORT).show();
                        return;
                    }
                } else if (!isSell) {
                    univalent = Double.parseDouble(mUnivalentEdit.getText().toString());
                    if (univalent < 0.01) {
                        Toast.makeText(getActivity(), "?0.01", Toast.LENGTH_SHORT).show();
                        return;
                    }
                } else if (isSell) {
                    count = Double.parseDouble(mCountEdit.getText().toString());
                    if (count < 0.01) {
                        Toast.makeText(getActivity(), "?0.01", Toast.LENGTH_SHORT).show();
                        return;
                    }
                }
            } catch (Exception e) {
                Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show();
                return;
            }
            //??
            mDialog = new ProgressDialog(getActivity());
            mDialog.setMessage("?,??");
            mDialog.setCanceledOnTouchOutside(false);
            mDialog.setCancelable(false);
            mDialog.show();
            //URL?
            String type = "";
            String price = univalent + "";
            String amount = count + "";
            if (isSell && isLimit) {
                //?         ?
                type = "sell";
            } else if (isSell && !isLimit) {
                //?         
                type = "sell_market";
                price = "";
            } else if (!isSell && isLimit) {
                //         ?
                type = "buy";
            } else if (!isSell && !isLimit) {
                //         
                type = "buy_market";
                amount = "";
            }

            RequestParameter parameter1 = new RequestParameter("api_key", SecurityConfig.USD_ACCESS_KEY);
            RequestParameter parameter2 = new RequestParameter("secret_key", SecurityConfig.USD_SECRET_KEY);
            RequestParameter parameter3 = new RequestParameter("type", type);
            RequestParameter parameter4 = new RequestParameter("price", price);
            RequestParameter parameter5 = new RequestParameter("amount", amount);
            List<RequestParameter> list = new ArrayList<>();
            list.add(parameter1);
            list.add(parameter2);
            list.add(parameter3);
            list.add(parameter4);
            list.add(parameter5);
            //
            BuyOrSellAsyncTask task = new BuyOrSellAsyncTask();
            task.execute(list);

        }
    });

    //??
    updateBalance();

    //?
    return view;

}

From source file:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java

protected void onMessageEditTextChanged(CharSequence message) {
    if (message == null || message.toString().trim().isEmpty()) {
        if (!fieldMessageEmpty) {
            fieldMessageEmpty = true;/*from   w  w  w  .jav  a 2  s  .c  o m*/
            sendButton.startAnimation(animation);
            sendButton.setImageResource(chatConfig.getShowAttachmentPanelIcon());
            QiscusPusherApi.getInstance().setUserTyping(qiscusChatRoom.getId(), qiscusChatRoom.getLastTopicId(),
                    false);
        }
    } else {
        if (fieldMessageEmpty) {
            fieldMessageEmpty = false;
            sendButton.startAnimation(animation);
            sendButton.setImageResource(chatConfig.getSendButtonIcon());
            QiscusPusherApi.getInstance().setUserTyping(qiscusChatRoom.getId(), qiscusChatRoom.getLastTopicId(),
                    true);
        }
    }
}