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