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.shared.ldap.message;
021
022
023 /**
024 * SearchResponseReference implementation
025 *
026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
027 * @version $Revision: 764131 $
028 */
029 public class SearchResponseReferenceImpl extends InternalAbstractResponse implements InternalSearchResponseReference
030 {
031 static final long serialVersionUID = 7423807019951309810L;
032
033 /** Referral holding the reference urls */
034 private InternalReferral referral;
035
036
037 // ------------------------------------------------------------------------
038 // Constructors
039 // ------------------------------------------------------------------------
040
041 /**
042 * Creates a Lockable SearchResponseReference as a reply to an SearchRequest
043 * to indicate the end of a search operation.
044 *
045 * @param id
046 * the session unique message id
047 */
048 public SearchResponseReferenceImpl(final int id)
049 {
050 super( id, TYPE );
051 }
052
053
054 // ------------------------------------------------------------------------
055 // SearchResponseReference Interface Method Implementations
056 // ------------------------------------------------------------------------
057
058 /**
059 * Gets the sequence of LdapUrls as a Referral instance.
060 *
061 * @return the sequence of LdapUrls
062 */
063 public InternalReferral getReferral()
064 {
065 return this.referral;
066 }
067
068
069 /**
070 * Sets the sequence of LdapUrls as a Referral instance.
071 *
072 * @param referral
073 * the sequence of LdapUrls
074 */
075 public void setReferral( InternalReferral referral )
076 {
077 this.referral = referral;
078 }
079
080
081 /**
082 * Checks to see if an object is equal to this SearchResponseReference stub.
083 *
084 * @param obj
085 * the object to compare to this response stub
086 * @return true if the objects are equivalent false otherwise
087 */
088 public boolean equals( Object obj )
089 {
090 if ( obj == this )
091 {
092 return true;
093 }
094
095 if ( !super.equals( obj ) )
096 {
097 return false;
098 }
099
100 InternalSearchResponseReference resp = ( InternalSearchResponseReference ) obj;
101
102 if ( this.referral != null && resp.getReferral() == null )
103 {
104 return false;
105 }
106
107 if ( this.referral == null && resp.getReferral() != null )
108 {
109 return false;
110 }
111
112 if ( this.referral != null && resp.getReferral() != null )
113 {
114 if ( !this.referral.equals( resp.getReferral() ) )
115 {
116 return false;
117 }
118 }
119
120 return true;
121 }
122 }