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.codec.controls.sort;
021
022
023import org.apache.directory.api.asn1.ber.grammar.States;
024
025
026/**
027 * Enumeration of states encountered while decoding a SortResponseControl.
028 *
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 */
031public enum SortResponseStates implements States
032{
033    /** Initialstate */ 
034    START_STATE,
035
036    /** SortResult ::= SEQUENCE transition */
037    SEQUENCE_STATE,
038
039    /** sortResult  ENUMERATED transition */
040    RESULT_CODE_STATE,
041    
042    /** attributeType [0] AttributeDescription OPTIONAL transition */
043    AT_DESC_STATE,
044
045    /** Final state */
046    END_STATE;
047
048    /**
049     * Get the grammar name
050     * 
051     * @return The grammar name
052     */
053    public String getGrammarName()
054    {
055        return "SORT_RESPONSE_GRAMMAR";
056    }
057
058
059    /**
060     * Get the string representing the state
061     * 
062     * @param state The state number
063     * @return The String representing the state
064     */
065    public String getState( int state )
066    {
067        return ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name();
068    }
069
070
071    @Override
072    public boolean isEndState()
073    {
074        return this == END_STATE;
075    }
076
077
078    @Override
079    public Enum<?> getStartState()
080    {
081        return START_STATE;
082    }
083
084}