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.padata;
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 PaData 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 PaDataStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    PADATA_SEQ_STATE, // 1
039
040    PADATA_TYPE_TAG_STATE, // 2
041
042    PADATA_TYPE_STATE, // 3
043
044    PADATA_VALUE_TAG_STATE, // 4
045
046    PADATA_VALUE_STATE, // 5
047
048    // End
049    LAST_PADATA_STATE; // 6
050
051    /**
052     * Get the grammar name
053     *
054     * @param grammar The grammar code
055     * @return The grammar name
056     */
057    public String getGrammarName( int grammar )
058    {
059        return "PADATA_GRAMMAR";
060    }
061
062
063    /**
064     * Get the grammar name
065     *
066     * @param grammar The grammar class
067     * @return The grammar name
068     */
069    public String getGrammarName( Grammar<PaDataContainer> grammar )
070    {
071        if ( grammar instanceof PaDataGrammar )
072        {
073            return "PADATA_GRAMMAR";
074        }
075        else
076        {
077            return "UNKNOWN GRAMMAR";
078        }
079    }
080
081
082    /**
083     * Get the string representing the state
084     *
085     * @param state The state number
086     * @return The String representing the state
087     */
088    public String getState( int state )
089    {
090        return ( ( state == LAST_PADATA_STATE.ordinal() ) ? "LAST_PADATA_STATE" : name() );
091    }
092
093
094    /**
095     * {@inheritDoc}
096     */
097    public boolean isEndState()
098    {
099        return this == LAST_PADATA_STATE;
100    }
101
102
103    /**
104     * {@inheritDoc}
105     */
106    public PaDataStatesEnum getStartState()
107    {
108        return START_STATE;
109    }
110}