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.message.control.replication;
021
022 /**
023 * This class describes the four possible Info values :
024 * <ul>
025 * <li>newcookie</li>
026 * <li>refreshDelete</li>
027 * <li>refreshpresent</li>
028 * <li>syncIdSet</li>
029 * </ul>
030 *
031 * @see <a href="http://www.faqs.org/rfcs/rfc4533.html">RFC 4533</a>
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 * @version $Rev: $
034 *
035 */
036 public enum SynchronizationInfoEnum
037 {
038 NEW_COOKIE(0),
039 REFRESH_DELETE(1),
040 REFRESH_PRESENT(2),
041 SYNC_ID_SET(3);
042
043 /** The internal value */
044 private int value;
045
046
047 /**
048 * Private constructor so no other instances can be created other than the
049 * public static constants in this class.
050 *
051 * @param value the integer value of the enumeration.
052 */
053 private SynchronizationInfoEnum( int value )
054 {
055 this.value = value;
056 }
057
058
059 /**
060 * @return The value associated with the current element.
061 */
062 public int getValue()
063 {
064 return value;
065 }
066
067
068 /**
069 * Get the {@link SynchronizationInfoEnum} instance from an integer value.
070 *
071 * @param value The value we want the enum element from
072 * @return The enum element associated with this integer
073 */
074 public static SynchronizationInfoEnum getSyncMode( int value )
075 {
076 if ( value == NEW_COOKIE.getValue() )
077 {
078 return NEW_COOKIE;
079 }
080 else if ( value == REFRESH_DELETE.getValue() )
081 {
082 return REFRESH_DELETE;
083 }
084 else if ( value == REFRESH_PRESENT.getValue() )
085 {
086 return REFRESH_PRESENT;
087 }
088 else
089 {
090 return SYNC_ID_SET;
091 }
092 }
093 }