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.extras.controls.syncrepl_impl;
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 SyncInfoValueControl'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 SyncInfoValueStatesEnum implements States
34  {
35      // ~ Static fields/initializers
36      // -----------------------------------------------------------------
37  
38      /** The END_STATE */
39      END_STATE,
40  
41      // =========================================================================
42      // SyncRequestValue control grammar states
43      // =========================================================================
44      /** Initial state */
45      START_STATE,
46  
47      /** NewCookie state */
48      NEW_COOKIE_STATE,
49  
50      /** RefreshDelete state */
51      REFRESH_DELETE_STATE,
52  
53      /** RefreshDelete cookie state */
54      REFRESH_DELETE_COOKIE_STATE,
55  
56      /** RefreshDelete refreshDone state */
57      REFRESH_DELETE_REFRESH_DONE_STATE,
58  
59      /** RefreshPresent state */
60      REFRESH_PRESENT_STATE,
61  
62      /** RefreshPresent cookie state */
63      REFRESH_PRESENT_COOKIE_STATE,
64  
65      /** RefreshPresent refreshDone state */
66      REFRESH_PRESENT_REFRESH_DONE_STATE,
67  
68      /** SyncIdSet state */
69      SYNC_ID_SET_STATE,
70  
71      /** SyncIdSet cookie state */
72      SYNC_ID_SET_COOKIE_STATE,
73  
74      /** SyncIdSet refreshDone state */
75      SYNC_ID_SET_REFRESH_DELETES_STATE,
76  
77      /** SyncIdSet SET OF UUIDs state */
78      SYNC_ID_SET_SET_OF_UUIDS_STATE,
79  
80      /** SyncIdSet UUID state */
81      SYNC_ID_SET_UUID_STATE,
82  
83      /** terminal state */
84      LAST_SYNC_INFO_VALUE_STATE;
85  
86      /**
87       * Get the grammar name
88       * 
89       * @param grammar The grammar code
90       * @return The grammar name
91       */
92      public String getGrammarName( int grammar )
93      {
94          return "SYNC_INFO_VALUE_GRAMMAR";
95      }
96  
97  
98      /**
99       * Get the grammar name
100      * 
101      * @param grammar The grammar class
102      * @return The grammar name
103      */
104     public String getGrammarName( Grammar<SyncInfoValueContainer> grammar )
105     {
106         if ( grammar instanceof SyncInfoValueGrammar )
107         {
108             return "SYNC_INFO_VALUE_GRAMMAR";
109         }
110 
111         return "UNKNOWN GRAMMAR";
112     }
113 
114 
115     /**
116      * Get the string representing the state
117      * 
118      * @param state The state number
119      * @return The String representing the state
120      */
121     public String getState( int state )
122     {
123         return ( ( state == END_STATE.ordinal() ) ? "SYNC_INFO_VALUE_END_STATE" : this.name() );
124     }
125 
126 
127     /**
128      * {@inheritDoc}
129      */
130     public boolean isEndState()
131     {
132         return this == END_STATE;
133     }
134 
135 
136     /**
137      * {@inheritDoc}
138      */
139     public SyncInfoValueStatesEnum getStartState()
140     {
141         return START_STATE;
142     }
143 }