1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
|
21
|
|
namespace Seasar.Dao.Node
|
22
|
|
{
|
23
|
|
public class IfNode : ContainerNode
|
24
|
|
{
|
25
|
|
private string expression;
|
26
|
|
private ElseNode elseNode;
|
27
|
|
private ExpressionUtil expressionUtil;
|
28
|
|
|
29
|
29
|
public IfNode(string expression)
|
30
|
|
{
|
31
|
29
|
expressionUtil = new ExpressionUtil();
|
32
|
29
|
this.expression = expressionUtil.parseExpression(expression);
|
33
|
29
|
if (this.expression == null)
|
34
|
0
|
throw new ApplicationException("IllegalBoolExpression=[" + this.expression + "]");
|
35
|
|
}
|
36
|
|
|
37
|
|
public string Expression
|
38
|
|
{
|
39
|
1
|
get { return this.expression; }
|
40
|
|
}
|
41
|
|
|
42
|
|
public ElseNode ElseNode
|
43
|
|
{
|
44
|
0
|
get { return elseNode; }
|
45
|
5
|
set { elseNode = value; }
|
46
|
|
}
|
47
|
|
|
48
|
31
|
public override void Accept(ICommandContext ctx)
|
49
|
|
{
|
50
|
31
|
object result = InvokeExpression(this.expression, ctx);
|
51
|
31
|
if (result != null)
|
52
|
|
{
|
53
|
31
|
if(Convert.ToBoolean(result))
|
54
|
|
{
|
55
|
16
|
base.Accept(ctx);
|
56
|
16
|
ctx.IsEnabled = true;
|
57
|
|
}
|
58
|
15
|
else if (elseNode != null)
|
59
|
|
{
|
60
|
5
|
elseNode.Accept(ctx);
|
61
|
5
|
ctx.IsEnabled = true;
|
62
|
|
}
|
63
|
|
}
|
64
|
|
else
|
65
|
|
{
|
66
|
0
|
throw new ApplicationException("IllegalBoolExpression=[" + this.expression + "]");
|
67
|
|
}
|
68
|
|
}
|
69
|
|
}
|
70
|
|
}
|
71
|
|
|