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 java.util.ArrayList;
032 import java.util.List;
033
034
035
036
037 /**
038 * This class defines a data structure for storing information about
039 * an entry that matches a given set of search criteria and should be
040 * returned to the client.
041 * When the search result entry contains attribute types only, the
042 * objectclass type (if requested) will be present in the user
043 * attributes. When the search result entry contains both attribute
044 * types and values, the objectclass attribute will not be present in
045 * the user attributes.
046 */
047 @org.opends.server.types.PublicAPI(
048 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
049 mayInstantiate=false,
050 mayExtend=false,
051 mayInvoke=true)
052 public final class SearchResultEntry
053 extends Entry
054 {
055 // The set of controls associated with this search result entry.
056 private List<Control> controls;
057
058
059
060 /**
061 * Creates a new search result entry based on the provided entry.
062 * The provided entry should have been a duplicate of a real entry
063 * so that any changes that may be made to this entry (e.g., by
064 * access control or plugins) will not impact the original entry.
065 *
066 * @param entry The entry to use to create this search result
067 * entry.
068 */
069 public SearchResultEntry(Entry entry)
070 {
071 super(entry.getDN(), entry.getObjectClasses(),
072 entry.getUserAttributes(),
073 entry.getOperationalAttributes());
074
075
076 this.controls = new ArrayList<Control>(0);
077 }
078
079
080
081 /**
082 * Creates a new search result entry based on the provided entry.
083 * The provided entry should have been a duplicate of a real entry
084 * so that any changes that may be made to this entry (e.g., by
085 * access control or plugins) will not impact the original entry.
086 *
087 * @param entry The entry to use to create this search result
088 * entry.
089 * @param controls The set of controls to return to the client
090 * with this entry.
091 */
092 public SearchResultEntry(Entry entry, List<Control> controls)
093 {
094 super(entry.getDN(), entry.getObjectClasses(),
095 entry.getUserAttributes(),
096 entry.getOperationalAttributes());
097
098
099 if (controls == null)
100 {
101 this.controls = new ArrayList<Control>(0);
102 }
103 else
104 {
105 this.controls = controls;
106 }
107 }
108
109
110
111 /**
112 * Retrieves the set of controls to include with this search result
113 * entry when it is sent to the client. This set of controls may be
114 * modified by the caller.
115 *
116 * @return The set of controls to include with this search result
117 * entry when it is sent to the client.
118 */
119 public List<Control> getControls()
120 {
121 return controls;
122 }
123 }
124