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    package org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue;
021    
022    
023    import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
024    import org.apache.directory.shared.asn1.ber.grammar.IStates;
025    
026    
027    /**
028     * This class store the SyncInfoValueControl's grammar constants. It is also used for
029     * debugging purposes.
030     * 
031     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032     * @version $Rev: 741888 $, $Date: 2009-02-07 13:57:03 +0100 (Sat, 07 Feb 2009) $, 
033     */
034    public class SyncInfoValueControlStatesEnum implements IStates
035    {
036        // ~ Static fields/initializers
037        // -----------------------------------------------------------------
038    
039        // =========================================================================
040        // SyncRequestValue control grammar states
041        // =========================================================================
042        /** Initial state */
043        public static final int START_STATE = 0;
044    
045        /** NewCookie state */
046        public static final int NEW_COOKIE_STATE = 1;
047    
048        /** RefreshDelete state */
049        public static final int REFRESH_DELETE_STATE = 2;
050        
051        /** RefreshDelete cookie state */
052        public static final int REFRESH_DELETE_COOKIE_STATE = 3;
053        
054        /** RefreshDelete refreshDone state */
055        public static final int REFRESH_DELETE_REFRESH_DONE_STATE = 4;
056        
057        /** RefreshPresent state */
058        public static final int REFRESH_PRESENT_STATE = 5;
059        
060        /** RefreshPresent cookie state */
061        public static final int REFRESH_PRESENT_COOKIE_STATE = 6;
062        
063        /** RefreshPresent refreshDone state */
064        public static final int REFRESH_PRESENT_REFRESH_DONE_STATE = 7;
065        
066        /** SyncIdSet state */
067        public static final int SYNC_ID_SET_STATE = 8;
068        
069        /** SyncIdSet cookie state */
070        public static final int SYNC_ID_SET_COOKIE_STATE = 9;
071        
072        /** SyncIdSet refreshDone state */
073        public static final int SYNC_ID_SET_REFRESH_DELETES_STATE = 10;
074        
075        /** SyncIdSet SET OF UUIDs state */
076        public static final int SYNC_ID_SET_SET_OF_UUIDS_STATE = 11;
077        
078        /** SyncIdSet UUID state */
079        public static final int SYNC_ID_SET_UUID_STATE = 12;
080    
081        /** terminal state */
082        public static final int LAST_SYNC_INFO_VALUE_STATE = 13;
083    
084        // =========================================================================
085        // States debug strings
086        // =========================================================================
087        /** A string representation of all the states */
088        private static String[] syncInfoValueString = new String[]
089            { 
090                "START_STATE",
091                "NEW_COOKIE_STATE",
092                "REFRESH_DELETE_STATE",
093                "REFRESH_DELETE_COOKIE_STATE",
094                "REFRESH_DELETE_REFRESH_DONE_STATE",
095                "REFRESH_PRESENT_STATE",
096                "REFRESH_PRESENT_COOKIE_STATE",
097                "REFRESH_PRESENT_REFRESH_DONE_STATE",
098                "SYNC_ID_SET_STATE",
099                "SYNC_ID_SET_COOKIE_STATE",
100                "SYNC_ID_SET_REFRESH_DELETES_STATE",
101                "SYNC_ID_SET_SET_OF_UUIDS_STATE",
102                "int SYNC_ID_SET_UUID_STATE"
103            };
104    
105        /** The instance */
106        private static SyncInfoValueControlStatesEnum instance = new SyncInfoValueControlStatesEnum();
107    
108    
109        // ~ Constructors
110        // -------------------------------------------------------------------------------
111    
112        /**
113         * This is a private constructor. This class is a singleton
114         */
115        private SyncInfoValueControlStatesEnum()
116        {
117        }
118    
119    
120        // ~ Methods
121        // ------------------------------------------------------------------------------------
122    
123        /**
124         * Get an instance of this class
125         * 
126         * @return An instance on this class
127         */
128        public static IStates getInstance()
129        {
130            return instance;
131        }
132    
133    
134        /**
135         * Get the grammar name
136         * 
137         * @param grammar The grammar code
138         * @return The grammar name
139         */
140        public String getGrammarName( int grammar )
141        {
142            return "SYNC_INFO_VALUE_GRAMMAR";
143        }
144    
145    
146        /**
147         * Get the grammar name
148         * 
149         * @param grammar The grammar class
150         * @return The grammar name
151         */
152        public String getGrammarName( IGrammar grammar )
153        {
154            if ( grammar instanceof SyncInfoValueControlGrammar )
155            {
156                return "SYNC_INFO_VALUE_GRAMMAR";
157            }
158    
159            return "UNKNOWN GRAMMAR";
160        }
161    
162    
163        /**
164         * Get the string representing the state
165         * 
166         * @param state The state number
167         * @return The String representing the state
168         */
169        public String getState( int state )
170        {
171            return ( ( state == GRAMMAR_END ) ? "SYNC_INFO_VALUE_END_STATE" : syncInfoValueString[state] );
172        }
173    }