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.encApRepPart;
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 EncApRepPart 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 EncApRepPartStatesEnum implements States
034{
035    // Start
036    START_STATE, // 0
037
038    // ----- EncApRepPart message --------------------------------------
039    ENC_AP_REP_PART_STATE, // 1
040    ENC_AP_REP_PART_SEQ_STATE, // 2
041
042    ENC_AP_REP_PART_CTIME_TAG_STATE, // 3
043    ENC_AP_REP_PART_CTIME_STATE, // 4
044
045    ENC_AP_REP_PART_CUSEC_TAG_STATE, // 5
046    ENC_AP_REP_PART_CUSEC_STATE, // 6
047
048    ENC_AP_REP_PART_SUBKEY_STATE, // 7
049
050    ENC_AP_REP_PART_SEQ_NUMBER_TAG_STATE, // 8
051    ENC_AP_REP_PART_SEQ_NUMBER_STATE, // 9
052
053    // End
054    LAST_ENC_AP_REP_PART_STATE; // 10
055
056    /**
057     * Get the grammar name
058     *
059     * @param grammar The grammar code
060     * @return The grammar name
061     */
062    public String getGrammarName( int grammar )
063    {
064        return "ENC_AP_REP_PART_GRAMMAR";
065    }
066
067
068    /**
069     * Get the grammar name
070     *
071     * @param grammar The grammar class
072     * @return The grammar name
073     */
074    public String getGrammarName( Grammar<EncApRepPartContainer> grammar )
075    {
076        if ( grammar instanceof EncApRepPartGrammar )
077        {
078            return "ENC_AP_REP_PART_GRAMMAR";
079        }
080        else
081        {
082            return "UNKNOWN GRAMMAR";
083        }
084    }
085
086
087    /**
088     * Get the string representing the state
089     *
090     * @param state The state number
091     * @return The String representing the state
092     */
093    public String getState( int state )
094    {
095        return ( ( state == LAST_ENC_AP_REP_PART_STATE.ordinal() ) ? "ENC_AP_REP_PART_END_STATE" : name() );
096    }
097
098
099    /**
100     * {@inheritDoc}
101     */
102    public boolean isEndState()
103    {
104        return this == LAST_ENC_AP_REP_PART_STATE;
105    }
106
107
108    /**
109     * {@inheritDoc}
110     */
111    public EncApRepPartStatesEnum getStartState()
112    {
113        return START_STATE;
114    }
115}