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