From: <fg...@us...> - 2010-01-18 17:37:07
|
Revision: 1677 http://openutils.svn.sourceforge.net/openutils/?rev=1677&view=rev Author: fgiust Date: 2010-01-18 17:36:56 +0000 (Mon, 18 Jan 2010) Log Message: ----------- ELFUNCTIONS-2 ElStringUtils.splitNewlines() always assumes linux-style line endings Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-18 17:19:39 UTC (rev 1676) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-18 17:36:56 UTC (rev 1677) @@ -20,8 +20,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; @@ -93,18 +91,18 @@ /** * Splits the given strings on newlines (<code>\n</code>) - * @param string string to be splitted - * @return splitted string + * @param string string to be split + * @return split string */ public static String[] splitNewlines(String string) { - return StringUtils.splitPreserveAllTokens(string, '\n'); + return StringUtils.splitPreserveAllTokens(StringUtils.replace(string, "\r", ""), '\n'); } /** * Splits the given strings on tabs (<code>\t</code>) - * @param string string to be splitted - * @return splitted string + * @param string string to be split + * @return split string */ public static String[] splitOnTabs(String string) { @@ -166,7 +164,7 @@ } /** - * Parse a double, passed as String, and return his ceil as a long (or 0L if parse fails) + * Parse a double, passed as String, and return his ceil as a long (or 0L if parse fails) * @param value the string to parse * @return the parsed double's floor as a long, or <code>0L</code> if parse fails * @see {@link Math#ceil(double)} @@ -182,7 +180,8 @@ } /** - * Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line is shortened. + * Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line + * is shortened. * @param text original text * @param lines number of lines * @param numOfCharsPerLine number of chars per line @@ -210,7 +209,6 @@ : text; } - public static String urlencode(String string) { try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2011-04-27 12:50:51
|
Revision: 3435 http://openutils.svn.sourceforge.net/openutils/?rev=3435&view=rev Author: fgiust Date: 2011-04-27 12:50:45 +0000 (Wed, 27 Apr 2011) Log Message: ----------- ELFUNCTIONS-9 Use StringEscapeUtils for escaping javascript texts Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-27 12:48:39 UTC (rev 3434) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-27 12:50:45 UTC (rev 3435) @@ -22,6 +22,7 @@ import java.net.URLDecoder; import java.net.URLEncoder; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; import org.apache.commons.lang.WordUtils; @@ -66,14 +67,12 @@ /** * Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is between ' * @param text the string to be escaped - * @param dbl If "true" the escaped string is returned between ", if false is returned between ' + * @param dbl deprecated - no effect * @return the escaped string between either ' or " */ public static String escapeJsText(String text, boolean dbl) { - String repl = dbl ? "\"" : "'"; - String with = "\\" + repl; - return repl + (text != null ? StringUtils.replace(text, repl, with) : "") + repl; + return StringEscapeUtils.escapeJavaScript(text); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |