List of usage examples for java.lang CharSequence length
int length();
From source file:edu.chalmers.dat076.moviefinder.service.TitleParser.java
public int checkForYear(CharSequence cs) { int year = 0; if (cs.length() == 4) { for (int i = 0; i < 4; i++) { if (Character.isDigit(cs.charAt(i))) { year = year * 10;/*from w w w . j av a 2s . co m*/ year = year + Character.getNumericValue(cs.charAt(i)); } else { return -1; } } } return year; }
From source file:org.deviceconnect.android.uiapp.fragment.profile.VibrationProfileFragment.java
/** * Vibration???.//from ww w.j av a2s. c om * @param pattern ? */ private void sendVibration(final CharSequence pattern) { (new AsyncTask<Void, Void, DConnectMessage>() { public DConnectMessage doInBackground(final Void... args) { String p = null; if (pattern != null && pattern.length() > 0) { p = pattern.toString(); } try { URIBuilder builder = new URIBuilder(); builder.setProfile(VibrationProfileConstants.PROFILE_NAME); builder.setAttribute(VibrationProfileConstants.ATTRIBUTE_VIBRATE); builder.addParameter(DConnectMessage.EXTRA_DEVICE_ID, getSmartDevice().getId()); if (p != null) { builder.addParameter(VibrationProfileConstants.PARAM_PATTERN, p); } builder.addParameter(DConnectMessage.EXTRA_ACCESS_TOKEN, getAccessToken()); HttpResponse response = getDConnectClient().execute(getDefaultHost(), new HttpPut(builder.build())); return (new HttpMessageFactory()).newDConnectMessage(response); } catch (URISyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(final DConnectMessage result) { if (getActivity().isFinishing()) { return; } TextView tv = (TextView) getView().findViewById(R.id.fragment_vibration_result); if (result == null) { tv.setText("failed"); } else { tv.setText(result.toString()); } } }).execute(); }
From source file:jef.tools.ArrayUtils.java
/** * CharSequence????char// w ww . j av a 2s. com * ?CharBuffer,StringBuilder,StringbufferIterator??? * * @param e * @return */ public static Iterable<Character> toIterable(final CharSequence e) { return new Iterable<Character>() { public Iterator<Character> iterator() { return new Iterator<Character>() { int n = 0; public boolean hasNext() { return n < e.length(); } public Character next() { return e.charAt(n++); } public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:org.greencheek.utils.environment.propertyplaceholder.resolver.value.VariablePlaceholderValueResolver.java
/** * Taken from Spring StringUtils (org.springframework.util.StringUtils;) * * Test whether the given string matches the given substring * at the given index.//from ww w. j av a 2 s. c o m * @param str the original string (or StringBuilder) * @param index the index in the original string to start matching against * @param substring the substring to match at the given index */ public boolean substringMatch(CharSequence str, int index, 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:com.acceleratedio.pac_n_zoom.SaveAnmActivity.java
public void onClick(View vw) { switch (vw.getId()) { case R.id.sav_tags: dsply_tags();//from ww w .j a v a 2s.co m break; default: Button btn_vw = (Button) vw; CharSequence btn_sqn = btn_vw.getText(); final StringBuilder strBldr = new StringBuilder(btn_sqn.length()); strBldr.append(btn_sqn); String tag_str = tagText.getText().toString(); int chr_idx = tag_str.lastIndexOf(" "); tag_str = tag_str.substring(0, chr_idx + 1) + strBldr.toString() + ' '; tagText.setText(tag_str, TextView.BufferType.EDITABLE); tagText.setSelection(tag_str.length()); srch_str = ""; dsply_tags(); } }
From source file:CSVParser.java
/** * precondition: sb.length() > 0//from w w w. j ava 2 s. c o m * @param sb A sequence of characters to examine * @return true if every character in the sequence is whitespace */ protected boolean isAllWhiteSpace(CharSequence sb) { boolean result = true; for (int i = 0; i < sb.length(); i++) { char c = sb.charAt(i); if (!Character.isWhitespace(c)) { return false; } } return result; }
From source file:com.example.activity.ProfileActivity.java
private void setPlayer() { ImageLoader.getInstance().displayImage(playerModel.player.avatar_url, head, BeeFrameworkApp.options_head); name.setText(playerModel.player.name); location.setText(playerModel.player.location); shots_count.setText(playerModel.player.shots_count + ""); likes_count.setText(playerModel.player.likes_count + ""); following_count.setText(playerModel.player.following_count + ""); followers_count.setText(playerModel.player.followers_count + ""); net.setText(playerModel.player.website_url); CharSequence text = net.getText(); if (text instanceof Spannable) { int end = text.length(); Spannable sp = (Spannable) net.getText(); URLSpan[] spans = sp.getSpans(0, end, URLSpan.class); SpannableStringBuilder style = new SpannableStringBuilder(text); style.clearSpans();// should clear old spans for (URLSpan span : spans) { JayceSpan mySpan = new JayceSpan(span.getURL()); style.setSpan(mySpan, sp.getSpanStart(span), sp.getSpanEnd(span), Spannable.SPAN_EXCLUSIVE_INCLUSIVE); }/*from w w w . ja v a 2 s.c o m*/ net.setText(style); } }
From source file:com.dianping.resource.io.util.PropertyPlaceholderHelper.java
private int findPlaceholderEndIndex(CharSequence buf, int startIndex) { int index = startIndex + this.placeholderPrefix.length(); int withinNestedPlaceholder = 0; while (index < buf.length()) { if (StringUtils.substringMatch(buf, index, this.placeholderSuffix)) { if (withinNestedPlaceholder > 0) { withinNestedPlaceholder--; index = index + this.placeholderSuffix.length(); } else { return index; }//from w w w . j a v a2 s . c o m } else if (StringUtils.substringMatch(buf, index, this.simplePrefix)) { withinNestedPlaceholder++; index = index + this.simplePrefix.length(); } else { index++; } } return -1; }
From source file:fr.landel.utils.commons.StringUtils.java
/** * Try to prefix the sequence/*www . j a v a2 s .com*/ * * @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:fr.landel.utils.commons.StringUtils.java
/** * Try to suffix the sequence/*from ww w . ja v a 2 s . co m*/ * * @param sequence * the sequence to suffix * @param suffix * the suffix * @return the suffixed sequence * @throws NullPointerException * if {@code sequence} or {@code suffix} are {@code null} */ public static String suffixIfNotEndsWith(final CharSequence sequence, final CharSequence suffix) { Objects.requireNonNull(sequence, ERROR_SEQUENCE); Objects.requireNonNull(suffix, ERROR_SUFFIX); int lSequence = sequence.length(); int lSuffix = suffix.length(); if (lSuffix == 0 || (lSequence >= lSuffix && sequence.subSequence(lSequence - lSuffix, lSequence).equals(suffix))) { return sequence.toString(); } return sequence.toString().concat(suffix.toString()); }