You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by bu...@apache.org on 2009/08/03 05:38:50 UTC
svn commit: r800191 [6/12] - in /lucene/java/trunk: ./ contrib/
contrib/queryparser/ contrib/queryparser/src/ contrib/queryparser/src/java/
contrib/queryparser/src/java/org/ contrib/queryparser/src/java/org/apache/
contrib/queryparser/src/java/org/apac...
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,36 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.PhraseSlopQueryNodeProcessor;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by {@link PhraseSlopQueryNodeProcessor} processor and
+ * must be defined in the {@link QueryConfigHandler}. This attribute tells the
+ * processor what is the default phrase slop when no slop is defined in a
+ * phrase. <br/>
+ *
+ */
+public interface FuzzyAttribute extends Attribute {
+ public void setPrefixLength(int prefixLength);
+ public int getPrefixLength();
+ public void setFuzzyMinSimilarity(float minSimilarity);
+ public float getFuzzyMinSimilarity();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,91 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.PhraseSlopQueryNodeProcessor;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by {@link PhraseSlopQueryNodeProcessor} processor and
+ * must be defined in the {@link QueryConfigHandler}. This attribute tells the
+ * processor what is the default phrase slop when no slop is defined in a
+ * phrase. <br/>
+ *
+ * @see org.apache.lucene.queryParser.original.config.FuzzyAttribute
+ */
+public class FuzzyAttributeImpl extends AttributeImpl
+ implements FuzzyAttribute {
+
+ private static final long serialVersionUID = -2104763012527049527L;
+
+ private int prefixLength = FuzzyQuery.defaultPrefixLength;
+
+ private float minSimilarity = FuzzyQuery.defaultMinSimilarity;
+
+ public FuzzyAttributeImpl() {
+ // empty constructor
+ }
+
+ public void setPrefixLength(int prefixLength) {
+ this.prefixLength = prefixLength;
+ }
+
+ public int getPrefixLength() {
+ return this.prefixLength;
+ }
+
+ public void setFuzzyMinSimilarity(float minSimilarity) {
+ this.minSimilarity = minSimilarity;
+ }
+
+ public float getFuzzyMinSimilarity() {
+ return this.minSimilarity;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof FuzzyAttributeImpl && other != null
+ && ((FuzzyAttributeImpl) other).prefixLength == this.prefixLength) {
+
+ return true;
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return Integer.valueOf(this.prefixLength).hashCode();
+ }
+
+ public String toString() {
+ return "<fuzzyAttribute prefixLength=" + this.prefixLength + "/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/FuzzyAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,35 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Locale;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by processor {@link ParametricRangeQueryNodeProcessor}
+ * and must be defined in the {@link QueryConfigHandler}. This attribute tells
+ * the processor what is the default {@link Locale} used to parse a date. <br/>
+ *
+ */
+public interface LocaleAttribute extends Attribute {
+ public void setLocale(Locale locale);
+ public Locale getLocale();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,87 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Locale;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by processor {@link ParametricRangeQueryNodeProcessor}
+ * and must be defined in the {@link QueryConfigHandler}. This attribute tells
+ * the processor what is the default {@link Locale} used to parse a date. <br/>
+ *
+ * @see org.apache.lucene.queryParser.original.config.LocaleAttribute
+ */
+public class LocaleAttributeImpl extends AttributeImpl
+ implements LocaleAttribute {
+
+ private static final long serialVersionUID = -6804760312720049526L;
+
+ private Locale locale = Locale.getDefault();
+
+ public LocaleAttributeImpl() {
+ locale = Locale.getDefault(); //default in 2.4
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public Locale getLocale() {
+ return this.locale;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof LocaleAttributeImpl) {
+ LocaleAttributeImpl localeAttr = (LocaleAttributeImpl) other;
+
+ if (localeAttr.locale == this.locale
+ || (this.locale != null && localeAttr.locale != null && this.locale
+ .equals(localeAttr.locale))) {
+
+ return true;
+
+ }
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return (this.locale == null) ? 0 : this.locale.hashCode();
+ }
+
+ public String toString() {
+ return "<localeAttribute locale=" + this.locale + "/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LocaleAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,35 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Locale;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by processor {@link ParametricRangeQueryNodeProcessor}
+ * and must be defined in the {@link QueryConfigHandler}. This attribute tells
+ * the processor what is the default {@link Locale} used to parse a date. <br/>
+ *
+ */
+public interface LowercaseExpandedTermsAttribute extends Attribute {
+ public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms);
+ public boolean isLowercaseExpandedTerms();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,82 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Locale;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by processor {@link ParametricRangeQueryNodeProcessor}
+ * and must be defined in the {@link QueryConfigHandler}. This attribute tells
+ * the processor what is the default {@link Locale} used to parse a date. <br/>
+ *
+ * @see org.apache.lucene.queryParser.original.config.LowercaseExpandedTermsAttribute
+ */
+public class LowercaseExpandedTermsAttributeImpl extends AttributeImpl
+ implements LowercaseExpandedTermsAttribute {
+
+ private static final long serialVersionUID = -2804760312723049527L;
+
+ private boolean lowercaseExpandedTerms = true;
+
+ public LowercaseExpandedTermsAttributeImpl() {
+ lowercaseExpandedTerms = true; // default in 2.4
+ }
+
+ public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms) {
+ this.lowercaseExpandedTerms = lowercaseExpandedTerms;
+ }
+
+ public boolean isLowercaseExpandedTerms() {
+ return this.lowercaseExpandedTerms;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof LowercaseExpandedTermsAttributeImpl
+ && ((LowercaseExpandedTermsAttributeImpl) other).lowercaseExpandedTerms == this.lowercaseExpandedTerms) {
+
+ return true;
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return this.lowercaseExpandedTerms ? -1 : Integer.MAX_VALUE;
+ }
+
+ public String toString() {
+ return "<lowercaseExpandedTerms lowercaseExpandedTerms="
+ + this.lowercaseExpandedTerms + "/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/LowercaseExpandedTermsAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,33 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.MultiFieldQueryNodeProcessor;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by {@link MultiFieldQueryNodeProcessor} processor and
+ * must be defined in the {@link QueryConfigHandler}. This attribute tells the
+ * processor to which fields the terms in the query should be expanded. <br/>
+ *
+ */
+public interface MultiFieldAttribute extends Attribute {
+ public void setFields(CharSequence[] fields);
+ public CharSequence[] getFields();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,81 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.MultiFieldQueryNodeProcessor;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by {@link MultiFieldQueryNodeProcessor} processor and
+ * must be defined in the {@link QueryConfigHandler}. This attribute tells the
+ * processor to which fields the terms in the query should be expanded. <br/>
+ *
+ * @see org.apache.lucene.queryParser.original.config.MultiFieldAttribute
+ */
+public class MultiFieldAttributeImpl extends AttributeImpl
+ implements MultiFieldAttribute {
+
+ private static final long serialVersionUID = -6809760312720049526L;
+
+ private CharSequence[] fields;
+
+ public MultiFieldAttributeImpl() {
+ // empty constructor
+ }
+
+ public void setFields(CharSequence[] fields) {
+ this.fields = fields;
+ }
+
+ public CharSequence[] getFields() {
+ return this.fields;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof MultiFieldAttributeImpl) {
+ MultiFieldAttributeImpl fieldsAttr = (MultiFieldAttributeImpl) other;
+
+ return Arrays.equals(this.fields, fieldsAttr.fields);
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return Arrays.hashCode(this.fields);
+ }
+
+ public String toString() {
+ return "<fieldsAttribute fields=" + Arrays.toString(this.fields) + "/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiFieldAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,37 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.search.MultiTermQuery;
+import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
+ * and should be defined in the {@link QueryConfigHandler} used by this
+ * processor. It basically tells the processor which {@link RewriteMethod} to
+ * use. <br/>
+ *
+ */
+public interface MultiTermRewriteMethodAttribute extends Attribute {
+ public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method);
+
+ public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,83 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.search.MultiTermQuery;
+import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
+ * and should be defined in the {@link QueryConfigHandler} used by this
+ * processor. It basically tells the processor which {@link RewriteMethod} to
+ * use. <br/>
+ *
+ * @see MultiTermRewriteMethodAttribute
+ */
+public class MultiTermRewriteMethodAttributeImpl extends AttributeImpl
+ implements MultiTermRewriteMethodAttribute {
+
+ private static final long serialVersionUID = -2104763012723049527L;
+
+ private MultiTermQuery.RewriteMethod multiTermRewriteMethod = MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
+
+ public MultiTermRewriteMethodAttributeImpl() {
+ // empty constructor
+ }
+
+ public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
+ multiTermRewriteMethod = method;
+ }
+
+ public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
+ return multiTermRewriteMethod;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof MultiTermRewriteMethodAttributeImpl
+ && ((MultiTermRewriteMethodAttributeImpl) other).multiTermRewriteMethod == this.multiTermRewriteMethod) {
+
+ return true;
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return multiTermRewriteMethod.hashCode();
+ }
+
+ public String toString() {
+ return "<multiTermRewriteMethod multiTermRewriteMethod="
+ + this.multiTermRewriteMethod + "/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/MultiTermRewriteMethodAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/OriginalQueryConfigHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/OriginalQueryConfigHandler.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/OriginalQueryConfigHandler.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/OriginalQueryConfigHandler.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,55 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.OriginalQueryNodeProcessorPipeline;
+
+/**
+ * This query configuration handler is used for almost every processor defined
+ * in the {@link OriginalQueryNodeProcessorPipeline} processor pipeline. It holds
+ * attributes that reproduces the configuration that could be set on the old
+ * lucene 2.4 QueryParser class. <br/>
+ *
+ * @see OriginalQueryNodeProcessorPipeline
+ */
+public class OriginalQueryConfigHandler extends QueryConfigHandler {
+
+
+
+ public OriginalQueryConfigHandler() {
+ // Add listener that will build the FieldConfig attributes.
+ addFieldConfigListener(new FieldBoostMapFCListener(this));
+ addFieldConfigListener(new FieldDateResolutionFCListener(this));
+
+ // Default Values
+ addAttribute(RangeCollatorAttribute.class);
+ addAttribute(DefaultOperatorAttribute.class);
+ addAttribute(AnalyzerAttribute.class);
+ addAttribute(FuzzyAttribute.class);
+ addAttribute(LowercaseExpandedTermsAttribute.class);
+ addAttribute(MultiTermRewriteMethodAttribute.class);
+ addAttribute(AllowLeadingWildcardAttribute.class);
+ addAttribute(PositionIncrementsAttribute.class);
+ addAttribute(LocaleAttribute.class);
+ addAttribute(DefaultPhraseSlopAttribute.class);
+ //addAttribute(DateResolutionAttribute.class);
+
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/OriginalQueryConfigHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,33 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.AnalyzerQueryNodeProcessor;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
+ * must be defined in the {@link QueryConfigHandler}. This attribute tells the
+ * processor if the position increment is enabled. <br/>
+ *
+ */
+public interface PositionIncrementsAttribute extends Attribute {
+ public void setPositionIncrementsEnabled(boolean positionIncrementsEnabled);
+ public boolean isPositionIncrementsEnabled();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,81 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.AnalyzerQueryNodeProcessor;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by {@link AnalyzerQueryNodeProcessor} processor and
+ * must be defined in the {@link QueryConfigHandler}. This attribute tells the
+ * processor if the position increment is enabled. <br/>
+ *
+ * @see org.apache.lucene.queryParser.original.config.PositionIncrementsAttribute
+ */
+public class PositionIncrementsAttributeImpl extends AttributeImpl
+ implements PositionIncrementsAttribute {
+
+ private static final long serialVersionUID = -2804763012793049527L;
+
+ private boolean positionIncrementsEnabled = false;
+
+ public PositionIncrementsAttributeImpl() {
+ positionIncrementsEnabled = false; //default in 2.4
+ }
+
+ public void setPositionIncrementsEnabled(boolean positionIncrementsEnabled) {
+ this.positionIncrementsEnabled = positionIncrementsEnabled;
+ }
+
+ public boolean isPositionIncrementsEnabled() {
+ return this.positionIncrementsEnabled;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof PositionIncrementsAttributeImpl
+ && other != null
+ && ((PositionIncrementsAttributeImpl) other).positionIncrementsEnabled == this.positionIncrementsEnabled) {
+
+ return true;
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return this.positionIncrementsEnabled ? -1 : Integer.MAX_VALUE;
+ }
+
+ public String toString() {
+ return "<positionIncrements positionIncrementsEnabled="
+ + this.positionIncrementsEnabled + "/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/PositionIncrementsAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttribute.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttribute.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttribute.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttribute.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,37 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.text.Collator;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.search.TermRangeQuery;
+import org.apache.lucene.util.Attribute;
+
+/**
+ * This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
+ * and must be defined in the {@link QueryConfigHandler}. This attribute tells
+ * the processor which {@link Collator} should be used for a
+ * {@link TermRangeQuery} <br/>
+ *
+ */
+public interface RangeCollatorAttribute extends Attribute {
+ public void setDateResolution(Collator rangeCollator);
+ public Collator getRangeCollator();
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttributeImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttributeImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttributeImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,89 @@
+package org.apache.lucene.queryParser.original.config;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.text.Collator;
+
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.search.TermRangeQuery;
+import org.apache.lucene.util.AttributeImpl;
+
+/**
+ * This attribute is used by {@link ParametricRangeQueryNodeProcessor} processor
+ * and must be defined in the {@link QueryConfigHandler}. This attribute tells
+ * the processor which {@link Collator} should be used for a
+ * {@link TermRangeQuery} <br/>
+ *
+ * @see org.apache.lucene.queryParser.original.config.RangeCollatorAttribute
+ */
+public class RangeCollatorAttributeImpl extends AttributeImpl
+ implements RangeCollatorAttribute {
+
+ private static final long serialVersionUID = -6804360312723049526L;
+
+ private Collator rangeCollator;
+
+ public RangeCollatorAttributeImpl() {
+ rangeCollator = null; // default value for 2.4
+ }
+
+ public void setDateResolution(Collator rangeCollator) {
+ this.rangeCollator = rangeCollator;
+ }
+
+ public Collator getRangeCollator() {
+ return this.rangeCollator;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void copyTo(AttributeImpl target) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean equals(Object other) {
+
+ if (other instanceof RangeCollatorAttributeImpl) {
+ RangeCollatorAttributeImpl rangeCollatorAttr = (RangeCollatorAttributeImpl) other;
+
+ if (rangeCollatorAttr.rangeCollator == this.rangeCollator
+ || rangeCollatorAttr.rangeCollator.equals(this.rangeCollator)) {
+
+ return true;
+
+ }
+
+ }
+
+ return false;
+
+ }
+
+ public int hashCode() {
+ return (this.rangeCollator == null) ? 0 : this.rangeCollator.hashCode();
+ }
+
+ public String toString() {
+ return "<rangeCollatorAttribute rangeCollator='" + this.rangeCollator
+ + "'/>";
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/RangeCollatorAttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/package.html?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/package.html (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/package.html Mon Aug 3 03:38:44 2009
@@ -0,0 +1,34 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<body>
+
+<h2>Original Lucene Query Configuration</h2>
+<p>
+The package org.apache.lucene.queryParser.original.config contains the Lucene
+query configuration handler and all the attributes used by it. This configuration
+handler reproduces almost everything that could be set on the old query parser.
+</p>
+<p>
+OriginalQueryConfigHandler is the class that should be used to configure the OriginalQueryNodeProcessorPipeline.
+</p>
+</body>
+</html>
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/config/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/BooleanModifierNode.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/BooleanModifierNode.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/BooleanModifierNode.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/BooleanModifierNode.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,39 @@
+package org.apache.lucene.queryParser.original.nodes;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.original.processors.GroupQueryNodeProcessor;
+
+/**
+ * A {@link BooleanModifierNode} has the same behaviour as
+ * {@link ModifierQueryNode}, it only indicates that this modifier was added by
+ * {@link GroupQueryNodeProcessor} and not by the user. <br/>
+ *
+ * @see ModifierQueryNode
+ */
+public class BooleanModifierNode extends ModifierQueryNode {
+
+ private static final long serialVersionUID = -557816496416587068L;
+
+ public BooleanModifierNode(QueryNode node, Modifier mod) {
+ super(node, mod);
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/BooleanModifierNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/MultiPhraseQueryNode.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/MultiPhraseQueryNode.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/MultiPhraseQueryNode.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/MultiPhraseQueryNode.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,108 @@
+package org.apache.lucene.queryParser.original.nodes;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.lucene.queryParser.core.nodes.FieldableNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNodeImpl;
+import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax;
+import org.apache.lucene.search.MultiPhraseQuery;
+import org.apache.lucene.search.PhraseQuery;
+
+/**
+ * A {@link MultiPhraseQueryNode} indicates that its children should be used to
+ * build a {@link MultiPhraseQuery} instead of {@link PhraseQuery}.
+ */
+public class MultiPhraseQueryNode extends QueryNodeImpl implements
+ FieldableNode {
+
+ private static final long serialVersionUID = -2138501723963320158L;
+
+ public MultiPhraseQueryNode() {
+ setLeaf(false);
+ allocate();
+
+ }
+
+ public String toString() {
+ if (getChildren() == null || getChildren().size() == 0)
+ return "<multiPhrase/>";
+ StringBuilder sb = new StringBuilder();
+ sb.append("<multiPhrase>");
+ for (QueryNode child : getChildren()) {
+ sb.append("\n");
+ sb.append(child.toString());
+ }
+ sb.append("\n</multiPhrase>");
+ return sb.toString();
+ }
+
+ public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) {
+ if (getChildren() == null || getChildren().size() == 0)
+ return "";
+
+ StringBuilder sb = new StringBuilder();
+ String filler = "";
+ for (QueryNode child : getChildren()) {
+ sb.append(filler).append(child.toQueryString(escapeSyntaxParser));
+ filler = ",";
+ }
+
+ return "[MTP[" + sb.toString() + "]]";
+ }
+
+ public QueryNode cloneTree() throws CloneNotSupportedException {
+ MultiPhraseQueryNode clone = (MultiPhraseQueryNode) super.cloneTree();
+
+ // nothing to do
+
+ return clone;
+ }
+
+ public CharSequence getField() {
+ List<QueryNode> children = getChildren();
+
+ if (children == null || children.size() == 0) {
+ return null;
+
+ } else {
+ return ((FieldableNode) children.get(0)).getField();
+ }
+
+ }
+
+ public void setField(CharSequence fieldName) {
+ List<QueryNode> children = getChildren();
+
+ if (children != null) {
+
+ for (QueryNode child : children) {
+
+ if (child instanceof FieldableNode) {
+ ((FieldableNode) child).setField(fieldName);
+ }
+
+ }
+
+ }
+
+ }
+
+} // end class MultitermQueryNode
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/MultiPhraseQueryNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/OriginalBooleanQueryNode.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/OriginalBooleanQueryNode.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/OriginalBooleanQueryNode.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/OriginalBooleanQueryNode.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,55 @@
+package org.apache.lucene.queryParser.original.nodes;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.lucene.queryParser.core.nodes.BooleanQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Similarity;
+
+/**
+ * A {@link OriginalBooleanQueryNode} has the same behavior as
+ * {@link BooleanQueryNode}. It only indicates if the coord should be enabled or
+ * not for this boolean query. <br/>
+ *
+ * @see Similarity#coord(int, int)
+ * @see BooleanQuery
+ */
+public class OriginalBooleanQueryNode extends BooleanQueryNode {
+
+ private static final long serialVersionUID = 1938287817191138787L;
+
+ private boolean disableCoord;
+
+ /**
+ * @param clauses
+ */
+ public OriginalBooleanQueryNode(List<QueryNode> clauses, boolean disableCoord) {
+ super(clauses);
+
+ this.disableCoord = disableCoord;
+
+ }
+
+ public boolean isDisableCoord() {
+ return this.disableCoord;
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/OriginalBooleanQueryNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/RangeQueryNode.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/RangeQueryNode.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/RangeQueryNode.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/RangeQueryNode.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,80 @@
+package org.apache.lucene.queryParser.original.nodes;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.text.Collator;
+
+import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode;
+import org.apache.lucene.queryParser.core.nodes.ParametricRangeQueryNode;
+import org.apache.lucene.queryParser.original.config.RangeCollatorAttribute;
+import org.apache.lucene.queryParser.original.processors.ParametricRangeQueryNodeProcessor;
+import org.apache.lucene.search.MultiTermQuery;
+
+/**
+ * This query node represents a range query. It also holds which collator will
+ * be used by the range query and if the constant score rewrite is enabled. <br/>
+ *
+ * @see ParametricRangeQueryNodeProcessor
+ * @see RangeCollatorAttribute
+ * @see org.apache.lucene.search.RangeQuery
+ */
+public class RangeQueryNode extends ParametricRangeQueryNode {
+
+ private static final long serialVersionUID = 7400866652044314657L;
+
+ private Collator collator;
+
+ private MultiTermQuery.RewriteMethod multiTermRewriteMethod;
+
+ /**
+ * @param lower
+ * @param upper
+ */
+ public RangeQueryNode(ParametricQueryNode lower, ParametricQueryNode upper,
+ Collator collator, MultiTermQuery.RewriteMethod multiTermRewriteMethod) {
+ super(lower, upper);
+
+ this.multiTermRewriteMethod = multiTermRewriteMethod;
+ this.collator = collator;
+
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder("<range>\n\t");
+ sb.append(this.getUpperBound()).append("\n\t");
+ sb.append(this.getLowerBound()).append("\n");
+ sb.append("</range>\n");
+
+ return sb.toString();
+
+ }
+
+ /**
+ * @return the collator
+ */
+ public Collator getCollator() {
+ return this.collator;
+ }
+
+ /**
+ * @return the rewrite method
+ */
+ public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
+ return multiTermRewriteMethod;
+ }
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/RangeQueryNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/package.html?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/package.html (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/package.html Mon Aug 3 03:38:44 2009
@@ -0,0 +1,31 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<body>
+
+<h2>Original Lucene Query Nodes</h2>
+<p>
+The package org.apache.lucene.queryParser.original.nodes contains QueryNode classes
+that are used specifically for Lucene query node tree. Any other generic QueryNode is
+defined under org.apache.lucene.queryParser.nodes.
+</p>
+</body>
+</html>
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/nodes/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/package.html?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/package.html (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/package.html Mon Aug 3 03:38:44 2009
@@ -0,0 +1,50 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<body>
+
+Contains the implementation of the Lucene query parser using the flexible query parser frameworks
+
+<h2>Lucene Flexible Query Parser Implementation</h2>
+<p>
+The old Lucene query parser used to have only one class that performed
+all the parsing operations. In the new query parser structure, the
+parsing was divided in 3 steps: parsing (syntax), processing (semantic)
+and building.
+</p>
+<p>
+The classes contained in the package org.apache.lucene.queryParser.original
+are used to reproduce the same behavior as the old query parser.
+</p>
+
+<p>
+Check <tt>org.apache.lucene.queryParser.original.OriginalQueryParserHelper</tt> to quick start using the Lucene query parser.
+</p>
+
+<p>
+There are 2 wrapper classes that extends QueryParser and MultiFieldQueryParser.
+The classes implement internally the new query parser structure. These 2
+classes are deprecated and should only be used when there is a need to use the
+old query parser interface.
+</p>
+
+</body>
+</html>
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/parser/EscapeQuerySyntaxImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/parser/EscapeQuerySyntaxImpl.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/parser/EscapeQuerySyntaxImpl.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/parser/EscapeQuerySyntaxImpl.java Mon Aug 3 03:38:44 2009
@@ -0,0 +1,296 @@
+package org.apache.lucene.queryParser.original.parser;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Locale;
+
+import org.apache.lucene.messages.MessageImpl;
+import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax;
+import org.apache.lucene.queryParser.core.util.UnescapedCharSequence;
+
+/**
+ */
+public class EscapeQuerySyntaxImpl implements EscapeQuerySyntax {
+
+ private static final char[] wildcardChars = { '*', '?' };
+
+ private static final String[] escapableTermExtraFirstChars = { "+", "-", "@" };
+
+ private static final String[] escapableTermChars = { "\"", "<", ">", "=",
+ "!", "(", ")", "^", "[", "{", ":", "]", "}", "~" };
+
+ // TODO: check what to do with these "*", "?", "\\"
+ private static final String[] escapableQuotedChars = { "\"" };
+ private static final String[] escapableWhiteChars = { " ", "\t", "\n", "\r",
+ "\f", "\b", "\u3000" };
+ private static final String[] escapableWordTokens = { "AND", "OR", "NOT",
+ "TO", "WITHIN", "SENTENCE", "PARAGRAPH", "INORDER" };
+
+ private static final CharSequence escapeChar(CharSequence str, Locale locale) {
+ if (str == null || str.length() == 0)
+ return str;
+
+ CharSequence buffer = str;
+
+ // regular escapable Char for terms
+ for (int i = 0; i < escapableTermChars.length; i++) {
+ buffer = replaceIgnoreCase(buffer, escapableTermChars[i].toLowerCase(),
+ "\\", locale);
+ }
+
+ // First Character of a term as more escaping chars
+ for (int i = 0; i < escapableTermExtraFirstChars.length; i++) {
+ if (buffer.charAt(0) == escapableTermExtraFirstChars[i].charAt(0)) {
+ buffer = "\\" + buffer.charAt(0)
+ + buffer.subSequence(1, buffer.length());
+ break;
+ }
+ }
+
+ return buffer;
+ }
+
+ private final CharSequence escapeQuoted(CharSequence str, Locale locale) {
+ if (str == null || str.length() == 0)
+ return str;
+
+ CharSequence buffer = str;
+
+ for (int i = 0; i < escapableQuotedChars.length; i++) {
+ buffer = replaceIgnoreCase(buffer, escapableTermChars[i].toLowerCase(),
+ "\\", locale);
+ }
+ return buffer;
+ }
+
+ private static final CharSequence escapeTerm(CharSequence term, Locale locale) {
+ if (term == null)
+ return term;
+
+ // Escape single Chars
+ term = escapeChar(term, locale);
+ term = escapeWhiteChar(term, locale);
+
+ // Escape Parser Words
+ for (int i = 0; i < escapableWordTokens.length; i++) {
+ if (escapableWordTokens[i].equalsIgnoreCase(term.toString()))
+ return "\\" + term;
+ }
+ return term;
+ }
+
+ /**
+ * replace with ignore case
+ *
+ * @param stringOrig
+ * string to get replaced
+ * @param sequence1
+ * the old character sequence in lowercase
+ * @param escapeChar
+ * the new character to prefix sequence1 in return string.
+ * @return the new String
+ */
+ private static CharSequence replaceIgnoreCase(CharSequence string,
+ CharSequence sequence1, CharSequence escapeChar, Locale locale) {
+ if (escapeChar == null || sequence1 == null || string == null)
+ throw new NullPointerException();
+
+ // empty string case
+ int count = string.length();
+ int sequence1Length = sequence1.length();
+ if (sequence1Length == 0) {
+ StringBuilder result = new StringBuilder((count + 1)
+ * escapeChar.length());
+ result.append(escapeChar);
+ for (int i = 0; i < count; i++) {
+ result.append(string.charAt(i));
+ result.append(escapeChar);
+ }
+ return result.toString();
+ }
+
+ // normal case
+ StringBuilder result = new StringBuilder();
+ char first = sequence1.charAt(0);
+ int start = 0, copyStart = 0, firstIndex;
+ while (start < count) {
+ if ((firstIndex = string.toString().toLowerCase(locale).indexOf(first,
+ start)) == -1)
+ break;
+ boolean found = true;
+ if (sequence1.length() > 1) {
+ if (firstIndex + sequence1Length > count)
+ break;
+ for (int i = 1; i < sequence1Length; i++) {
+ if (string.toString().toLowerCase(locale).charAt(firstIndex + i) != sequence1
+ .charAt(i)) {
+ found = false;
+ break;
+ }
+ }
+ }
+ if (found) {
+ result.append(string.toString().substring(copyStart, firstIndex));
+ result.append(escapeChar);
+ result.append(string.toString().substring(firstIndex,
+ firstIndex + sequence1Length));
+ copyStart = start = firstIndex + sequence1Length;
+ } else {
+ start = firstIndex + 1;
+ }
+ }
+ if (result.length() == 0 && copyStart == 0)
+ return string;
+ result.append(string.toString().substring(copyStart));
+ return result.toString();
+ }
+
+ /**
+ * escape all tokens that are part of the parser syntax on a given string
+ *
+ * @param string
+ * string to get replaced
+ * @param locale
+ * locale to be used when performing string compares
+ * @return the new String
+ */
+ private static final CharSequence escapeWhiteChar(CharSequence str,
+ Locale locale) {
+ if (str == null || str.length() == 0)
+ return str;
+
+ CharSequence buffer = str;
+
+ for (int i = 0; i < escapableWhiteChars.length; i++) {
+ buffer = replaceIgnoreCase(buffer, escapableWhiteChars[i].toLowerCase(),
+ "\\", locale);
+ }
+ return buffer;
+ }
+
+ public CharSequence escape(CharSequence text, Locale locale, Type type) {
+ if (text == null || text.length() == 0)
+ return text;
+
+ // escape wildcards and the escape char (this has to be perform before
+ // anything else)
+ // since we need to preserve the UnescapedCharSequence and escape the
+ // original escape chars
+ if (text instanceof UnescapedCharSequence) {
+ text = ((UnescapedCharSequence) text).toStringEscaped(wildcardChars);
+ } else {
+ text = new UnescapedCharSequence(text).toStringEscaped(wildcardChars);
+ }
+
+ if (type == Type.STRING) {
+ return escapeQuoted(text, locale);
+ } else {
+ return escapeTerm(text, locale);
+ }
+ }
+
+ /**
+ * Returns a String where the escape char has been removed, or kept only once
+ * if there was a double escape.
+ *
+ * Supports escaped unicode characters, e. g. translates <code>A</code> to
+ * <code>A</code>.
+ *
+ */
+ public static UnescapedCharSequence discardEscapeChar(CharSequence input)
+ throws ParseException {
+ // Create char array to hold unescaped char sequence
+ char[] output = new char[input.length()];
+ boolean[] wasEscaped = new boolean[input.length()];
+
+ // The length of the output can be less than the input
+ // due to discarded escape chars. This variable holds
+ // the actual length of the output
+ int length = 0;
+
+ // We remember whether the last processed character was
+ // an escape character
+ boolean lastCharWasEscapeChar = false;
+
+ // The multiplier the current unicode digit must be multiplied with.
+ // E. g. the first digit must be multiplied with 16^3, the second with
+ // 16^2...
+ int codePointMultiplier = 0;
+
+ // Used to calculate the codepoint of the escaped unicode character
+ int codePoint = 0;
+
+ for (int i = 0; i < input.length(); i++) {
+ char curChar = input.charAt(i);
+ if (codePointMultiplier > 0) {
+ codePoint += hexToInt(curChar) * codePointMultiplier;
+ codePointMultiplier >>>= 4;
+ if (codePointMultiplier == 0) {
+ output[length++] = (char) codePoint;
+ codePoint = 0;
+ }
+ } else if (lastCharWasEscapeChar) {
+ if (curChar == 'u') {
+ // found an escaped unicode character
+ codePointMultiplier = 16 * 16 * 16;
+ } else {
+ // this character was escaped
+ output[length] = curChar;
+ wasEscaped[length] = true;
+ length++;
+ }
+ lastCharWasEscapeChar = false;
+ } else {
+ if (curChar == '\\') {
+ lastCharWasEscapeChar = true;
+ } else {
+ output[length] = curChar;
+ length++;
+ }
+ }
+ }
+
+ if (codePointMultiplier > 0) {
+ throw new ParseException(new MessageImpl(
+ QueryParserMessages.INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION));
+ }
+
+ if (lastCharWasEscapeChar) {
+ throw new ParseException(new MessageImpl(
+ QueryParserMessages.INVALID_SYNTAX_ESCAPE_CHARACTER));
+ }
+
+ return new UnescapedCharSequence(output, wasEscaped, 0, length);
+ }
+
+ /** Returns the numeric value of the hexadecimal character */
+ private static final int hexToInt(char c) throws ParseException {
+ if ('0' <= c && c <= '9') {
+ return c - '0';
+ } else if ('a' <= c && c <= 'f') {
+ return c - 'a' + 10;
+ } else if ('A' <= c && c <= 'F') {
+ return c - 'A' + 10;
+ } else {
+ throw new ParseException(new MessageImpl(
+ QueryParserMessages.INVALID_SYNTAX_ESCAPE_NONE_HEX_UNICODE, c));
+ }
+ }
+
+}
Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/parser/EscapeQuerySyntaxImpl.java
------------------------------------------------------------------------------
svn:eol-style = native