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.util.List;
22
import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax;
25
* A {@link TokenizedPhraseQueryNode} represents a node created by a code that
26
* tokenizes/lemmatizes/analyzes.
28
public class TokenizedPhraseQueryNode extends QueryNodeImpl implements
31
private static final long serialVersionUID = -7185108320787917541L;
33
public TokenizedPhraseQueryNode() {
39
public String toString() {
40
if (getChildren() == null || getChildren().size() == 0)
41
return "<tokenizedphrase/>";
42
StringBuilder sb = new StringBuilder();
43
sb.append("<tokenizedtphrase>");
44
for (QueryNode child : getChildren()) {
46
sb.append(child.toString());
48
sb.append("\n</tokenizedphrase>");
52
// This text representation is not re-parseable
53
public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) {
54
if (getChildren() == null || getChildren().size() == 0)
57
StringBuilder sb = new StringBuilder();
59
for (QueryNode child : getChildren()) {
60
sb.append(filler).append(child.toQueryString(escapeSyntaxParser));
64
return "[TP[" + sb.toString() + "]]";
68
public QueryNode cloneTree() throws CloneNotSupportedException {
69
TokenizedPhraseQueryNode clone = (TokenizedPhraseQueryNode) super
77
public CharSequence getField() {
78
List<QueryNode> children = getChildren();
80
if (children == null || children.size() == 0) {
84
return ((FieldableNode) children.get(0)).getField();
89
public void setField(CharSequence fieldName) {
90
List<QueryNode> children = getChildren();
92
if (children != null) {
94
for (QueryNode child : getChildren()) {
96
if (child instanceof FieldableNode) {
97
((FieldableNode) child).setField(fieldName);
106
} // end class MultitermQueryNode