From: <fg...@us...> - 2010-01-20 14:48:10
|
Revision: 1691 http://openutils.svn.sourceforge.net/openutils/?rev=1691&view=rev Author: fgiust Date: 2010-01-20 14:48:04 +0000 (Wed, 20 Jan 2010) Log Message: ----------- added urldecode Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 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-20 14:47:55 UTC (rev 1690) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-20 14:48:04 UTC (rev 1691) @@ -19,6 +19,7 @@ package net.sourceforge.openutils.elfunctions; import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.net.URLEncoder; import org.apache.commons.lang.StringUtils; @@ -61,10 +62,11 @@ { return "\n"; } + /** - * Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is bewteen ' - * @param String text - the string to be escaped - * @param boolean dbl - If "true" the escaped string is returned between ", if false is returned bewteen ' + * Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is between ' + * @param String text - the string to be escaped + * @param boolean dbl - If "true" the escaped string is returned between ", if false is returned between ' * @return the escaped string between either ' or " */ public static String escapeJsText(String text, boolean dbl) @@ -73,12 +75,13 @@ String with = "\\" + repl; return repl + (text != null ? StringUtils.replace(text, repl, with) : "") + repl; } + /** * Crops a String to a given length, adding a suffix if needed. - * @param java.lang.String value- The string to be adapted + * @param java.lang.String value- The string to be adapted * @param int maxLength - The number of chars of the string to be kept * @param java.lang.String ellipses - The suffix to be added if the string is not complete - * @return adapeted String + * @return adapted String */ public static String adaptStringLength(String value, int maxLength, String ellipses) { @@ -89,6 +92,7 @@ return value; } + /** * Strip any html tag from a String. * @param java.lang.String - The string to be stripped @@ -195,8 +199,8 @@ } /** - * Shorten a text with a number of lines and a number of chars per line to be displayed. Display optional ellipses where the - * line is shortened. + * Shorten a text with a number of lines and a number of chars per line to be displayed. Display optional ellipses + * where the line is shortened. * @param String text original text * @param int lines number of lines * @param int numOfCharsPerLine number of chars per line @@ -236,4 +240,17 @@ return string; } } + + public static String urldecode(String string) + { + try + { + return URLDecoder.decode(string, "UTF-8"); + } + catch (UnsupportedEncodingException e) + { + // should never happen + return string; + } + } } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-20 14:47:55 UTC (rev 1690) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-20 14:48:04 UTC (rev 1691) @@ -78,7 +78,7 @@ </example> </function> <function> - <description>Crops a String to a given length, adding a suffix (for example "...") if needed. The function accept 3 parameters: + <description>Crops a String to a given length, adding a suffix (for example "...") if needed. The function accept 3 parameters: <![CDATA[<br/><strong>java.lang.String:</strong> The string to be adapted<br/> <strong>int:</strong> The number of chars of the string to be kept<br/> <strong>java.lang.String:</strong> The suffix to be added if the string is not complete @@ -158,10 +158,14 @@ <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.Long toCeilLong(java.lang.String)</function-signature> </function> - <function> <name>urlencode</name> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String urlencode(java.lang.String)</function-signature> </function> + <function> + <name>urldecode</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String urldecode(java.lang.String)</function-signature> + </function> </taglib> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |