001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2015 ForgeRock AS.
016 */
017package org.opends.server.types;
018
019import java.util.ArrayList;
020import java.util.List;
021
022
023
024
025/**
026 * This class defines a data structure for storing information about
027 * an entry that matches a given set of search criteria and should be
028 * returned to the client.
029 * When the search result entry contains attribute types only, the
030 * objectclass type (if requested) will be present in the user
031 * attributes.  When the search result entry contains both attribute
032 * types and values, the objectclass attribute will not be present in
033 * the user attributes.
034 */
035@org.opends.server.types.PublicAPI(
036     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
037     mayInstantiate=false,
038     mayExtend=false,
039     mayInvoke=true)
040public final class SearchResultEntry
041       extends Entry
042{
043  /** The set of controls associated with this search result entry. */
044  private final List<Control> controls;
045
046
047
048  /**
049   * Creates a new search result entry based on the provided entry.
050   * The provided entry should have been a duplicate of a real entry
051   * so that any changes that may be made to this entry (e.g., by
052   * access control or plugins) will not impact the original entry.
053   *
054   * @param  entry  The entry to use to create this search result
055   *                entry.
056   */
057  public SearchResultEntry(Entry entry)
058  {
059    super(entry.getName(), entry.getObjectClasses(),
060          entry.getUserAttributes(),
061          entry.getOperationalAttributes());
062
063
064    this.controls = new ArrayList<>(0);
065  }
066
067
068
069  /**
070   * Creates a new search result entry based on the provided entry.
071   * The provided entry should have been a duplicate of a real entry
072   * so that any changes that may be made to this entry (e.g., by
073   * access control or plugins) will not impact the original entry.
074   *
075   * @param  entry     The entry to use to create this search result
076   *                   entry.
077   * @param  controls  The set of controls to return to the client
078   *                   with this entry.
079   */
080  public SearchResultEntry(Entry entry, List<Control> controls)
081  {
082    super(entry.getName(), entry.getObjectClasses(),
083          entry.getUserAttributes(),
084          entry.getOperationalAttributes());
085
086
087    if (controls == null)
088    {
089      this.controls = new ArrayList<>(0);
090    }
091    else
092    {
093      this.controls = controls;
094    }
095  }
096
097
098
099  /**
100   * Retrieves the set of controls to include with this search result
101   * entry when it is sent to the client.  This set of controls may be
102   * modified by the caller.
103   *
104   * @return  The set of controls to include with this search result
105   *          entry when it is sent to the client.
106   */
107  public List<Control> getControls()
108  {
109    return controls;
110  }
111}
112