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 */ 020package org.apache.directory.server.core.api.entry; 021 022 023import org.apache.directory.api.ldap.model.entry.Entry; 024import org.apache.directory.api.ldap.model.name.Dn; 025 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 */ 033public class ServerSearchResult 034{ 035 /** Distinguished name for this result */ 036 private Dn dn; 037 038 /** The associated entry */ 039 private Entry serverEntry; 040 041 /** Tells if the name is relative to the target context */ 042 private boolean isRelative; 043 044 /** The bound object */ 045 private Object object; 046 047 048 /** 049 * 050 * Creates a new instance of ServerSearchResult. 051 * 052 * @param dn Distinguished name for this result 053 * @param serverEntry The associated entry 054 * @param isRelative Tells if the name is relative to the target context 055 */ 056 public ServerSearchResult( Dn dn, Entry serverEntry, boolean isRelative ) 057 { 058 this.dn = dn; 059 this.serverEntry = serverEntry; 060 this.serverEntry.setDn( dn ); 061 this.isRelative = isRelative; 062 } 063 064 065 /** 066 * 067 * Creates a new instance of ServerSearchResult. 068 * 069 * @param dn Distinguished name for this result 070 * @param serverEntry The associated entry 071 */ 072 public ServerSearchResult( Dn dn, Entry serverEntry ) 073 { 074 this.dn = dn; 075 this.serverEntry = serverEntry; 076 this.serverEntry.setDn( dn ); 077 } 078 079 080 /** 081 * @return The result Dn 082 */ 083 public Dn getDn() 084 { 085 return dn; 086 } 087 088 089 /** 090 * @return The entry 091 */ 092 public Entry getServerEntry() 093 { 094 return serverEntry; 095 } 096 097 098 public boolean isRelative() 099 { 100 return isRelative; 101 } 102 103 104 public void setRelative( boolean isRelative ) 105 { 106 this.isRelative = isRelative; 107 } 108 109 110 public void setServerEntry( Entry serverEntry ) 111 { 112 this.serverEntry = serverEntry; 113 } 114 115 116 public Object getObject() 117 { 118 return object; 119 } 120 121 122 public void setObject( Object object ) 123 { 124 this.object = object; 125 } 126 127 128 /** 129 * @see Object#toString() 130 */ 131 public String toString() 132 { 133 String name = ( dn == null ? "null" : ( dn == Dn.EMPTY_DN ? "\"\"" : dn.getName() ) ); 134 return "ServerSearchResult : " + name + "\n" + serverEntry; 135 } 136}