[PATCH] (issue1620) Fix WstWriter Column Header format
Wald Commits
scm-commit at wald.intevation.org
Thu Dec 5 19:29:57 CET 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1386268192 -3600
# Node ID 197bd0958cba3bb7b00d9d09e17da46fde36d066
# Parent e609722a1e86bec429b9c1b25a62eae6c668fd64
(issue1620) Fix WstWriter Column Header format.
- Size is always 9 for a name, fill with spaces if not.
- column-bez-text is the longform if a name contains spaces it is
quoted.
This should enable more exotic waterlevel names which are needed
for issue1020
diff -r e609722a1e86 -r 197bd0958cba artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java Thu Dec 05 17:38:10 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java Thu Dec 05 19:29:52 2013 +0100
@@ -139,15 +139,10 @@
if (name != null) {
cols++;
+ int i = 0;
String basename = name;
-
- int i = 0;
while (columnNames.contains(name)) {
name = basename + "_" + i++;
-
- if (name.length() > 9) {
- name = name.substring(name.length() - 9);
- }
}
columnNames.add(name);
@@ -164,9 +159,33 @@
logger.debug("WstWriter.writeHeader");
writer.println(cols);
+
+ writer.print("*!column-bez-text ");
+
+ List<String> quotedNames = new ArrayList<String>(columnNames.size());
+
+ for (String name: columnNames) {
+ if (name.contains(" ")) {
+ name = "'" + name + "'";
+ }
+ quotedNames.add(name);
+ }
+ writer.println(StringUtils.join(quotedNames, " "));
writer.print(" ");
- writer.print(StringUtils.join(columnNames, " "));
+ for (String columnName: columnNames) {
+ if (columnName.length() > 9) {
+ writer.printf(locale, "%9s",
+ columnName.substring(columnName.length() - 9));
+ } else {
+ writer.printf(locale, "%9s", columnName);
+ // This is weird but i was to lazy to lookup
+ // how to do this another way.
+ for (int i = 9 - columnName.length(); i > 0; i--) {
+ writer.print(" ");
+ }
+ }
+ }
writer.println();
More information about the Dive4elements-commits
mailing list