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