0N/A/*
2362N/A * Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.naming.directory;
0N/A
0N/Aimport javax.naming.Binding;
0N/A
0N/A/**
0N/A * This class represents an item in the NamingEnumeration returned as a
0N/A * result of the DirContext.search() methods.
0N/A *<p>
0N/A * A SearchResult instance is not synchronized against concurrent
0N/A * multithreaded access. Multiple threads trying to access and modify
0N/A * a single SearchResult instance should lock the object.
0N/A *
0N/A * @author Rosanna Lee
0N/A * @author Scott Seligman
0N/A *
0N/A * @see DirContext#search
0N/A * @since 1.3
0N/A */
0N/A
0N/Apublic class SearchResult extends Binding {
0N/A /**
0N/A * Contains the attributes returned with the object.
0N/A * @serial
0N/A */
0N/A private Attributes attrs;
0N/A
0N/A /**
0N/A * Constructs a search result using the result's name, its bound object, and
0N/A * its attributes.
0N/A *<p>
0N/A * <tt>getClassName()</tt> will return the class name of <tt>obj</tt>
0N/A * (or null if <tt>obj</tt> is null) unless the class name has been
0N/A * explicitly set using <tt>setClassName()</tt>.
0N/A *
0N/A * @param name The non-null name of the search item. It is relative
0N/A * to the <em>target context</em> of the search (which is
0N/A * named by the first parameter of the <code>search()</code> method)
0N/A *
0N/A * @param obj The object bound to name. Can be null.
0N/A * @param attrs The attributes that were requested to be returned with
0N/A * this search item. Cannot be null.
0N/A * @see javax.naming.NameClassPair#setClassName
0N/A * @see javax.naming.NameClassPair#getClassName
0N/A */
0N/A public SearchResult(String name, Object obj, Attributes attrs) {
0N/A super(name, obj);
0N/A this.attrs = attrs;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a search result using the result's name, its bound object, and
0N/A * its attributes, and whether the name is relative.
0N/A *<p>
0N/A * <tt>getClassName()</tt> will return the class name of <tt>obj</tt>
0N/A * (or null if <tt>obj</tt> is null) unless the class name has been
0N/A * explicitly set using <tt>setClassName()</tt>
0N/A *
0N/A * @param name The non-null name of the search item.
0N/A * @param obj The object bound to name. Can be null.
0N/A * @param attrs The attributes that were requested to be returned with
0N/A * this search item. Cannot be null.
0N/A * @param isRelative true if <code>name</code> is relative
0N/A * to the target context of the search (which is named by
0N/A * the first parameter of the <code>search()</code> method);
0N/A * false if <code>name</code> is a URL string.
0N/A * @see javax.naming.NameClassPair#setClassName
0N/A * @see javax.naming.NameClassPair#getClassName
0N/A */
0N/A public SearchResult(String name, Object obj, Attributes attrs,
0N/A boolean isRelative) {
0N/A super(name, obj, isRelative);
0N/A this.attrs = attrs;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a search result using the result's name, its class name,
0N/A * its bound object, and its attributes.
0N/A *
0N/A * @param name The non-null name of the search item. It is relative
0N/A * to the <em>target context</em> of the search (which is
0N/A * named by the first parameter of the <code>search()</code> method)
0N/A *
0N/A * @param className The possibly null class name of the object
0N/A * bound to <tt>name</tt>. If null, the class name of <tt>obj</tt> is
0N/A * returned by <tt>getClassName()</tt>. If <tt>obj</tt> is also null,
0N/A * <tt>getClassName()</tt> will return null.
0N/A * @param obj The object bound to name. Can be null.
0N/A * @param attrs The attributes that were requested to be returned with
0N/A * this search item. Cannot be null.
0N/A * @see javax.naming.NameClassPair#setClassName
0N/A * @see javax.naming.NameClassPair#getClassName
0N/A */
0N/A public SearchResult(String name, String className,
0N/A Object obj, Attributes attrs) {
0N/A super(name, className, obj);
0N/A this.attrs = attrs;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a search result using the result's name, its class name,
0N/A * its bound object, its attributes, and whether the name is relative.
0N/A *
0N/A * @param name The non-null name of the search item.
0N/A * @param className The possibly null class name of the object
0N/A * bound to <tt>name</tt>. If null, the class name of <tt>obj</tt> is
0N/A * returned by <tt>getClassName()</tt>. If <tt>obj</tt> is also null,
0N/A * <tt>getClassName()</tt> will return null.
0N/A * @param obj The object bound to name. Can be null.
0N/A * @param attrs The attributes that were requested to be returned with
0N/A * this search item. Cannot be null.
0N/A * @param isRelative true if <code>name</code> is relative
0N/A * to the target context of the search (which is named by
0N/A * the first parameter of the <code>search()</code> method);
0N/A * false if <code>name</code> is a URL string.
0N/A * @see javax.naming.NameClassPair#setClassName
0N/A * @see javax.naming.NameClassPair#getClassName
0N/A */
0N/A public SearchResult(String name, String className, Object obj,
0N/A Attributes attrs, boolean isRelative) {
0N/A super(name, className, obj, isRelative);
0N/A this.attrs = attrs;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the attributes in this search result.
0N/A *
0N/A * @return The non-null attributes in this search result. Can be empty.
0N/A * @see #setAttributes
0N/A */
0N/A public Attributes getAttributes() {
0N/A return attrs;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Sets the attributes of this search result to <code>attrs</code>.
0N/A * @param attrs The non-null attributes to use. Can be empty.
0N/A * @see #getAttributes
0N/A */
0N/A public void setAttributes(Attributes attrs) {
0N/A this.attrs = attrs;
0N/A // ??? check for null?
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Generates the string representation of this SearchResult.
0N/A * The string representation consists of the string representation
0N/A * of the binding and the string representation of
0N/A * this search result's attributes, separated by ':'.
0N/A * The contents of this string is useful
0N/A * for debugging and is not meant to be interpreted programmatically.
0N/A *
0N/A * @return The string representation of this SearchResult. Cannot be null.
0N/A */
0N/A public String toString() {
0N/A return super.toString() + ":" + getAttributes();
0N/A }
0N/A
0N/A /**
0N/A * Use serialVersionUID from JNDI 1.1.1 for interoperability
0N/A */
0N/A private static final long serialVersionUID = -9158063327699723172L;
0N/A}