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 possible scopes that may be 037 * used for a search request. This is based on the LDAP specification 038 * defined in RFC 2251 but also includes the subordinate subtree 039 * search scope defined in draft-sermersheim-ldap-subordinate-scope. 040 */ 041 @org.opends.server.types.PublicAPI( 042 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 043 mayInstantiate=false, 044 mayExtend=false, 045 mayInvoke=true) 046 public enum SearchScope 047 { 048 /** 049 * The search scope that indicates only the entry specified as the 050 * search base should be considered a candidate for matching. 051 */ 052 BASE_OBJECT(LDAPConstants.SCOPE_BASE_OBJECT), 053 054 055 056 /** 057 * The search scope that indicates only those entries that are 058 * immediate children of the entry specified as the search base (and 059 * not any of their descendants, and not the search base itself) 060 * should be considered candidates for matching. 061 */ 062 SINGLE_LEVEL(LDAPConstants.SCOPE_SINGLE_LEVEL), 063 064 065 066 /** 067 * The search scope that indicates the entry specified as the search 068 * base and all descendants (recursively) should be considered 069 * candidates for matching. 070 */ 071 WHOLE_SUBTREE(LDAPConstants.SCOPE_WHOLE_SUBTREE), 072 073 074 075 /** 076 * The search scope that indicates all descendants (recursively) 077 * below the entry specified as the search base (but not the search 078 * base entry itself) should be considered candidates for matching. 079 */ 080 SUBORDINATE_SUBTREE(LDAPConstants.SCOPE_SUBORDINATE_SUBTREE); 081 082 083 084 // The integer value associated with this search scope. 085 private int intValue; 086 087 088 089 /** 090 * Creates a new search scope with the provided integer value. 091 * 092 * @param intValue The integer value associated with this search 093 * scope. 094 */ 095 private SearchScope(int intValue) 096 { 097 this.intValue = intValue; 098 } 099 100 101 102 /** 103 * Retrieves the integer value associated with this search scope. 104 * 105 * @return The integer value associated with this search scope. 106 */ 107 public int intValue() 108 { 109 return intValue; 110 } 111 112 113 114 /** 115 * Retrieves a string representation of this search scope. 116 * 117 * @return A string representation of this search scope. 118 */ 119 public String toString() 120 { 121 switch (intValue) 122 { 123 case LDAPConstants.SCOPE_BASE_OBJECT: 124 return "baseObject"; 125 case LDAPConstants.SCOPE_SINGLE_LEVEL: 126 return "singleLevel"; 127 case LDAPConstants.SCOPE_WHOLE_SUBTREE: 128 return "wholeSubtree"; 129 case LDAPConstants.SCOPE_SUBORDINATE_SUBTREE: 130 return "subordinateSubtree"; 131 default: 132 return "Unknown"; 133 } 134 } 135 } 136