protected CharSequence encode(CharSequence str) { return Strings.replaceAll(str, "]]>", "]]]]><![CDATA[>"); }
/** * Escapes any occurrences of <em>-</em> character in the style and variation * attributes with <em>~</em>. Any occurrence of <em>~</em> is encoded as <em>~~</em>. * * @param attribute * the attribute to escape * @return the attribute with escaped separator character */ public static CharSequence escapeAttributesSeparator(String attribute) { CharSequence tmp = Strings.replaceAll(attribute, "~", "~~"); return Strings.replaceAll(tmp, "-", "~"); }
/** * Escapes any occurrences of <em>-</em> character in the style and variation * attributes with <em>~</em>. Any occurrence of <em>~</em> is encoded as <em>~~</em>. * * @param attribute * the attribute to escape * @return the attribute with escaped separator character */ public static CharSequence escapeAttributesSeparator(String attribute) { CharSequence tmp = Strings.replaceAll(attribute, "~", "~~"); return Strings.replaceAll(tmp, "-", "~"); }
protected CharSequence encode(CharSequence str) { return Strings.replaceAll(str, "]]>", "]]]]><![CDATA[>"); }
/** * Replaces on this text. * * @param searchFor * What to search for * @param replaceWith * What to replace with * @return This string value with searchFor replaces with replaceWith */ public final CharSequence replaceAll(final CharSequence searchFor, final CharSequence replaceWith) { return Strings.replaceAll(text, searchFor, replaceWith); }
/** * Replaces on this text. * * @param searchFor * What to search for * @param replaceWith * What to replace with * @return This string value with searchFor replaces with replaceWith */ public final CharSequence replaceAll(final CharSequence searchFor, final CharSequence replaceWith) { return Strings.replaceAll(text, searchFor, replaceWith); }
/** * Create the parser for the current document. * * @param document * The document to parse */ public HtmlDocumentParser(final String document) { CharSequence tmp = Strings.replaceAll(document, "\n", ""); tmp = Strings.replaceAll(tmp, "\r", ""); this.document = Strings.replaceAll(tmp, "\t", " ").toString(); pos = 0; }
/** * Create the parser for the current document. * * @param document * The document to parse */ public HtmlDocumentParser(final String document) { CharSequence tmp = Strings.replaceAll(document, "\n", ""); tmp = Strings.replaceAll(tmp, "\r", ""); this.document = Strings.replaceAll(tmp, "\t", " ").toString(); pos = 0; }
/** * Create the parser for the current document. * * @param document * The document to parse */ public HtmlDocumentParser(final String document) { CharSequence tmp = Strings.replaceAll(document, "\n", ""); tmp = Strings.replaceAll(tmp, "\r", ""); this.document = Strings.replaceAll(tmp, "\t", " ").toString(); pos = 0; }
/** * Constructor. * @param latLng the position where the info window should be opened * @param content the (HTML) content which should be shown. Any containing * apostrophes will be escaped. */ public GInfoWindow(GLatLng latLng, String content) { this(latLng); this.content = Strings.replaceAll(content, "'", "\\'").toString(); }
/** * Encodes a string so it is safe to use inside CDATA blocks * * @param str * @return encoded string */ protected String encode(String str) { if (str == null) { return null; } return Strings.replaceAll(str, "]", "]^").toString(); }
/** * Reverts the escaping applied by {@linkplain #escapeAttributesSeparator(String)} - unescapes * occurrences of <em>~</em> character in the style and variation attributes with <em>-</em>. * * @param attribute * the attribute to unescape * @return the attribute with escaped separator character */ public static String unescapeAttributesSeparator(String attribute) { String tmp = attribute.replaceAll("(\\w)~(\\w)", "$1-$2"); return Strings.replaceAll(tmp, "~~", "~").toString(); }
/** * Reverts the escaping applied by {@linkplain #escapeAttributesSeparator(String)} - unescapes * occurrences of <em>~</em> character in the style and variation attributes with <em>-</em>. * * @param attribute * the attribute to unescape * @return the attribute with escaped separator character */ public static String unescapeAttributesSeparator(String attribute) { String tmp = attribute.replaceAll("(\\w)~(\\w)", "$1-$2"); return Strings.replaceAll(tmp, "~~", "~").toString(); }
/** * Escapes single quotes in localized strings to be used as JavaScript strings enclosed in single quotes * * @param key resource key for localized message * @return localized string with escaped single quotes */ protected String getEscapedJsString(String key) { String value = getString(key); return Strings.replaceAll(value, "'", "\\'").toString(); }
/** * Escapes single quotes in localized strings to be used as JavaScript strings enclosed in single quotes * * @param key resource key for localized message * @return localized string with escaped single quotes */ protected String getEscapedJsString(String key) { String value = getString(key); return Strings.replaceAll(value, "'", "\\'").toString(); }
@Override public String getObject() { if (wrapped != null && wrapped.getObject() != null) { String object = Strings.escapeMarkup(wrapped.getObject()).toString(); return Strings.replaceAll(object, "\n", "<br/>").toString(); } return null; }
private CharSequence escapeAttribute(final CharSequence attr) { if(null == attr) { return null; } CharSequence escaped = Strings.escapeMarkup(attr.toString()); // No need to escape the apostrophe; it just clutters the markup return Strings.replaceAll(escaped, "'", "'"); }
/** * Escapes single quotes in localized strings to be used as JavaScript * strings enclosed in single quotes * * @param key * resource key for localized message * @return localized string with escaped single quotes */ protected String getEscapedJsString(String key) { String value = getString(key); return Strings.replaceAll(value, "'", "\\'").toString(); }
/** * Escapes single quotes in localized strings to be used as JavaScript strings enclosed in * single quotes * * @param key * resource key for localized message * @return localized string with escaped single quotes */ protected String getEscapedJsString(String key) { String value = getString(key); return Strings.replaceAll(value, "'", "\\'").toString(); }
protected String getPath(Component component) { String path = component.getPageRelativePath(); if (StringUtils.isEmpty(path)) { return null; } // escape some noncompliant characters path = Strings.replaceAll(path, "_", "__").toString(); path = path.replace('.', '_'); path = path.replace('-', '_'); path = path.replace(' ', '_'); path = path.replace(':', '_'); return path; } }