Path: blob/master/src/java.naming/share/classes/javax/naming/directory/DirContext.java
41159 views
/*1* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming.directory;2627import javax.naming.*;2829/**30* The directory service interface, containing31* methods for examining and updating attributes32* associated with objects, and for searching the directory.33*34* <h2>Names</h2>35* Each name passed as an argument to a {@code DirContext} method is relative36* to that context. The empty name is used to name the context itself.37* The name parameter may never be null.38* <p>39* Most of the methods have overloaded versions with one taking a40* <code>Name</code> parameter and one taking a <code>String</code>.41* These overloaded versions are equivalent in that if42* the <code>Name</code> and <code>String</code> parameters are just43* different representations of the same name, then the overloaded44* versions of the same methods behave the same.45* In the method descriptions below, only one version is documented.46* The second version instead has a link to the first: the same47* documentation applies to both.48* <p>49* See {@code Context} for a discussion on the interpretation of the50* name argument to the {@code Context} methods. These same rules51* apply to the name argument to the {@code DirContext} methods.52*53* <h2>Attribute Models</h2>54* There are two basic models of what attributes should be55* associated with. First, attributes may be directly associated with a56* DirContext object.57* In this model, an attribute operation on the named object is58* roughly equivalent59* to a lookup on the name (which returns the DirContext object),60* followed by the attribute operation invoked on the DirContext object61* in which the caller supplies an empty name. The attributes can be viewed62* as being stored along with the object (note that this does not imply that63* the implementation must do so).64* <p>65* The second model is that attributes are associated with a66* name (typically an atomic name) in a DirContext.67* In this model, an attribute operation on the named object is68* roughly equivalent to a lookup on the name of the parent DirContext of the69* named object, followed by the attribute operation invoked on the parent70* in which the caller supplies the terminal atomic name.71* The attributes can be viewed as being stored in the parent DirContext72* (again, this does not imply that the implementation must do so).73* Objects that are not DirContexts can have attributes, as long as74* their parents are DirContexts.75* <p>76* JNDI support both of these models.77* It is up to the individual service providers to decide where to78* "store" attributes.79* JNDI clients are safest when they do not make assumptions about80* whether an object's attributes are stored as part of the object, or stored81* within the parent object and associated with the object's name.82*83* <h2>Attribute Type Names</h2>84* In the {@code getAttributes()} and {@code search()} methods,85* you can supply the attributes to return by supplying a list of86* attribute names (strings).87* The attributes that you get back might not have the same names as the88* attribute names you have specified. This is because some directories89* support features that cause them to return other attributes. Such90* features include attribute subclassing, attribute name synonyms, and91* attribute language codes.92* <p>93* In attribute subclassing, attributes are defined in a class hierarchy.94* In some directories, for example, the "name" attribute might be the95* superclass of all name-related attributes, including "commonName" and96* "surName". Asking for the "name" attribute might return both the97* "commonName" and "surName" attributes.98* <p>99* With attribute type synonyms, a directory can assign multiple names to100* the same attribute. For example, "cn" and "commonName" might both101* refer to the same attribute. Asking for "cn" might return the102* "commonName" attribute.103* <p>104* Some directories support the language codes for attributes.105* Asking such a directory for the "description" attribute, for example,106* might return all of the following attributes:107* <ul>108* <li>description109* <li>description;lang-en110* <li>description;lang-de111* <li>description;lang-fr112* </ul>113*114*115*<h2>Operational Attributes</h2>116*<p>117* Some directories have the notion of "operational attributes" which are118* attributes associated with a directory object for administrative119* purposes. An example of operational attributes is the access control120* list for an object.121* <p>122* In the {@code getAttributes()} and {@code search()} methods,123* you can specify that all attributes associated with the requested objects124* be returned by supply {@code null} as the list of attributes to return.125* The attributes returned do <em>not</em> include operational attributes.126* In order to retrieve operational attributes, you must name them explicitly.127*128*129* <h2>Named Context</h2>130* <p>131* There are certain methods in which the name must resolve to a context132* (for example, when searching a single level context). The documentation133* of such methods134* use the term <em>named context</em> to describe their name parameter.135* For these methods, if the named object is not a DirContext,136* <code>NotContextException</code> is thrown.137* Aside from these methods, there is no requirement that the138* <em>named object</em> be a DirContext.139*140*<h2>Parameters</h2>141*<p>142* An {@code Attributes}, {@code SearchControls}, or array object143* passed as a parameter to any method will not be modified by the144* service provider. The service provider may keep a reference to it145* for the duration of the operation, including any enumeration of the146* method's results and the processing of any referrals generated.147* The caller should not modify the object during this time.148* An {@code Attributes} object returned by any method is owned by149* the caller. The caller may subsequently modify it; the service150* provider will not.151*152*<h2>Exceptions</h2>153*<p>154* All the methods in this interface can throw a NamingException or155* any of its subclasses. See NamingException and their subclasses156* for details on each exception.157*158* @author Rosanna Lee159* @author Scott Seligman160* @author R. Vasudevan161*162* @see javax.naming.Context163* @since 1.3164*/165166public interface DirContext extends Context {167168/**169* Retrieves all of the attributes associated with a named object.170* See the class description regarding attribute models, attribute171* type names, and operational attributes.172*173* @param name174* the name of the object from which to retrieve attributes175* @return the set of attributes associated with <code>name</code>.176* Returns an empty attribute set if name has no attributes;177* never null.178* @throws NamingException if a naming exception is encountered179*180* @see #getAttributes(String)181* @see #getAttributes(Name, String[])182*/183public Attributes getAttributes(Name name) throws NamingException;184185/**186* Retrieves all of the attributes associated with a named object.187* See {@link #getAttributes(Name)} for details.188*189* @param name190* the name of the object from which to retrieve attributes191* @return the set of attributes associated with <code>name</code>192*193* @throws NamingException if a naming exception is encountered194*/195public Attributes getAttributes(String name) throws NamingException;196197/**198* Retrieves selected attributes associated with a named object.199* See the class description regarding attribute models, attribute200* type names, and operational attributes.201*202* <p> If the object does not have an attribute203* specified, the directory will ignore the nonexistent attribute204* and return those requested attributes that the object does have.205*206* <p> A directory might return more attributes than was requested207* (see <strong>Attribute Type Names</strong> in the class description),208* but is not allowed to return arbitrary, unrelated attributes.209*210* <p> See also <strong>Operational Attributes</strong> in the class211* description.212*213* @param name214* the name of the object from which to retrieve attributes215* @param attrIds216* the identifiers of the attributes to retrieve.217* null indicates that all attributes should be retrieved;218* an empty array indicates that none should be retrieved.219* @return the requested attributes; never null220*221* @throws NamingException if a naming exception is encountered222*/223public Attributes getAttributes(Name name, String[] attrIds)224throws NamingException;225226/**227* Retrieves selected attributes associated with a named object.228* See {@link #getAttributes(Name, String[])} for details.229*230* @param name231* The name of the object from which to retrieve attributes232* @param attrIds233* the identifiers of the attributes to retrieve.234* null indicates that all attributes should be retrieved;235* an empty array indicates that none should be retrieved.236* @return the requested attributes; never null237*238* @throws NamingException if a naming exception is encountered239*/240public Attributes getAttributes(String name, String[] attrIds)241throws NamingException;242243/**244* This constant specifies to add an attribute with the specified values.245* <p>246* If attribute does not exist,247* create the attribute. The resulting attribute has a union of the248* specified value set and the prior value set.249* Adding an attribute with no value will throw250* <code>InvalidAttributeValueException</code> if the attribute must have251* at least one value. For a single-valued attribute where that attribute252* already exists, throws <code>AttributeInUseException</code>.253* If attempting to add more than one value to a single-valued attribute,254* throws <code>InvalidAttributeValueException</code>.255* <p>256* The value of this constant is {@code 1}.257*258* @see ModificationItem259* @see #modifyAttributes260*/261public static final int ADD_ATTRIBUTE = 1;262263/**264* This constant specifies to replace an attribute with specified values.265*<p>266* If attribute already exists,267* replaces all existing values with new specified values. If the268* attribute does not exist, creates it. If no value is specified,269* deletes all the values of the attribute.270* Removal of the last value will remove the attribute if the attribute271* is required to have at least one value. If272* attempting to add more than one value to a single-valued attribute,273* throws <code>InvalidAttributeValueException</code>.274* <p>275* The value of this constant is {@code 2}.276*277* @see ModificationItem278* @see #modifyAttributes279*/280public static final int REPLACE_ATTRIBUTE = 2;281282/**283* This constant specifies to delete284* the specified attribute values from the attribute.285*<p>286* The resulting attribute has the set difference of its prior value set287* and the specified value set.288* If no values are specified, deletes the entire attribute.289* If the attribute does not exist, or if some or all members of the290* specified value set do not exist, this absence may be ignored291* and the operation succeeds, or a NamingException may be thrown to292* indicate the absence.293* Removal of the last value will remove the attribute if the294* attribute is required to have at least one value.295* <p>296* The value of this constant is {@code 3}.297*298* @see ModificationItem299* @see #modifyAttributes300*/301public static final int REMOVE_ATTRIBUTE = 3;302303/**304* Modifies the attributes associated with a named object.305* The order of the modifications is not specified. Where306* possible, the modifications are performed atomically.307*308* @param name309* the name of the object whose attributes will be updated310* @param mod_op311* the modification operation, one of:312* <code>ADD_ATTRIBUTE</code>,313* <code>REPLACE_ATTRIBUTE</code>,314* <code>REMOVE_ATTRIBUTE</code>.315* @param attrs316* the attributes to be used for the modification; may not be null317*318* @throws AttributeModificationException if the modification cannot319* be completed successfully320* @throws NamingException if a naming exception is encountered321*322* @see #modifyAttributes(Name, ModificationItem[])323*/324public void modifyAttributes(Name name, int mod_op, Attributes attrs)325throws NamingException;326327/**328* Modifies the attributes associated with a named object.329* See {@link #modifyAttributes(Name, int, Attributes)} for details.330*331* @param name332* the name of the object whose attributes will be updated333* @param mod_op334* the modification operation, one of:335* <code>ADD_ATTRIBUTE</code>,336* <code>REPLACE_ATTRIBUTE</code>,337* <code>REMOVE_ATTRIBUTE</code>.338* @param attrs339* the attributes to be used for the modification; may not be null340*341* @throws AttributeModificationException if the modification cannot342* be completed successfully343* @throws NamingException if a naming exception is encountered344*/345public void modifyAttributes(String name, int mod_op, Attributes attrs)346throws NamingException;347348/**349* Modifies the attributes associated with a named object using350* an ordered list of modifications.351* The modifications are performed352* in the order specified. Each modification specifies a353* modification operation code and an attribute on which to354* operate. Where possible, the modifications are355* performed atomically.356*357* @param name358* the name of the object whose attributes will be updated359* @param mods360* an ordered sequence of modifications to be performed;361* may not be null362*363* @throws AttributeModificationException if the modifications364* cannot be completed successfully365* @throws NamingException if a naming exception is encountered366*367* @see #modifyAttributes(Name, int, Attributes)368* @see ModificationItem369*/370public void modifyAttributes(Name name, ModificationItem[] mods)371throws NamingException;372373/**374* Modifies the attributes associated with a named object using375* an ordered list of modifications.376* See {@link #modifyAttributes(Name, ModificationItem[])} for details.377*378* @param name379* the name of the object whose attributes will be updated380* @param mods381* an ordered sequence of modifications to be performed;382* may not be null383*384* @throws AttributeModificationException if the modifications385* cannot be completed successfully386* @throws NamingException if a naming exception is encountered387*/388public void modifyAttributes(String name, ModificationItem[] mods)389throws NamingException;390391/**392* Binds a name to an object, along with associated attributes.393* If {@code attrs} is null, the resulting binding will have394* the attributes associated with {@code obj} if {@code obj} is a395* {@code DirContext}, and no attributes otherwise.396* If {@code attrs} is non-null, the resulting binding will have397* {@code attrs} as its attributes; any attributes associated with398* {@code obj} are ignored.399*400* @param name401* the name to bind; may not be empty402* @param obj403* the object to bind; possibly null404* @param attrs405* the attributes to associate with the binding406*407* @throws NameAlreadyBoundException if name is already bound408* @throws InvalidAttributesException if some "mandatory" attributes409* of the binding are not supplied410* @throws NamingException if a naming exception is encountered411*412* @see Context#bind(Name, Object)413* @see #rebind(Name, Object, Attributes)414*/415public void bind(Name name, Object obj, Attributes attrs)416throws NamingException;417418/**419* Binds a name to an object, along with associated attributes.420* See {@link #bind(Name, Object, Attributes)} for details.421*422* @param name423* the name to bind; may not be empty424* @param obj425* the object to bind; possibly null426* @param attrs427* the attributes to associate with the binding428*429* @throws NameAlreadyBoundException if name is already bound430* @throws InvalidAttributesException if some "mandatory" attributes431* of the binding are not supplied432* @throws NamingException if a naming exception is encountered433*/434public void bind(String name, Object obj, Attributes attrs)435throws NamingException;436437/**438* Binds a name to an object, along with associated attributes,439* overwriting any existing binding.440* If {@code attrs} is null and {@code obj} is a {@code DirContext},441* the attributes from {@code obj} are used.442* If {@code attrs} is null and {@code obj} is not a {@code DirContext},443* any existing attributes associated with the object already bound444* in the directory remain unchanged.445* If {@code attrs} is non-null, any existing attributes associated with446* the object already bound in the directory are removed and {@code attrs}447* is associated with the named object. If {@code obj} is a448* {@code DirContext} and {@code attrs} is non-null, the attributes449* of {@code obj} are ignored.450*451* @param name452* the name to bind; may not be empty453* @param obj454* the object to bind; possibly null455* @param attrs456* the attributes to associate with the binding457*458* @throws InvalidAttributesException if some "mandatory" attributes459* of the binding are not supplied460* @throws NamingException if a naming exception is encountered461*462* @see Context#bind(Name, Object)463* @see #bind(Name, Object, Attributes)464*/465public void rebind(Name name, Object obj, Attributes attrs)466throws NamingException;467468/**469* Binds a name to an object, along with associated attributes,470* overwriting any existing binding.471* See {@link #rebind(Name, Object, Attributes)} for details.472*473* @param name474* the name to bind; may not be empty475* @param obj476* the object to bind; possibly null477* @param attrs478* the attributes to associate with the binding479*480* @throws InvalidAttributesException if some "mandatory" attributes481* of the binding are not supplied482* @throws NamingException if a naming exception is encountered483*/484public void rebind(String name, Object obj, Attributes attrs)485throws NamingException;486487/**488* Creates and binds a new context, along with associated attributes.489* This method creates a new subcontext with the given name, binds it in490* the target context (that named by all but terminal atomic491* component of the name), and associates the supplied attributes492* with the newly created object.493* All intermediate and target contexts must already exist.494* If {@code attrs} is null, this method is equivalent to495* {@code Context.createSubcontext()}.496*497* @param name498* the name of the context to create; may not be empty499* @param attrs500* the attributes to associate with the newly created context501* @return the newly created context502*503* @throws NameAlreadyBoundException if the name is already bound504* @throws InvalidAttributesException if <code>attrs</code> does not505* contain all the mandatory attributes required for creation506* @throws NamingException if a naming exception is encountered507*508* @see Context#createSubcontext(Name)509*/510public DirContext createSubcontext(Name name, Attributes attrs)511throws NamingException;512513/**514* Creates and binds a new context, along with associated attributes.515* See {@link #createSubcontext(Name, Attributes)} for details.516*517* @param name518* the name of the context to create; may not be empty519* @param attrs520* the attributes to associate with the newly created context521* @return the newly created context522*523* @throws NameAlreadyBoundException if the name is already bound524* @throws InvalidAttributesException if <code>attrs</code> does not525* contain all the mandatory attributes required for creation526* @throws NamingException if a naming exception is encountered527*/528public DirContext createSubcontext(String name, Attributes attrs)529throws NamingException;530531// -------------------- schema operations532533/**534* Retrieves the schema associated with the named object.535* The schema describes rules regarding the structure of the namespace536* and the attributes stored within it. The schema537* specifies what types of objects can be added to the directory and where538* they can be added; what mandatory and optional attributes an object539* can have. The range of support for schemas is directory-specific.540*541* <p> This method returns the root of the schema information tree542* that is applicable to the named object. Several named objects543* (or even an entire directory) might share the same schema.544*545* <p> Issues such as structure and contents of the schema tree,546* permission to modify to the contents of the schema547* tree, and the effect of such modifications on the directory548* are dependent on the underlying directory.549*550* @param name551* the name of the object whose schema is to be retrieved552* @return the schema associated with the context; never null553* @throws OperationNotSupportedException if schema not supported554* @throws NamingException if a naming exception is encountered555*/556public DirContext getSchema(Name name) throws NamingException;557558/**559* Retrieves the schema associated with the named object.560* See {@link #getSchema(Name)} for details.561*562* @param name563* the name of the object whose schema is to be retrieved564* @return the schema associated with the context; never null565* @throws OperationNotSupportedException if schema not supported566* @throws NamingException if a naming exception is encountered567*/568public DirContext getSchema(String name) throws NamingException;569570/**571* Retrieves a context containing the schema objects of the572* named object's class definitions.573*<p>574* One category of information found in directory schemas is575* <em>class definitions</em>. An "object class" definition576* specifies the object's <em>type</em> and what attributes (mandatory577* and optional) the object must/can have. Note that the term578* "object class" being referred to here is in the directory sense579* rather than in the Java sense.580* For example, if the named object is a directory object of581* "Person" class, {@code getSchemaClassDefinition()} would return a582* {@code DirContext} representing the (directory's) object class583* definition of "Person".584*<p>585* The information that can be retrieved from an object class definition586* is directory-dependent.587*<p>588* Prior to JNDI 1.2, this method589* returned a single schema object representing the class definition of590* the named object.591* Since JNDI 1.2, this method returns a {@code DirContext} containing592* all of the named object's class definitions.593*594* @param name595* the name of the object whose object class596* definition is to be retrieved597* @return the {@code DirContext} containing the named598* object's class definitions; never null599*600* @throws OperationNotSupportedException if schema not supported601* @throws NamingException if a naming exception is encountered602*/603public DirContext getSchemaClassDefinition(Name name)604throws NamingException;605606/**607* Retrieves a context containing the schema objects of the608* named object's class definitions.609* See {@link #getSchemaClassDefinition(Name)} for details.610*611* @param name612* the name of the object whose object class613* definition is to be retrieved614* @return the {@code DirContext} containing the named615* object's class definitions; never null616*617* @throws OperationNotSupportedException if schema not supported618* @throws NamingException if a naming exception is encountered619*/620public DirContext getSchemaClassDefinition(String name)621throws NamingException;622623// -------------------- search operations624625/**626* Searches in a single context for objects that contain a627* specified set of attributes, and retrieves selected attributes.628* The search is performed using the default629* <code>SearchControls</code> settings.630* <p>631* For an object to be selected, each attribute in632* <code>matchingAttributes</code> must match some attribute of the633* object. If <code>matchingAttributes</code> is empty or634* null, all objects in the target context are returned.635*<p>636* An attribute <em>A</em><sub>1</sub> in637* <code>matchingAttributes</code> is considered to match an638* attribute <em>A</em><sub>2</sub> of an object if639* <em>A</em><sub>1</sub> and <em>A</em><sub>2</sub> have the same640* identifier, and each value of <em>A</em><sub>1</sub> is equal641* to some value of <em>A</em><sub>2</sub>. This implies that the642* order of values is not significant, and that643* <em>A</em><sub>2</sub> may contain "extra" values not found in644* <em>A</em><sub>1</sub> without affecting the comparison. It645* also implies that if <em>A</em><sub>1</sub> has no values, then646* testing for a match is equivalent to testing for the presence647* of an attribute <em>A</em><sub>2</sub> with the same648* identifier.649*<p>650* The precise definition of "equality" used in comparing attribute values651* is defined by the underlying directory service. It might use the652* <code>Object.equals</code> method, for example, or might use a schema653* to specify a different equality operation.654* For matching based on operations other than equality (such as655* substring comparison) use the version of the <code>search</code>656* method that takes a filter argument.657* <p>658* When changes are made to this {@code DirContext},659* the effect on enumerations returned by prior calls to this method660* is undefined.661*<p>662* If the object does not have the attribute663* specified, the directory will ignore the nonexistent attribute664* and return the requested attributes that the object does have.665*<p>666* A directory might return more attributes than was requested667* (see <strong>Attribute Type Names</strong> in the class description),668* but is not allowed to return arbitrary, unrelated attributes.669*<p>670* See also <strong>Operational Attributes</strong> in the class671* description.672*673* @param name674* the name of the context to search675* @param matchingAttributes676* the attributes to search for. If empty or null,677* all objects in the target context are returned.678* @param attributesToReturn679* the attributes to return. null indicates that680* all attributes are to be returned;681* an empty array indicates that none are to be returned.682* @return683* a non-null enumeration of {@code SearchResult} objects.684* Each {@code SearchResult} contains the attributes685* identified by <code>attributesToReturn</code>686* and the name of the corresponding object, named relative687* to the context named by <code>name</code>.688* @throws NamingException if a naming exception is encountered689*690* @see SearchControls691* @see SearchResult692* @see #search(Name, String, Object[], SearchControls)693*/694public NamingEnumeration<SearchResult>695search(Name name,696Attributes matchingAttributes,697String[] attributesToReturn)698throws NamingException;699700/**701* Searches in a single context for objects that contain a702* specified set of attributes, and retrieves selected attributes.703* See {@link #search(Name, Attributes, String[])} for details.704*705* @param name706* the name of the context to search707* @param matchingAttributes708* the attributes to search for709* @param attributesToReturn710* the attributes to return711* @return a non-null enumeration of {@code SearchResult} objects712* @throws NamingException if a naming exception is encountered713*/714public NamingEnumeration<SearchResult>715search(String name,716Attributes matchingAttributes,717String[] attributesToReturn)718throws NamingException;719720/**721* Searches in a single context for objects that contain a722* specified set of attributes.723* This method returns all the attributes of such objects.724* It is equivalent to supplying null as725* the {@code attributesToReturn} parameter to the method726* <code>search(Name, Attributes, String[])</code>.727* <br>728* See {@link #search(Name, Attributes, String[])} for a full description.729*730* @param name731* the name of the context to search732* @param matchingAttributes733* the attributes to search for734* @return an enumeration of {@code SearchResult} objects735* @throws NamingException if a naming exception is encountered736*737* @see #search(Name, Attributes, String[])738*/739public NamingEnumeration<SearchResult>740search(Name name, Attributes matchingAttributes)741throws NamingException;742743/**744* Searches in a single context for objects that contain a745* specified set of attributes.746* See {@link #search(Name, Attributes)} for details.747*748* @param name749* the name of the context to search750* @param matchingAttributes751* the attributes to search for752* @return an enumeration of {@code SearchResult} objects753* @throws NamingException if a naming exception is encountered754*/755public NamingEnumeration<SearchResult>756search(String name, Attributes matchingAttributes)757throws NamingException;758759/**760* Searches in the named context or object for entries that satisfy the761* given search filter. Performs the search as specified by762* the search controls.763* <p>764* The format and interpretation of <code>filter</code> follows RFC 2254765* with the766* following interpretations for <code>attr</code> and <code>value</code>767* mentioned in the RFC.768* <p>769* <code>attr</code> is the attribute's identifier.770* <p>771* <code>value</code> is the string representation the attribute's value.772* The translation of this string representation into the attribute's value773* is directory-specific.774* <p>775* For the assertion "someCount=127", for example, <code>attr</code>776* is "someCount" and <code>value</code> is "127".777* The provider determines, based on the attribute ID ("someCount")778* (and possibly its schema), that the attribute's value is an integer.779* It then parses the string "127" appropriately.780*<p>781* Any non-ASCII characters in the filter string should be782* represented by the appropriate Java (Unicode) characters, and783* not encoded as UTF-8 octets. Alternately, the784* "backslash-hexcode" notation described in RFC 2254 may be used.785*<p>786* If the directory does not support a string representation of787* some or all of its attributes, the form of <code>search</code> that788* accepts filter arguments in the form of Objects can be used instead.789* The service provider for such a directory would then translate790* the filter arguments to its service-specific representation791* for filter evaluation.792* See <code>search(Name, String, Object[], SearchControls)</code>.793* <p>794* RFC 2254 defines certain operators for the filter, including substring795* matches, equality, approximate match, greater than, less than. These796* operators are mapped to operators with corresponding semantics in the797* underlying directory. For example, for the equals operator, suppose798* the directory has a matching rule defining "equality" of the799* attributes in the filter. This rule would be used for checking800* equality of the attributes specified in the filter with the attributes801* of objects in the directory. Similarly, if the directory has a802* matching rule for ordering, this rule would be used for803* making "greater than" and "less than" comparisons.804*<p>805* Not all of the operators defined in RFC 2254 are applicable to all806* attributes. When an operator is not applicable, the exception807* <code>InvalidSearchFilterException</code> is thrown.808* <p>809* The result is returned in an enumeration of {@code SearchResult}s.810* Each {@code SearchResult} contains the name of the object811* and other information about the object (see SearchResult).812* The name is either relative to the target context of the search813* (which is named by the <code>name</code> parameter), or814* it is a URL string. If the target context is included in815* the enumeration (as is possible when816* <code>cons</code> specifies a search scope of817* <code>SearchControls.OBJECT_SCOPE</code> or818* <code>SearchControls.SUBSTREE_SCOPE</code>), its name is the empty819* string. The {@code SearchResult} may also contain attributes of the820* matching object if the {@code cons} argument specified that attributes821* be returned.822*<p>823* If the object does not have a requested attribute, that824* nonexistent attribute will be ignored. Those requested825* attributes that the object does have will be returned.826*<p>827* A directory might return more attributes than were requested828* (see <strong>Attribute Type Names</strong> in the class description)829* but is not allowed to return arbitrary, unrelated attributes.830*<p>831* See also <strong>Operational Attributes</strong> in the class832* description.833*834* @param name835* the name of the context or object to search836* @param filter837* the filter expression to use for the search; may not be null838* @param cons839* the search controls that control the search. If null,840* the default search controls are used (equivalent841* to {@code (new SearchControls())}).842* @return an enumeration of {@code SearchResult}s of843* the objects that satisfy the filter; never null844*845* @throws InvalidSearchFilterException if the search filter specified is846* not supported or understood by the underlying directory847* @throws InvalidSearchControlsException if the search controls848* contain invalid settings849* @throws NamingException if a naming exception is encountered850*851* @see #search(Name, String, Object[], SearchControls)852* @see SearchControls853* @see SearchResult854*/855public NamingEnumeration<SearchResult>856search(Name name,857String filter,858SearchControls cons)859throws NamingException;860861/**862* Searches in the named context or object for entries that satisfy the863* given search filter. Performs the search as specified by864* the search controls.865* See {@link #search(Name, String, SearchControls)} for details.866*867* @param name868* the name of the context or object to search869* @param filter870* the filter expression to use for the search; may not be null871* @param cons872* the search controls that control the search. If null,873* the default search controls are used (equivalent874* to {@code (new SearchControls())}).875*876* @return an enumeration of {@code SearchResult}s for877* the objects that satisfy the filter.878* @throws InvalidSearchFilterException if the search filter specified is879* not supported or understood by the underlying directory880* @throws InvalidSearchControlsException if the search controls881* contain invalid settings882* @throws NamingException if a naming exception is encountered883*/884public NamingEnumeration<SearchResult>885search(String name,886String filter,887SearchControls cons)888throws NamingException;889890/**891* Searches in the named context or object for entries that satisfy the892* given search filter. Performs the search as specified by893* the search controls.894*<p>895* The interpretation of <code>filterExpr</code> is based on RFC896* 2254. It may additionally contain variables of the form897* <code>{i}</code> -- where <code>i</code> is an integer -- that898* refer to objects in the <code>filterArgs</code> array. The899* interpretation of <code>filterExpr</code> is otherwise900* identical to that of the <code>filter</code> parameter of the901* method <code>search(Name, String, SearchControls)</code>.902*<p>903* When a variable <code>{i}</code> appears in a search filter, it904* indicates that the filter argument <code>filterArgs[i]</code>905* is to be used in that place. Such variables may be used906* wherever an <em>attr</em>, <em>value</em>, or907* <em>matchingrule</em> production appears in the filter grammar908* of RFC 2254, section 4. When a string-valued filter argument909* is substituted for a variable, the filter is interpreted as if910* the string were given in place of the variable, with any911* characters having special significance within filters (such as912* <code>'*'</code>) having been escaped according to the rules of913* RFC 2254.914*<p>915* For directories that do not use a string representation for916* some or all of their attributes, the filter argument917* corresponding to an attribute value may be of a type other than918* String. Directories that support unstructured binary-valued919* attributes, for example, should accept byte arrays as filter920* arguments. The interpretation (if any) of filter arguments of921* any other type is determined by the service provider for that922* directory, which maps the filter operations onto operations with923* corresponding semantics in the underlying directory.924*<p>925* This method returns an enumeration of the results.926* Each element in the enumeration contains the name of the object927* and other information about the object (see <code>SearchResult</code>).928* The name is either relative to the target context of the search929* (which is named by the <code>name</code> parameter), or930* it is a URL string. If the target context is included in931* the enumeration (as is possible when932* <code>cons</code> specifies a search scope of933* <code>SearchControls.OBJECT_SCOPE</code> or934* <code>SearchControls.SUBSTREE_SCOPE</code>),935* its name is the empty string.936*<p>937* The {@code SearchResult} may also contain attributes of the matching938* object if the {@code cons} argument specifies that attributes be939* returned.940*<p>941* If the object does not have a requested attribute, that942* nonexistent attribute will be ignored. Those requested943* attributes that the object does have will be returned.944*<p>945* A directory might return more attributes than were requested946* (see <strong>Attribute Type Names</strong> in the class description)947* but is not allowed to return arbitrary, unrelated attributes.948*<p>949* If a search filter with invalid variable substitutions is provided950* to this method, the result is undefined.951* When changes are made to this DirContext,952* the effect on enumerations returned by prior calls to this method953* is undefined.954*<p>955* See also <strong>Operational Attributes</strong> in the class956* description.957*958* @param name959* the name of the context or object to search960* @param filterExpr961* the filter expression to use for the search.962* The expression may contain variables of the963* form "<code>{i}</code>" where <code>i</code>964* is a nonnegative integer. May not be null.965* @param filterArgs966* the array of arguments to substitute for the variables967* in <code>filterExpr</code>. The value of968* <code>filterArgs[i]</code> will replace each969* occurrence of "<code>{i}</code>".970* If null, equivalent to an empty array.971* @param cons972* the search controls that control the search. If null,973* the default search controls are used (equivalent974* to {@code (new SearchControls())}).975* @return an enumeration of {@code SearchResult}s of the objects976* that satisfy the filter; never null977*978* @throws ArrayIndexOutOfBoundsException if {@code filterExpr} contains979* <code>{i}</code> expressions where <code>i</code> is outside980* the bounds of the array <code>filterArgs</code>981* @throws InvalidSearchControlsException if {@code cons} contains982* invalid settings983* @throws InvalidSearchFilterException if {@code filterExpr} with984* {@code filterArgs} represents an invalid search filter985* @throws NamingException if a naming exception is encountered986*987* @see #search(Name, Attributes, String[])988* @see java.text.MessageFormat989*/990public NamingEnumeration<SearchResult>991search(Name name,992String filterExpr,993Object[] filterArgs,994SearchControls cons)995throws NamingException;996997/**998* Searches in the named context or object for entries that satisfy the999* given search filter. Performs the search as specified by1000* the search controls.1001* See {@link #search(Name, String, Object[], SearchControls)} for details.1002*1003* @param name1004* the name of the context or object to search1005* @param filterExpr1006* the filter expression to use for the search.1007* The expression may contain variables of the1008* form "<code>{i}</code>" where <code>i</code>1009* is a nonnegative integer. May not be null.1010* @param filterArgs1011* the array of arguments to substitute for the variables1012* in <code>filterExpr</code>. The value of1013* <code>filterArgs[i]</code> will replace each1014* occurrence of "<code>{i}</code>".1015* If null, equivalent to an empty array.1016* @param cons1017* the search controls that control the search. If null,1018* the default search controls are used (equivalent1019* to {@code (new SearchControls())}).1020* @return an enumeration of {@code SearchResult}s of the objects1021* that satisfy the filter; never null1022*1023* @throws ArrayIndexOutOfBoundsException if {@code filterExpr} contains1024* <code>{i}</code> expressions where <code>i</code> is outside1025* the bounds of the array <code>filterArgs</code>1026* @throws InvalidSearchControlsException if {@code cons} contains1027* invalid settings1028* @throws InvalidSearchFilterException if {@code filterExpr} with1029* {@code filterArgs} represents an invalid search filter1030* @throws NamingException if a naming exception is encountered1031*/1032public NamingEnumeration<SearchResult>1033search(String name,1034String filterExpr,1035Object[] filterArgs,1036SearchControls cons)1037throws NamingException;1038}103910401041