1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.api.ldap.model.message.controls; 21 22 23 /** 24 * A simple Subentries Control implementation. This control is described in 25 * RFC 3672 : 26 * The subentries control MAY be sent with a searchRequest to control 27 * the visibility of entries and subentries which are within scope. 28 * Non-visible entries or subentries are not returned in response to the 29 * request. 30 * 31 * The subentries control is an LDAP Control whose controlType is 32 * 1.3.6.1.4.1.4203.1.10.1, criticality is TRUE or FALSE (hence absent), 33 * and controlValue contains a BER-encoded BOOLEAN indicating 34 * visibility. A controlValue containing the value TRUE indicates that 35 * subentries are visible and normal entries are not. A controlValue 36 * containing the value FALSE indicates that normal entries are visible 37 * and subentries are not. 38 * 39 * Note that TRUE visibility has the three octet encoding { 01 01 FF } 40 * and FALSE visibility has the three octet encoding { 01 01 00 }. 41 * 42 * The controlValue SHALL NOT be absent. 43 * 44 * In absence of this control, subentries are not visible to singleLevel 45 * and wholeSubtree scope Search requests but are visible to baseObject 46 * scope Search requests. 47 * 48 * There is no corresponding response control. 49 * 50 * This control is not appropriate for non-Search operations. 51 * 52 * 53 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 54 */ 55 public class SubentriesImpl extends AbstractControl implements Subentries 56 { 57 private boolean visibility = false; 58 59 60 /** 61 * Default constructor 62 */ 63 public SubentriesImpl() 64 { 65 super( OID ); 66 } 67 68 69 /** 70 * returns Tells if the Subentry values are visible or not 71 */ 72 public boolean isVisible() 73 { 74 return visibility; 75 } 76 77 78 /** 79 * @param visibility Set the visibility flag 80 */ 81 public void setVisibility( boolean visibility ) 82 { 83 this.visibility = visibility; 84 } 85 86 87 /** 88 * @see Object#hashCode() 89 */ 90 @Override 91 public int hashCode() 92 { 93 int h = super.hashCode(); 94 95 h = h * 37 + ( visibility ? 1 : 0 ); 96 97 return h; 98 } 99 100 101 /** 102 * @see Object#equals(Object) 103 */ 104 public boolean equals( Object o ) 105 { 106 if ( !super.equals( o ) ) 107 { 108 return false; 109 } 110 111 Subentries otherDecorator = ( Subentries ) o; 112 113 return ( visibility == otherDecorator.isVisible() ); 114 } 115 116 117 /** 118 * Return a String representing this EntryChangeControl. 119 */ 120 public String toString() 121 { 122 StringBuffer sb = new StringBuffer(); 123 124 sb.append( " Subentries Control\n" ); 125 sb.append( " oid : " ).append( getOid() ).append( '\n' ); 126 sb.append( " critical : " ).append( isCritical() ).append( '\n' ); 127 sb.append( " Visibility : '" ).append( visibility ).append( "'\n" ); 128 129 return sb.toString(); 130 } 131 }