|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.sdr.calls.ast.AstNode net.cscott.sdr.calls.ast.Comp net.cscott.sdr.calls.ast.If
public class If
If
rejects its child as suitable for execution from
the current formation unless its condition evaluates true.
js> iff = new If(If.When.BEFORE, new Expr("true"), new Seq(Apply.makeApply("nothing"))); (If 'BEFORE (Expr true) (Seq (Apply 'nothing)))
js> iff = new If(If.When.AFTER, new Expr("true"), new Seq(Apply.makeApply("nothing")), "Message!"); (If 'AFTER (Expr true) (Seq (Apply 'nothing)) "Message!")
js> importPackage(net.cscott.sdr.util) js> iff = new If(If.When.BEFORE, new Expr("true"), new Seq(Apply.makeApply("nothing")), "Message!", Fraction.ONE_HALF); (If 'BEFORE (Expr true) (Seq (Apply 'nothing)) "Message!" 1/2)
Nested Class Summary | |
---|---|
static class |
If.When
When to evaluate an If : before or after its child. |
Field Summary | |
---|---|
Comp |
child
The child to evaluate, iff the condition is true. |
Expr |
condition
The condition to evaluate. |
String |
message
User-friendly message to report if the condition fails, or null. |
Fraction |
priority
Priority of the message: if a parallel operation causes failures in multiple places, the one with the highest priority will be reported. |
If.When |
when
Evaluate condition before or after the child is evaluated? |
Fields inherited from class net.cscott.sdr.calls.ast.AstNode |
---|
type |
Constructor Summary | |
---|---|
If(If.When when,
Expr condition,
Comp child)
|
|
If(If.When when,
Expr condition,
Comp child,
String msg)
|
|
If(If.When when,
Expr condition,
Comp child,
String msg,
Fraction priority)
|
Method Summary | ||
---|---|---|
|
accept(TransformVisitor<T> v,
T t)
Visitor pattern implementation for transformations. |
|
|
accept(ValueVisitor<RESULT,CLOSURE> v,
CLOSURE cl)
Visitor pattern implementation for computations. |
|
String |
argsToString()
|
|
If |
build(Expr condition,
Comp child)
Factory: creates new If only if it would differ from this. |
Methods inherited from class net.cscott.sdr.calls.ast.AstNode |
---|
toString, valueOf |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final If.When when
public final Expr condition
public final Comp child
public final String message
public final Fraction priority
Constructor Detail |
---|
public If(If.When when, Expr condition, Comp child)
public If(If.When when, Expr condition, Comp child, String msg)
public If(If.When when, Expr condition, Comp child, String msg, Fraction priority)
Method Detail |
---|
public <T> Comp accept(TransformVisitor<T> v, T t)
AstNode
AstNode
accepts a TransformVisitor
and a
value, and returns an instance of its own type (ie,
Seq.accept(tv, "A")
returns a Seq
).
The 't' parameter is a closure.
accept
in class Comp
public <RESULT,CLOSURE> RESULT accept(ValueVisitor<RESULT,CLOSURE> v, CLOSURE cl)
AstNode
AstNode
accepts a ValueVisitor
and a closure,
and returns an object of the appropriate result type.
accept
in class AstNode
public If build(Expr condition, Comp child)
public String argsToString()
argsToString
in class AstNode
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |