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 * Codec states for SortRequestControl.
028 *
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 */
031public enum SortRequestStates implements States
032{
033    /** Initial state */
034    START_STATE,
035
036    /** SortKeyList ::= SEQUENCE OF transition */
037    SEQUENCE_OF_SEQUENCE_STATE,
038    
039    /** SortKeyList ::= SEQUENCE OF SEQUENCE transition */
040    SORT_KEY_SEQUENCE_STATE,
041
042    /** attributeType   AttributeDescription transition */
043    AT_DESC_STATE,
044
045    /** orderingRule    [0] MatchingRuleId OPTIONAL transition */
046    ORDER_RULE_STATE,
047
048    /** reverseOrder    [1] BOOLEAN DEFAULT FALSE transition */
049    REVERSE_ORDER_STATE,
050
051    /** Final state */
052    END_STATE;
053
054    /**
055     * Get the grammar name
056     * 
057     * @return The grammar name
058     */
059    public String getGrammarName()
060    {
061        return "SORT_REQUEST_GRAMMAR";
062    }
063
064
065    /**
066     * Get the string representing the state
067     * 
068     * @param state The state number
069     * @return The String representing the state
070     */
071    public String getState( int state )
072    {
073        return ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name();
074    }
075
076
077    /**
078     * {@inheritDoc}
079     */
080    @Override
081    public boolean isEndState()
082    {
083        return this == END_STATE;
084    }
085
086
087    /**
088     * {@inheritDoc}
089     */
090    @Override
091    public Enum<?> getStartState()
092    {
093        return START_STATE;
094    }
095}