001 /* 002 * Copyright 2013-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021 package com.unboundid.ldap.sdk.unboundidds.extensions; 022 023 024 025 import com.unboundid.util.ThreadSafety; 026 import com.unboundid.util.ThreadSafetyLevel; 027 028 029 030 /** 031 * <BLOCKQUOTE> 032 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 033 * LDAP SDK for Java. It is not available for use in applications that 034 * include only the Standard Edition of the LDAP SDK, and is not supported for 035 * use in conjunction with non-UnboundID products. 036 * </BLOCKQUOTE> 037 * This enum defines the types of configurations that may be obtained using the 038 * get configuration extended operation. 039 */ 040 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 041 public enum GetConfigurationType 042 { 043 /** 044 * The type used to specify the current active configuration. 045 */ 046 ACTIVE(GetConfigurationType.ACTIVE_BER_TYPE, 0), 047 048 049 050 /** 051 * The type used to specify the baseline configuration for the current server 052 * version. 053 */ 054 BASELINE(GetConfigurationType.BASELINE_BER_TYPE, 1), 055 056 057 058 /** 059 * The type used to specify an archived configuration that was previously 060 * in effect. 061 */ 062 ARCHIVED(GetConfigurationType.ARCHIVED_BER_TYPE, 2); 063 064 065 066 /** 067 * The BER type used to designate the active type. 068 */ 069 static final byte ACTIVE_BER_TYPE = (byte) 0x80; 070 071 072 073 /** 074 * The BER type used to designate the baseline type. 075 */ 076 static final byte BASELINE_BER_TYPE = (byte) 0x81; 077 078 079 080 /** 081 * The BER type used to designate the archived type. 082 */ 083 static final byte ARCHIVED_BER_TYPE = (byte) 0x82; 084 085 086 087 // The BER type that should be used when this configuration type needs to be 088 // encoded in a get configuration request. 089 private final byte berType; 090 091 // The integer value that should be used when this configuration type needs to 092 // be encoded as an enumerated element in a get configuration result. 093 private final int intValue; 094 095 096 097 /** 098 * Creates a new get configuration type value with the specified information. 099 * 100 * @param berType The BER type that should be used when this configuration 101 * type needs to be encoded in a get configuration request. 102 * @param intValue The integer value that should be used when this 103 * configuration type needs to be encoded as an enumerated 104 * element in a get configuration result. 105 */ 106 private GetConfigurationType(final byte berType, final int intValue) 107 { 108 this.berType = berType; 109 this.intValue = intValue; 110 } 111 112 113 114 /** 115 * Retrieves the BER type that should be used when this configuration type 116 * needs to be encoded in a get configuration request. 117 * 118 * @return The BER type that should be used when this configuration type 119 * needs to be encoded in a get configuration request. 120 */ 121 public byte getBERType() 122 { 123 return berType; 124 } 125 126 127 128 /** 129 * Retrieves the integer value that should be used when this configuration 130 * type needs to be encoded as an enumerated element in a get configuration 131 * result. 132 * 133 * @return The integer value that should be used when this configuration 134 * type needs to be encoded as an enumerated element in a get 135 * configuration result. 136 */ 137 public int getIntValue() 138 { 139 return intValue; 140 } 141 142 143 144 /** 145 * Retrieves the get configuration type value that has the specified BER type. 146 * 147 * @param berType The BER type for the get configuration type value to 148 * retrieve. 149 * 150 * @return The get configuration type value for the specified BER type, or 151 * {@code null} if there is no enum value with the specified BER 152 * type. 153 */ 154 public static GetConfigurationType forBERType(final byte berType) 155 { 156 for (final GetConfigurationType t : values()) 157 { 158 if (t.berType == berType) 159 { 160 return t; 161 } 162 } 163 164 return null; 165 } 166 167 168 169 /** 170 * Retrieves the get configuration type value that has the specified integer 171 * value. 172 * 173 * @param intValue The integer value for the get configuration type value 174 * to retrieve. 175 * 176 * @return The get configuration type value for the specified integer value, 177 * or {@code null} if there is no enum value with the specified 178 * integer value. 179 */ 180 public static GetConfigurationType forIntValue(final int intValue) 181 { 182 for (final GetConfigurationType t : values()) 183 { 184 if (t.intValue == intValue) 185 { 186 return t; 187 } 188 } 189 190 return null; 191 } 192 }