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.codec.search; 21 22 23 import java.nio.ByteBuffer; 24 25 import org.apache.directory.api.asn1.EncoderException; 26 27 28 /** 29 * An abstract Asn1Object used to store the filter. A filter is seen as a tree 30 * with a root. This class does nothing, it's just the root of all the different 31 * filters. 32 * 33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 34 */ 35 public abstract class Filter 36 { 37 /** The identifier of the associated TLV */ 38 int tlvId; 39 40 /** The parent TLV id */ 41 protected int parentTlvId; 42 43 /** The parent Filter */ 44 protected Filter parent; 45 46 47 /** 48 * The constructor. 49 */ 50 public Filter( int tlvId ) 51 { 52 this.tlvId = tlvId; 53 } 54 55 56 /** 57 * The constructor. 58 */ 59 public Filter() 60 { 61 } 62 63 64 /** 65 * Get the parent 66 * 67 * @return Returns the parent. 68 */ 69 public Filter getParent() 70 { 71 return parent; 72 } 73 74 75 /** 76 * Get the parent 77 * 78 * @return Returns the parent. 79 */ 80 public int getParentTlvId() 81 { 82 return parentTlvId; 83 } 84 85 86 /** 87 * Set the parent 88 * 89 * @param parent The parent to set. 90 */ 91 public void setParent( Filter parent, int parentTlvId ) 92 { 93 this.parent = parent; 94 this.parentTlvId = parentTlvId; 95 } 96 97 98 public int getTlvId() 99 { 100 return tlvId; 101 } 102 103 104 /** 105 * Compute the Filter length 106 */ 107 public abstract int computeLength(); 108 109 110 /** 111 * Encode the Filter message to a PDU. 112 * @param buffer The buffer where to put the PDU 113 * @return The PDU. 114 */ 115 public abstract ByteBuffer encode( ByteBuffer buffer ) throws EncoderException; 116 }