1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.asn1.ber.grammar;
21
22
23 import org.apache.directory.api.asn1.ber.Asn1Container;
24 import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
25 import org.apache.directory.api.asn1.util.Asn1StringUtils;
26
27
28
29
30
31
32
33
34
35
36 public class GrammarTransition<C extends Asn1Container>
37 {
38
39 private Action<C> action;
40
41
42 private Enum<?> previousState;
43
44
45 private Enum<?> currentState;
46
47
48 private int currentTag;
49
50
51
52
53
54
55
56
57
58
59 public GrammarTransition( Enum<?> previousState, Enum<?> currentState, int currentTag, Action<C> action )
60 {
61 this.previousState = previousState;
62 this.currentState = currentState;
63 this.action = action;
64 this.currentTag = currentTag;
65 }
66
67
68
69
70
71
72
73
74
75 public GrammarTransition( Enum<?> previousState, Enum<?> currentState, int currentTag )
76 {
77 this.previousState = previousState;
78 this.currentState = currentState;
79 this.currentTag = currentTag;
80 }
81
82
83
84
85
86
87
88
89
90
91 public GrammarTransition( Enum<?> previousState, Enum<?> currentState, UniversalTag currentTag, Action<C> action )
92 {
93 this.previousState = previousState;
94 this.currentState = currentState;
95 this.action = action;
96 this.currentTag = currentTag.getValue();
97 }
98
99
100
101
102
103
104
105
106
107 public GrammarTransition( Enum<?> previousState, Enum<?> currentState, UniversalTag currentTag )
108 {
109 this.previousState = previousState;
110 this.currentState = currentState;
111 this.currentTag = currentTag.getValue();
112 }
113
114
115
116
117
118
119
120 public boolean hasAction()
121 {
122 return action != null;
123 }
124
125
126
127
128
129 public Action<C> getAction()
130 {
131 return action;
132 }
133
134
135
136
137
138 public Enum<?> getCurrentState()
139 {
140 return currentState;
141 }
142
143
144
145
146
147 public Enum<?> getPreviousState()
148 {
149 return previousState;
150 }
151
152
153
154
155
156 @Override
157 public String toString()
158 {
159 StringBuilder sb = new StringBuilder();
160
161 sb.append( "Transition from state <" ).append( previousState ).append( "> " );
162 sb.append( "to state <" ).append( currentState ).append( ">, " );
163 sb.append( "tag <" ).append( Asn1StringUtils.dumpByte( ( byte ) currentTag ) ).append( ">, " );
164 sb.append( "action : " );
165
166 if ( action == null )
167 {
168 sb.append( "no action" );
169 }
170 else
171 {
172 sb.append( action );
173 }
174
175 return sb.toString();
176 }
177 }