1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.message;
21
22
23 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
24 import org.apache.directory.api.ldap.model.entry.Entry;
25 import org.apache.directory.api.ldap.model.name.Dn;
26
27
28
29
30
31
32
33 public class SearchResultEntryImpl extends AbstractResponse implements SearchResultEntry
34 {
35 static final long serialVersionUID = -8357316233060886637L;
36
37
38 private Entry entry = new DefaultEntry();
39
40
41
42
43
44
45 public SearchResultEntryImpl()
46 {
47 super( -1, MessageTypeEnum.SEARCH_RESULT_ENTRY );
48 }
49
50
51
52
53
54
55
56
57 public SearchResultEntryImpl( final int id )
58 {
59 super( id, MessageTypeEnum.SEARCH_RESULT_ENTRY );
60 }
61
62
63
64
65
66
67
68
69
70
71
72 public Entry getEntry()
73 {
74 return entry;
75 }
76
77
78
79
80
81
82
83 public void setEntry( Entry entry )
84 {
85 this.entry = entry;
86 }
87
88
89
90
91
92
93
94 public Dn getObjectName()
95 {
96 return ( entry == null ? null : entry.getDn() );
97 }
98
99
100
101
102
103
104
105 public void setObjectName( Dn objectName )
106 {
107 if ( entry != null )
108 {
109 entry.setDn( objectName );
110 }
111 }
112
113
114
115
116
117 @Override
118 public int hashCode()
119 {
120 int hash = 37;
121 if ( entry != null )
122 {
123 hash = hash * 17 + entry.hashCode();
124 }
125 hash = hash * 17 + super.hashCode();
126
127 return hash;
128 }
129
130
131
132
133
134
135
136
137
138
139 public boolean equals( Object obj )
140 {
141 if ( this == obj )
142 {
143 return true;
144 }
145
146 if ( !super.equals( obj ) )
147 {
148 return false;
149 }
150
151 if ( !( obj instanceof SearchResultEntry ) )
152 {
153 return false;
154 }
155
156 SearchResultEntry resp = ( SearchResultEntry ) obj;
157
158 return entry.equals( resp.getEntry() );
159 }
160
161
162
163
164
165 public String toString()
166 {
167 StringBuilder sb = new StringBuilder();
168
169 sb.append( " Search Result Entry\n" );
170
171 if ( entry != null )
172 {
173 sb.append( entry );
174 }
175 else
176 {
177 sb.append( " No entry\n" );
178 }
179
180 return super.toString( sb.toString() );
181 }
182 }