]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/output/template/OutputVariableCommand.java
add: documentation to output classes
[gigi.git] / src / org / cacert / gigi / output / template / OutputVariableCommand.java
index 900b557d81aeae917b2a36c6d64eefa2a64fadc4..5dce3aed211c1c45452d96929e6e0c3c9484dabe 100644 (file)
@@ -1,20 +1,42 @@
 package org.cacert.gigi.output.template;
 
 import java.io.PrintWriter;
+import java.util.Collection;
 import java.util.Map;
 
-import org.cacert.gigi.Language;
-import org.cacert.gigi.output.Outputable;
+import org.cacert.gigi.localisation.Language;
 
-final class OutputVariableCommand implements Outputable {
-       private final String raw;
+/**
+ * Emits a variable.
+ */
+public final class OutputVariableCommand implements Translatable {
 
-       OutputVariableCommand(String raw) {
-               this.raw = raw;
-       }
+    private final String raw;
 
-       @Override
-       public void output(PrintWriter out, Language l, Map<String, Object> vars) {
-               Template.outputVar(out, l, vars, raw);
-       }
-}
\ No newline at end of file
+    private final boolean unescaped;
+
+    /**
+     * Creates a new OutputVariableCommand.
+     * 
+     * @param raw
+     *            the variable to emit. If starting with <code>!</code> the
+     *            variable is emitted non-HTML-escaped.
+     */
+    public OutputVariableCommand(String raw) {
+        if (raw.charAt(0) == '!') {
+            unescaped = true;
+            this.raw = raw.substring(1);
+        } else {
+            unescaped = false;
+            this.raw = raw;
+        }
+    }
+
+    @Override
+    public void output(PrintWriter out, Language l, Map<String, Object> vars) {
+        Template.outputVar(out, l, vars, raw, unescaped);
+    }
+
+    @Override
+    public void addTranslations(Collection<String> s) {}
+}