List of usage examples for java.lang CharSequence subSequence
CharSequence subSequence(int start, int end);
From source file:org.esigate.impl.UrlRewriter.java
/** * Fixes all resources urls and returns the result. * /* ww w . j a v a 2 s . co m*/ * @param input * The html to be processed. * * @param requestUrl * The request URL. * @param baseUrlParam * The base URL selected for this request. * @param visibleBaseUrl * The base URL viewed by the browser. * @param absolute * Should the rewritten urls contain the scheme host and port * * @return the result of this renderer. */ public CharSequence rewriteHtml(CharSequence input, String requestUrl, String baseUrlParam, String visibleBaseUrl, boolean absolute) { StringBuffer result = new StringBuffer(input.length()); Matcher m = URL_PATTERN.matcher(input); while (m.find()) { String url = input.subSequence(m.start(3) + 1, m.end(3) - 1).toString(); String tag = m.group(0); String quote = input.subSequence(m.end(3) - 1, m.end(3)).toString(); // Browsers tolerate urls with white spaces before or after String trimmedUrl = StringUtils.trim(url); String rewrittenUrl = url; trimmedUrl = unescapeHtml(trimmedUrl); if (trimmedUrl.isEmpty()) { LOG.debug("empty url kept unchanged"); } else if (trimmedUrl.startsWith("#")) { LOG.debug("anchor url kept unchanged: [{}]", url); } else if (JAVASCRIPT_CONCATENATION_PATTERN.matcher(trimmedUrl).find()) { LOG.debug("url in javascript kept unchanged: [{}]", url); } else if (m.group(2).equalsIgnoreCase("content")) { if (META_REFRESH_PATTERN.matcher(tag).find()) { rewrittenUrl = rewriteRefresh(trimmedUrl, requestUrl, baseUrlParam, visibleBaseUrl); rewrittenUrl = escapeHtml(rewrittenUrl); LOG.debug("refresh url [{}] rewritten [{}]", url, rewrittenUrl); } else { LOG.debug("content attribute kept unchanged: [{}]", url); } } else { rewrittenUrl = rewriteUrl(trimmedUrl, requestUrl, baseUrlParam, visibleBaseUrl, absolute); rewrittenUrl = escapeHtml(rewrittenUrl); LOG.debug("url [{}] rewritten [{}]", url, rewrittenUrl); } m.appendReplacement(result, ""); // Copy what is between the previous match and the current match result.append("<"); result.append(m.group(1)); result.append(m.group(2)); result.append("="); result.append(quote); result.append(rewrittenUrl); result.append(quote); if (m.groupCount() > 3) { result.append(m.group(4)); } result.append(">"); } m.appendTail(result); // Copy the reminder of the input return result; }
From source file:ti.modules.titanium.audio.streamer.NotificationHelper.java
public void showNotification() { if (mNotification == null) { return;// w w w . j a v a 2 s . co m } CharSequence oldvalue = mNotification.tickerText; if (oldvalue != null) { if (oldvalue.toString().endsWith(" ")) { mNotification.tickerText = oldvalue.subSequence(0, oldvalue.length() - 1); } else { mNotification.tickerText = oldvalue + " "; } } mNotificationManager.notify(mNotificationId, mNotification); }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static String subStringAfterFirst(final CharSequence toSearch, final CharSequence sequence, final Boolean caseSensitive) { final int idx = indexOf(toSearch, sequence, caseSensitive); return (idx < 0) ? null : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence))); }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static String substringAfterFirst(final CharSequence toSearch, final CharSequence sequence, final Boolean caseSensitive) { final int idx = indexOf(toSearch, sequence, caseSensitive); return (idx < 0) ? null : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence))); }
From source file:com.sahildave.snackbar.SnackBar.java
public void setContainerLiveHelp(View snackView, String message, String[] subMessageArray) { TextView mSnackSubMsgView = (TextView) snackView.findViewById(R.id.snackSubMessage); TextView mSnackMsgView = (TextView) snackView.findViewById(R.id.snackMessage); mSnackMsgView.setText(message);/*www .j a va 2 s . c o m*/ CharSequence subMessage = getBulletSpanMessage(subMessageArray); mSnackSubMsgView.setText(subMessage.subSequence(0, subMessage.length() - 1)); //to remove extra new line char }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static String subStringAfterLast(final CharSequence toSearch, final CharSequence sequence, final Boolean caseSensitive) { final int idx = lastIndexOf(toSearch, sequence, caseSensitive); return (idx < 0) ? null : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence))); }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static String substringAfterLast(final CharSequence toSearch, final CharSequence sequence, final Boolean caseSensitive) { final int idx = lastIndexOf(toSearch, sequence, caseSensitive); return (idx < 0) ? null : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence))); }
From source file:org.archive.extractor.RegexHTMLLinkExtractor.java
/** * @param value/*from w ww. j a v a 2s. c om*/ * @param context */ protected void processLink(CharSequence value, LinkContext context) { String link = TextUtils.replaceAll(ESCAPED_AMP, value, "&"); if (TextUtils.matches(JAVASCRIPT, link)) { processScriptCode(value.subSequence(11, value.length())); } else { addLinkFromString(link, context, Hop.NAVLINK); } }
From source file:com.cyberway.issue.extractor.RegexpHTMLLinkExtractor.java
/** * @param value/* w w w.ja v a2 s. c o m*/ * @param context */ protected void processLink(CharSequence value, CharSequence context) { String link = TextUtils.replaceAll(ESCAPED_AMP, value, "&"); if (TextUtils.matches(JAVASCRIPT, link)) { processScriptCode(value.subSequence(11, value.length())); } else { addLinkFromString(link, context, Link.NAVLINK_HOP); } }
From source file:com.sahildave.snackbar.SnackBar.java
private void addMultiLineInfo(String message, String[] subMessageArray, MessageType messageType) { View v = activity.getLayoutInflater().inflate(R.layout.usb_multiline_info, null); TextView mSnackMsgView = (TextView) v.findViewById(R.id.snackMessage); TextView mSnackSubMsgView = (TextView) v.findViewById(R.id.snackSubMessage); ImageView mSnackIcon = (ImageView) v.findViewById(R.id.snackIcon); mSnackMsgView.setText(message);// w w w .j a va 2 s .c o m setSnackIcon(messageType, mSnackIcon); CharSequence subMessage = getBulletSpanMessage(subMessageArray); mSnackSubMsgView.setText(subMessage.subSequence(0, subMessage.length() - 1)); //to remove extra new line char v.setTag(messageType); addToView(v); }