From: <fg...@us...> - 2008-12-11 16:37:45
|
Revision: 951 http://openutils.svn.sourceforge.net/openutils/?rev=951&view=rev Author: fgiust Date: 2008-12-11 16:37:40 +0000 (Thu, 11 Dec 2008) Log Message: ----------- docs 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 2008-12-11 16:28:22 UTC (rev 950) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2008-12-11 16:37:40 UTC (rev 951) @@ -100,4 +100,15 @@ return StringUtils.splitPreserveAllTokens(string, '\t'); } + /** + * Tests if this string ends with the specified suffix. + * @param string + * @param suffix + * @return true if the string ends with the suffix, false otherwise + */ + public static boolean endsWith(String string, String suffix) + { + return string.endsWith(suffix); + } + } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2008-12-11 16:28:22 UTC (rev 950) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2008-12-11 16:37:40 UTC (rev 951) @@ -1,73 +1,84 @@ <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" - version="2.0"> - <description>Openutils EL functions: stringutils</description> - <display-name>Openutils EL functions: stringutils</display-name> - <tlib-version>1.0</tlib-version> - <short-name>su</short-name> - <uri>http://openutils.sf.net/openutils-stringutils</uri> - <function> - <name>capitaliseAllWords</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String capitaliseAllWords(java.lang.String)</function-signature> - </function> - <function> - <name>substringAfterLast</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String substringAfterLast(java.lang.String, java.lang.String)</function-signature> - </function> - <function> - <name>substringBeforeLast</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String substringBeforeLast(java.lang.String, java.lang.String)</function-signature> + version="2.0"> + <description>Openutils EL functions: stringutils</description> + <display-name>Openutils EL functions: stringutils</display-name> + <tlib-version>1.0</tlib-version> + <short-name>su</short-name> + <uri>http://openutils.sf.net/openutils-stringutils</uri> + <function> + <description>Capitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.</description> + <name>capitaliseAllWords</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String capitaliseAllWords(java.lang.String)</function-signature> </function> <function> + <description>Gets the substring after the last occurrence of a separator. The separator is not returned.</description> + <name>substringAfterLast</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String substringAfterLast(java.lang.String, java.lang.String)</function-signature> + </function> + <function> + <description>Gets the substring before the last occurrence of a separator. The separator is not returned.</description> + <name>substringBeforeLast</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String substringBeforeLast(java.lang.String, java.lang.String)</function-signature> + </function> + <function> + <description>Checks if a String is whitespace, empty ("") or null.</description> <name>isBlank</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean isBlank(java.lang.String )</function-signature> </function> <function> + <description>Creates a random string whose length is the number of characters specified.</description> <name>randomAlphanumeric</name> <function-class>org.apache.commons.lang.RandomStringUtils</function-class> <function-signature>java.lang.String randomAlphanumeric(int)</function-signature> - </function> + </function> <function> <description>Unescapes a String</description> <name>unescapeXml</name> <function-class>org.apache.commons.lang.StringEscapeUtils</function-class> <function-signature>java.lang.String unescapeXml(java.lang.String)</function-signature> - </function> - <function> - <name>space</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String space()</function-signature> - </function> - <function> - <name>tab</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String tab()</function-signature> - </function> - <function> - <name>newline</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String newline()</function-signature> </function> - <function> - <name>escJsTxt</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String escapeJsText(java.lang.String, boolean)</function-signature> - </function> - <function> - <name>adaptStringLength</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String adaptStringLength(java.lang.String, int, java.lang.String)</function-signature> - </function> - <function> - <name>stripHtmlTags</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String stripHtmlTags(java.lang.String)</function-signature> + <function> + <description>Output a white space.</description> + <name>space</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String space()</function-signature> </function> <function> + <description>Output a tab character.</description> + <name>tab</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String tab()</function-signature> + </function> + <function> + <description>Output a newline character.</description> + <name>newline</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String newline()</function-signature> + </function> + <function> + <description>Escapes a javascript string.</description> + <name>escJsTxt</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String escapeJsText(java.lang.String, boolean)</function-signature> + </function> + <function> + <description>Crops a String to a given length, adding a suffix (for example "...") if needed.</description> + <name>adaptStringLength</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String adaptStringLength(java.lang.String, int, java.lang.String)</function-signature> + </function> + <function> + <description>Strip any html tag from a String.</description> + <name>stripHtmlTags</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String stripHtmlTags(java.lang.String)</function-signature> + </function> + <function> <description>Splits the given strings on newlines</description> <name>splitNewlines</name> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> @@ -90,5 +101,11 @@ <name>defaultIfEmpty</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String defaultIfEmpty(java.lang.String, java.lang.String)</function-signature> - </function> + </function> + <function> + <description>A wrapper around java.lang.String#endsWith(..). Tests if this string ends with the specified suffix.</description> + <name>endsWith</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>boolean endsWith(java.lang.String, 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. |
From: <cs...@us...> - 2010-01-14 17:44:54
|
Revision: 1640 http://openutils.svn.sourceforge.net/openutils/?rev=1640&view=rev Author: cstrap Date: 2010-01-14 17:44:47 +0000 (Thu, 14 Jan 2010) Log Message: ----------- ELStringUtils - splitAndTokenize: splits on newlines and on tabs. Return a list of objects (usually used with a grid component) MgnlUtilsElFunction: - getLink: return a cleaned url (accept uuid, internal link, http link and a generic strings) 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-14 16:18:55 UTC (rev 1639) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-14 17:44:47 UTC (rev 1640) @@ -15,6 +15,9 @@ */ package net.sourceforge.openutils.elfunctions; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; import org.apache.commons.lang.WordUtils; @@ -104,6 +107,25 @@ } /** + * Splits the given strings on newline (<code>\n</code>) and after on tabs (<code>\t</code>) + * Usually used to retrieve data from a magnolia grid component + * @param string string to be splitted + * @return array + */ + public static String[][] splitAndTokenize(String string) + { + List<String[]> list = new ArrayList<String[]>(); + for (String line : ElStringUtils.splitNewlines(string)) + { + if (StringUtils.isNotBlank(line)) + { + list.add(ElStringUtils.splitOnTabs(line)); + } + } + return list.toArray(new String[0][]); + } + + /** * Tests if this string ends with the specified suffix. * @param string * @param suffix Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-14 16:18:55 UTC (rev 1639) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-14 17:44:47 UTC (rev 1640) @@ -97,6 +97,12 @@ <function-signature>java.lang.String[] splitOnTabs(java.lang.String)</function-signature> </function> <function> + <description>Splits the given string on newlines and after on tab characters</description> + <name>splitAndTokenize</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String[][] splitAndTokenize(java.lang.String)</function-signature> + </function> + <function> <description>Strips whitespaces from the start and the end of a String</description> <name>strip</name> <function-class>org.apache.commons.lang.StringUtils</function-class> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-01-14 22:08:35
|
Revision: 1644 http://openutils.svn.sourceforge.net/openutils/?rev=1644&view=rev Author: fgiust Date: 2010-01-14 22:08:28 +0000 (Thu, 14 Jan 2010) Log Message: ----------- added urlencode 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-14 21:21:53 UTC (rev 1643) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-14 22:08:28 UTC (rev 1644) @@ -15,6 +15,8 @@ */ package net.sourceforge.openutils.elfunctions; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -107,8 +109,8 @@ } /** - * Splits the given strings on newline (<code>\n</code>) and after on tabs (<code>\t</code>) - * Usually used to retrieve data from a magnolia grid component + * Splits the given strings on newline (<code>\n</code>) and after on tabs (<code>\t</code>) Usually used to + * retrieve data from a magnolia grid component * @param string string to be splitted * @return array */ @@ -124,7 +126,7 @@ } return list.toArray(new String[0][]); } - + /** * Tests if this string ends with the specified suffix. * @param string @@ -234,4 +236,16 @@ return text.replaceAll("\\<.*?>", ""); } + public static String urlencode(String string) + { + try + { + return URLEncoder.encode(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-14 21:21:53 UTC (rev 1643) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-14 22:08:28 UTC (rev 1644) @@ -153,4 +153,9 @@ <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String stripTags(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> </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. |
From: <me...@us...> - 2010-01-15 14:50:30
|
Revision: 1649 http://openutils.svn.sourceforge.net/openutils/?rev=1649&view=rev Author: memila Date: 2010-01-15 14:50:20 +0000 (Fri, 15 Jan 2010) Log Message: ----------- comment added 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-15 14:24:12 UTC (rev 1648) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-15 14:50:20 UTC (rev 1649) @@ -120,7 +120,7 @@ } /** - * safely parse a long + * Parse a number, passed as String, and return his Long * @param value the string to parse * @return the parsed long, or <code>0L</code> if parse fails * @see {@link NumberUtils#toLong()} @@ -131,7 +131,7 @@ } /** - * safely parse a double, and return his closest rounding as a long + * Parse a number, passed as String, and return his closest rounding as a long (or 0L if parse fails) * @param value the string to parse * @return the closest long to the parsed double, or <code>0L</code> if parse fails * @see {@link Math#round(double)} @@ -147,7 +147,7 @@ } /** - * safely parse a double, and return his floor as a long + * Parse a double, passed as String, and return his floor 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#floor(double)} @@ -163,7 +163,7 @@ } /** - * safely parse a double, and return his ceil as a long + * 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)} @@ -179,7 +179,7 @@ } /** - * Shorten a text + * 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 @@ -207,15 +207,6 @@ : text; } - /** - * strip xml and html tags - * @param text the text to strip - * @return the stripped text - */ - public static String stripTags(String text) - { - return text.replaceAll("\\<.*?>", ""); - } public static String urlencode(String string) { Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-15 14:24:12 UTC (rev 1648) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-15 14:50:20 UTC (rev 1649) @@ -116,38 +116,36 @@ </function> <function> <name>shorten</name> + <description>Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line is shortened.</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String shorten(java.lang.String, int, int, java.lang.String)</function-signature> </function> <function> <name>toLong</name> + <description>Parse a number, passed as String, and return his Long</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.Long toLong(java.lang.String)</function-signature> </function> <function> <name>toRoundedLong</name> - <description>safely parse a double, and return his closest rounding as a long (or 0L if parse fails)</description> + <description>Parse a number, passed as String, and return his closest rounding as a long (or 0L if parse fails)</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.Long toRoundedLong(java.lang.String)</function-signature> </function> <function> <name>toFloorLong</name> - <description>safely parse a double, and return his floor as a long (or 0L if parse fails)</description> + <description>Parse a double, passed as String, and return his floor as a long (or 0L if parse fails)</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.Long toFloorLong(java.lang.String)</function-signature> </function> <function> <name>toCeilLong</name> - <description>safely parse a double, and return his ceil as a long (or 0L if parse fails)</description> + <description>Parse a double, passed as String, and return his ceil as a long (or 0L if parse fails)</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.Long toCeilLong(java.lang.String)</function-signature> </function> + <function> - <name>stripTags</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String stripTags(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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <me...@us...> - 2010-01-19 09:53:36
|
Revision: 1679 http://openutils.svn.sourceforge.net/openutils/?rev=1679&view=rev Author: memila Date: 2010-01-19 09:53:27 +0000 (Tue, 19 Jan 2010) Log Message: ----------- input parameter descrptions added to both tld and java files 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-18 17:59:05 UTC (rev 1678) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-19 09:53:27 UTC (rev 1679) @@ -61,14 +61,25 @@ { 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 ' + * @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; } - + /** + * Crops a String to a given length, adding a suffix if needed. + * @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 + */ public static String adaptStringLength(String value, int maxLength, String ellipses) { if (value != null && value.length() > maxLength) @@ -78,7 +89,11 @@ return value; } - + /** + * Strip any html tag from a String. + * @param java.lang.String - The string to be stripped + * @return stripped String + */ public static String stripHtmlTags(String string) { if (StringUtils.isNotBlank(string)) @@ -180,12 +195,12 @@ } /** - * 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 - * @param ellipses ellipses ('...') + * 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 + * @param String ellipses optional ellipses ('...') to display optional ellipses where the line is shortened. * @return cropped string */ public static String shorten(String text, int lines, int numOfCharsPerLine, String ellipses) Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-18 17:59:05 UTC (rev 1678) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-19 09:53:27 UTC (rev 1679) @@ -67,16 +67,30 @@ <function-signature>java.lang.String newline()</function-signature> </function> <function> - <description>Escapes a javascript string.</description> + <description>Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is bewteen '</description> <name>escJsTxt</name> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String escapeJsText(java.lang.String, boolean)</function-signature> + <example> + <![CDATA[ + escJsTxt("xyz\\23",true) : "xyz\23" + ]]> + </example> </function> <function> - <description>Crops a String to a given length, adding a suffix (for example "...") if needed.</description> + <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 + ]]></description> <name>adaptStringLength</name> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String adaptStringLength(java.lang.String, int, java.lang.String)</function-signature> + <example> + <![CDATA[ + adaptStringLength("pre",2,"post") : prpost + ]]> + </example> </function> <function> <description>Strip any html tag from a String.</description> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <me...@us...> - 2010-01-20 15:14:03
|
Revision: 1692 http://openutils.svn.sourceforge.net/openutils/?rev=1692&view=rev Author: memila Date: 2010-01-20 15:13:49 +0000 (Wed, 20 Jan 2010) Log Message: ----------- added more documentation to tld doc and fix @param in java file 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:48:04 UTC (rev 1691) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-20 15:13:49 UTC (rev 1692) @@ -65,8 +65,8 @@ /** * 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 ' + * @param text the string to be escaped + * @param 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) @@ -78,9 +78,9 @@ /** * Crops a String to a given length, adding a suffix if needed. - * @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 + * @param value The string to be adapted + * @param maxLength The number of chars of the string to be kept + * @param ellipses The suffix to be added if the string is not complete * @return adapted String */ public static String adaptStringLength(String value, int maxLength, String ellipses) @@ -95,7 +95,7 @@ /** * Strip any html tag from a String. - * @param java.lang.String - The string to be stripped + * @param string string The string to be stripped * @return stripped String */ public static String stripHtmlTags(String string) @@ -130,8 +130,8 @@ /** * Tests if this string ends with the specified suffix. - * @param string - * @param suffix + * @param string string to evaluate + * @param suffix suffix to be added * @return true if the string ends with the suffix, false otherwise */ public static boolean endsWith(String string, String suffix) @@ -201,10 +201,10 @@ /** * 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 - * @param String ellipses optional ellipses ('...') to display optional ellipses where the line is shortened. + * @param text original text + * @param lines number of lines + * @param numOfCharsPerLine number of chars per line + * @param ellipses optional ellipses ('...') to display optional ellipses where the line is shortened. * @return cropped string */ public static String shorten(String text, int lines, int numOfCharsPerLine, String ellipses) @@ -227,7 +227,11 @@ ? StringUtils.substring(wrapped, 0, j) + (ellipses == null ? StringUtils.EMPTY : ellipses) : text; } - + /** + * Enconde a url in UTF-8 format + * @param string url to be encoded + * @return a url UTF-8 encoded + */ public static String urlencode(String string) { try @@ -240,7 +244,11 @@ return string; } } - + /** + * Decode a url in UTF-8 format + * @param string url to be decoded + * @return a url UTF-8 decoded + */ public static String urldecode(String string) { try 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:48:04 UTC (rev 1691) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-20 15:13:49 UTC (rev 1692) @@ -13,13 +13,21 @@ <function-signature>java.lang.String capitaliseAllWords(java.lang.String)</function-signature> </function> <function> - <description>Gets the substring after the last occurrence of a separator. The separator is not returned.</description> + <description>Gets the substring after the last occurrence of a separator. The separator is not returned. The function accept 2 parameters:<![CDATA[ + <br/> + <strong>java.lang.String: </strong>the String to get a substring from, may be null<br/> + <strong>java.lang.String: </strong>the String to search for, may be null<br/> + ]]></description> <name>substringAfterLast</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringAfterLast(java.lang.String, java.lang.String)</function-signature> </function> <function> - <description>Gets the substring before the last occurrence of a separator. The separator is not returned.</description> + <description>Gets the substring before the last occurrence of a separator. The separator is not returned. The function accept 2 parameters:<![CDATA[ + <br/> + <strong>java.lang.String: </strong>the String to get a substring from, may be null<br/> + <strong>java.lang.String: </strong>the String to search for, may be null<br/> + ]]></description> <name>substringBeforeLast</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringBeforeLast(java.lang.String, java.lang.String)</function-signature> @@ -79,9 +87,9 @@ </function> <function> <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 + <![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 ]]></description> <name>adaptStringLength</name> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> @@ -117,20 +125,35 @@ <function-signature>java.lang.String strip(java.lang.String)</function-signature> </function> <function> - <description>Returns either the passed in String, or if the String is empty or null, the value of defaultStr</description> + <description>Returns either the passed in String, or if the String is empty or null, the value of defaultStr. The function accept 2 parameters:<![CDATA[ + <br/> + <strong>java.lang.String: </strong>the String to check, may be null<br/> + <strong>java.lang.String: </strong>the default String to return if the string to check is null of empty<br/> + ]]></description> <name>defaultIfEmpty</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String defaultIfEmpty(java.lang.String, java.lang.String)</function-signature> </function> <function> - <description>A wrapper around java.lang.String#endsWith(..). Tests if this string ends with the specified suffix.</description> + <description>A wrapper around java.lang.String#endsWith(..). Tests if this string ends with the specified suffix. The function accept 2 parameters:<![CDATA[ + <br/> + <strong>java.lang.String: </strong>string to evaluate<br/> + <strong>java.lang.String: </strong>suffix<br/> + ]]></description> <name>endsWith</name> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>boolean endsWith(java.lang.String, java.lang.String)</function-signature> </function> <function> <name>shorten</name> - <description>Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line is shortened.</description> + <description>Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line is shortened. The function accept 4 parameters: + <![CDATA[ + <br/> + <strong>java.lang.String: </strong>original text<br/> + <strong>int: </strong>number of lines<br/> + <strong>int: </strong>number of chars per line + <strong>java.lang.String: </strong>optional ellipses ('...') to display optional ellipses where the line is shortened. + ]]></description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String shorten(java.lang.String, int, int, java.lang.String)</function-signature> </function> @@ -160,11 +183,13 @@ </function> <function> <name>urlencode</name> + <description>Enconde a url in UTF-8 format</description> <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> + <description>Decode a url in UTF-8 format</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String urldecode(java.lang.String)</function-signature> </function> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <me...@us...> - 2010-01-20 15:33:06
|
Revision: 1693 http://openutils.svn.sourceforge.net/openutils/?rev=1693&view=rev Author: memila Date: 2010-01-20 15:33:00 +0000 (Wed, 20 Jan 2010) Log Message: ----------- added local string to passed as parameter Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-01-20 15:13:49 UTC (rev 1692) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-01-20 15:33:00 UTC (rev 1693) @@ -146,22 +146,24 @@ * formats a date using the given pattern or built-in style * @param date the date to format * @param pattern a valid pattern, or one of "short", "medium", "long", "full" (case insensitive) + * @param languageId lowercase two-letter ISO-639 code. * @return the formatted date */ - public static String formatDate(Calendar date, String pattern) + public static String formatDate(Calendar date, String pattern, String languageId) { - return format(date, pattern, true, false, null); + return format(date, pattern, true, false, new Locale(languageId)); } /** * formats a time using the given pattern or built-in style * @param time the time to format * @param pattern a valid pattern, or one of "short", "medium", "long", "full" (case insensitive) + * @param languageId lowercase two-letter ISO-639 code. * @return the formatted time */ - public static String formatTime(Calendar time, String pattern) + public static String formatTime(Calendar time, String pattern, String languageId) { - return format(time, pattern, false, true, null); + return format(time, pattern, false, true, new Locale(languageId)); } /** @@ -169,11 +171,12 @@ * time with the syntax "date_format;time_format" (ex: "long;short") * @param dateTime the date and time * @param pattern date pattern + * @param languageId lowercase two-letter ISO-639 code. * @return formatted string */ - public static String formatDateTime(Calendar dateTime, String pattern) + public static String formatDateTime(Calendar dateTime, String pattern, String languageId) { - return format(dateTime, pattern, true, true, null); + return format(dateTime, pattern, true, true, new Locale(languageId)); } /** Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-01-20 15:13:49 UTC (rev 1692) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-01-20 15:33:00 UTC (rev 1693) @@ -13,7 +13,7 @@ different styles for date and time with the syntax "date_style;time_style" (e.g. "short;long") </description> <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> - <function-signature>java.lang.String formatDateTime(java.util.Calendar, java.lang.String)</function-signature> + <function-signature>java.lang.String formatDateTime(java.util.Calendar, java.lang.String, java.lang.String)</function-signature> </function> <function> <name>formatDateTimeWithLocale</name> @@ -29,13 +29,13 @@ <name>formatDate</name> <description>Format a date based on a given pattern, or a builtin style (short, medium, long or full)</description> <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> - <function-signature>java.lang.String formatDate(java.util.Calendar, java.lang.String)</function-signature> + <function-signature>java.lang.String formatDate(java.util.Calendar, java.lang.String, java.lang.String)</function-signature> </function> <function> <name>formatTime</name> <description>Format a time based on a given pattern, or a builtin style (short, medium, long or full)</description> <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> - <function-signature>java.lang.String formatTime(java.util.Calendar, java.lang.String)</function-signature> + <function-signature>java.lang.String formatTime(java.util.Calendar, java.lang.String, java.lang.String)</function-signature> </function> <function> <name>formatInterval</name> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2010-01-20 16:59:03
|
Revision: 1696 http://openutils.svn.sourceforge.net/openutils/?rev=1696&view=rev Author: fgiust Date: 2010-01-20 16:58:56 +0000 (Wed, 20 Jan 2010) Log Message: ----------- spell check + formatting Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-01-20 15:52:38 UTC (rev 1695) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-01-20 16:58:56 UTC (rev 1696) @@ -146,10 +146,10 @@ * formats a date using the given pattern or built-in style * @param date the date to format * @param pattern a valid pattern, or one of "short", "medium", "long", "full" (case insensitive) - * @param languageId lowercase two-letter ISO-639 code. + * @param languageId lowercase two-letter ISO-639 code. * @return the formatted date */ - public static String formatDate(Calendar date, String pattern, String languageId) + public static String formatDate(Calendar date, String pattern, String languageId) { return format(date, pattern, true, false, new Locale(languageId)); } @@ -158,10 +158,10 @@ * formats a time using the given pattern or built-in style * @param time the time to format * @param pattern a valid pattern, or one of "short", "medium", "long", "full" (case insensitive) - * @param languageId lowercase two-letter ISO-639 code. + * @param languageId lowercase two-letter ISO-639 code. * @return the formatted time */ - public static String formatTime(Calendar time, String pattern, String languageId) + public static String formatTime(Calendar time, String pattern, String languageId) { return format(time, pattern, false, true, new Locale(languageId)); } @@ -174,7 +174,7 @@ * @param languageId lowercase two-letter ISO-639 code. * @return formatted string */ - public static String formatDateTime(Calendar dateTime, String pattern, String languageId) + public static String formatDateTime(Calendar dateTime, String pattern, String languageId) { return format(dateTime, pattern, true, true, new Locale(languageId)); } 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 15:52:38 UTC (rev 1695) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-01-20 16:58:56 UTC (rev 1696) @@ -227,8 +227,9 @@ ? StringUtils.substring(wrapped, 0, j) + (ellipses == null ? StringUtils.EMPTY : ellipses) : text; } + /** - * Enconde a url in UTF-8 format + * Encodes a url in UTF-8 format * @param string url to be encoded * @return a url UTF-8 encoded */ @@ -244,8 +245,9 @@ return string; } } + /** - * Decode a url in UTF-8 format + * Decodes a url in UTF-8 format * @param string url to be decoded * @return a url UTF-8 decoded */ Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-01-20 15:52:38 UTC (rev 1695) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-01-20 16:58:56 UTC (rev 1696) @@ -28,7 +28,7 @@ <function> <name>formatDate</name> <description>Format a date based on a given pattern, or a builtin style (short, medium, long or full)</description> - <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> + <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> <function-signature>java.lang.String formatDate(java.util.Calendar, java.lang.String, java.lang.String)</function-signature> </function> <function> @@ -46,14 +46,13 @@ <function> <name>getMillisFromNow</name> <description>retrieve the milliseconds in difference between now and the input date</description> - <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> + <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> <function-signature>java.lang.Long getMillisFromNow(java.util.Calendar)</function-signature> </function> <function> <name>parseDate</name> <description>parse a date with a given pattern and return the parsed date as a calendar object (null safe)</description> - <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> + <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> <function-signature>java.util.Calendar parseDate(java.lang.String, java.lang.String)</function-signature> </function> - </taglib> \ No newline at end of file Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-20 15:52:38 UTC (rev 1695) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-01-20 16:58:56 UTC (rev 1696) @@ -189,7 +189,7 @@ </function> <function> <name>urldecode</name> - <description>Decode a url in UTF-8 format</description> + <description>Decode a url in UTF-8 format</description> <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String urldecode(java.lang.String)</function-signature> </function> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2010-03-08 14:00:05
|
Revision: 2106 http://openutils.svn.sourceforge.net/openutils/?rev=2106&view=rev Author: diego_schivo Date: 2010-03-08 13:59:59 +0000 (Mon, 08 Mar 2010) Log Message: ----------- ELFUNCTIONS-5 collectionutils (toList, shuffle, entryset, paginateCollection) Added Paths: ----------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld Added: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java (rev 0) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java 2010-03-08 13:59:59 UTC (rev 2106) @@ -0,0 +1,95 @@ +package net.sourceforge.openutils.elfunctions; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author dschivo + * @version $Id$ + */ +public class CollectionElUtils +{ + + /** + * Logger. + */ + private static Logger log = LoggerFactory.getLogger(CollectionElUtils.class); + + /** + * Converts an array to a list + * @param array + * @return + */ + public static List< ? > toList(Object[] array) + { + if (array == null) + { + return Collections.EMPTY_LIST; + } + return Arrays.asList(array); + } + + /** + * Randomly permutes the specified list + * @param input + * @return + */ + public static List< ? > shuffle(List< ? > input) + { + if (input == null) + { + return null; + } + + Collections.shuffle(input); + return input; + } + + /** + * Retuns the set of Map.Entry from a Map (can be used to iterate on the map) + * @param map Map + * @return entry set + */ + public static Set<Map.Entry> entryset(Map map) + { + if (map == null) + { + return null; + } + return map.entrySet(); + } + + /** + * Splits a collection into pages of the specified size + * @param collection + * @param pageSize + * @return + */ + public static List<List> paginateCollection(Collection collection, int pageSize) + { + int index = 0; + List<List> pages = new ArrayList<List>(); + List page = null; + for (Object obj : collection) + { + if (index % pageSize == 0) + { + page = new ArrayList(); + pages.add(page); + } + page.add(obj); + index++; + } + return pages; + } + +} Property changes on: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld (rev 0) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld 2010-03-08 13:59:59 UTC (rev 2106) @@ -0,0 +1,33 @@ +<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" + version="2.0"> + <description>Collection-related EL functions</description> + <display-name>collectionutils</display-name> + <tlib-version>1.0</tlib-version> + <short-name>cu</short-name> + <uri>collectionutils</uri> + <function> + <name>toList</name> + <description>Converts an array to a list</description> + <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> + <function-signature>java.util.List toList(java.lang.Object[])</function-signature> + </function> + <function> + <name>shuffle</name> + <description>Randomly permutes the specified list</description> + <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> + <function-signature>java.util.List shuffle(java.util.List)</function-signature> + </function> + <function> + <name>entryset</name> + <description>Retuns the set of Map.Entry from a Map (can be used to iterate on the map)</description> + <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> + <function-signature>java.util.Map$Entry entryset(java.util.Map)</function-signature> + </function> + <function> + <name>paginateCollection</name> + <description>Splits a collection into pages of the specified size</description> + <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> + <function-signature>java.util.List paginateCollection(java.util.Collection, int)</function-signature> + </function> +</taglib> Property changes on: trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2010-03-08 14:09:27
|
Revision: 2107 http://openutils.svn.sourceforge.net/openutils/?rev=2107&view=rev Author: diego_schivo Date: 2010-03-08 14:09:21 +0000 (Mon, 08 Mar 2010) Log Message: ----------- ELFUNCTIONS-6 EL function currentDateIncluded Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-03-08 13:59:59 UTC (rev 2106) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-03-08 14:09:21 UTC (rev 2107) @@ -327,4 +327,31 @@ return midniteCalendar; } + /** + * Tests if the current date is between the specified time limits + * @param from + * @param to + * @return + */ + public static boolean currentDateIncluded(Calendar from, Calendar to) + { + if (from == null && to == null) + { + return true; + } + + Calendar now = Calendar.getInstance(); + + if (from != null && now.before(from)) + { + return false; + } + if (to != null && now.after(to)) + { + return false; + } + return true; + + } + } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-03-08 13:59:59 UTC (rev 2106) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-03-08 14:09:21 UTC (rev 2107) @@ -55,4 +55,10 @@ <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> <function-signature>java.util.Calendar parseDate(java.lang.String, java.lang.String)</function-signature> </function> + <function> + <name>currentDateIncluded</name> + <description>Tests if the current date is between the specified time limits</description> + <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> + <function-signature>boolean currentDateIncluded(java.util.Calendar, java.util.Calendar)</function-signature> + </function> </taglib> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <die...@us...> - 2010-03-08 17:50:35
|
Revision: 2113 http://openutils.svn.sourceforge.net/openutils/?rev=2113&view=rev Author: diego_schivo Date: 2010-03-08 17:50:29 +0000 (Mon, 08 Mar 2010) Log Message: ----------- ELFUNCTIONS-5 javadoc Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-03-08 17:40:53 UTC (rev 2112) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2010-03-08 17:50:29 UTC (rev 2113) @@ -328,10 +328,10 @@ } /** - * Tests if the current date is between the specified time limits - * @param from - * @param to - * @return + * Tests if the current date is between the specified time interval (limits included) + * @param from interval start + * @param to interval end + * @return true if the current date falls within the specified interval, false otherwise */ public static boolean currentDateIncluded(Calendar from, Calendar to) { Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-03-08 17:40:53 UTC (rev 2112) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2010-03-08 17:50:29 UTC (rev 2113) @@ -57,7 +57,7 @@ </function> <function> <name>currentDateIncluded</name> - <description>Tests if the current date is between the specified time limits</description> + <description>Tests if the current date is between the specified time interval (limits included)</description> <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> <function-signature>boolean currentDateIncluded(java.util.Calendar, java.util.Calendar)</function-signature> </function> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2010-10-01 09:03:11
|
Revision: 3115 http://openutils.svn.sourceforge.net/openutils/?rev=3115&view=rev Author: carlocolombo Date: 2010-10-01 09:03:04 +0000 (Fri, 01 Oct 2010) Log Message: ----------- Function wrapper for NumberUtils.isNumber 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-09-23 17:08:01 UTC (rev 3114) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2010-10-01 09:03:04 UTC (rev 3115) @@ -263,4 +263,14 @@ return string; } } + + /** + * Wrapper function for NumberUtils.isNumber + * @param string + * @return true if string is a number, false otherwise + */ + public static Boolean isNumber(String string) + { + return NumberUtils.isNumber(string); + } } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-09-23 17:08:01 UTC (rev 3114) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2010-10-01 09:03:04 UTC (rev 3115) @@ -193,4 +193,10 @@ <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> <function-signature>java.lang.String urldecode(java.lang.String)</function-signature> </function> + <function> + <name>isNumber</name> + <description>Wrapper function for NumberUtils.isNumber</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.Boolean isNumber(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. |
From: <mmu...@us...> - 2011-04-07 08:09:01
|
Revision: 3408 http://openutils.svn.sourceforge.net/openutils/?rev=3408&view=rev Author: mmunaretto Date: 2011-04-07 08:08:55 +0000 (Thu, 07 Apr 2011) Log Message: ----------- added function adaptStringLengthWholeWord 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 2011-04-01 13:51:55 UTC (rev 3407) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-07 08:08:55 UTC (rev 3408) @@ -304,4 +304,28 @@ return hyphened; } + + /** + * Cut the #value string based on the #maxLength number characters, being careful to not truncate the last word, + * adding #ellipses to the end + * @param value + * @param maxLength + * @param ellipses + * @return + */ + public static String adaptStringLengthWholeWord(String value, int maxLength, String ellipses) + { + if (value != null && value.length() > maxLength) + { + String result = value.substring(0, maxLength + 1); + int p = result.length() - 1; + while (p > 0 && result.charAt(p) >= 'A') + { + p--; + } + return result.substring(0, p) + ellipses; + } + return value; + } + } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2011-04-01 13:51:55 UTC (rev 3407) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2011-04-07 08:08:55 UTC (rev 3408) @@ -1,152 +1,159 @@ <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" - version="2.0"> - <description>Openutils EL functions: stringutils</description> - <display-name>stringutils</display-name> - <tlib-version>1.0</tlib-version> - <short-name>su</short-name> - <uri>http://openutils.sf.net/openutils-stringutils</uri> - <function> - <description>Capitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.</description> - <name>capitaliseAllWords</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String capitaliseAllWords(java.lang.String)</function-signature> - </function> - <function> - <description>Gets the substring after the last occurrence of a separator. The separator is not returned. The function takes 2 parameters:<![CDATA[ + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" + version="2.0"> + <description>Openutils EL functions: stringutils</description> + <display-name>stringutils</display-name> + <tlib-version>1.0</tlib-version> + <short-name>su</short-name> + <uri>http://openutils.sf.net/openutils-stringutils</uri> + <function> + <description>Capitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.</description> + <name>capitaliseAllWords</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String + capitaliseAllWords(java.lang.String)</function-signature> + </function> + <function> + <description>Gets the substring after the last occurrence of a separator. The separator is not returned. The function takes 2 parameters:<![CDATA[ <br/> <strong>java.lang.String: </strong>the String to get a substring from, may be null<br/> <strong>java.lang.String: </strong>the String to search for, may be null<br/> ]]></description> - <name>substringAfterLast</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String substringAfterLast(java.lang.String, java.lang.String)</function-signature> - </function> - <function> - <description>Gets the substring before the last occurrence of a separator. The separator is not returned. The function takes 2 parameters:<![CDATA[ + <name>substringAfterLast</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String + substringAfterLast(java.lang.String, java.lang.String)</function-signature> + </function> + <function> + <description>Gets the substring before the last occurrence of a separator. The separator is not returned. The function takes 2 parameters:<![CDATA[ <br/> <strong>java.lang.String: </strong>the String to get a substring from, may be null<br/> <strong>java.lang.String: </strong>the String to search for, may be null<br/> ]]></description> - <name>substringBeforeLast</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String substringBeforeLast(java.lang.String, java.lang.String)</function-signature> - </function> - <function> - <description>Checks if a String is whitespace, empty ("") or null.</description> - <name>isBlank</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>boolean isBlank(java.lang.String )</function-signature> - </function> - <function> - <description>Creates a random string whose length is the number of characters specified.</description> - <name>randomAlphanumeric</name> - <function-class>org.apache.commons.lang.RandomStringUtils</function-class> - <function-signature>java.lang.String randomAlphanumeric(int)</function-signature> - </function> - <function> - <description>Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), from the Math.random() sequence.</description> - <name>randomInt</name> - <function-class>org.apache.commons.lang.math.RandomUtils</function-class> - <function-signature>int nextInt(int)</function-signature> - </function> - <function> - <description>Unescapes a String</description> - <name>unescapeXml</name> - <function-class>org.apache.commons.lang.StringEscapeUtils</function-class> - <function-signature>java.lang.String unescapeXml(java.lang.String)</function-signature> - </function> - <function> - <description>Output a white space.</description> - <name>space</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String space()</function-signature> - </function> - <function> - <description>Output a tab character.</description> - <name>tab</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String tab()</function-signature> - </function> - <function> - <description>Output a newline character.</description> - <name>newline</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String newline()</function-signature> - </function> - <function> - <description>Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is bewteen '</description> - <name>escJsTxt</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String escapeJsText(java.lang.String, boolean)</function-signature> - <example> + <name>substringBeforeLast</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String + substringBeforeLast(java.lang.String, java.lang.String)</function-signature> + </function> + <function> + <description>Checks if a String is whitespace, empty ("") or null.</description> + <name>isBlank</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>boolean isBlank(java.lang.String )</function-signature> + </function> + <function> + <description>Creates a random string whose length is the number of characters specified.</description> + <name>randomAlphanumeric</name> + <function-class>org.apache.commons.lang.RandomStringUtils</function-class> + <function-signature>java.lang.String randomAlphanumeric(int)</function-signature> + </function> + <function> + <description>Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), from the Math.random() sequence.</description> + <name>randomInt</name> + <function-class>org.apache.commons.lang.math.RandomUtils</function-class> + <function-signature>int nextInt(int)</function-signature> + </function> + <function> + <description>Unescapes a String</description> + <name>unescapeXml</name> + <function-class>org.apache.commons.lang.StringEscapeUtils</function-class> + <function-signature>java.lang.String unescapeXml(java.lang.String)</function-signature> + </function> + <function> + <description>Output a white space.</description> + <name>space</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String space()</function-signature> + </function> + <function> + <description>Output a tab character.</description> + <name>tab</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String tab()</function-signature> + </function> + <function> + <description>Output a newline character.</description> + <name>newline</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String newline()</function-signature> + </function> + <function> + <description>Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is bewteen '</description> + <name>escJsTxt</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String escapeJsText(java.lang.String, + boolean)</function-signature> + <example> <![CDATA[ escJsTxt("xyz\\23",true) : "xyz\23" ]]> </example> - </function> - <function> - <description>Crops a String to a given length, adding a suffix (for example "...") if needed. The function takes 3 parameters: + </function> + <function> + <description>Crops a String to a given length, adding a suffix (for example "...") if needed. The function takes 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 ]]></description> - <name>adaptStringLength</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String adaptStringLength(java.lang.String, int, java.lang.String)</function-signature> - <example> + <name>adaptStringLength</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String + adaptStringLength(java.lang.String, int, java.lang.String)</function-signature> + <example> <![CDATA[ adaptStringLength("pre",2,"post") : prpost ]]> </example> - </function> - <function> - <description>Strip any html tag from a String.</description> - <name>stripHtmlTags</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String stripHtmlTags(java.lang.String)</function-signature> - </function> - <function> - <description>Splits the given strings on newlines</description> - <name>splitNewlines</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String[] splitNewlines(java.lang.String)</function-signature> - </function> - <function> - <description>Splits the given string on tab characters</description> - <name>splitOnTabs</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String[] splitOnTabs(java.lang.String)</function-signature> - </function> - <function> - <description>Strips whitespaces from the start and the end of a String</description> - <name>strip</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String strip(java.lang.String)</function-signature> - </function> - <function> - <description>Returns either the passed in String, or if the String is empty or null, the value of defaultStr. The function takes 2 parameters:<![CDATA[ + </function> + <function> + <description>Strip any html tag from a String.</description> + <name>stripHtmlTags</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String stripHtmlTags(java.lang.String)</function-signature> + </function> + <function> + <description>Splits the given strings on newlines</description> + <name>splitNewlines</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String[] splitNewlines(java.lang.String)</function-signature> + </function> + <function> + <description>Splits the given string on tab characters</description> + <name>splitOnTabs</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String[] splitOnTabs(java.lang.String)</function-signature> + </function> + <function> + <description>Strips whitespaces from the start and the end of a String</description> + <name>strip</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String strip(java.lang.String)</function-signature> + </function> + <function> + <description>Returns either the passed in String, or if the String is empty or null, the value of defaultStr. The function takes 2 parameters:<![CDATA[ <br/> <strong>java.lang.String: </strong>the String to check, may be null<br/> <strong>java.lang.String: </strong>the default String to return if the string to check is null of empty<br/> ]]></description> - <name>defaultIfEmpty</name> - <function-class>org.apache.commons.lang.StringUtils</function-class> - <function-signature>java.lang.String defaultIfEmpty(java.lang.String, java.lang.String)</function-signature> - </function> - <function> - <description>A wrapper around java.lang.String#endsWith(..). Tests if this string ends with the specified suffix. The function takes 2 parameters:<![CDATA[ + <name>defaultIfEmpty</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature>java.lang.String defaultIfEmpty(java.lang.String, + java.lang.String)</function-signature> + </function> + <function> + <description>A wrapper around java.lang.String#endsWith(..). Tests if this string ends with the specified suffix. The function takes 2 parameters:<![CDATA[ <br/> <strong>java.lang.String: </strong>string to evaluate<br/> <strong>java.lang.String: </strong>suffix<br/> ]]></description> - <name>endsWith</name> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>boolean endsWith(java.lang.String, java.lang.String)</function-signature> - </function> - <function> - <name>shorten</name> - <description>Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line is shortened. The function takes 4 parameters: + <name>endsWith</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>boolean endsWith(java.lang.String, + java.lang.String)</function-signature> + </function> + <function> + <name>shorten</name> + <description>Shorten a text with a number of lines and a number of chars per line to be displayed. Display ellipses the line is shortened. The function takes 4 parameters: <![CDATA[ <br/> <strong>java.lang.String: </strong>original text<br/> @@ -154,55 +161,64 @@ <strong>int: </strong>number of chars per line <strong>java.lang.String: </strong>optional ellipses ('...') to display optional ellipses where the line is shortened. ]]></description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String shorten(java.lang.String, int, int, java.lang.String)</function-signature> - </function> - <function> - <name>toLong</name> - <description>Parse a number, passed as String, and return his Long</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.Long toLong(java.lang.String)</function-signature> - </function> - <function> - <name>toRoundedLong</name> - <description>Parse a number, passed as String, and return his closest rounding as a long (or 0L if parse fails)</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.Long toRoundedLong(java.lang.String)</function-signature> - </function> - <function> - <name>toFloorLong</name> - <description>Parse a double, passed as String, and return his floor as a long (or 0L if parse fails)</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.Long toFloorLong(java.lang.String)</function-signature> - </function> - <function> - <name>toCeilLong</name> - <description>Parse a double, passed as String, and return his ceil as a long (or 0L if parse fails)</description> - <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> - <description>Enconde a url in UTF-8 format</description> - <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> - <description>Decode a url in UTF-8 format</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String urldecode(java.lang.String)</function-signature> - </function> - <function> - <name>isNumber</name> - <description>Wrapper function for NumberUtils.isNumber</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.Boolean isNumber(java.lang.String)</function-signature> - </function> - <function> - <name>simpleHyphenation</name> - <description>his function splits a string in to more lines of #characters</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String simpleHyphenation(java.lang.String, int)</function-signature> - </function> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String shorten(java.lang.String, int, + int, java.lang.String)</function-signature> + </function> + <function> + <name>toLong</name> + <description>Parse a number, passed as String, and return his Long</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.Long toLong(java.lang.String)</function-signature> + </function> + <function> + <name>toRoundedLong</name> + <description>Parse a number, passed as String, and return his closest rounding as a long (or 0L if parse fails)</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.Long toRoundedLong(java.lang.String)</function-signature> + </function> + <function> + <name>toFloorLong</name> + <description>Parse a double, passed as String, and return his floor as a long (or 0L if parse fails)</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.Long toFloorLong(java.lang.String)</function-signature> + </function> + <function> + <name>toCeilLong</name> + <description>Parse a double, passed as String, and return his ceil as a long (or 0L if parse fails)</description> + <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> + <description>Enconde a url in UTF-8 format</description> + <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> + <description>Decode a url in UTF-8 format</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String urldecode(java.lang.String)</function-signature> + </function> + <function> + <name>isNumber</name> + <description>Wrapper function for NumberUtils.isNumber</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.Boolean isNumber(java.lang.String)</function-signature> + </function> + <function> + <name>simpleHyphenation</name> + <description>This function splits a string in to more lines of #characters</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String + simpleHyphenation(java.lang.String, int)</function-signature> + </function> + <function> + <name>adaptStringLengthWholeWord</name> + <description>Cut the #value string based on the #maxLength number characters, being careful to not truncate the last word, adding #ellipses to the end</description> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String + adaptStringLengthWholeWord(java.lang.String, int, 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. |
From: <fg...@us...> - 2011-04-10 08:27:07
|
Revision: 3424 http://openutils.svn.sourceforge.net/openutils/?rev=3424&view=rev Author: fgiust Date: 2011-04-10 08:27:01 +0000 (Sun, 10 Apr 2011) Log Message: ----------- "cosmetic" change, from languageid to locale as parameter names Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2011-04-10 08:04:23 UTC (rev 3423) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/DateElUtils.java 2011-04-10 08:27:01 UTC (rev 3424) @@ -23,6 +23,7 @@ import java.util.Calendar; import java.util.Locale; +import org.apache.commons.lang.LocaleUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.FastDateFormat; import org.slf4j.Logger; @@ -146,24 +147,24 @@ * formats a date using the given pattern or built-in style * @param date the date to format * @param pattern a valid pattern, or one of "short", "medium", "long", "full" (case insensitive) - * @param languageId lowercase two-letter ISO-639 code. + * @param locale lowercase two-letter ISO-639 code. * @return the formatted date */ - public static String formatDate(Calendar date, String pattern, String languageId) + public static String formatDate(Calendar date, String pattern, String locale) { - return format(date, pattern, true, false, new Locale(languageId)); + return format(date, pattern, true, false, LocaleUtils.toLocale(locale)); } /** * formats a time using the given pattern or built-in style * @param time the time to format * @param pattern a valid pattern, or one of "short", "medium", "long", "full" (case insensitive) - * @param languageId lowercase two-letter ISO-639 code. + * @param locale lowercase two-letter ISO-639 code. * @return the formatted time */ - public static String formatTime(Calendar time, String pattern, String languageId) + public static String formatTime(Calendar time, String pattern, String locale) { - return format(time, pattern, false, true, new Locale(languageId)); + return format(time, pattern, false, true, LocaleUtils.toLocale(locale)); } /** @@ -171,25 +172,26 @@ * time with the syntax "date_format;time_format" (ex: "long;short") * @param dateTime the date and time * @param pattern date pattern - * @param languageId lowercase two-letter ISO-639 code. + * @param locale lowercase two-letter ISO-639 code. * @return formatted string */ - public static String formatDateTime(Calendar dateTime, String pattern, String languageId) + public static String formatDateTime(Calendar dateTime, String pattern, String locale) { - return format(dateTime, pattern, true, true, new Locale(languageId)); + return format(dateTime, pattern, true, true, LocaleUtils.toLocale(locale)); } /** * Formats a date and/or time using the given pattern or built-in style - supports composite formats for date and * time with the syntax "date_format;time_format" (ex: "long;short") with locale * @param dateTime the date and time - * @param languageId lowercase two-letter ISO-639 code. + * @param locale lowercase two-letter ISO-639 code. * @param pattern date pattern * @return formatted string */ - public static String formatDateTimeWithLocale(Calendar dateTime, String languageId, String pattern) + @Deprecated + public static String formatDateTimeWithLocale(Calendar dateTime, String locale, String pattern) { - return format(dateTime, pattern, true, true, new Locale(languageId)); + return format(dateTime, pattern, true, true, LocaleUtils.toLocale(locale)); } /** Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2011-04-10 08:04:23 UTC (rev 3423) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/dateutils.tld 2011-04-10 08:27:01 UTC (rev 3424) @@ -9,8 +9,9 @@ <function> <name>formatDateTime</name> <description> - Format a date and time based on a given pattern, or a builtin style (short, medium, long or full). Also supports - different styles for date and time with the syntax "date_style;time_style" (e.g. "short;long") + Format a date and time based on a given pattern, or a builtin style (short, medium, long or full). Also supports + different styles for date and time with the syntax "date_style;time_style" (e.g. "short;long"). + Parameters: Calendar dateTime, String pattern, String locale </description> <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> <function-signature>java.lang.String formatDateTime(java.util.Calendar, java.lang.String, java.lang.String)</function-signature> @@ -18,7 +19,7 @@ <function> <name>formatDateTimeWithLocale</name> <description> - Format a date and time with a specified language (lowercase two-letter ISO-639 code) based on a given pattern, or a builtin style (short, medium, long or full). Also supports + Format a date and time with a specified locale (lowercase two-letter ISO-639 code) based on a given pattern, or a builtin style (short, medium, long or full). Also supports different styles for date and time with the syntax "date_style;time_style" (e.g. "short;long") </description> <function-class>net.sourceforge.openutils.elfunctions.DateElUtils</function-class> 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:48:45
|
Revision: 3434 http://openutils.svn.sourceforge.net/openutils/?rev=3434&view=rev Author: fgiust Date: 2011-04-27 12:48:39 +0000 (Wed, 27 Apr 2011) Log Message: ----------- remove a duplicate function 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 2011-04-27 12:43:28 UTC (rev 3433) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-27 12:48:39 UTC (rev 3434) @@ -305,27 +305,4 @@ return hyphened; } - /** - * Cut the #value string based on the #maxLength number characters, being careful to not truncate the last word, - * adding #ellipses to the end - * @param value - * @param maxLength - * @param ellipses - * @return - */ - public static String adaptStringLengthWholeWord(String value, int maxLength, String ellipses) - { - if (value != null && value.length() > maxLength) - { - String result = value.substring(0, maxLength + 1); - int p = result.length() - 1; - while (p > 0 && result.charAt(p) >= 'A') - { - p--; - } - return result.substring(0, p) + ellipses; - } - return value; - } - } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2011-04-27 12:43:28 UTC (rev 3433) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2011-04-27 12:48:39 UTC (rev 3434) @@ -214,11 +214,4 @@ <function-signature>java.lang.String simpleHyphenation(java.lang.String, int)</function-signature> </function> - <function> - <name>adaptStringLengthWholeWord</name> - <description>Cut the #value string based on the #maxLength number characters, being careful to not truncate the last word, adding #ellipses to the end</description> - <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> - <function-signature>java.lang.String - adaptStringLengthWholeWord(java.lang.String, int, 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. |
From: <fg...@us...> - 2011-04-27 12:57:27
|
Revision: 3436 http://openutils.svn.sourceforge.net/openutils/?rev=3436&view=rev Author: fgiust Date: 2011-04-27 12:57:20 +0000 (Wed, 27 Apr 2011) Log Message: ----------- ELFUNCTIONS-9 new function for javascript escaping 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 2011-04-27 12:50:45 UTC (rev 3435) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-27 12:57:20 UTC (rev 3436) @@ -67,11 +67,23 @@ /** * 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 deprecated - no effect + * @param 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) { + String repl = dbl ? "\"" : "'"; + String with = "\\" + repl; + return repl + (text != null ? StringUtils.replace(text, repl, with) : "") + repl; + } + + /** + * Escapes a javascript string. + * @param text the string to be escaped + * @return the escaped string + */ + public static String escapeJavascript(String text) + { return StringEscapeUtils.escapeJavaScript(text); } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2011-04-27 12:50:45 UTC (rev 3435) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/stringutils.tld 2011-04-27 12:57:20 UTC (rev 3436) @@ -89,6 +89,17 @@ ]]> </example> </function> + <function> + <description>Escapes a javascript string.</description> + <name>escapeJavascript</name> + <function-class>net.sourceforge.openutils.elfunctions.ElStringUtils</function-class> + <function-signature>java.lang.String escapeJavascript(java.lang.String)</function-signature> + <example> + <![CDATA[ + escapeJavascript("xyz\\2'3",true) : xyz\\2\'3 + ]]> + </example> + </function> <function> <description>Crops a String to a given length, adding a suffix (for example "...") if needed. The function takes 3 parameters: <![CDATA[<br/><strong>java.lang.String:</strong> the string to be adapted<br/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2011-08-11 09:25:23
|
Revision: 3606 http://openutils.svn.sourceforge.net/openutils/?rev=3606&view=rev Author: carlocolombo Date: 2011-08-11 09:25:16 +0000 (Thu, 11 Aug 2011) Log Message: ----------- wrapper around List.contains Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java 2011-08-11 09:06:03 UTC (rev 3605) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/CollectionElUtils.java 2011-08-11 09:25:16 UTC (rev 3606) @@ -110,4 +110,24 @@ return pages; } + /** + * wrapper around contains + * @param list + * @param o + * @return + */ + public static boolean contains(List< ? > list, Object o) + { + return list.contains(o); + } + + /** wrapper around contains (using arrays) + * @param array + * @param o + * @return + */ + public static boolean contains2(Object[] array, Object o) + { + return toList(array).contains(o); + } } Modified: trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld =================================================================== --- trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld 2011-08-11 09:06:03 UTC (rev 3605) +++ trunk/openutils-elfunctions/src/main/resources/META-INF/collectionutils.tld 2011-08-11 09:25:16 UTC (rev 3606) @@ -30,4 +30,16 @@ <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> <function-signature>java.util.List paginateCollection(java.util.Collection, int)</function-signature> </function> -</taglib> + <function> + <name>contains</name> + <description>Wrapper around contains</description> + <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> + <function-signature>boolean contains(java.util.List,java.lang.Object)</function-signature> + </function> + <function> + <name>contains2</name> + <description>Wrapper around contains (use array)</description> + <function-class>net.sourceforge.openutils.elfunctions.CollectionElUtils</function-class> + <function-signature>boolean contains(java.lang.Object[],java.lang.Object)</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. |