View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.codec.controls.search.subentries;
21  
22  
23  import org.apache.directory.api.asn1.ber.grammar.Grammar;
24  import org.apache.directory.api.asn1.ber.grammar.States;
25  
26  
27  /**
28   * This class store the SubEntryControl's grammar constants. It is also used for
29   * debugging purposes.
30   * 
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public enum SubentriesStates implements States
34  {
35      // ~ Static fields/initializers
36      // -----------------------------------------------------------------
37  
38      /** The END_STATE */
39      END_STATE,
40  
41      // =========================================================================
42      // Sub entry control grammar states
43      // =========================================================================
44  
45      /** Starting state */
46      START_STATE,
47  
48      /** Visibility Value */
49      SUB_ENTRY_VISIBILITY_STATE,
50  
51      /** terminal state */
52      LAST_SUB_ENTRY_STATE;
53  
54      /**
55       * Get the grammar name
56       * 
57       * @param grammar The grammar code
58       * @return The grammar name
59       */
60      public String getGrammarName( int grammar )
61      {
62          return "SUB_ENTRY_GRAMMAR";
63      }
64  
65  
66      /**
67       * Get the grammar name
68       * 
69       * @param grammar The grammar class
70       * @return The grammar name
71       */
72      public String getGrammarName( Grammar<SubentriesContainer> grammar )
73      {
74          if ( grammar instanceof SubentriesGrammar )
75          {
76              return "SUB_ENTRY_GRAMMAR";
77          }
78  
79          return "UNKNOWN GRAMMAR";
80      }
81  
82  
83      /**
84       * Get the string representing the state
85       * 
86       * @param state The state number
87       * @return The String representing the state
88       */
89      public String getState( int state )
90      {
91          return ( ( state == END_STATE.ordinal() ) ? "SUB_ENTRY_END_STATE" : name() );
92      }
93  
94  
95      /**
96       * {@inheritDoc}
97       */
98      public boolean isEndState()
99      {
100         return this == END_STATE;
101     }
102 
103 
104     /**
105      * {@inheritDoc}
106      */
107     public SubentriesStates getStartState()
108     {
109         return START_STATE;
110     }
111 }