public class IfTemplate extends ContentTemplate
ContentTemplate.createIf(String)m_content| Constructor and Description |
|---|
IfTemplate(java.lang.String condition)
Constructor for IfTemplate.
|
| Modifier and Type | Method and Description |
|---|---|
BlockTemplate |
createElse()
create an else statement for this condition
|
java.lang.String |
getCondition()
get the condition.
|
void |
setCondition(java.lang.String condition)
set the expression to evaluate for this condition
|
void |
write(java.io.PrintWriter writer,
int indent)
this implementation of write follows the rule that if
this statement has an else statement which only contains
another if statement the statement should read
} else if (
instead of closing the else and starting with a new condition. |
void |
write(java.io.PrintWriter writer,
int indent,
boolean firstLine)
write the if statement to the PrintWriter
|
addImport, addText, createFor, createIf, createTry, createTry, createWhile, getContent, getParent, makeInstance, makeInstance, makeInstance, setContent, setParentpublic IfTemplate(java.lang.String condition)
condition - String, an expression defining the condition for this statementpublic void write(java.io.PrintWriter writer,
int indent)
this implementation of write follows the rule that if
this statement has an else statement which only contains
another if statement the statement should read } else if (
instead of closing the else and starting with a new condition.
write in interface Templatewrite in class ContentTemplatewriter - PrintWriter, an initialized PrintWriter to write this
element of the Class toindent - int, the indention for this element.
Value is multiplied by four to give the number of spaces used for indention
Template.write(java.io.PrintWriter, int)public void write(java.io.PrintWriter writer,
int indent,
boolean firstLine)
writer - PrintWriterindent - int, current indentfirstLine - boolean, false if this is a condition which is the only
content of an else branch, true if it is a regular conditionTypeWriterException - If the condition is not set or if it is emptyTemplate.write(java.io.PrintWriter, int)public BlockTemplate createElse()
public void setCondition(java.lang.String condition)
condition - String, the expressionpublic java.lang.String getCondition()