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 */ 020package org.apache.directory.api.ldap.model.message.controls; 021 022 023/** 024 * A persistence search object 025 * 026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 027 */ 028public class PersistentSearchImpl extends AbstractControl implements PersistentSearch 029{ 030 031 /** 032 * If changesOnly is TRUE, the server MUST NOT return any existing entries 033 * that match the search criteria. Entries are only returned when they are 034 * changed (added, modified, deleted, or subject to a modifyDN operation). 035 */ 036 private boolean changesOnly = true; 037 038 /** 039 * If returnECs is TRUE, the server MUST return an Entry Change Notification 040 * control with each entry returned as the result of changes. 041 */ 042 private boolean returnECs = false; 043 044 /** 045 * As changes are made to the server, the effected entries MUST be returned 046 * to the client if they match the standard search criteria and if the 047 * operation that caused the change is included in the changeTypes field. 048 * The changeTypes field is the logical OR of one or more of these values: 049 * add (1), 050 * delete (2), 051 * modify (4), 052 * modDN (8). 053 */ 054 private int changeTypes = CHANGE_TYPES_MAX; 055 056 057 /** 058 * Default constructor 059 * 060 */ 061 public PersistentSearchImpl() 062 { 063 super( OID ); 064 } 065 066 067 public void setChangesOnly( boolean changesOnly ) 068 { 069 this.changesOnly = changesOnly; 070 } 071 072 073 public boolean isChangesOnly() 074 { 075 return changesOnly; 076 } 077 078 079 public void setReturnECs( boolean returnECs ) 080 { 081 this.returnECs = returnECs; 082 } 083 084 085 public boolean isReturnECs() 086 { 087 return returnECs; 088 } 089 090 091 public void setChangeTypes( int changeTypes ) 092 { 093 this.changeTypes = changeTypes; 094 } 095 096 097 public int getChangeTypes() 098 { 099 return changeTypes; 100 } 101 102 103 public boolean isNotificationEnabled( ChangeType changeType ) 104 { 105 return ( changeType.getValue() & changeTypes ) > 0; 106 } 107 108 109 public void enableNotification( ChangeType changeType ) 110 { 111 changeTypes |= changeType.getValue(); 112 } 113 114 115 /** 116 * Return a String representing this PSearchControl. 117 */ 118 public String toString() 119 { 120 StringBuffer sb = new StringBuffer(); 121 122 sb.append( " Persistant Search Control\n" ); 123 sb.append( " oid : " ).append( getOid() ).append( '\n' ); 124 sb.append( " critical : " ).append( isCritical() ).append( '\n' ); 125 sb.append( " changeTypes : '" ).append( changeTypes ).append( "'\n" ); 126 sb.append( " changesOnly : '" ).append( changesOnly ).append( "'\n" ); 127 sb.append( " returnECs : '" ).append( returnECs ).append( "'\n" ); 128 129 return sb.toString(); 130 } 131}