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.extras.extended.ads_impl.gracefulDisconnect;
021
022
023import org.apache.directory.api.asn1.ber.grammar.Grammar;
024import org.apache.directory.api.asn1.ber.grammar.States;
025
026
027/**
028 * This class store the GracefulDisconnect's grammar constants. It is also used
029 * for debugging purposes.
030 * 
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public enum GracefulDisconnectStatesEnum implements States
034{
035    // ~ Static fields/initializers
036    // -----------------------------------------------------------------
037
038    /** The END_STATE */
039    END_STATE,
040
041    // =========================================================================
042    // GracefulDisconnect grammar states
043    // =========================================================================
044    /** Initial state */
045    START_STATE,
046
047    /** Sequence */
048    GRACEFUL_DISCONNECT_SEQUENCE_STATE,
049
050    /** Time offline */
051    TIME_OFFLINE_STATE,
052
053    /** Delay */
054    DELAY_STATE,
055
056    /** Replicated contexts */
057    REPLICATED_CONTEXTS_STATE,
058
059    /** Referral */
060    REFERRAL_STATE,
061
062    /** terminal state */
063    LAST_GRACEFUL_DISCONNECT_STATE;
064
065    /**
066     * Get the grammar name
067     * 
068     * @param grammar The grammar code
069     * @return The grammar name
070     */
071    public String getGrammarName( int grammar )
072    {
073        return "GRACEFUL_DISCONNECT_GRAMMAR";
074    }
075
076
077    /**
078     * Get the grammar name
079     * 
080     * @param grammar The grammar class
081     * @return The grammar name
082     */
083    public String getGrammarName( Grammar<GracefulDisconnectContainer> grammar )
084    {
085        return "GRACEFUL_DISCONNECT_GRAMMAR";
086    }
087
088
089    /**
090     * Get the string representing the state
091     * 
092     * @param state The state number
093     * @return The String representing the state
094     */
095    public String getState( int state )
096    {
097        return ( ( state == END_STATE.ordinal() ) ? "GRACEFUL_DISCONNECT_END_STATE" : name() );
098    }
099
100
101    /**
102     * {@inheritDoc}
103     */
104    public boolean isEndState()
105    {
106        return this == END_STATE;
107    }
108
109
110    /**
111     * {@inheritDoc}
112     */
113    public GracefulDisconnectStatesEnum getStartState()
114    {
115        return START_STATE;
116    }
117}