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
021package org.apache.directory.api.ldap.model.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 */
030public interface ExprNode extends Cloneable
031{
032    /**
033     * Gets an annotation on the tree by key.
034     * 
035     * @param key the annotation key.
036     * @return the annotation value.
037     */
038    Object get( Object key );
039
040
041    /**
042     * Sets a annotation key to a value.
043     * 
044     * @param key the annotation key.
045     * @param value the annotation value.
046     */
047    void set( String key, Object value );
048
049
050    /**
051     * Tests to see if this node is a leaf or branch node.
052     * 
053     * @return true if the node is a leaf,false otherwise
054     */
055    boolean isLeaf();
056
057
058    /**
059     * Tells if this Node is Schema aware.
060     * 
061     * @return true if the Node is SchemaAware
062     */
063    boolean isSchemaAware();
064
065
066    /**
067     * Gets the assertion type of this node. Make it possible to use switch
068     * statements on the node type.
069     * 
070     * @return the assertion type
071     */
072    AssertionType getAssertionType();
073
074
075    /**
076     * Recursively appends the refinement string representation of this node and its
077     * descendants in prefix notation to a buffer.
078     *
079     * @param buf the buffer to append to.
080     * @return The buffer in which the refinement has been appended
081     * @throws UnsupportedOperationException if this node isn't a part of a refinement.
082     */
083    StringBuilder printRefinementToBuffer( StringBuilder buf );
084
085
086    /**
087     * Element/node accept method for visitor pattern.
088     * 
089     * @param visitor the filter expression tree structure visitor
090     * @return the modified element
091     */
092    Object accept( FilterVisitor visitor );
093
094
095    /**
096     * Clone this expression node.
097     * 
098     * @return the cloned expression node
099     */
100    ExprNode clone();
101}