List of usage examples for java.lang CharSequence charAt
char charAt(int index);
From source file:org.getlantern.firetweet.adapter.UserHashtagAutoCompleteAdapter.java
@Override public Cursor runQueryOnBackgroundThread(final CharSequence constraint) { char token = mToken; if (mEditText != null && constraint != null) { final CharSequence text = mEditText.getText(); token = text.charAt(mEditText.getSelectionEnd() - constraint.length() - 1); }// ww w . j a v a 2s . co m if (isAtSymbol(token) == isAtSymbol(mToken)) { final FilterQueryProvider filter = getFilterQueryProvider(); if (filter != null) return filter.runQuery(constraint); } mToken = token; final String constraintEscaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null; if (isAtSymbol(token)) { final Expression selection; final String[] selectionArgs; if (constraintEscaped != null) { final long[] nicknameIds = Utils.getMatchedNicknameIds(ParseUtils.parseString(constraint), mUserNicknamePreferences); selection = Expression.or(Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"), Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"), Expression.in(new Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds))); selectionArgs = new String[] { constraintEscaped, constraintEscaped }; } else { selection = null; selectionArgs = null; } final OrderBy orderBy = new OrderBy( new String[] { CachedUsers.LAST_SEEN, "score", CachedUsers.SCREEN_NAME, CachedUsers.NAME }, new boolean[] { false, false, true, true }); final Cursor cursor = mResolver.query( Uri.withAppendedPath(CachedUsers.CONTENT_URI_WITH_SCORE, String.valueOf(mAccountId)), CachedUsers.BASIC_COLUMNS, selection != null ? selection.getSQL() : null, selectionArgs, orderBy.getSQL()); if (Utils.isDebugBuild() && cursor == null) throw new NullPointerException(); return cursor; } else { final String selection = constraintEscaped != null ? CachedHashtags.NAME + " LIKE ?||'%' ESCAPE '^'" : null; final String[] selectionArgs = constraintEscaped != null ? new String[] { constraintEscaped } : null; final Cursor cursor = mDatabase.query(true, CachedHashtags.TABLE_NAME, CachedHashtags.COLUMNS, selection, selectionArgs, null, null, CachedHashtags.NAME, null); if (Utils.isDebugBuild() && cursor == null) throw new NullPointerException(); return cursor; } }
From source file:org.jamon.integration.TestBase.java
private String removeCrs(CharSequence string) { StringBuilder buffer = new StringBuilder(string.length()); for (int i = 0; i < string.length(); ++i) { char c = string.charAt(i); if (c != '\r') { buffer.append(c);/*from www . ja va 2s .com*/ } } return buffer.toString(); }
From source file:org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter.java
@Override public Cursor runQueryOnBackgroundThread(final CharSequence constraint) { char token = mToken; if (mEditText != null && constraint != null) { final CharSequence text = mEditText.getText(); token = text.charAt(mEditText.getSelectionEnd() - constraint.length() - 1); }//from w ww . j av a2s .c om if (isAtSymbol(token) == isAtSymbol(mToken)) { final FilterQueryProvider filter = getFilterQueryProvider(); if (filter != null) return filter.runQuery(constraint); } mToken = token; final String constraintEscaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null; if (isAtSymbol(token)) { final Expression selection; final String[] selectionArgs; if (constraintEscaped != null) { final long[] nicknameIds = Utils.getMatchedNicknameIds(ParseUtils.parseString(constraint), mUserColorNameManager); selection = Expression.or(Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"), Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"), Expression.in(new Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds))); selectionArgs = new String[] { constraintEscaped, constraintEscaped }; } else { selection = null; selectionArgs = null; } final OrderBy orderBy = new OrderBy( new String[] { CachedUsers.LAST_SEEN, "score", CachedUsers.SCREEN_NAME, CachedUsers.NAME }, new boolean[] { false, false, true, true }); final Cursor cursor = mResolver.query( Uri.withAppendedPath(CachedUsers.CONTENT_URI_WITH_SCORE, String.valueOf(mAccountId)), CachedUsers.BASIC_COLUMNS, selection != null ? selection.getSQL() : null, selectionArgs, orderBy.getSQL()); if (BuildConfig.DEBUG && cursor == null) throw new NullPointerException(); return cursor; } else { final String selection = constraintEscaped != null ? CachedHashtags.NAME + " LIKE ?||'%' ESCAPE '^'" : null; final String[] selectionArgs = constraintEscaped != null ? new String[] { constraintEscaped } : null; final Cursor cursor = mDatabase.query(true, CachedHashtags.TABLE_NAME, CachedHashtags.COLUMNS, selection, selectionArgs, null, null, CachedHashtags.NAME, null); if (BuildConfig.DEBUG && cursor == null) throw new NullPointerException(); return cursor; } }
From source file:cn.remex.core.util.StringUtils.java
/** * ???????/*from w ww . j a v a2 s . com*/ * Test whether the given string matches the given substring * at the given param. * @param str the original string (or StringBuffer) ? * @param index the param in the original string to start matching against ? * @param substring the substring to match at the given param ?? */ public static boolean substringMatch(final CharSequence str, final int index, final CharSequence substring) { for (int j = 0; j < substring.length(); j++) { int i = index + j; if (i >= str.length() || str.charAt(i) != substring.charAt(j)) { return false; } } return true; }
From source file:de.vanita5.twittnuker.adapter.UserHashtagAutoCompleteAdapter.java
@Override public Cursor runQueryOnBackgroundThread(final CharSequence constraint) { char token = mToken; if (mEditText != null && constraint != null) { final CharSequence text = mEditText.getText(); token = text.charAt(mEditText.getSelectionEnd() - constraint.length() - 1); }/* w w w .j a v a2s . c om*/ if (isAtSymbol(token) == isAtSymbol(mToken)) { final FilterQueryProvider filter = getFilterQueryProvider(); if (filter != null) return filter.runQuery(constraint); } mToken = token; final String constraint_escaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null; if (isAtSymbol(token)) { final StringBuilder builder = new StringBuilder(); builder.append(CachedUsers.SCREEN_NAME + " LIKE ?||'%' ESCAPE '^'"); builder.append(" OR "); builder.append(CachedUsers.NAME + " LIKE ?||'%' ESCAPE '^'"); builder.append(" OR "); builder.append(Where.in(new Column(CachedUsers.USER_ID), new RawItemArray(getMatchedNicknameIds(ParseUtils.parseString(constraint)))).getSQL()); final String selection = constraint_escaped != null ? builder.toString() : null; final String[] selectionArgs = constraint_escaped != null ? new String[] { constraint_escaped, constraint_escaped } : null; final String orderBy = CachedUsers.SCREEN_NAME + ", " + CachedUsers.NAME; return mResolver.query(CachedUsers.CONTENT_URI, CACHED_USERS_COLUMNS, selection, selectionArgs, orderBy); } else { final String selection = constraint_escaped != null ? CachedHashtags.NAME + " LIKE ?||'%' ESCAPE '^'" : null; final String[] selectionArgs = constraint_escaped != null ? new String[] { constraint_escaped } : null; return mDatabase.query(true, CachedHashtags.TABLE_NAME, CachedHashtags.COLUMNS, selection, selectionArgs, null, null, CachedHashtags.NAME, null); } }
From source file:com.example.android.uamp.ui.tv.CardViewHolder.java
private void setCardImage(Context context, Bitmap art) { if (mCardView == null) { return;/* w ww . j av a2s.com*/ } Drawable artDrawable = null; if (art != null) { artDrawable = new BitmapDrawable(context.getResources(), art); } else { CharSequence title = mCardView.getTitleText(); if (title != null && title.length() > 0) { artDrawable = new TextDrawable(String.valueOf(title.charAt(0))); } } mCardView.setMainImage(artDrawable); }
From source file:cn.remex.core.util.StringUtils.java
/** * ?????/* w w w. jav a 2 s . c o m*/ * Check whether the given CharSequence contains any whitespace characters. * @param str the CharSequence to check (may be <code>null</code>) ? * @return <code>true</code> if the CharSequence is not empty and * contains at least 1 whitespace character * @see java.lang.Character#isWhitespace */ public static boolean containsWhitespace(final CharSequence str) { if (!hasLength(str)) { return false; } int strLen = str.length(); for (int i = 0; i < strLen; i++) { if (Character.isWhitespace(str.charAt(i))) { return true; } } return false; }
From source file:se.sawano.java.security.otp.google.keyuri.PercentEscaper.java
@Override protected int nextEscapeIndex(CharSequence csq, int index, int end) { notNull(csq);/*from w ww .j a v a2s. c om*/ for (; index < end; index++) { char c = csq.charAt(index); if (c >= safeOctets.length || !safeOctets[c]) { break; } } return index; }
From source file:com.bayapps.android.robophish.ui.tv.CardPresenter.java
private void setCardImage(CardViewHolder cardViewHolder, Bitmap art) { if (cardViewHolder.mCardView == null) { return;/*from w ww. j a va 2 s. com*/ } Drawable artDrawable = null; if (art != null) { artDrawable = new BitmapDrawable(mContext.getResources(), art); } else { CharSequence title = cardViewHolder.mCardView.getTitleText(); if (title != null && title.length() > 0) { artDrawable = new TextDrawable(String.valueOf(title.charAt(0))); } } cardViewHolder.mCardView.setMainImage(artDrawable); }
From source file:org.sipfoundry.sipxconfig.bulk.csv.CsvParserImpl.java
/** * Checks if the line has contains full CSV fields only. * * @return true if String contains unmatched quote characters *//*from w ww . j a v a2 s . c o m*/ boolean hasUnmatchedFieldQuotes(CharSequence line) { boolean inQuotedField = false; boolean possibleEndQuote = false; for (int i = 0; i < line.length(); i++) { if (FIELD_QUOTE == line.charAt(i)) { if (inQuotedField) { possibleEndQuote = true; } else { inQuotedField = true; } } else if (possibleEndQuote) { if (FIELD_SEPARATOR == line.charAt(i)) { inQuotedField = false; } possibleEndQuote = false; } } if (possibleEndQuote) { inQuotedField = false; } return inQuotedField; }