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.search.pagedSearch;
021
022
023import org.apache.directory.api.asn1.ber.grammar.States;
024
025
026/**
027 * This class store the PagedSearchControl's grammar constants. It is also used for
028 * debugging purposes.
029 * 
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public enum PagedResultsStates implements States
033{
034    // ~ Static fields/initializers
035    // -----------------------------------------------------------------
036
037    /** The END_STATE */
038    END_STATE,
039
040    // =========================================================================
041    // Paged search control grammar states
042    // =========================================================================
043    /** Initial state */
044    START_STATE,
045
046    /** Sequence Value */
047    PAGED_SEARCH_SEQUENCE_STATE,
048
049    /** Size Value */
050    SIZE_STATE,
051
052    /** Cookie Value */
053    COOKIE_STATE,
054
055    /** terminal state */
056    LAST_PAGED_SEARCH_STATE;
057
058    /**
059     * Get the grammar name
060     * 
061     * @return The grammar name
062     */
063    public String getGrammarName()
064    {
065        return "PAGED_SEARCH_GRAMMAR";
066    }
067
068
069    /**
070     * Get the string representing the state
071     * 
072     * @param state The state number
073     * @return The String representing the state
074     */
075    public String getState( int state )
076    {
077        return ( state == END_STATE.ordinal() ) ? "PAGED_SEARCH_END_STATE" : name();
078    }
079
080
081    /**
082     * {@inheritDoc}
083     */
084    @Override
085    public boolean isEndState()
086    {
087        return this == END_STATE;
088    }
089
090
091    /**
092     * {@inheritDoc}
093     */
094    @Override
095    public PagedResultsStates getStartState()
096    {
097        return START_STATE;
098    }
099}