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 NEW_COOKIE(0), 39 REFRESH_DELETE(1), 40 REFRESH_PRESENT(2), 41 SYNC_ID_SET(3); 42 43 /** The internal value */ 44 private int value; 45 46 47 /** 48 * Private constructor so no other instances can be created other than the 49 * public static constants in this class. 50 * 51 * @param value the integer value of the enumeration. 52 */ 53 private SynchronizationInfoEnum( int value ) 54 { 55 this.value = value; 56 } 57 58 59 /** 60 * @return The value associated with the current element. 61 */ 62 public int getValue() 63 { 64 return value; 65 } 66 67 68 /** 69 * Get the {@link SynchronizationInfoEnum} instance from an integer value. 70 * 71 * @param value The value we want the enum element from 72 * @return The enum element associated with this integer 73 */ 74 public static SynchronizationInfoEnum getSyncMode( int value ) 75 { 76 if ( value == NEW_COOKIE.getValue() ) 77 { 78 return NEW_COOKIE; 79 } 80 else if ( value == REFRESH_DELETE.getValue() ) 81 { 82 return REFRESH_DELETE; 83 } 84 else if ( value == REFRESH_PRESENT.getValue() ) 85 { 86 return REFRESH_PRESENT; 87 } 88 else 89 { 90 return SYNC_ID_SET; 91 } 92 } 93 }