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.Grammar; 024import org.apache.directory.api.asn1.ber.grammar.States; 025 026 027/** 028 * Enumeration of states encountered while decoding a SortResponseControl. 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public enum SortResponseStates implements States 033{ 034 START_STATE, 035 036 SEQUENCE_STATE, 037 038 RESULT_CODE_STATE, 039 040 AT_DESC_STATE, 041 042 END_STATE; 043 044 /** 045 * Get the grammar name 046 * 047 * @param grammar The grammar code 048 * @return The grammar name 049 */ 050 public String getGrammarName( int grammar ) 051 { 052 return "SORT_RESPONSE_GRAMMAR"; 053 } 054 055 056 /** 057 * Get the grammar name 058 * 059 * @param grammar The grammar class 060 * @return The grammar name 061 */ 062 public String getGrammarName( Grammar<?> grammar ) 063 { 064 if ( grammar instanceof SortResponseGrammar ) 065 { 066 return "SORT_RESPONSE_GRAMMAR"; 067 } 068 069 return "UNKNOWN GRAMMAR"; 070 } 071 072 073 /** 074 * Get the string representing the state 075 * 076 * @param state The state number 077 * @return The String representing the state 078 */ 079 public String getState( int state ) 080 { 081 return ( ( state == END_STATE.ordinal() ) ? "SORT_REQUEST_END_STATE" : name() ); 082 } 083 084 085 @Override 086 public boolean isEndState() 087 { 088 return ( this == END_STATE ); 089 } 090 091 092 @Override 093 public Enum<?> getStartState() 094 { 095 return START_STATE; 096 } 097 098}