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:com.tomagoyaky.jdwp.IOUtils.java

/**
 * Converts the specified CharSequence to an input stream, encoded as bytes
 * using the specified character encoding.
 *
 * @param input the CharSequence to convert
 * @param encoding the encoding to use, null means platform default
 * @return an input stream/*from   w w  w  .j a v  a  2 s  .  c  om*/
 * @since 2.3
 */
public static InputStream toInputStream(final CharSequence input, final Charset encoding) {
    return toInputStream(input.toString(), encoding);
}

From source file:com.ieeton.user.activity.ChatActivity.java

/**
 * ?gridview?view//from   w w w.  j a  v  a2s .c  o  m
 * 
 * @param i
 * @return
 */
private View getGridChildView(int i) {
    View view = View.inflate(this, R.layout.expression_gridview, null);
    ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview);
    List<String> list = new ArrayList<String>();
    if (i == 1) {
        List<String> list1 = reslist.subList(0, 20);
        list.addAll(list1);
    } else if (i == 2) {
        list.addAll(reslist.subList(20, reslist.size()));
    }
    list.add("delete_expression");
    final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list);
    gv.setAdapter(expressionAdapter);
    gv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String filename = expressionAdapter.getItem(position);
            try {
                // ????
                // ?????
                if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) {

                    if (filename != "delete_expression") { // ?
                        // ????SmileUtils
                        Class clz = Class.forName("com.ieeton.user.utils.SmileUtils");
                        Field field = clz.getField(filename);
                        mEditTextContent
                                .append(SmileUtils.getSmiledText(ChatActivity.this, (String) field.get(null)));
                    } else { // 
                        if (!TextUtils.isEmpty(mEditTextContent.getText())) {

                            int selectionStart = mEditTextContent.getSelectionStart();// ??
                            if (selectionStart > 0) {
                                String body = mEditTextContent.getText().toString();
                                String tempStr = body.substring(0, selectionStart);
                                int i = tempStr.lastIndexOf("[");// ???
                                if (i != -1) {
                                    CharSequence cs = tempStr.substring(i, selectionStart);
                                    if (SmileUtils.containsKey(cs.toString()))
                                        mEditTextContent.getEditableText().delete(i, selectionStart);
                                    else
                                        mEditTextContent.getEditableText().delete(selectionStart - 1,
                                                selectionStart);
                                } else {
                                    mEditTextContent.getEditableText().delete(selectionStart - 1,
                                            selectionStart);
                                }
                            }
                        }

                    }
                }
            } catch (Exception e) {
            }

        }
    });
    return view;
}

From source file:com.servoy.j2db.util.Utils.java

public static boolean stringContainsIgnoreCase(final CharSequence source, String contains) {
    if (stringIsEmpty(source) || stringIsEmpty(contains))
        return false;
    return (source.toString().toLowerCase().contains(contains.toLowerCase()));
}

From source file:com.tomagoyaky.jdwp.IOUtils.java

/**
 * Writes chars from a <code>CharSequence</code> to a <code>Writer</code>.
 *
 * @param data the <code>CharSequence</code> to write, null ignored
 * @param output the <code>Writer</code> to write to
 * @throws NullPointerException if output is null
 * @throws IOException          if an I/O error occurs
 * @since 2.0/*from www  .  j a  v a2s  . c o m*/
 */
public static void write(final CharSequence data, final Writer output) throws IOException {
    if (data != null) {
        write(data.toString(), output);
    }
}

From source file:cn.kangeqiu.kq.activity.ChatActivity.java

/**
 * ?gridview?view//from w w  w .  ja va 2  s.  co  m
 * 
 * @param i
 * @return
 */
private View getGridChildView(int i) {

    View view = View.inflate(this, R.layout.expression_gridview, null);
    ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview);
    List<String> list = new ArrayList<String>();
    if (i == 1) {
        List<String> list1 = reslist.subList(0, 20);
        list.addAll(list1);
    } else if (i == 2) {
        list.addAll(reslist.subList(20, reslist.size()));
    }
    list.add("delete_expression");
    final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list);
    gv.setAdapter(expressionAdapter);
    gv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String filename = expressionAdapter.getItem(position);
            try {
                // ????
                // ?????
                // if (buttonSetModeKeyboard.getVisibility() !=
                // View.VISIBLE) {

                if (filename != "delete_expression") { // ?
                    // ????SmileUtils
                    Class clz = Class.forName("cn.kangeqiu.kq.utils.SmileUtils");
                    Field field = clz.getField(filename);
                    mEditTextContent
                            .append(SmileUtils.getSmiledText(ChatActivity.this, (String) field.get(null)));
                } else { // 
                    if (!TextUtils.isEmpty(mEditTextContent.getText())) {

                        int selectionStart = mEditTextContent.getSelectionStart();// ??
                        if (selectionStart > 0) {
                            String body = mEditTextContent.getText().toString();
                            String tempStr = body.substring(0, selectionStart);
                            int i = tempStr.lastIndexOf("[");// ???
                            if (i != -1) {
                                CharSequence cs = tempStr.substring(i, selectionStart);
                                if (SmileUtils.containsKey(cs.toString()))
                                    mEditTextContent.getEditableText().delete(i, selectionStart);
                                else
                                    mEditTextContent.getEditableText().delete(selectionStart - 1,
                                            selectionStart);
                            } else {
                                mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart);
                            }
                        }
                    }

                }
                // }
            } catch (Exception e) {
            }

        }
    });
    return view;
}

From source file:com.tomagoyaky.jdwp.IOUtils.java

/**
 * Writes chars from a <code>CharSequence</code> to bytes on an
 * <code>OutputStream</code> using the specified character encoding.
 * <p/>//w w  w.j  a v  a2  s  .  c om
 * This method uses {@link String#getBytes(String)}.
 *
 * @param data the <code>CharSequence</code> to write, null ignored
 * @param output the <code>OutputStream</code> to write to
 * @param encoding the encoding to use, null means platform default
 * @throws NullPointerException if output is null
 * @throws IOException          if an I/O error occurs
 * @since 2.3
 */
public static void write(final CharSequence data, final OutputStream output, final Charset encoding)
        throws IOException {
    if (data != null) {
        write(data.toString(), output, encoding);
    }
}

From source file:com.github.helenusdriver.driver.impl.TableInfoImpl.java

/**
 * Gets a column field for the POJO in this table given its column name.
 *
 * @author paouelle//from  w  ww .  j ava2s .c  o m
 *
 * @param  name the name of the column to retrieve in this table
 * @return the corresponding column field or <code>null</code> if not defined
 */
public FieldInfoImpl<T> getColumn(CharSequence name) {
    return (name != null) ? columns.get(name.toString()) : null;
}

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

@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
    // sc = station count
    final int sc = 10;
    // ac = address count
    final int ac = 5;
    // pc = points of interest count
    final int pc = 5;
    // t = sap (stops and/or addresses and/or pois)
    final HttpUrl.Builder url = API_BASE.newBuilder();
    url.addQueryParameter("eID", "tx_vrsinfo_ass2_objects");
    url.addQueryParameter("sc", Integer.toString(sc));
    url.addQueryParameter("ac", Integer.toString(ac));
    url.addQueryParameter("pc", Integer.toString(pc));
    url.addQueryParameter("t", "sap");
    url.addQueryParameter("q", constraint.toString());

    final CharSequence page = httpClient.get(url.build());

    try {//from w w  w .  jav  a2  s.c o  m
        final List<SuggestedLocation> locations = new ArrayList<>();

        final JSONObject head = new JSONObject(page.toString());
        final String error = Strings.emptyToNull(head.optString("error", "").trim());
        if (error != null) {
            if (error.equals("ASS2-Server lieferte leere Antwort."))
                return new SuggestLocationsResult(new ResultHeader(NetworkId.VRS, SERVER_PRODUCT),
                        SuggestLocationsResult.Status.SERVICE_DOWN);
            else if (error.equals("Leere Suche"))
                return new SuggestLocationsResult(new ResultHeader(NetworkId.VRS, SERVER_PRODUCT), locations);
            else
                throw new IllegalStateException("unknown error: " + error);
        }
        final JSONArray stops = head.optJSONArray("stops");
        final JSONArray addresses = head.optJSONArray("addresses");
        final JSONArray pois = head.optJSONArray("pois");

        final int nStops = stops.length();
        for (int iStop = 0; iStop < nStops; iStop++) {
            final JSONObject stop = stops.optJSONObject(iStop);
            final Location location = parseLocationAndPosition(stop).location;
            locations.add(new SuggestedLocation(location, sc + ac + pc - iStop));
        }

        final int nAddresses = addresses.length();
        for (int iAddress = 0; iAddress < nAddresses; iAddress++) {
            final JSONObject address = addresses.optJSONObject(iAddress);
            final Location location = parseLocationAndPosition(address).location;
            locations.add(new SuggestedLocation(location, ac + pc - iAddress));
        }

        final int nPois = pois.length();
        for (int iPoi = 0; iPoi < nPois; iPoi++) {
            final JSONObject poi = pois.optJSONObject(iPoi);
            final Location location = parseLocationAndPosition(poi).location;
            locations.add(new SuggestedLocation(location, pc - iPoi));
        }

        final ResultHeader header = new ResultHeader(NetworkId.VRS, SERVER_PRODUCT);
        return new SuggestLocationsResult(header, locations);
    } catch (final JSONException x) {
        throw new RuntimeException("cannot parse: '" + page + "' on " + url, x);
    }
}

From source file:com.github.helenusdriver.driver.impl.TableInfoImpl.java

/**
 * Gets the a primary column fields for the POJO in this table given its
 * column name./*w  ww . j  a va  2s.  c  o m*/
 *
 * @author paouelle
 *
 * @param  name the name of the primary column to retrieve in this table
 * @return the corresponding primary column field or <code>null</code> if
 *         not defined
 */
public FieldInfoImpl<T> getPrimaryKey(CharSequence name) {
    return (name != null) ? primaryKeyColumns.get(name.toString()) : null;
}