add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / queryparser / src / java / org / apache / lucene / queryParser / core / nodes / QueryNode.java
1 package org.apache.lucene.queryParser.core.nodes;
2
3 /**
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 import java.io.Serializable;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax;
25
26 /**
27  * A {@link QueryNode} is a interface implemented by all nodes on a QueryNode
28  * tree.
29  */
30 public interface QueryNode extends Serializable {
31
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);
35
36   /** for printing */
37   public String toString();
38
39   /** get Children nodes */
40   public List<QueryNode> getChildren();
41
42   /** verify if a node is a Leaf node */
43   public boolean isLeaf();
44
45   /** verify if a node contains a tag */
46   public boolean containsTag(String tagName);
47   
48   /** verify if a node contains a tag 
49    * @deprecated use {@link #containsTag(String)} instead
50    */
51   @Deprecated
52   public boolean containsTag(CharSequence tagName);
53
54   /**
55    * @param tagName
56    * @return of stored on under that tag name
57    */
58   public Object getTag(String tagName);
59   
60   /**
61    * @param tagName
62    * @return of stored on under that tag name
63    * 
64    * @deprecated use {@link #getTag(String)} instead
65    */
66   @Deprecated
67   public Object getTag(CharSequence tagName);
68
69   public QueryNode getParent();
70
71   /**
72    * Recursive clone the QueryNode tree The tags are not copied to the new tree
73    * when you call the cloneTree() method
74    * 
75    * @return the cloned tree
76    * @throws CloneNotSupportedException
77    */
78   public QueryNode cloneTree() throws CloneNotSupportedException;
79
80   // Below are the methods that can change state of a QueryNode
81   // Write Operations (not Thread Safe)
82
83   // add a new child to a non Leaf node
84   public void add(QueryNode child);
85
86   public void add(List<QueryNode> children);
87
88   // reset the children of a node
89   public void set(List<QueryNode> children);
90
91   /**
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.
95    * 
96    * @param tagName
97    * @param value
98    */
99   public void setTag(String tagName, Object value);
100   
101   /**
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.
105    * 
106    * @param tagName
107    * @param value
108    * 
109    * @deprecated use {@link #setTag(String, Object)} instead
110    */
111   @Deprecated
112   public void setTag(CharSequence tagName, Object value);
113
114   /**
115    * Unset a tag. tagName will be converted to lowercase.
116    * 
117    * @param tagName
118    */
119   public void unsetTag(String tagName);
120   
121   /**
122    * Unset a tag. tagName will be converted to lowercase.
123    * 
124    * @param tagName
125    * 
126    * @deprecated use {@link #unsetTag(String)} instead
127    */
128   @Deprecated
129   public void unsetTag(CharSequence tagName);
130
131   /**
132    * Returns a map containing all tags attached to this query node. 
133    * 
134    * @return a map containing all tags attached to this query node
135    * 
136    * @deprecated use {@link #getTagMap()}
137    */
138   @Deprecated
139   public Map<CharSequence, Object> getTags();
140   
141   /**
142    * Returns a map containing all tags attached to this query node. 
143    * 
144    * @return a map containing all tags attached to this query node
145    */
146   public Map<String, Object> getTagMap();
147
148 }