View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.db;
18  
19  
20  import javax.naming.directory.Attributes;
21  import javax.naming.directory.SearchResult;
22  import java.math.BigInteger;
23  
24  
25  /***
26   * A special search result that includes the unique database primary key or 
27   * 'row id' of the entry in the master table for quick lookup.  This speeds 
28   * up various operations.
29   * 
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   * @version $Rev: 159259 $
32   */
33  public class DbSearchResult extends SearchResult
34  {
35      private static final long serialVersionUID = 3976739172700860977L;
36  
37      /*** the primary key used for the resultant entry */
38      private final BigInteger id;
39      
40      
41      // ------------------------------------------------------------------------
42      // C O N S T R U C T O R S
43      // ------------------------------------------------------------------------
44      
45      
46      /***
47       * Creates a database search result.
48       * 
49       * @param id the database id of the entry
50       * @param name the user provided relative or distinguished name
51       * @param obj the object if any
52       * @param attrs the attributes of the entry
53       */
54      public DbSearchResult( BigInteger id, String name, Object obj,
55          Attributes attrs )
56      {
57          super( name, obj, attrs );
58          this.id = id;
59      }
60  
61      
62      /***
63       * Creates a database search result.
64       * 
65       * @param id the database id of the entry
66       * @param name the user provided relative or distinguished name
67       * @param obj the object if any
68       * @param attrs the attributes of the entry
69       * @param isRelative whether or not the name is relative to the base
70       */
71      public DbSearchResult( BigInteger id, String name, Object obj,
72          Attributes attrs, boolean isRelative )
73      {
74          super( name, obj, attrs, isRelative );
75          this.id = id;
76      }
77  
78      
79      /***
80       * Creates a database search result.
81       * 
82       * @param id the database id of the entry
83       * @param name the user provided relative or distinguished name
84       * @param className the classname of the entry if any
85       * @param obj the object if any
86       * @param attrs the attributes of the entry
87       */
88      public DbSearchResult( BigInteger id, String name, String className,
89          Object obj, Attributes attrs )
90      {
91          super( name, className, obj, attrs );
92          this.id = id;
93      }
94  
95      
96      /***
97       * Creates a database search result.
98       * 
99       * @param id the database id of the entry
100      * @param name the user provided relative or distinguished name
101      * @param className the classname of the entry if any
102      * @param obj the object if any
103      * @param attrs the attributes of the entry
104      * @param isRelative whether or not the name is relative to the base
105      */
106     public DbSearchResult( BigInteger id, String name, String className,
107         Object obj, Attributes attrs, boolean isRelative )
108     {
109         super( name, className, obj, attrs, isRelative );
110         this.id = id;
111     }
112     
113     
114     /***
115      * Gets the unique row id of the entry into the master table.
116      * 
117      * @return Returns the id.
118      */
119     public BigInteger getId()
120     {
121         return id;
122     }
123 }