Author: desruisseaux
Date: Thu Aug 8 09:57:15 2013
New Revision: 1511661
URL: http://svn.apache.org/r1511661
Log:
TreeTableFormat needs to use DateFormat and NumberFormat when appropriate.
This is required not only for better formatting, but also for fixing a test
failure when executing the tests in various timezones.
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
Modified:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java?rev=1511661&r1=1511660&r2=1511661&view=diff
==============================================================================
---
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
[UTF-8] (original)
+++
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
[UTF-8] Thu Aug 8 09:57:15 2013
@@ -604,10 +604,10 @@ public class TreeTableFormat extends Tab
/**
* Appends a textual representation of the given value.
*
- * @param format The format to use.
+ * @param format The format to use for the column as a whole, or
{@code null} if unknown.
* @param value The value to format (may be {@code null}).
*/
- private void formatValue(final Format format, final Object value)
throws IOException {
+ private void formatValue(Format format, final Object value) throws
IOException {
final CharSequence text;
if (value == null) {
text = " "; // String for missing value.
@@ -619,12 +619,21 @@ public class TreeTableFormat extends Tab
text = format.format(value);
} else if (value instanceof InternationalString) {
text = ((InternationalString) value).toString(getLocale());
+ } else if (value instanceof CharSequence) {
+ text = value.toString();
} else if (value instanceof CodeList<?>) {
text = Types.getCodeTitle((CodeList<?>)
value).toString(getLocale());
} else if (value instanceof Enum<?>) {
text = CharSequences.upperCaseToSentence(((Enum<?>)
value).name());
} else {
- text = String.valueOf(value);
+ /*
+ * Check for a value-by-value format only as last resort.
+ * If a column-wide format was given in argument to this
method,
+ * that format should have been used by above code in order to
+ * produce a more uniform formatting.
+ */
+ format = getFormat(value.getClass());
+ text = (format != null) ? format.format(value) :
value.toString();
}
append(text);
}
Modified:
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java?rev=1511661&r1=1511660&r2=1511661&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
[UTF-8] Thu Aug 8 09:57:15 2013
@@ -119,7 +119,7 @@ public final strictfp class MetadataRead
" │ ├─Citation\n" +
" │ │ ├─Title……………………………………………………………………………… Sea Surface
Temperature Analysis Model\n" +
" │ │ ├─Date\n" +
- " │ │ │ ├─Date……………………………………………………………………… Thu Sep 22
02:00:00 CEST 2005\n" +
+ " │ │ │ ├─Date……………………………………………………………………… 2005/09/22
00:00:00\n" +
" │ │ │ └─Date type………………………………………………………… Creation\n" +
" │ │ ├─Identifier\n" +
" │ │ │ ├─Code………………………………………………………………………
NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +