Revision: 570
http://svn.sourceforge.net/stripes/?rev=570&view=rev
Author: bengunter
Date: 2007-06-11 05:47:19 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
added protected getFormatter(Object) which checks for null Configuration or
FormatterFactory before trying to get a Formatter. This was causing lots of
test failures when there was no Configuration object available.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
Modified: trunk/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
2007-06-05 21:34:45 UTC (rev 569)
+++ trunk/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
2007-06-11 12:47:19 UTC (rev 570)
@@ -20,6 +20,7 @@
import java.util.Locale;
import java.util.Map;
+import net.sourceforge.stripes.config.Configuration;
import net.sourceforge.stripes.controller.StripesFilter;
import net.sourceforge.stripes.exception.StripesRuntimeException;
import net.sourceforge.stripes.format.Formatter;
@@ -243,16 +244,35 @@
*/
@SuppressWarnings("unchecked")
protected String format(Object value) {
- if (value == null) {
- return "";
- }
- else {
- FormatterFactory factory =
StripesFilter.getConfiguration().getFormatterFactory();
- Formatter formatter =
factory.getFormatter(value.getClass(), locale, null, null);
- if (formatter == null)
- return value.toString();
- else
- return formatter.format(value);
- }
- }
+ if (value == null) {
+ return "";
+ }
+ else {
+ Formatter formatter = getFormatter(value);
+ if (formatter == null)
+ return value.toString();
+ else
+ return formatter.format(value);
+ }
+ }
+
+ /**
+ * Tries to get a formatter for the given value using the [EMAIL
PROTECTED] FormatterFactory}. Returns
+ * null if there is no [EMAIL PROTECTED] Configuration} or [EMAIL
PROTECTED] FormatterFactory} available (e.g. in a
+ * test environment) or if there is no [EMAIL PROTECTED] Formatter}
configured for the value's type.
+ *
+ * @param value the object to be formatted
+ * @return a formatter, if one can be found; null otherwise
+ */
+ protected Formatter getFormatter(Object value) {
+ Configuration configuration = StripesFilter.getConfiguration();
+ if (configuration == null)
+ return null;
+
+ FormatterFactory factory = configuration.getFormatterFactory();
+ if (factory == null)
+ return null;
+
+ return factory.getFormatter(value.getClass(), locale, null, null);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development