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 * @param tlvId The TLV identifier 51 */ 52 public Filter( int tlvId ) 53 { 54 this.tlvId = tlvId; 55 } 56 57 58 /** 59 * The constructor. 60 */ 61 public Filter() 62 { 63 } 64 65 66 /** 67 * Get the parent 68 * 69 * @return Returns the parent. 70 */ 71 public Filter getParent() 72 { 73 return parent; 74 } 75 76 77 /** 78 * Get the parent 79 * 80 * @return Returns the parent. 81 */ 82 public int getParentTlvId() 83 { 84 return parentTlvId; 85 } 86 87 88 /** 89 * Set the parent 90 * 91 * @param parent The parent to set. 92 * @param parentTlvId The Parent TLV identifier 93 */ 94 public void setParent( Filter parent, int parentTlvId ) 95 { 96 this.parent = parent; 97 this.parentTlvId = parentTlvId; 98 } 99 100 101 /** 102 * @return The TLV identifier 103 */ 104 public int getTlvId() 105 { 106 return tlvId; 107 } 108 109 110 /** 111 * Compute the Filter length 112 * 113 * @return the encoded length 114 */ 115 public abstract int computeLength(); 116 117 118 /** 119 * Encode the Filter message to a PDU. 120 * 121 * @param buffer The buffer where to put the PDU 122 * @return The PDU. 123 * @throws EncoderException If the encoding failed 124 */ 125 public abstract ByteBuffer encode( ByteBuffer buffer ) throws EncoderException; 126 }