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
021 package org.apache.directory.shared.ldap.trigger;
022
023 import javax.naming.Name;
024
025 import org.apache.directory.shared.ldap.filter.SearchScope;
026
027
028 /**
029 *
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 * @version $Rev:$, $Date:$
032 */
033 public class StoredProcedureSearchContextOption implements StoredProcedureOption
034 {
035
036 private final Name baseObject;
037 private SearchScope searchScope;
038
039
040 public StoredProcedureSearchContextOption( Name baseObject )
041 {
042 // the default search scope is "base"
043 this( baseObject, SearchScope.OBJECT );
044 }
045
046 public StoredProcedureSearchContextOption( Name baseObject, SearchScope searchScope )
047 {
048 this.baseObject = baseObject;
049 this.searchScope = searchScope;
050 }
051
052 public Name getBaseObject()
053 {
054 return baseObject;
055 }
056
057 public SearchScope getSearchScope()
058 {
059 return searchScope;
060 }
061
062 public String toString()
063 {
064 return "searchContext { scope " + searchScope + " } \"" + baseObject + "\"";
065 }
066
067 /**
068 * @see java.lang.Object#hashCode()
069 * @return the instance's hash code
070 */
071 public int hashCode()
072 {
073 int h = 37;
074
075 h = h*17 + ( ( baseObject == null ) ? 0 : baseObject.hashCode() );
076 h = h*17 + ( ( searchScope == null ) ? 0 : searchScope.hashCode() );
077
078 return h;
079 }
080
081 /* (non-Javadoc)
082 * @see java.lang.Object#equals(java.lang.Object)
083 */
084 public boolean equals( Object obj )
085 {
086 if ( this == obj )
087 return true;
088 if ( obj == null )
089 return false;
090 if ( getClass() != obj.getClass() )
091 return false;
092 final StoredProcedureSearchContextOption other = ( StoredProcedureSearchContextOption ) obj;
093 if ( baseObject == null )
094 {
095 if ( other.baseObject != null )
096 return false;
097 }
098 else if ( !baseObject.equals( other.baseObject ) )
099 return false;
100 if ( searchScope == null )
101 {
102 if ( other.searchScope != null )
103 return false;
104 }
105 else if ( !searchScope.equals( other.searchScope ) )
106 return false;
107 return true;
108 }
109
110 }