]> WPIA git - gigi.git/blob - src/org/cacert/gigi/output/template/SprintfCommand.java
Format code according do BenBE's formatter.
[gigi.git] / src / org / cacert / gigi / output / template / SprintfCommand.java
1 package org.cacert.gigi.output.template;
2
3 import java.io.PrintWriter;
4 import java.util.LinkedList;
5 import java.util.Map;
6
7 import org.cacert.gigi.Language;
8 import org.cacert.gigi.output.Outputable;
9
10 public final class SprintfCommand implements Outputable {
11
12     private final String text;
13
14     private final LinkedList<String> store;
15
16     public SprintfCommand(String text, LinkedList<String> store) {
17         this.text = text;
18         this.store = store;
19     }
20
21     @Override
22     public void output(PrintWriter out, Language l, Map<String, Object> vars) {
23         String[] parts = l.getTranslation(text).split("%s");
24         String[] myvars = store.toArray(new String[store.size()]);
25         out.print(parts[0]);
26         for (int j = 1; j < parts.length; j++) {
27             Template.outputVar(out, l, vars, myvars[j - 1].substring(1));
28             out.print(parts[j]);
29         }
30     }
31 }