001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.types; 028 029 030 031 import org.opends.server.protocols.ldap.LDAPConstants; 032 033 034 035 /** 036 * This enumeration defines the set of behaviors that a search 037 * operation can exhibit whenever an alias is encountered. This is 038 * based on the LDAP specification defined in RFC 2251. 039 */ 040 @org.opends.server.types.PublicAPI( 041 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 042 mayInstantiate=false, 043 mayExtend=false, 044 mayInvoke=true) 045 public enum DereferencePolicy 046 { 047 /** 048 * The dereference policy that indicates that aliases should never 049 * be dereferenced when processing the search. 050 */ 051 NEVER_DEREF_ALIASES(LDAPConstants.DEREF_NEVER), 052 053 054 055 /** 056 * The dereference policy that indicates that any aliases found 057 * while looking for candidate entries should be dereferenced. 058 */ 059 DEREF_IN_SEARCHING(LDAPConstants.DEREF_IN_SEARCHING), 060 061 062 063 /** 064 * The dereference policy that indicates that if the entry specified 065 * as the base DN is an alias, it should be dereferenced. 066 */ 067 DEREF_FINDING_BASE_OBJECT(LDAPConstants.DEREF_FINDING_BASE), 068 069 070 071 /** 072 * The dereference policy that indicates that any dereferences 073 * encountered should be dereferenced. 074 */ 075 DEREF_ALWAYS(LDAPConstants.DEREF_ALWAYS); 076 077 078 079 // The integer value associated with this dereference policy. 080 private int intValue; 081 082 083 084 /** 085 * Creates a new dereference policy with the provided integer value. 086 * 087 * @param intValue The integer value for this dereference policy. 088 */ 089 private DereferencePolicy(int intValue) 090 { 091 this.intValue = intValue; 092 } 093 094 095 096 /** 097 * Retrieves the integer value associated with this search scope. 098 * 099 * @return The integer value associated with this search scope. 100 */ 101 public int intValue() 102 { 103 return intValue; 104 } 105 106 107 108 /** 109 * Retrieves a string representation of this alias dereferencing 110 * policy. 111 * 112 * @return A string representation of this alias dereferencing 113 * policy. 114 */ 115 public String toString() 116 { 117 switch (intValue) 118 { 119 case LDAPConstants.DEREF_NEVER: 120 return "neverDerefAliases"; 121 case LDAPConstants.DEREF_IN_SEARCHING: 122 return "derefInSearching"; 123 case LDAPConstants.DEREF_FINDING_BASE: 124 return "derefFidingBaseObj"; 125 case LDAPConstants.DEREF_ALWAYS: 126 return "derefAlways"; 127 default: 128 return "Unknown"; 129 } 130 } 131 } 132