1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.flow.builder; |
20 | |
|
21 | |
import javax.el.ValueExpression; |
22 | |
import javax.faces.flow.builder.SwitchBuilder; |
23 | |
import javax.faces.flow.builder.SwitchCaseBuilder; |
24 | |
import org.apache.myfaces.flow.FlowImpl; |
25 | |
import org.apache.myfaces.flow.SwitchNodeImpl; |
26 | |
import org.apache.myfaces.view.facelets.el.ELText; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class SwitchBuilderImpl extends SwitchBuilder |
34 | |
{ |
35 | |
private FlowBuilderImpl _flowBuilder; |
36 | |
private FlowImpl _facesFlow; |
37 | |
private SwitchNodeImpl _switchNodeImpl; |
38 | |
private SwitchCaseBuilderImpl _lastSwitchCaseBuilderImpl; |
39 | |
|
40 | |
public SwitchBuilderImpl(FlowBuilderImpl flowBuilder, FlowImpl facesFlow, String switchNodeId) |
41 | 0 | { |
42 | 0 | this._flowBuilder = flowBuilder; |
43 | 0 | this._facesFlow = facesFlow; |
44 | 0 | this._switchNodeImpl = new SwitchNodeImpl(switchNodeId); |
45 | 0 | this._facesFlow.putSwitch(switchNodeId, _switchNodeImpl); |
46 | 0 | this._lastSwitchCaseBuilderImpl = new SwitchCaseBuilderImpl( |
47 | |
this._flowBuilder, this._facesFlow, this, this._switchNodeImpl); |
48 | 0 | } |
49 | |
|
50 | |
@Override |
51 | |
public SwitchCaseBuilder switchCase() |
52 | |
{ |
53 | 0 | return this._lastSwitchCaseBuilderImpl.switchCase(); |
54 | |
} |
55 | |
|
56 | |
@Override |
57 | |
public SwitchCaseBuilder defaultOutcome(String outcome) |
58 | |
{ |
59 | 0 | if (ELText.isLiteral(outcome)) |
60 | |
{ |
61 | 0 | this._switchNodeImpl.setDefaultOutcome(outcome); |
62 | |
} |
63 | |
else |
64 | |
{ |
65 | 0 | this._switchNodeImpl.setDefaultOutcome(_flowBuilder.createValueExpression(outcome)); |
66 | |
} |
67 | 0 | return _lastSwitchCaseBuilderImpl; |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public SwitchCaseBuilder defaultOutcome(ValueExpression outcome) |
72 | |
{ |
73 | 0 | this._switchNodeImpl.setDefaultOutcome(outcome); |
74 | 0 | return _lastSwitchCaseBuilderImpl; |
75 | |
} |
76 | |
|
77 | |
@Override |
78 | |
public SwitchBuilder markAsStartNode() |
79 | |
{ |
80 | 0 | _facesFlow.setStartNodeId(_switchNodeImpl.getId()); |
81 | 0 | return this; |
82 | |
} |
83 | |
} |