001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 package org.apache.directory.server.core.entry; 021 022 023 024 import org.apache.directory.shared.ldap.entry.ServerEntry; 025 import org.apache.directory.shared.ldap.name.DN; 026 027 /** 028 * Creates a wrapper around a SearchResult object so that we can use the DN 029 * instead of parser it over and over 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 * @version $Rev$, $Date$ 033 */ 034 public class ServerSearchResult 035 { 036 /** Distinguished name for this result */ 037 private DN dn; 038 039 /** The associated entry */ 040 private ServerEntry serverEntry; 041 042 /** Tells if the name is relative to the target context */ 043 private boolean isRelative; 044 045 /** The bound object */ 046 private Object object; 047 048 049 public ServerSearchResult( DN dn, Object obj, ServerEntry serverEntry ) 050 { 051 this.dn = dn; 052 this.serverEntry = serverEntry; 053 this.serverEntry.setDn( dn ); 054 } 055 056 057 public ServerSearchResult( DN dn, Object obj, ServerEntry serverEntry, boolean isRelative ) 058 { 059 this.dn = dn; 060 this.serverEntry = serverEntry; 061 this.serverEntry.setDn( dn ); 062 this.isRelative = isRelative; 063 } 064 065 066 public ServerSearchResult( DN dn, String className, Object obj, ServerEntry serverEntry ) 067 { 068 this.dn = dn; 069 this.serverEntry = serverEntry; 070 this.serverEntry.setDn( dn ); 071 } 072 073 074 public ServerSearchResult( DN dn, String className, Object obj, ServerEntry serverEntry, boolean isRelative ) 075 { 076 this.dn = dn; 077 this.serverEntry = serverEntry; 078 this.serverEntry.setDn( dn ); 079 } 080 081 082 /** 083 * @return The result DN 084 */ 085 public DN getDn() 086 { 087 return dn; 088 } 089 090 091 /** 092 * @return The entry 093 */ 094 public ServerEntry getServerEntry() 095 { 096 return serverEntry; 097 } 098 099 100 public boolean isRelative() 101 { 102 return isRelative; 103 } 104 105 106 public void setRelative( boolean isRelative ) 107 { 108 this.isRelative = isRelative; 109 } 110 111 112 public void setServerEntry( ServerEntry serverEntry ) 113 { 114 this.serverEntry = serverEntry; 115 } 116 117 118 public Object getObject() 119 { 120 return object; 121 } 122 123 124 public void setObject( Object object ) 125 { 126 this.object = object; 127 } 128 129 130 /** 131 * @see Object#toString() 132 */ 133 public String toString() 134 { 135 String name = (dn == null ? "null" : ( dn == DN.EMPTY_DN ? "\"\"" : dn.getName() ) ); 136 return "ServerSearchResult : " + name + "\n" + serverEntry; 137 } 138 }