View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.core.entry;
21  
22  
23  
24  import org.apache.directory.shared.ldap.name.LdapDN;
25  
26  /**
27   * Creates a wrapper around a SearchResult object so that we can use the LdapDN
28   * instead of parser it over and over
29   *
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   * @version $Rev$, $Date$
32   */
33  public class ServerSearchResult
34  {
35      /** Distinguished name for this result */
36      private LdapDN dn;
37      
38      /** The associated entry */
39      private ServerEntry serverEntry;
40      
41      /** Tells if the name is relative to the target context */
42      private boolean isRelative;
43      
44      /** The bound object */
45      private Object object;
46      
47  
48      public ServerSearchResult( LdapDN dn, Object obj, ServerEntry serverEntry )
49      {
50          this.dn = dn;
51          this.serverEntry = serverEntry;
52          this.serverEntry.setDn( dn );
53      }
54  
55  
56      public ServerSearchResult( LdapDN dn, Object obj, ServerEntry serverEntry, boolean isRelative )
57      {
58          this.dn = dn;
59          this.serverEntry = serverEntry;
60          this.serverEntry.setDn( dn );
61          this.isRelative = isRelative;
62      }
63  
64  
65      public ServerSearchResult( LdapDN dn, String className, Object obj, ServerEntry serverEntry )
66      {
67          this.dn = dn;
68          this.serverEntry = serverEntry;
69          this.serverEntry.setDn( dn );
70      }
71  
72  
73      public ServerSearchResult( LdapDN dn, String className, Object obj, ServerEntry serverEntry, boolean isRelative ) 
74      {
75          this.dn = dn;
76          this.serverEntry = serverEntry;
77          this.serverEntry.setDn( dn );
78      }
79  
80  
81      /**
82       * @return The result DN
83       */
84      public LdapDN getDn()
85      {
86          return dn;
87      }
88      
89      
90      /**
91       * @return The entry
92       */
93      public ServerEntry getServerEntry()
94      {
95          return serverEntry;
96      }
97  
98  
99      public boolean isRelative() 
100     {
101         return isRelative;
102     }
103 
104 
105     public void setRelative( boolean isRelative ) 
106     {
107         this.isRelative = isRelative;
108     }
109 
110 
111     public void setServerEntry( ServerEntry serverEntry ) 
112     {
113         this.serverEntry = serverEntry;
114     }
115 
116 
117     public Object getObject() 
118     {
119         return object;
120     }
121 
122 
123     public void setObject( Object object ) 
124     {
125         this.object = object;
126     }
127     
128     
129     /**
130      * @see Object#toString()
131      */
132     public String toString()
133     {
134         String name = (dn == null ? "null" : ( dn == LdapDN.EMPTY_LDAPDN ? "\"\"" : dn.getUpName() ) );
135         return "ServerSearchResult : " + name + "\n" + serverEntry;
136     }
137 }