View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.directory.api.ldap.codec;
21  
22  
23  import org.apache.directory.api.asn1.ber.Asn1Container;
24  import org.apache.directory.api.asn1.ber.grammar.Grammar;
25  import org.apache.directory.api.asn1.ber.grammar.States;
26  
27  
28  /**
29   * This class store the Ldap grammar's constants. It is also used for debugging
30   * purpose
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public enum LdapStatesEnum implements States
35  {
36      /** The END_STATE */
37      END_STATE,
38  
39      START_STATE,
40      LDAP_MESSAGE_STATE,
41      MESSAGE_ID_STATE,
42      BIND_REQUEST_STATE,
43      BIND_RESPONSE_STATE,
44      UNBIND_REQUEST_STATE,
45      SEARCH_REQUEST_STATE,
46      SEARCH_RESULT_ENTRY_STATE,
47      SEARCH_RESULT_DONE_STATE,
48      SEARCH_RESULT_REFERENCE_STATE,
49      MODIFY_REQUEST_STATE,
50      MODIFY_RESPONSE_STATE,
51      ADD_REQUEST_STATE,
52      ADD_RESPONSE_STATE,
53      DEL_REQUEST_STATE,
54      DEL_RESPONSE_STATE,
55      MODIFY_DN_REQUEST_STATE,
56      MODIFY_DN_RESPONSE_STATE,
57      COMPARE_REQUEST_STATE,
58      COMPARE_RESPONSE_STATE,
59      ABANDON_REQUEST_STATE,
60      EXTENDED_REQUEST_STATE,
61      EXTENDED_RESPONSE_STATE,
62      VERSION_STATE,
63      NAME_STATE,
64      SIMPLE_STATE,
65      SASL_STATE,
66      MECHANISM_STATE,
67      CREDENTIALS_STATE,
68      RESULT_CODE_BR_STATE,
69      MATCHED_DN_BR_STATE,
70      ERROR_MESSAGE_BR_STATE,
71      REFERRALS_BR_STATE,
72      REFERRAL_BR_STATE,
73      SERVER_SASL_CREDENTIALS_STATE,
74      RESULT_CODE_STATE,
75      MATCHED_DN_STATE,
76      ERROR_MESSAGE_STATE,
77      REFERRALS_STATE,
78      REFERRAL_STATE,
79      REQUEST_NAME_STATE,
80      REQUEST_VALUE_STATE,
81      RESPONSE_NAME_STATE,
82      RESPONSE_STATE,
83      RESULT_CODE_ER_STATE,
84      MATCHED_DN_ER_STATE,
85      ERROR_MESSAGE_ER_STATE,
86      REFERRALS_ER_STATE,
87      REFERRAL_ER_STATE,
88      ENTRY_STATE,
89      ATTRIBUTES_STATE,
90      ATTRIBUTE_STATE,
91      TYPE_STATE,
92      VALUES_STATE,
93      VALUE_STATE,
94      OBJECT_STATE,
95      MODIFICATIONS_STATE,
96      MODIFICATIONS_SEQ_STATE,
97      OPERATION_STATE,
98      MODIFICATION_STATE,
99      TYPE_MOD_STATE,
100     VALS_STATE,
101     ATTRIBUTE_VALUE_STATE,
102     ENTRY_MOD_DN_STATE,
103     NEW_RDN_STATE,
104     DELETE_OLD_RDN_STATE,
105     NEW_SUPERIOR_STATE,
106     ENTRY_COMP_STATE,
107     AVA_STATE,
108     ATTRIBUTE_DESC_STATE,
109     ASSERTION_VALUE_STATE,
110     BASE_OBJECT_STATE,
111     SCOPE_STATE,
112     DEREF_ALIAS_STATE,
113     SIZE_LIMIT_STATE,
114     TIME_LIMIT_STATE,
115     TYPES_ONLY_STATE,
116     AND_STATE,
117     OR_STATE,
118     NOT_STATE,
119     EQUALITY_MATCH_STATE,
120     SUBSTRING_FILTER_STATE,
121     GREATER_OR_EQUAL_STATE,
122     LESS_OR_EQUAL_STATE,
123     PRESENT_STATE,
124     APPROX_MATCH_STATE,
125     EXTENSIBLE_MATCH_STATE,
126     ATTRIBUTE_DESC_FILTER_STATE,
127     ASSERTION_VALUE_FILTER_STATE,
128     ATTRIBUTE_DESCRIPTION_LIST_STATE,
129     ATTRIBUTE_DESCRIPTION_STATE,
130     TYPE_SUBSTRING_STATE,
131     SUBSTRINGS_STATE,
132     INITIAL_STATE,
133     ANY_STATE,
134     FINAL_STATE,
135     MATCHING_RULE_STATE,
136     TYPE_MATCHING_RULE_STATE,
137     MATCH_VALUE_STATE,
138     DN_ATTRIBUTES_STATE,
139     OBJECT_NAME_STATE,
140     ATTRIBUTES_SR_STATE,
141     PARTIAL_ATTRIBUTES_LIST_STATE,
142     TYPE_SR_STATE,
143     VALS_SR_STATE,
144     ATTRIBUTE_VALUE_SR_STATE,
145     REFERENCE_STATE,
146     CONTROLS_STATE,
147     CONTROL_STATE,
148     CONTROL_TYPE_STATE,
149     CRITICALITY_STATE,
150     CONTROL_VALUE_STATE,
151     INTERMEDIATE_RESPONSE_STATE,
152     INTERMEDIATE_RESPONSE_NAME_STATE,
153     INTERMEDIATE_RESPONSE_VALUE_STATE,
154     LAST_LDAP_STATE;
155 
156     /**
157      * Get the grammar name
158      *
159      * @param grammar
160      *            The grammar code
161      * @return The grammar name
162      */
163     public String getGrammarName( int grammar )
164     {
165         return "LDAP_MESSAGE_GRAMMAR";
166     }
167 
168 
169     /**
170      * Get the grammar name
171      *
172      * @param grammar
173      *            The grammar class
174      * @return The grammar name
175      */
176     public String getGrammarName( Grammar<Asn1Container> grammar )
177     {
178         if ( grammar instanceof LdapMessageGrammar )
179         {
180             return "LDAP_MESSAGE_GRAMMAR";
181         }
182         else
183         {
184             return "UNKNOWN GRAMMAR";
185         }
186     }
187 
188 
189     /**
190      * Get the string representing the state
191      *
192      * @param state The state number
193      * @return The String representing the state
194      */
195     public String getState( int state )
196     {
197         return ( ( state == END_STATE.ordinal() ) ? "LDAP_MESSAGE_END_STATE" : name() );
198     }
199 
200 
201     /**
202      * {@inheritDoc}
203      */
204     public boolean isEndState()
205     {
206         return this == END_STATE;
207     }
208 
209 
210     /**
211      * {@inheritDoc}
212      */
213     public LdapStatesEnum getStartState()
214     {
215         return START_STATE;
216     }
217 }