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.kerberos.codec.adAndOr;
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 AD-AND-OR grammar's constants. It is also used for debugging
029 * purpose
030 *
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public enum AdAndOrStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- AD-AND-OR message --------------------------------------
039    AD_AND_OR_STATE, // 1
040
041    AD_AND_OR_CONDITION_COUNT_TAG_STATE, // 2
042    AD_AND_OR_CONDITION_COUNT_STATE, // 3
043
044    AD_AND_OR_ELEMENTS_TAG_STATE, // 4
045
046    // End
047    LAST_AD_AND_OR_STATE; // 5
048
049    /**
050     * Get the grammar name
051     *
052     * @param grammar The grammar code
053     * @return The grammar name
054     */
055    public String getGrammarName( int grammar )
056    {
057        return "AD_AND_OR_GRAMMAR";
058    }
059
060
061    /**
062     * Get the grammar name
063     *
064     * @param grammar The grammar class
065     * @return The grammar name
066     */
067    public String getGrammarName( Grammar<AdAndOrContainer> grammar )
068    {
069        if ( grammar instanceof AdAndOrGrammar )
070        {
071            return "AD_AND_OR_GRAMMAR";
072        }
073        else
074        {
075            return "UNKNOWN GRAMMAR";
076        }
077    }
078
079
080    /**
081     * Get the string representing the state
082     *
083     * @param state The state number
084     * @return The String representing the state
085     */
086    public String getState( int state )
087    {
088        return ( ( state == LAST_AD_AND_OR_STATE.ordinal() ) ? "AD_AND_OR_END_STATE" : name() );
089    }
090
091
092    /**
093     * {@inheritDoc}
094     */
095    public boolean isEndState()
096    {
097        return this == LAST_AD_AND_OR_STATE;
098    }
099
100
101    /**
102     * {@inheritDoc}
103     */
104    public AdAndOrStatesEnum getStartState()
105    {
106        return START_STATE;
107    }
108}