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 * https://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 021package org.apache.directory.api.ldap.trigger; 022 023 024import org.apache.directory.api.ldap.model.message.SearchScope; 025import org.apache.directory.api.ldap.model.name.Dn; 026 027 028/** 029 * The search context option of the triggered stored procedure. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public class StoredProcedureSearchContextOption implements StoredProcedureOption 034{ 035 036 private final Dn baseObject; 037 private SearchScope searchScope; 038 039 040 /** 041 * Instantiates a new stored procedure search context option. 042 * 043 * @param baseObject the base object 044 */ 045 public StoredProcedureSearchContextOption( Dn baseObject ) 046 { 047 // the default search scope is "base" 048 this( baseObject, SearchScope.OBJECT ); 049 } 050 051 052 /** 053 * Instantiates a new stored procedure search context option. 054 * 055 * @param baseObject the base object 056 * @param searchScope the search scope 057 */ 058 public StoredProcedureSearchContextOption( Dn baseObject, SearchScope searchScope ) 059 { 060 this.baseObject = baseObject; 061 this.searchScope = searchScope; 062 } 063 064 065 /** 066 * Gets the base object. 067 * 068 * @return the base object 069 */ 070 public Dn getBaseObject() 071 { 072 return baseObject; 073 } 074 075 076 /** 077 * Gets the search scope. 078 * 079 * @return the search scope 080 */ 081 public SearchScope getSearchScope() 082 { 083 return searchScope; 084 } 085 086 087 /** 088 * {@inheritDoc} 089 */ 090 @Override 091 public String toString() 092 { 093 return "searchContext { scope " + searchScope + " } \"" + baseObject + "\""; 094 } 095 096 097 /** 098 * {@inheritDoc} 099 */ 100 @Override 101 public int hashCode() 102 { 103 int h = 37; 104 105 h = h * 17 + ( ( baseObject == null ) ? 0 : baseObject.hashCode() ); 106 h = h * 17 + ( ( searchScope == null ) ? 0 : searchScope.hashCode() ); 107 108 return h; 109 } 110 111 112 /** 113 * {@inheritDoc} 114 */ 115 @Override 116 public boolean equals( Object obj ) 117 { 118 if ( this == obj ) 119 { 120 return true; 121 } 122 if ( obj == null ) 123 { 124 return false; 125 } 126 if ( getClass() != obj.getClass() ) 127 { 128 return false; 129 } 130 final StoredProcedureSearchContextOption other = ( StoredProcedureSearchContextOption ) obj; 131 if ( baseObject == null ) 132 { 133 if ( other.baseObject != null ) 134 { 135 return false; 136 } 137 } 138 else if ( !baseObject.equals( other.baseObject ) ) 139 { 140 return false; 141 } 142 if ( searchScope == null ) 143 { 144 if ( other.searchScope != null ) 145 { 146 return false; 147 } 148 } 149 else if ( !searchScope.equals( other.searchScope ) ) 150 { 151 return false; 152 } 153 return true; 154 } 155 156}