001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.directory.api.ldap.codec;
021
022
023import org.apache.directory.api.asn1.ber.grammar.States;
024
025
026/**
027 * This class store the Ldap grammar's constants. It is also used for debugging
028 * purpose
029 *
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public enum LdapStatesEnum implements States
033{
034    /** The END_STATE */
035    END_STATE,
036
037    START_STATE,
038    LDAP_MESSAGE_STATE,
039    MESSAGE_ID_STATE,
040    BIND_REQUEST_STATE,
041    BIND_RESPONSE_STATE,
042    UNBIND_REQUEST_STATE,
043    SEARCH_REQUEST_STATE,
044    SEARCH_RESULT_ENTRY_STATE,
045    SEARCH_RESULT_DONE_STATE,
046    SEARCH_RESULT_REFERENCE_STATE,
047    MODIFY_REQUEST_STATE,
048    MODIFY_RESPONSE_STATE,
049    ADD_REQUEST_STATE,
050    ADD_RESPONSE_STATE,
051    DEL_REQUEST_STATE,
052    DEL_RESPONSE_STATE,
053    MODIFY_DN_REQUEST_STATE,
054    MODIFY_DN_RESPONSE_STATE,
055    COMPARE_REQUEST_STATE,
056    COMPARE_RESPONSE_STATE,
057    ABANDON_REQUEST_STATE,
058    EXTENDED_REQUEST_STATE,
059    EXTENDED_RESPONSE_STATE,
060    VERSION_STATE,
061    NAME_STATE,
062    SIMPLE_STATE,
063    SASL_STATE,
064    MECHANISM_STATE,
065    CREDENTIALS_STATE,
066    RESULT_CODE_BR_STATE,
067    MATCHED_DN_BR_STATE,
068    ERROR_MESSAGE_BR_STATE,
069    REFERRALS_BR_STATE,
070    REFERRAL_BR_STATE,
071    SERVER_SASL_CREDENTIALS_STATE,
072    RESULT_CODE_STATE,
073    MATCHED_DN_STATE,
074    ERROR_MESSAGE_STATE,
075    REFERRALS_STATE,
076    REFERRAL_STATE,
077    REQUEST_NAME_STATE,
078    REQUEST_VALUE_STATE,
079    RESPONSE_NAME_STATE,
080    RESPONSE_STATE,
081    RESULT_CODE_ER_STATE,
082    MATCHED_DN_ER_STATE,
083    ERROR_MESSAGE_ER_STATE,
084    REFERRALS_ER_STATE,
085    REFERRAL_ER_STATE,
086    ENTRY_STATE,
087    ATTRIBUTES_STATE,
088    ATTRIBUTE_STATE,
089    TYPE_STATE,
090    VALUES_STATE,
091    VALUE_STATE,
092    OBJECT_STATE,
093    MODIFICATIONS_STATE,
094    MODIFICATIONS_SEQ_STATE,
095    OPERATION_STATE,
096    MODIFICATION_STATE,
097    TYPE_MOD_STATE,
098    VALS_STATE,
099    ATTRIBUTE_VALUE_STATE,
100    ENTRY_MOD_DN_STATE,
101    NEW_RDN_STATE,
102    DELETE_OLD_RDN_STATE,
103    NEW_SUPERIOR_STATE,
104    ENTRY_COMP_STATE,
105    AVA_STATE,
106    ATTRIBUTE_DESC_STATE,
107    ASSERTION_VALUE_STATE,
108    BASE_OBJECT_STATE,
109    SCOPE_STATE,
110    DEREF_ALIAS_STATE,
111    SIZE_LIMIT_STATE,
112    TIME_LIMIT_STATE,
113    TYPES_ONLY_STATE,
114    AND_STATE,
115    OR_STATE,
116    NOT_STATE,
117    EQUALITY_MATCH_STATE,
118    SUBSTRING_FILTER_STATE,
119    GREATER_OR_EQUAL_STATE,
120    LESS_OR_EQUAL_STATE,
121    PRESENT_STATE,
122    APPROX_MATCH_STATE,
123    EXTENSIBLE_MATCH_STATE,
124    ATTRIBUTE_DESC_FILTER_STATE,
125    ASSERTION_VALUE_FILTER_STATE,
126    ATTRIBUTE_DESCRIPTION_LIST_STATE,
127    ATTRIBUTE_DESCRIPTION_STATE,
128    TYPE_SUBSTRING_STATE,
129    SUBSTRINGS_STATE,
130    INITIAL_STATE,
131    ANY_STATE,
132    FINAL_STATE,
133    MATCHING_RULE_STATE,
134    TYPE_MATCHING_RULE_STATE,
135    MATCH_VALUE_STATE,
136    DN_ATTRIBUTES_STATE,
137    OBJECT_NAME_STATE,
138    ATTRIBUTES_SR_STATE,
139    PARTIAL_ATTRIBUTES_LIST_STATE,
140    TYPE_SR_STATE,
141    VALS_SR_STATE,
142    ATTRIBUTE_VALUE_SR_STATE,
143    REFERENCE_STATE,
144    CONTROLS_STATE,
145    CONTROL_STATE,
146    CONTROL_TYPE_STATE,
147    CRITICALITY_STATE,
148    CONTROL_VALUE_STATE,
149    INTERMEDIATE_RESPONSE_STATE,
150    INTERMEDIATE_RESPONSE_NAME_STATE,
151    INTERMEDIATE_RESPONSE_VALUE_STATE,
152    LAST_LDAP_STATE;
153
154    /**
155     * Get the grammar name
156     *
157     * @return The grammar name
158     */
159    public String getGrammarName()
160    {
161        return "LDAP_MESSAGE_GRAMMAR";
162    }
163
164
165    /**
166     * Get the string representing the state
167     *
168     * @param state The state number
169     * @return The String representing the state
170     */
171    public String getState( int state )
172    {
173        return ( state == END_STATE.ordinal() ) ? "LDAP_MESSAGE_END_STATE" : name();
174    }
175
176
177    /**
178     * {@inheritDoc}
179     */
180    @Override
181    public boolean isEndState()
182    {
183        return this == END_STATE;
184    }
185
186
187    /**
188     * {@inheritDoc}
189     */
190    @Override
191    public LdapStatesEnum getStartState()
192    {
193        return START_STATE;
194    }
195}