fix: put blanks between name components
authorLucas Werkmeister <mail@lucaswerkmeister.de>
Tue, 28 Mar 2017 10:20:13 +0000 (12:20 +0200)
committerLucas Werkmeister <mail@lucaswerkmeister.de>
Wed, 29 Mar 2017 18:31:36 +0000 (20:31 +0200)
The previous commit attempted to fix

     Welcome back, Felix Dörre !

but instead produced

     Welcome back, FelixDörre!

Clearly, while we don’t want spaces around the full name, there should
be spaces in between the individual name parts.

Change-Id: I498ea9a0fdaf0f5b3191a3fc3cc47d0a3187b4f5

src/club/wpia/gigi/dbObjects/Name.java

index da7e719..d5bff5c 100644 (file)
@@ -187,17 +187,20 @@ public class Name implements Outputable, IdCachable {
 
         @Override
         public void output(PrintWriter out) {
-            outputNameParts(out, "fname", firstNames);
-            outputNameParts(out, "lname", lastNames);
-            outputNameParts(out, "suffix", suffixes);
+            outputNameParts(out, "fname", firstNames, false);
+            outputNameParts(out, "lname", lastNames, true);
+            outputNameParts(out, "suffix", suffixes, true);
         }
 
-        private void outputNameParts(PrintWriter out, String type, NamePart[] input) {
+        private void outputNameParts(PrintWriter out, String type, NamePart[] input, boolean leadingSpace) {
             StringBuilder res;
             res = new StringBuilder();
             appendArray(res, input);
             if (res.length() > 0) {
                 res.deleteCharAt(res.length() - 1);
+                if (leadingSpace) {
+                    out.print(" ");
+                }
                 out.print("<span class='" + type + "'>");
                 out.print(HTMLEncoder.encodeHTML(res.toString()));
                 out.print("</span>");