You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2009/06/05 19:30:10 UTC
svn commit: r782072 - in
/myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal:
share/xml/XMLUtils.java taglib/util/TagUtils.java
Author: jwaldman
Date: Fri Jun 5 17:30:09 2009
New Revision: 782072
URL: http://svn.apache.org/viewvc?rev=782072&view=rev
Log:
TRINIDAD-1494 Support java.util.Set as property type
trinidad-1.0.x
For Jing Wu
Modified:
myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/xml/XMLUtils.java
myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
Modified: myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/xml/XMLUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/xml/XMLUtils.java?rev=782072&r1=782071&r2=782072&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/xml/XMLUtils.java (original)
+++ myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/xml/XMLUtils.java Fri Jun 5 17:30:09 2009
@@ -23,6 +23,9 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -340,6 +343,41 @@
*/
static public String[] parseNameTokens(String stringValue)
{
+ List<String> list = parseNameTokensAsList(stringValue);
+
+ if (list == null)
+ return null;
+ else
+ return list.toArray(new String[list.size()]);
+
+ }
+
+ /**
+ * Parses a whitespace separated series of name tokens.
+ * @param stringValue the full string
+ * @return a set of each constituent value, or null
+ * if there are no tokens (that is, the string is empty or
+ * all whitespace)
+ */
+ static public Set<String> parseNameTokensAsSet(String stringValue)
+ {
+ List<String> list = parseNameTokensAsList(stringValue);
+
+ if (list == null)
+ return null;
+ else
+ return new HashSet(list);
+ }
+
+ /**
+ * Parses a whitespace separated series of name tokens.
+ * @param stringValue the full string
+ * @return a list of each constituent value, or null
+ * if there are no tokens (that is, the string is empty or
+ * all whitespace)
+ */
+ static public List<String> parseNameTokensAsList(String stringValue)
+ {
if (stringValue == null)
return null;
@@ -384,7 +422,7 @@
if (list.isEmpty())
return null;
- return list.toArray(new String[list.size()]);
+ return list;
}
/**
Modified: myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java?rev=782072&r1=782071&r2=782072&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java (original)
+++ myfaces/trinidad/branches/trinidad-1.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java Fri Jun 5 17:30:09 2009
@@ -29,6 +29,7 @@
import java.util.Date;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
import java.util.TimeZone;
import javax.faces.application.Application;
@@ -153,6 +154,36 @@
}
/**
+ * These are normally NMTOKEN type in attributes
+ * String --> Set<String>
+ * @param value
+ * @return
+ */
+ public static Set<String> getStringSet(
+ Object value) throws ParseException
+ {
+ if (value == null)
+ return null;
+
+ return _getTokensSet(value.toString());
+ }
+
+ /**
+ * These are normally NMTOKEN type in attributes
+ * String --> List<String>
+ * @param value
+ * @return
+ */
+ public static List<String> getStringList(
+ Object value) throws ParseException
+ {
+ if (value == null)
+ return null;
+
+ return _getTokensList(value.toString());
+ }
+
+ /**
* ISO Date String --> Date
* @param value
* @return
@@ -298,6 +329,40 @@
}
/**
+ * Takes a string that is a composite of tokens, extracts tokens delimited
+ * by any whitespace character sequence combination and returns a set
+ * of String of such tokens.
+ * @throws ParseException In case of invalid character in the specified
+ * composite. The only invalid character is a comma (',').
+ */
+ private static Set<String> _getTokensSet(String tokenComposite)
+ throws ParseException
+ {
+ if (tokenComposite == null || "".equals(tokenComposite))
+ return null;
+
+ return XMLUtils.parseNameTokensAsSet(tokenComposite);
+ }
+
+
+ /**
+ * Takes a string that is a composite of tokens, extracts tokens delimited
+ * by any whitespace character sequence combination and returns a list
+ * of String of such tokens.
+ * @throws ParseException In case of invalid character in the specified
+ * composite. The only invalid character is a comma (',').
+ */
+ private static List<String> _getTokensList(String tokenComposite)
+ throws ParseException
+ {
+ if (tokenComposite == null || "".equals(tokenComposite))
+ return null;
+
+ return XMLUtils.parseNameTokensAsList(tokenComposite);
+ }
+
+
+ /**
* Parse a string into a java.util.Date object. The
* string must be in ISO 9601 format (yyyy-MM-dd).
* @todo why not throw the exception in a different format?