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 */
020
021 package org.apache.directory.shared.ldap.filter;
022
023
024 /**
025 * Root expression node interface which all expression nodes in the filter
026 * expression tree implement.
027 *
028 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
029 * @version $Revision: 746607 $
030 */
031 public interface ExprNode extends Cloneable
032 {
033 /**
034 * Gets an annotation on the tree by key.
035 *
036 * @param key the annotation key.
037 * @return the annotation value.
038 */
039 Object get( Object key );
040
041
042 /**
043 * Sets a annotation key to a value.
044 *
045 * @param key the annotation key.
046 * @param value the annotation value.
047 */
048 void set( String key, Object value );
049
050
051 /**
052 * Tests to see if this node is a leaf or branch node.
053 *
054 * @return true if the node is a leaf,false otherwise
055 */
056 boolean isLeaf();
057
058
059 /**
060 * Gets the assertion type of this node. Make it possible to use switch
061 * statements on the node type.
062 *
063 * @return the assertion type
064 */
065 AssertionType getAssertionType();
066
067 /**
068 * Recursively appends the refinement string representation of this node and its
069 * descendants in prefix notation to a buffer.
070 *
071 * TODO - Why is this here? Why not put it in some utility class?
072 *
073 * @param buf the buffer to append to.
074 * @return The buffer in which the refinement has been appended
075 * @throws UnsupportedOperationException if this node isn't a part of a refinement.
076 * @return the refinement buffer
077 */
078 StringBuilder printRefinementToBuffer( StringBuilder buf );
079
080
081 /**
082 * Element/node accept method for visitor pattern.
083 *
084 * @param visitor the filter expression tree structure visitor
085 * TODO - what is this modified element ?
086 * @return the modified element
087 */
088 Object accept( FilterVisitor visitor );
089
090
091 /**
092 * Clone the object
093 * @return
094 */
095 ExprNode clone();
096 }