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.shared.ldap.codec; 021 022 023import org.apache.directory.shared.asn1.ber.Asn1Container; 024import org.apache.directory.shared.asn1.ber.grammar.Grammar; 025import org.apache.directory.shared.asn1.ber.grammar.States; 026 027 028/** 029 * This class store the Ldap grammar's constants. It is also used for debugging 030 * purpose 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public enum LdapStatesEnum implements States 035{ 036 /** The END_STATE */ 037 END_STATE, 038 039 START_STATE, 040 LDAP_MESSAGE_STATE, 041 MESSAGE_ID_STATE, 042 BIND_REQUEST_STATE, 043 BIND_RESPONSE_STATE, 044 UNBIND_REQUEST_STATE, 045 SEARCH_REQUEST_STATE, 046 SEARCH_RESULT_ENTRY_STATE, 047 SEARCH_RESULT_DONE_STATE, 048 SEARCH_RESULT_REFERENCE_STATE, 049 MODIFY_REQUEST_STATE, 050 MODIFY_RESPONSE_STATE, 051 ADD_REQUEST_STATE, 052 ADD_RESPONSE_STATE, 053 DEL_REQUEST_STATE, 054 DEL_RESPONSE_STATE, 055 MODIFY_DN_REQUEST_STATE, 056 MODIFY_DN_RESPONSE_STATE, 057 COMPARE_REQUEST_STATE, 058 COMPARE_RESPONSE_STATE, 059 ABANDON_REQUEST_STATE, 060 EXTENDED_REQUEST_STATE, 061 EXTENDED_RESPONSE_STATE, 062 VERSION_STATE, 063 NAME_STATE, 064 SIMPLE_STATE, 065 SASL_STATE, 066 MECHANISM_STATE, 067 CREDENTIALS_STATE, 068 RESULT_CODE_BR_STATE, 069 MATCHED_DN_BR_STATE, 070 ERROR_MESSAGE_BR_STATE, 071 REFERRALS_BR_STATE, 072 REFERRAL_BR_STATE, 073 SERVER_SASL_CREDENTIALS_STATE, 074 RESULT_CODE_STATE, 075 MATCHED_DN_STATE, 076 ERROR_MESSAGE_STATE, 077 REFERRALS_STATE, 078 REFERRAL_STATE, 079 REQUEST_NAME_STATE, 080 REQUEST_VALUE_STATE, 081 RESPONSE_NAME_STATE, 082 RESPONSE_STATE, 083 RESULT_CODE_ER_STATE, 084 MATCHED_DN_ER_STATE, 085 ERROR_MESSAGE_ER_STATE, 086 REFERRALS_ER_STATE, 087 REFERRAL_ER_STATE, 088 ENTRY_STATE, 089 ATTRIBUTES_STATE, 090 ATTRIBUTE_STATE, 091 TYPE_STATE, 092 VALUES_STATE, 093 VALUE_STATE, 094 OBJECT_STATE, 095 MODIFICATIONS_STATE, 096 MODIFICATIONS_SEQ_STATE, 097 OPERATION_STATE, 098 MODIFICATION_STATE, 099 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 /** 158 * Get the grammar name 159 * 160 * @param grammar 161 * The grammar code 162 * @return The grammar name 163 */ 164 public String getGrammarName( int grammar ) 165 { 166 return "LDAP_MESSAGE_GRAMMAR"; 167 } 168 169 170 /** 171 * Get the grammar name 172 * 173 * @param grammar 174 * The grammar class 175 * @return The grammar name 176 */ 177 public String getGrammarName( Grammar<Asn1Container> grammar ) 178 { 179 if ( grammar instanceof LdapMessageGrammar ) 180 { 181 return "LDAP_MESSAGE_GRAMMAR"; 182 } 183 else 184 { 185 return "UNKNOWN GRAMMAR"; 186 } 187 } 188 189 190 /** 191 * Get the string representing the state 192 * 193 * @param state The state number 194 * @return The String representing the state 195 */ 196 public String getState( int state ) 197 { 198 return ( ( state == END_STATE.ordinal() ) ? "LDAP_MESSAGE_END_STATE" : name() ); 199 } 200 201 202 /** 203 * {@inheritDoc} 204 */ 205 public boolean isEndState() 206 { 207 return this == END_STATE; 208 } 209 210 211 /** 212 * {@inheritDoc} 213 */ 214 public LdapStatesEnum getStartState() 215 { 216 return START_STATE; 217 } 218}