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