Apache Solr open-source search software
LUCENE-4981: Remove deprecated classes.
Adrien Grandc06fd47cba2b
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilter.javadeleted file mode 100644index c77af32aa7a..00000000000--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilter.java+++ /dev/null@@ -1,93 +0,0 @@-package org.apache.lucene.analysis.position;--/*- * 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.io.IOException;--import org.apache.lucene.analysis.TokenFilter;-import org.apache.lucene.analysis.TokenStream;-import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;-import org.apache.lucene.queryparser.classic.QueryParser;--/** Set the positionIncrement of all tokens to the "positionIncrement",- * except the first return token which retains its original positionIncrement value.- * The default positionIncrement value is zero.- * @deprecated (4.4) PositionFilter makes {@link TokenStream} graphs inconsistent- * which can cause highlighting bugs. Its main use-case being to make- * {@link QueryParser} generate boolean queries instead of phrase- * queries, it is now advised to use- * {@link QueryParser#setAutoGeneratePhraseQueries(boolean) QueryParser.setAutoGeneratePhraseQueries(false)}- * (for simple cases) or to override {@link QueryParser#newFieldQuery}.- */-@Deprecated-public final class PositionFilter extends TokenFilter {-- /** Position increment to assign to all but the first token - default = 0 */- private final int positionIncrement;-- /** The first token must have non-zero positionIncrement **/- private boolean firstTokenPositioned = false;-- private PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);-- /**- * Constructs a PositionFilter that assigns a position increment of zero to- * all but the first token from the given input stream.- *- * @param input the input stream- */- public PositionFilter(final TokenStream input) {- this(input, 0);- }-- /**- * Constructs a PositionFilter that assigns the given position increment to- * all but the first token from the given input stream.- *- * @param input the input stream- * @param positionIncrement position increment to assign to all but the first- * token from the input stream- */- public PositionFilter(final TokenStream input, final int positionIncrement) {- super(input);- if (positionIncrement < 0) {- throw new IllegalArgumentException("positionIncrement may not be negative");- }- this.positionIncrement = positionIncrement;- }-- @Override- public final boolean incrementToken() throws IOException {- if (input.incrementToken()) {- if (firstTokenPositioned) {- posIncrAtt.setPositionIncrement(positionIncrement);- } else {- firstTokenPositioned = true;- }- return true;- } else {- return false;- }- }-- @Override- public void reset() throws IOException {- super.reset();- firstTokenPositioned = false;- }-}diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilterFactory.javadeleted file mode 100644index ec2ba5f8085..00000000000--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilterFactory.java+++ /dev/null@@ -1,64 +0,0 @@-package org.apache.lucene.analysis.position;--/*- * 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.analysis.TokenStream;-import org.apache.lucene.analysis.position.PositionFilter;-import org.apache.lucene.analysis.util.TokenFilterFactory;-import org.apache.lucene.util.Version;--import java.util.Map;--/**- * Factory for {@link PositionFilter}.- * Set the positionIncrement of all tokens to the "positionIncrement", except the first return token which retains its- * original positionIncrement value. The default positionIncrement value is zero.- * <pre class="prettyprint">- * <fieldType name="text_position" class="solr.TextField" positionIncrementGap="100">- * <analyzer>- * <tokenizer class="solr.WhitespaceTokenizerFactory"/>- * <filter class="solr.PositionFilterFactory" positionIncrement="0"/>- * </analyzer>- * </fieldType></pre>- *- * @see org.apache.lucene.analysis.position.PositionFilter- * @since solr 1.4- * @deprecated (4.4)- */-@Deprecated-public class PositionFilterFactory extends TokenFilterFactory {- private final int positionIncrement;-- /** Creates a new PositionFilterFactory */- public PositionFilterFactory(Map<String,String> args) {- super(args);- positionIncrement = getInt(args, "positionIncrement", 0);- if (!args.isEmpty()) {- throw new IllegalArgumentException("Unknown parameters: " + args);- }- if (luceneMatchVersion != null && luceneMatchVersion.onOrAfter(Version.LUCENE_44)) {- throw new IllegalArgumentException("PositionFilter is deprecated as of Lucene 4.4. You should either fix your code to not use it or use Lucene 4.3 version compatibility");- }- }-- @Override- public PositionFilter create(TokenStream input) {- return new PositionFilter(input, positionIncrement);- }-}-diff --git a/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactoryindex 21d6db8d723..3497e30f58d 100644--- a/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory+++ b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory@@ -76,7 +76,6 @@ org.apache.lucene.analysis.payloads.DelimitedPayloadTokenFilterFactoryorg.apache.lucene.analysis.payloads.NumericPayloadTokenFilterFactoryorg.apache.lucene.analysis.payloads.TokenOffsetPayloadTokenFilterFactoryorg.apache.lucene.analysis.payloads.TypeAsPayloadTokenFilterFactory-org.apache.lucene.analysis.position.PositionFilterFactoryorg.apache.lucene.analysis.pt.PortugueseLightStemFilterFactoryorg.apache.lucene.analysis.pt.PortugueseMinimalStemFilterFactoryorg.apache.lucene.analysis.pt.PortugueseStemFilterFactorydiff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.javaindex cf2e9742ebd..35d21112988 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java@@ -66,22 +66,15 @@ import org.apache.lucene.analysis.compound.hyphenation.HyphenationTree;import org.apache.lucene.analysis.hunspell.HunspellDictionary;import org.apache.lucene.analysis.hunspell.HunspellDictionaryTest;import org.apache.lucene.analysis.miscellaneous.HyphenatedWordsFilter;-import org.apache.lucene.analysis.miscellaneous.KeepWordFilter;-import org.apache.lucene.analysis.miscellaneous.LengthFilter;import org.apache.lucene.analysis.miscellaneous.LimitTokenCountFilter;import org.apache.lucene.analysis.miscellaneous.LimitTokenPositionFilter;import org.apache.lucene.analysis.miscellaneous.StemmerOverrideFilter;import org.apache.lucene.analysis.miscellaneous.StemmerOverrideFilter.StemmerOverrideMap;-import org.apache.lucene.analysis.miscellaneous.TrimFilter;import org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter;-import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;-import org.apache.lucene.analysis.ngram.EdgeNGramTokenizer;-import org.apache.lucene.analysis.ngram.Lucene43NGramTokenizer;import org.apache.lucene.analysis.path.PathHierarchyTokenizer;import org.apache.lucene.analysis.path.ReversePathHierarchyTokenizer;import org.apache.lucene.analysis.payloads.IdentityEncoder;import org.apache.lucene.analysis.payloads.PayloadEncoder;-import org.apache.lucene.analysis.position.PositionFilter;import org.apache.lucene.analysis.snowball.TestSnowball;import org.apache.lucene.analysis.standard.StandardTokenizer;import org.apache.lucene.analysis.synonym.SynonymMap;diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/EdgeNGramTokenFilterTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/EdgeNGramTokenFilterTest.javaindex 54e74e0b705..5cc152bb65c 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/EdgeNGramTokenFilterTest.java+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/EdgeNGramTokenFilterTest.java@@ -17,22 +17,21 @@ package org.apache.lucene.analysis.ngram;* limitations under the License.*/+import java.io.IOException;+import java.io.Reader;+import java.io.StringReader;+import java.util.Random;+import org.apache.lucene.analysis.Analyzer;+import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.MockTokenizer;import org.apache.lucene.analysis.TokenFilter;import org.apache.lucene.analysis.TokenStream;-import org.apache.lucene.analysis.BaseTokenStreamTestCase;import org.apache.lucene.analysis.Tokenizer;import org.apache.lucene.analysis.core.KeywordTokenizer;import org.apache.lucene.analysis.core.WhitespaceTokenizer;-import org.apache.lucene.analysis.position.PositionFilter;import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;-import java.io.IOException;-import java.io.Reader;-import java.io.StringReader;-import java.util.Random;-/*** Tests {@link EdgeNGramTokenFilter} for correctness.*/diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/position/PositionFilterTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/position/PositionFilterTest.javadeleted file mode 100644index be13ec63ce9..00000000000--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/position/PositionFilterTest.java+++ /dev/null@@ -1,139 +0,0 @@-package org.apache.lucene.analysis.position;--/*- * 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.analysis.BaseTokenStreamTestCase;-import org.apache.lucene.analysis.TokenStream;-import org.apache.lucene.analysis.shingle.ShingleFilter;-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;--public class PositionFilterTest extends BaseTokenStreamTestCase {-- public class TestTokenStream extends TokenStream {-- protected int index = 0;- protected String[] testToken;- protected final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);-- public TestTokenStream(String[] testToken) {- super();- this.testToken = testToken;- }-- @Override- public final boolean incrementToken() {- clearAttributes();- if (index < testToken.length) {- termAtt.setEmpty().append(testToken[index++]);- return true;- } else {- return false;- }- }- @Override- public void reset() {- index = 0;- }- }-- public static final String[] TEST_TOKEN = new String[]{- "please",- "divide",- "this",- "sentence",- "into",- "shingles",- };- public static final int[] TEST_TOKEN_POSITION_INCREMENTS = new int[]{- 1, 0, 0, 0, 0, 0- };- public static final int[] TEST_TOKEN_NON_ZERO_POSITION_INCREMENTS = new int[]{- 1, 5, 5, 5, 5, 5- };-- public static final String[] SIX_GRAM_NO_POSITIONS_TOKENS = new String[]{- "please",- "please divide",- "please divide this",- "please divide this sentence",- "please divide this sentence into",- "please divide this sentence into shingles",- "divide",- "divide this",- "divide this sentence",- "divide this sentence into",- "divide this sentence into shingles",- "this",- "this sentence",- "this sentence into",- "this sentence into shingles",- "sentence",- "sentence into",- "sentence into shingles",- "into",- "into shingles",- "shingles",- };- public static final int[] SIX_GRAM_NO_POSITIONS_INCREMENTS = new int[]{- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0- };- public static final String[] SIX_GRAM_NO_POSITIONS_TYPES = new String[]{- "word", "shingle", "shingle", "shingle", "shingle", "shingle",- "word", "shingle", "shingle", "shingle", "shingle",- "word", "shingle", "shingle", "shingle",- "word", "shingle", "shingle",- "word", "shingle",- "word"- };-- public void testFilter() throws Exception {-- assertTokenStreamContents(new PositionFilter(new TestTokenStream(TEST_TOKEN)),- TEST_TOKEN,- TEST_TOKEN_POSITION_INCREMENTS);- }-- public void testNonZeroPositionIncrement() throws Exception {-- assertTokenStreamContents(new PositionFilter(new TestTokenStream(TEST_TOKEN), 5),- TEST_TOKEN,- TEST_TOKEN_NON_ZERO_POSITION_INCREMENTS);- }-- public void testReset() throws Exception {-- PositionFilter filter = new PositionFilter(new TestTokenStream(TEST_TOKEN));- assertTokenStreamContents(filter, TEST_TOKEN, TEST_TOKEN_POSITION_INCREMENTS);- filter.reset();- // Make sure that the reset filter provides correct position increments- assertTokenStreamContents(filter, TEST_TOKEN, TEST_TOKEN_POSITION_INCREMENTS);- }-- /** Tests ShingleFilter up to six shingles against six terms.- * Tests PositionFilter setting all but the first positionIncrement to zero.- * @throws java.io.IOException @see Token#next(Token)- */- public void test6GramFilterNoPositions() throws Exception {-- ShingleFilter filter = new ShingleFilter(new TestTokenStream(TEST_TOKEN), 6);- assertTokenStreamContents(new PositionFilter(filter),- SIX_GRAM_NO_POSITIONS_TOKENS,- SIX_GRAM_NO_POSITIONS_INCREMENTS);- }--}