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 */
020
021package org.apache.directory.api.ldap.extras.controls.vlv_impl;
022
023
024import org.apache.directory.api.asn1.ber.grammar.Grammar;
025import org.apache.directory.api.asn1.ber.grammar.States;
026
027
028/**
029 * This class store the VirtualListViewRequest grammar constants. It is also used for
030 * debugging purposes.
031 *
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 */
034public enum VirtualListViewRequestStates implements States
035{
036    START_STATE,
037    VLV_SEQUENCE_STATE,
038    VLV_BEFORE_COUNT_STATE,
039    VLV_AFTER_COUNT_STATE,
040    VLV_TARGET_BY_OFFSET_STATE,
041    VLV_OFFSET_STATE,
042    VLV_CONTENT_COUNT_STATE,
043    VLV_CONTEXT_ID_STATE,
044    VLV_ASSERTION_VALUE_STATE,
045    END_STATE;
046
047    public String getGrammarName( int grammar )
048    {
049        return "VLV_REQUEST_GRAMMAR";
050    }
051
052
053    public String getGrammarName( Grammar<?> grammar )
054    {
055        if ( grammar instanceof VirtualListViewRequestGrammar )
056        {
057            return "VLV_REQUEST_GRAMMAR";
058        }
059
060        return "UNKNOWN GRAMMAR";
061    }
062
063
064    public String getState( int state )
065    {
066        return ( ( state == END_STATE.ordinal() ) ? "VLV_REQUEST_END_STATE" : name() );
067    }
068
069
070    @Override
071    public boolean isEndState()
072    {
073        return this == END_STATE;
074    }
075
076
077    @Override
078    public Enum<?> getStartState()
079    {
080        return START_STATE;
081    }
082}