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 package org.apache.directory.shared.ldap.codec.search.controls.persistentSearch; 021 022 023 import org.apache.directory.shared.asn1.ber.grammar.IGrammar; 024 import org.apache.directory.shared.asn1.ber.grammar.IStates; 025 026 027 /** 028 * This class store the PSearchControl's grammar constants. It is also used for 029 * debugging purposes. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 * @version $Rev: 905297 $, $Date: 2010-02-01 16:04:10 +0100 (Mon, 01 Feb 2010) $, 033 */ 034 public class PersistentSearchControlStatesEnum implements IStates 035 { 036 // ~ Static fields/initializers 037 // ----------------------------------------------------------------- 038 039 // ========================================================================= 040 // Persistent search control grammar states 041 // ========================================================================= 042 /** Initial state */ 043 public static final int START_STATE = 0; 044 045 /** Sequence Value */ 046 public static final int PSEARCH_SEQUENCE_STATE = 1; 047 048 /** changeTypes Value */ 049 public static final int CHANGE_TYPES_STATE = 2; 050 051 /** changesOnly Value */ 052 public static final int CHANGES_ONLY_STATE = 3; 053 054 /** returnECs Value */ 055 public static final int RETURN_ECS_STATE = 4; 056 057 /** terminal state */ 058 public static final int LAST_PSEARCH_STATE = 5; 059 060 // ========================================================================= 061 // States debug strings 062 // ========================================================================= 063 /** A string representation of all the states */ 064 private static String[] PSearchString = new String[] 065 { 066 "START_STATE", 067 "PSEARCH_SEQUENCE_VALUE", 068 "CHANGE_TYPES_STATE", 069 "CHANGES_ONLY_STATE", 070 "RETURN_ECS_STATE" 071 }; 072 073 /** The instance */ 074 private static PersistentSearchControlStatesEnum instance = new PersistentSearchControlStatesEnum(); 075 076 077 // ~ Constructors 078 // ------------------------------------------------------------------------------- 079 080 /** 081 * This is a private constructor. This class is a singleton 082 */ 083 private PersistentSearchControlStatesEnum() 084 { 085 } 086 087 088 // ~ Methods 089 // ------------------------------------------------------------------------------------ 090 091 /** 092 * Get an instance of this class 093 * 094 * @return An instance on this class 095 */ 096 public static IStates getInstance() 097 { 098 return instance; 099 } 100 101 102 /** 103 * Get the grammar name 104 * 105 * @param grammar The grammar code 106 * @return The grammar name 107 */ 108 public String getGrammarName( int grammar ) 109 { 110 return "PSEARCH_GRAMMAR"; 111 } 112 113 114 /** 115 * Get the grammar name 116 * 117 * @param grammar The grammar class 118 * @return The grammar name 119 */ 120 public String getGrammarName( IGrammar grammar ) 121 { 122 if ( grammar instanceof PersistentSearchControlGrammar ) 123 { 124 return "PSEARCH_GRAMMAR"; 125 } 126 127 return "UNKNOWN GRAMMAR"; 128 } 129 130 131 /** 132 * Get the string representing the state 133 * 134 * @param state The state number 135 * @return The String representing the state 136 */ 137 public String getState( int state ) 138 { 139 return ( ( state == GRAMMAR_END ) ? "PSEARCH_END_STATE" : PSearchString[state] ); 140 } 141 }