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 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 {
42 this._flowBuilder = flowBuilder;
43 this._facesFlow = facesFlow;
44 this._switchNodeImpl = new SwitchNodeImpl(switchNodeId);
45 this._facesFlow.putSwitch(switchNodeId, _switchNodeImpl);
46 this._lastSwitchCaseBuilderImpl = new SwitchCaseBuilderImpl(
47 this._flowBuilder, this._facesFlow, this, this._switchNodeImpl);
48 }
49
50 @Override
51 public SwitchCaseBuilder switchCase()
52 {
53 return this._lastSwitchCaseBuilderImpl.switchCase();
54 }
55
56 @Override
57 public SwitchCaseBuilder defaultOutcome(String outcome)
58 {
59 if (ELText.isLiteral(outcome))
60 {
61 this._switchNodeImpl.setDefaultOutcome(outcome);
62 }
63 else
64 {
65 this._switchNodeImpl.setDefaultOutcome(_flowBuilder.createValueExpression(outcome));
66 }
67 return _lastSwitchCaseBuilderImpl;
68 }
69
70 @Override
71 public SwitchCaseBuilder defaultOutcome(ValueExpression outcome)
72 {
73 this._switchNodeImpl.setDefaultOutcome(outcome);
74 return _lastSwitchCaseBuilderImpl;
75 }
76
77 @Override
78 public SwitchBuilder markAsStartNode()
79 {
80 _facesFlow.setStartNodeId(_switchNodeImpl.getId());
81 return this;
82 }
83 }