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.bstek.dorado.view.resolver.ViewServiceResolver.java

@Override
public Writer append(CharSequence csq) throws IOException {
    if (escapeEnabled) {
        if (csq == null) {
            return writer.append(null);
        } else {/*from w w w. ja v  a 2  s. co m*/
            return super.append(escapeCDataContent(csq.toString()));
        }
    } else {
        return writer.append(csq);
    }
}

From source file:at.jclehner.rxdroid.preferences.DrugNamePreference2.java

@Override
protected View onCreateDialogView() {
    mEditText = new AutoCompleteTextView(getContext());
    mAutoCompleteAdapter = new ArrayAdapter<String>(this.getContext(),
            android.R.layout.simple_dropdown_item_1line);
    System.out.println("Initializing autocomplete...");
    mEditText.setThreshold(3);/*from w w w  . j  a  va  2  s .c  o  m*/
    mEditText.setAdapter(mAutoCompleteAdapter);
    mEditText.addTextChangedListener(new TextWatcher() {
        private boolean shouldAutoComplete = true;

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            shouldAutoComplete = true;
            for (int position = 0; position < mAutoCompleteAdapter.getCount(); position++) {
                if (mAutoCompleteAdapter.getItem(position).equalsIgnoreCase(s.toString())) {
                    shouldAutoComplete = false;
                    break;
                }
            }
        }

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

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (shouldAutoComplete) {
                new DoAutoCompleteSearch().execute(s.toString());
            }
        }
    });
    //      mEditText = new EditText(getContext());
    mEditText.setText(getValue());
    mEditText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    //mEditText.setSelectAllOnFocus(true);
    mEditText.addTextChangedListener(mWatcher);
    return mEditText;
}

From source file:fr.landel.utils.commons.StringUtils.java

/**
 * Try to prefix the sequence//from ww w.j a v  a2  s  .  c o  m
 * 
 * @param sequence
 *            the sequence to prefix
 * @param prefix
 *            the prefix
 * @return the prefixed sequence
 * @throws NullPointerException
 *             if {@code sequence} or {@code prefix} are {@code null}
 */
public static String prefixIfNotStartsWith(final CharSequence sequence, final CharSequence prefix) {
    Objects.requireNonNull(sequence, ERROR_SEQUENCE);
    Objects.requireNonNull(prefix, ERROR_PREFIX);

    int lSequence = sequence.length();
    int lPrefix = prefix.length();
    if (lPrefix == 0 || (lSequence >= lPrefix && sequence.subSequence(0, lPrefix).equals(prefix))) {
        return sequence.toString();
    }
    return prefix.toString().concat(sequence.toString());
}

From source file:br.msf.commons.util.CharSequenceUtils.java

@SuppressWarnings("unchecked")
public static List<MatchEntry> findPattern(final CharSequence regex, final CharSequence sequence) {
    return (isEmptyOrNull(regex) || isEmptyOrNull(sequence)) ? Collections.EMPTY_LIST
            : findPattern(Pattern.compile(regex.toString()), sequence);
}

From source file:it.unimi.dsi.util.Properties.java

/** Saves the configuration to the specified file.
 * // ww  w  .ja va2 s  .  c  o  m
 * @param filename a file name.
 */

public void save(final CharSequence filename) throws ConfigurationException, IOException {
    final Writer w = new OutputStreamWriter(new FileOutputStream(filename.toString()), "UTF-8");
    super.save(w);
    w.close();
}

From source file:net.eledge.android.europeana.gui.dialog.NameInputDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();

    View view = inflater.inflate(R.layout.dialog_nameinput, null);
    TextView text = (TextView) view.findViewById(R.id.dialog_nameinput_textview);
    if (resText != -1) {
        text.setText(resText);/*from   ww w . j a  va 2 s. c o  m*/
    } else {
        text.setVisibility(View.GONE);
    }
    mInput = (EditText) view.findViewById(R.id.dialog_nameinput_edittext);
    mInput.setHint(resInput);
    mInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //ignore
        }

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

        @Override
        public void afterTextChanged(Editable s) {
            mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(StringUtils.isNotBlank(s.toString()));
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    if (resTitle != -1) {
        builder.setTitle(resTitle);
    }
    builder.setPositiveButton(resPositiveButton, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            String input = mInput.getText().toString();
            if (StringUtils.isNotBlank(input)) {
                mListener.positiveResponse(input);
                NameInputDialog.this.dismiss();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            mListener.negativeResponse();
            mDialog.dismiss();
        }
    });
    mDialog = builder.create();
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setCancelable(false);
    return mDialog;
}

From source file:fr.cph.chicago.fragment.BusFragment.java

private final void addView() {
    mAdapter = new BusAdapter(mActivity);
    mListView.setAdapter(mAdapter);//w w  w  . j a  v a2s  .  c o m
    mTextFilter.setVisibility(TextView.VISIBLE);
    mTextFilter.addTextChangedListener(new TextWatcher() {

        private BusData busData = DataHolder.getInstance().getBusData();
        private List<BusRoute> busRoutes = null;

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            busRoutes = new ArrayList<BusRoute>();
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            List<BusRoute> busRoutes = busData.getRoutes();
            for (BusRoute busRoute : busRoutes) {
                if (StringUtils.containsIgnoreCase(busRoute.getId(), s.toString().trim())
                        || StringUtils.containsIgnoreCase(busRoute.getName(), s.toString().trim())) {
                    this.busRoutes.add(busRoute);
                }
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
            mAdapter.setRoutes(busRoutes);
            mAdapter.notifyDataSetChanged();
        }
    });
}

From source file:com.ichi2.anki.FilteredDeckOptions.java

protected void updateSummaries() {
    mAllowCommit = false;//www  .j a v a 2  s  .c om
    // for all text preferences, set summary as current database value
    for (String key : mPref.mValues.keySet()) {
        Preference pref = this.findPreference(key);
        String value = null;
        if (pref == null) {
            continue;
        } else if (pref instanceof CheckBoxPreference) {
            continue;
        } else if (pref instanceof ListPreference) {
            ListPreference lp = (ListPreference) pref;
            CharSequence entry = lp.getEntry();
            if (entry != null) {
                value = entry.toString();
            } else {
                value = "";
            }
        } else {
            value = this.mPref.getString(key, "");
        }
        // update value for EditTexts
        if (pref instanceof EditTextPreference) {
            ((EditTextPreference) pref).setText(value);
        }
        // update summary
        if (!mPref.mSummaries.containsKey(key)) {
            CharSequence s = pref.getSummary();
            mPref.mSummaries.put(key, s != null ? pref.getSummary().toString() : null);
        }
        String summ = mPref.mSummaries.get(key);
        if (summ != null && summ.contains("XXX")) {
            pref.setSummary(summ.replace("XXX", value));
        } else {
            pref.setSummary(value);
        }
    }
    mAllowCommit = true;
}

From source file:com.bstek.dorado.view.resolver.ViewServiceResolver.java

@Override
public Writer append(CharSequence csq, int start, int end) throws IOException {
    if (escapeEnabled) {
        if (csq == null) {
            return writer.append(null, start, end);
        } else {//from   ww  w.jav  a  2 s. c  o  m
            return super.append(escapeCDataContent(csq.toString()), start, end);
        }
    } else {
        return writer.append(csq, start, end);
    }
}

From source file:org.cocos2dx.lib.TextInputWraper.java

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after);
    mText = s.toString();
}