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.subentries; 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 SubEntryControl'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 SubentriesControlStatesEnum implements IStates 035 { 036 // ~ Static fields/initializers 037 // ----------------------------------------------------------------- 038 039 // ========================================================================= 040 // Sub entry control grammar states 041 // ========================================================================= 042 043 /** Starting state */ 044 public static final int START_STATE = 0; 045 046 /** Visibility Value */ 047 public static final int SUB_ENTRY_VISIBILITY_STATE = 1; 048 049 /** terminal state */ 050 public static final int LAST_SUB_ENTRY_STATE = 2; 051 052 // ========================================================================= 053 // States debug strings 054 // ========================================================================= 055 /** A string representation of all the states */ 056 private static String[] SubEntryString = new String[] 057 { 058 "START_STATE", 059 "SUB_ENTRY_VISIBILITY_STATE" 060 }; 061 062 /** The instance */ 063 private static SubentriesControlStatesEnum instance = new SubentriesControlStatesEnum(); 064 065 066 // ~ Constructors 067 // ------------------------------------------------------------------------------- 068 069 /** 070 * This is a private constructor. This class is a singleton 071 */ 072 private SubentriesControlStatesEnum() 073 { 074 } 075 076 077 // ~ Methods 078 // ------------------------------------------------------------------------------------ 079 080 /** 081 * Get an instance of this class 082 * 083 * @return An instance on this class 084 */ 085 public static IStates getInstance() 086 { 087 return instance; 088 } 089 090 091 /** 092 * Get the grammar name 093 * 094 * @param grammar The grammar code 095 * @return The grammar name 096 */ 097 public String getGrammarName( int grammar ) 098 { 099 return "SUB_ENTRY_GRAMMAR"; 100 } 101 102 103 /** 104 * Get the grammar name 105 * 106 * @param grammar The grammar class 107 * @return The grammar name 108 */ 109 public String getGrammarName( IGrammar grammar ) 110 { 111 if ( grammar instanceof SubentriesControlGrammar ) 112 { 113 return "SUB_ENTRY_GRAMMAR"; 114 } 115 116 return "UNKNOWN GRAMMAR"; 117 } 118 119 120 /** 121 * Get the string representing the state 122 * 123 * @param state The state number 124 * @return The String representing the state 125 */ 126 public String getState( int state ) 127 { 128 return ( ( state == GRAMMAR_END ) ? "SUB_ENTRY_END_STATE" : SubEntryString[state] ); 129 } 130 }