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 */ 020 021 package org.apache.directory.shared.ldap.codec.extended.operations.storedProcedure; 022 023 024 import org.apache.directory.shared.asn1.ber.grammar.IGrammar; 025 import org.apache.directory.shared.asn1.ber.grammar.IStates; 026 027 028 /** 029 * Constants for StoredProcedureGrammar 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 * @version $Rev$, $Date$, 033 */ 034 public class StoredProcedureStatesEnum implements IStates 035 { 036 //~ Static fields/initializers ----------------------------------------------------------------- 037 038 //========================================================================= 039 // StoredProcedure 040 //========================================================================= 041 /** starting state */ 042 public static final int START_STATE = 0; 043 044 /** StoredProcedure */ 045 public static final int STORED_PROCEDURE_STATE = 1; 046 047 // Language --------------------------------------------------------------- 048 /** Language */ 049 public static final int LANGUAGE_STATE = 2; 050 051 // Procedure -------------------------------------------------------------- 052 /** Procedure */ 053 public static final int PROCEDURE_STATE = 3; 054 055 // Parameters ------------------------------------------------------------- 056 /** Parameters */ 057 public static final int PARAMETERS_STATE = 4; 058 059 // Parameter -------------------------------------------------------------- 060 /** Parameter */ 061 public static final int PARAMETER_STATE = 5; 062 063 // Parameter type --------------------------------------------------------- 064 /** Parameter type */ 065 public static final int PARAMETER_TYPE_STATE = 6; 066 067 // Parameters value ------------------------------------------------------- 068 /** Parameter value */ 069 public static final int PARAMETER_VALUE_STATE = 7; 070 071 public static final int LAST_STORED_PROCEDURE_STATE = 8; 072 073 //========================================================================= 074 // States debug strings 075 //========================================================================= 076 /** A string representation of all the states */ 077 private static String[] StoredProcedureString = new String[] 078 { 079 "START_STATE", 080 "STORED_PROCEDURE_STATE", 081 "LANGUAGE_STATE", 082 "PROCEDURE_STATE", 083 "PARAMETERS_STATE", 084 "PARAMETER_TYPE_STATE", 085 "PARAMETER_VALUE_STATE" 086 }; 087 088 /** The instance */ 089 private static StoredProcedureStatesEnum instance = new StoredProcedureStatesEnum(); 090 091 092 //~ Constructors ------------------------------------------------------------------------------- 093 094 /** 095 * This is a private constructor. This class is a singleton 096 * 097 */ 098 private StoredProcedureStatesEnum() 099 { 100 } 101 102 103 //~ Methods ------------------------------------------------------------------------------------ 104 105 /** 106 * Get an instance of this class 107 * @return An instance on this class 108 */ 109 public static IStates getInstance() 110 { 111 return instance; 112 } 113 114 115 /** 116 * Get the grammar name 117 * @param grammar The grammar code 118 * @return The grammar name 119 */ 120 public String getGrammarName( int grammar ) 121 { 122 return "STORED_PROCEDURE_GRAMMAR"; 123 } 124 125 126 /** 127 * Get the grammar name 128 * @param grammar The grammar class 129 * @return The grammar name 130 */ 131 public String getGrammarName( IGrammar grammar ) 132 { 133 if ( grammar instanceof StoredProcedureGrammar ) 134 { 135 return "STORED_PROCEDURE_GRAMMAR"; 136 } 137 else 138 { 139 return "UNKNOWN GRAMMAR"; 140 } 141 } 142 143 144 /** 145 * Get the string representing the state 146 * 147 * @param state The state number 148 * @return The String representing the state 149 */ 150 public String getState( int state ) 151 { 152 return ( ( state == GRAMMAR_END ) ? "STORED_PROCEDURE_END_STATE" : StoredProcedureString[state] ); 153 } 154 }