X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2Ftemplate%2FSprintfCommand.java;h=006155d2ffdd6f12836aa639506cff4e423a0407;hb=341ed1dbc2f8cc8cedb50b12914aa113d12958ee;hp=385da25cae38a60f1b61a80ce1a39a6ee896a139;hpb=0e926f650b13aba58cece09280ba24901e8fc61d;p=gigi.git
diff --git a/src/org/cacert/gigi/output/template/SprintfCommand.java b/src/org/cacert/gigi/output/template/SprintfCommand.java
index 385da25c..006155d2 100644
--- a/src/org/cacert/gigi/output/template/SprintfCommand.java
+++ b/src/org/cacert/gigi/output/template/SprintfCommand.java
@@ -13,12 +13,24 @@ import java.util.regex.Pattern;
import org.cacert.gigi.localisation.Language;
import org.cacert.gigi.util.HTMLEncoder;
+/**
+ * A pattern that is to be translated before variables are inserted.
+ */
public final class SprintfCommand implements Translatable {
private final String text;
private final String[] store;
+ /**
+ * Creates a new SprintfCommand based on its pre-parsed contents.
+ *
+ * @param text
+ * a string with {0},{1},..
as placeholders.
+ * @param store
+ * the data to put into the placeholders: ${var}, $!{var},
+ * !'plain'.
+ */
public SprintfCommand(String text, List store) {
this.text = text;
this.store = store.toArray(new String[store.size()]);
@@ -28,7 +40,13 @@ public final class SprintfCommand implements Translatable {
private static final Pattern processingInstruction = Pattern.compile("(" + VARIABLE + ")|(!'[^{}'\\$]*)'");
- public SprintfCommand(String content) {
+ /**
+ * Creates a new SprintfCommand that is parsed as from template source.
+ *
+ * @param content
+ * the part from the template that is to be parsed.
+ */
+ protected SprintfCommand(String content) {
StringBuffer raw = new StringBuffer();
List var = new LinkedList();
int counter = 0;
@@ -82,6 +100,17 @@ public final class SprintfCommand implements Translatable {
s.add(text);
}
+ /**
+ * Creates a simple {@link SprintfCommand} wrapped in a {@link Scope} to fit
+ * in now constant variables into this template.
+ *
+ * @param msg
+ * the message (to be translated) with {0},{1},...
+ * as placeholders.
+ * @param vars
+ * the variables to put into the placeholders.
+ * @return the constructed {@link Outputable}.
+ */
public static Outputable createSimple(String msg, String... vars) {
HashMap scope = new HashMap<>();
String[] store = new String[vars.length];