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.syncInfoValue;
21  
22  
23  /**
24   * This class describes the four possible Info values :
25   * <ul>
26   * <li>newcookie</li>
27   * <li>refreshDelete</li>
28   * <li>refreshpresent</li>
29   * <li>syncIdSet</li>
30   * </ul>
31   * 
32   * @see <a href="http://www.faqs.org/rfcs/rfc4533.html">RFC 4533</a>
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   *
35   */
36  public enum SynchronizationInfoEnum
37  {
38      /** A new cookie */
39      NEW_COOKIE(0),
40      
41      /** The refresh delete phase */
42      REFRESH_DELETE(1),
43  
44      /** The refresh present phase */
45      REFRESH_PRESENT(2),
46      
47      /** The sync ID set */
48      SYNC_ID_SET(3);
49  
50      /** The internal value */
51      private int value;
52  
53  
54      /**
55       * Private constructor so no other instances can be created other than the
56       * public static constants in this class.
57       * 
58       * @param value the integer value of the enumeration.
59       */
60      SynchronizationInfoEnum( int value )
61      {
62          this.value = value;
63      }
64  
65  
66      /**
67       * @return The value associated with the current element.
68       */
69      public int getValue()
70      {
71          return value;
72      }
73  
74  
75      /**
76       * Get the {@link SynchronizationInfoEnum} instance from an integer value.
77       * 
78       * @param value The value we want the enum element from
79       * @return The enum element associated with this integer
80       */
81      public static SynchronizationInfoEnum getSyncMode( int value )
82      {
83          if ( value == NEW_COOKIE.getValue() )
84          {
85              return NEW_COOKIE;
86          }
87          else if ( value == REFRESH_DELETE.getValue() )
88          {
89              return REFRESH_DELETE;
90          }
91          else if ( value == REFRESH_PRESENT.getValue() )
92          {
93              return REFRESH_PRESENT;
94          }
95          else
96          {
97              return SYNC_ID_SET;
98          }
99      }
100 }