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.certGeneration;
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 CertGeneration'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 CertGenerationStatesEnum implements States
034{
035
036    /** The END_STATE */
037    END_STATE,
038
039    /** start state*/
040    START_STATE,
041
042    /** sequence*/
043    CERT_GENERATION_REQUEST_SEQUENCE_STATE,
044
045    /** the target Dn*/
046    TARGETDN_STATE,
047
048    /** the issuer Dn*/
049    ISSUER_STATE,
050
051    /** the subject Dn*/
052    SUBJECT_STATE,
053
054    /** the key algorithm*/
055    KEY_ALGORITHM_STATE,
056
057    /** terminal state */
058    LAST_CERT_GENERATION_STATE;
059
060    /**
061     * Get the grammar name
062     * 
063     * @param grammar The grammar class
064     * @return The grammar name
065     */
066    public String getGrammarName( Grammar<CertGenerationContainer> grammar )
067    {
068        return "CERT_GENERATION_GRAMMER";
069    }
070
071
072    /**
073     * Get the grammar name
074     * 
075     * @param grammar The grammar code
076     * @return The grammar name
077     */
078    public String getGrammarName( int grammar )
079    {
080        return "CERT_GENERATION_GRAMMER";
081    }
082
083
084    /**
085     * Get the string representing the state
086     * 
087     * @param state The state number
088     * @return The String representing the state
089     */
090    public String getState( int state )
091    {
092        return ( ( state == END_STATE.ordinal() ) ? "CERT_GENERATION_END_STATE" : this.name() );
093    }
094
095
096    /**
097     * {@inheritDoc}
098     */
099    public boolean isEndState()
100    {
101        return this == END_STATE;
102    }
103
104
105    /**
106     * {@inheritDoc}
107     */
108    public CertGenerationStatesEnum getStartState()
109    {
110        return START_STATE;
111    }
112}