1 package org.apache.lucene.queryParser.core.nodes;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.io.Serializable;
21 import java.util.List;
24 import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax;
27 * A {@link QueryNode} is a interface implemented by all nodes on a QueryNode
30 public interface QueryNode extends Serializable {
32 /** convert to a query string understood by the query parser */
33 // TODO: this interface might be changed in the future
34 public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser);
37 public String toString();
39 /** get Children nodes */
40 public List<QueryNode> getChildren();
42 /** verify if a node is a Leaf node */
43 public boolean isLeaf();
45 /** verify if a node contains a tag */
46 public boolean containsTag(String tagName);
48 /** verify if a node contains a tag
49 * @deprecated use {@link #containsTag(String)} instead
52 public boolean containsTag(CharSequence tagName);
56 * @return of stored on under that tag name
58 public Object getTag(String tagName);
62 * @return of stored on under that tag name
64 * @deprecated use {@link #getTag(String)} instead
67 public Object getTag(CharSequence tagName);
69 public QueryNode getParent();
72 * Recursive clone the QueryNode tree The tags are not copied to the new tree
73 * when you call the cloneTree() method
75 * @return the cloned tree
76 * @throws CloneNotSupportedException
78 public QueryNode cloneTree() throws CloneNotSupportedException;
80 // Below are the methods that can change state of a QueryNode
81 // Write Operations (not Thread Safe)
83 // add a new child to a non Leaf node
84 public void add(QueryNode child);
86 public void add(List<QueryNode> children);
88 // reset the children of a node
89 public void set(List<QueryNode> children);
92 * Associate the specified value with the specified tagName. If the tagName
93 * already exists, the old value is replaced. The tagName and value cannot be
94 * null. tagName will be converted to lowercase.
99 public void setTag(String tagName, Object value);
102 * Associate the specified value with the specified tagName. If the tagName
103 * already exists, the old value is replaced. The tagName and value cannot be
104 * null. tagName will be converted to lowercase.
109 * @deprecated use {@link #setTag(String, Object)} instead
112 public void setTag(CharSequence tagName, Object value);
115 * Unset a tag. tagName will be converted to lowercase.
119 public void unsetTag(String tagName);
122 * Unset a tag. tagName will be converted to lowercase.
126 * @deprecated use {@link #unsetTag(String)} instead
129 public void unsetTag(CharSequence tagName);
132 * Returns a map containing all tags attached to this query node.
134 * @return a map containing all tags attached to this query node
136 * @deprecated use {@link #getTagMap()}
139 public Map<CharSequence, Object> getTags();
142 * Returns a map containing all tags attached to this query node.
144 * @return a map containing all tags attached to this query node
146 public Map<String, Object> getTagMap();