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     * docs/licenses/cddl.txt
011     * or http://www.opensource.org/licenses/cddl1.php.
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     * docs/licenses/cddl.txt.  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 2010-2013 UnboundID Corp.
026     */
027    package com.unboundid.directory.sdk.ds.types;
028    
029    
030    
031    import java.io.Serializable;
032    
033    import com.unboundid.util.NotMutable;
034    import com.unboundid.util.ThreadSafety;
035    import com.unboundid.util.ThreadSafetyLevel;
036    
037    
038    
039    /**
040     * This class defines a structure which may be used to provide information about
041     * the result of the processing performed by a search entry plugin.
042     */
043    @NotMutable()
044    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
045    public final class SearchEntryPluginResult
046           implements Serializable
047    {
048      /**
049       * A predefined result instance that indicates all processing completed
050       * successfully.
051       */
052      public static final SearchEntryPluginResult SUCCESS =
053           new SearchEntryPluginResult(false, true, true, true);
054    
055    
056    
057      /**
058       * The serial version UID for this serializable class.
059       */
060      private static final long serialVersionUID = 6301478866012072554L;
061    
062    
063    
064      // Indicates whether the client connection was terminated by the plugin.
065      private final boolean connectionTerminated;
066    
067      // Indicates whether the server should continue processing other search entry
068      // plugins for the associated entry.
069      private final boolean continuePluginProcessing;
070    
071      // Indicates whether the server should continue processing for the associated
072      // search operation.
073      private final boolean continueSearchProcessing;
074    
075      // Indicates whether the associated entry should be returned to the client.
076      private final boolean sendEntry;
077    
078    
079    
080      /**
081       * Creates a new search entry plugin result with the provided information.
082       *
083       * @param  connectionTerminated      Indicates whether the client connection
084       *                                   was terminated by the plugin.
085       * @param  continuePluginProcessing  Indicates whether to continue processing
086       *                                   other search entry plugins for the
087       *                                   entry.
088       * @param  sendEntry                 Indicates whether to send the entry to
089       *                                   the client.
090       * @param  continueSearchProcessing  Indicates whether to continue processing
091       *                                   the associated search operation.
092       */
093      public SearchEntryPluginResult(final boolean connectionTerminated,
094                                     final boolean continuePluginProcessing,
095                                     final boolean sendEntry,
096                                     final boolean continueSearchProcessing)
097      {
098        this.connectionTerminated     = connectionTerminated;
099        this.continuePluginProcessing = continuePluginProcessing;
100        this.sendEntry                = sendEntry;
101        this.continueSearchProcessing = continueSearchProcessing;
102      }
103    
104    
105    
106      /**
107       * Indicates whether the client connection was terminated by the plugin.
108       *
109       * @return  {@code true} if the client connection was terminated by the
110       *          plugin, or {@code false} if not.
111       */
112      public boolean connectionTerminated()
113      {
114        return connectionTerminated;
115      }
116    
117    
118    
119      /**
120       * Indicates whether to continue processing other search entry plugins for
121       * the associated entry.
122       *
123       * @return  {@code true} if the server should continue processing other
124       *          search entry plugins for the associated entry, or {@code false} if
125       *          not.
126       */
127      public boolean continuePluginProcessing()
128      {
129        return continuePluginProcessing;
130      }
131    
132    
133    
134      /**
135       * Indicates whether to continue processing for the associated search
136       * operation.
137       *
138       * @return  {@code true} if the server should continue processing for the
139       *          associated search operation, or {@code false} if not and the
140       *          search done response should be sent to the client.
141       */
142      public boolean continueSearchProcessing()
143      {
144        return continueSearchProcessing;
145      }
146    
147    
148    
149      /**
150       * Indicates whether the associated entry should be returned to the client.
151       *
152       * @return  {@code true} if the entry should be returned to the client, or
153       *          {@code false} if the server should exclude the entry from the
154       *          set of search results.
155       */
156      public boolean sendEntry()
157      {
158        return sendEntry;
159      }
160    
161    
162    
163      /**
164       * Retrieves a string representation of this search entry plugin result.
165       *
166       * @return  A string representation of this search entry plugin result.
167       */
168      @Override()
169      public String toString()
170      {
171        final StringBuilder buffer = new StringBuilder();
172    
173        buffer.append("SearchEntryPluginResult(connectionTerminated=");
174        buffer.append(connectionTerminated);
175        buffer.append(", continuePluginProcessing=");
176        buffer.append(continuePluginProcessing);
177        buffer.append(", sendEntry=");
178        buffer.append(sendEntry);
179        buffer.append(", continueSearchProcessing=");
180        buffer.append(continueSearchProcessing);
181        buffer.append(')');
182    
183        return buffer.toString();
184      }
185    }