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.codec.search; 021 022 023import java.nio.ByteBuffer; 024 025import org.apache.directory.api.asn1.EncoderException; 026 027 028/** 029 * An abstract Asn1Object used to store the filter. A filter is seen as a tree 030 * with a root. This class does nothing, it's just the root of all the different 031 * filters. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public abstract class Filter 036{ 037 /** The identifier of the associated TLV */ 038 int tlvId; 039 040 /** The parent TLV id */ 041 protected int parentTlvId; 042 043 /** The parent Filter */ 044 protected Filter parent; 045 046 047 /** 048 * The constructor. 049 */ 050 public Filter( int tlvId ) 051 { 052 this.tlvId = tlvId; 053 } 054 055 056 /** 057 * The constructor. 058 */ 059 public Filter() 060 { 061 } 062 063 064 /** 065 * Get the parent 066 * 067 * @return Returns the parent. 068 */ 069 public Filter getParent() 070 { 071 return parent; 072 } 073 074 075 /** 076 * Get the parent 077 * 078 * @return Returns the parent. 079 */ 080 public int getParentTlvId() 081 { 082 return parentTlvId; 083 } 084 085 086 /** 087 * Set the parent 088 * 089 * @param parent The parent to set. 090 */ 091 public void setParent( Filter parent, int parentTlvId ) 092 { 093 this.parent = parent; 094 this.parentTlvId = parentTlvId; 095 } 096 097 098 public int getTlvId() 099 { 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}