X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2Ftemplate%2FIfStatement.java;h=f2248bcc72fd3a3987b87cc22f7192d5c2883bdc;hb=7a9b55470434239a3dd260005932e9e6096a9921;hp=0347a363db8798f3d98356fc68bbdea737c19d1f;hpb=ec24cf6925bb3729a644580ad4a9375d05883c62;p=gigi.git diff --git a/src/org/cacert/gigi/output/template/IfStatement.java b/src/org/cacert/gigi/output/template/IfStatement.java index 0347a363..f2248bcc 100644 --- a/src/org/cacert/gigi/output/template/IfStatement.java +++ b/src/org/cacert/gigi/output/template/IfStatement.java @@ -1,11 +1,16 @@ package org.cacert.gigi.output.template; import java.io.PrintWriter; +import java.util.Collection; import java.util.Map; import org.cacert.gigi.localisation.Language; -public final class IfStatement implements Outputable { +/** + * One ore two {@link Outputable}s that are emitted conditionally if a given + * variable is neither null nor {@link Boolean#FALSE}. + */ +public final class IfStatement implements Translatable { private final String variable; @@ -13,12 +18,30 @@ public final class IfStatement implements Outputable { private final TemplateBlock iffalse; + /** + * Creates a new {@link IfStatement} with an empty else-part. + * + * @param variable + * the variable to check + * @param body + * the body to emit conditionally. + */ public IfStatement(String variable, TemplateBlock body) { this.variable = variable; this.iftrue = body; this.iffalse = null; } + /** + * Creates a new {@link IfStatement} with an else-block. + * + * @param variable + * the variable to check + * @param iftrue + * the block to emit if the check succeeds. + * @param iffalse + * the block to emit if the check fails + */ public IfStatement(String variable, TemplateBlock iftrue, TemplateBlock iffalse) { this.variable = variable; this.iftrue = iftrue; @@ -36,4 +59,12 @@ public final class IfStatement implements Outputable { } } + @Override + public void addTranslations(Collection s) { + iftrue.addTranslations(s); + if (iffalse != null) { + iffalse.addTranslations(s); + } + } + }