From ef04c1623726ef9c946525838d1efbd9f1bf280c Mon Sep 17 00:00:00 2001 From: Hans Joachim Desserud Date: Tue, 6 Jan 2015 21:23:47 +0100 Subject: [PATCH] Removed deprecated classes Former-commit-id: 7b4de8148c8de485d39842b2fdecc8cbc2895da3 --- .../data/lucene/SearchVersionAnalyzer.java | 65 ------------ .../data/lucene/VersionAnalyzer.java | 62 ------------ .../data/lucene/VersionTokenizingFilter.java | 98 ------------------- 3 files changed, 225 deletions(-) delete mode 100644 dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchVersionAnalyzer.java delete mode 100644 dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionAnalyzer.java delete mode 100644 dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionTokenizingFilter.java diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchVersionAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchVersionAnalyzer.java deleted file mode 100644 index 7802aeed6..000000000 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchVersionAnalyzer.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of dependency-check-core. - * - * Licensed 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. - * - * Copyright (c) 2012 Jeremy Long. All Rights Reserved. - */ -package org.owasp.dependencycheck.data.lucene; - -import java.io.Reader; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.core.LowerCaseFilter; -import org.apache.lucene.analysis.core.WhitespaceTokenizer; -import org.apache.lucene.util.Version; - -/** - * SearchVersionAnalyzer is a Lucene Analyzer used to analyze version information. - * - * @author Jeremy Long - * @deprecated version information is no longer stored in lucene - */ -@Deprecated -public class SearchVersionAnalyzer extends Analyzer { - //TODO consider implementing payloads/custom attributes... - // use custom attributes for major, minor, x, x, x, rcx - // these can then be used to weight the score for searches on the version. - // see http://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/analysis/package-summary.html#package_description - // look at this article to implement - // http://www.codewrecks.com/blog/index.php/2012/08/25/index-your-blog-using-tags-and-lucene-net/ - - /** - * Creates a new SearchVersionAnalyzer. - * - */ - public SearchVersionAnalyzer() { - } - - /** - * Creates the TokenStreamComponents - * - * @param fieldName the field name being analyzed - * @param reader the reader containing the input - * @return the TokenStreamComponents - */ - @Override - protected TokenStreamComponents createComponents(String fieldName, Reader reader) { - final Tokenizer source = new WhitespaceTokenizer(reader); - TokenStream stream = source; - stream = new LowerCaseFilter(stream); - stream = new VersionTokenizingFilter(stream); - return new TokenStreamComponents(source, stream); - } -} diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionAnalyzer.java deleted file mode 100644 index b66fb7bc5..000000000 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionAnalyzer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of dependency-check-core. - * - * Licensed 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. - * - * Copyright (c) 2012 Jeremy Long. All Rights Reserved. - */ -package org.owasp.dependencycheck.data.lucene; - -import java.io.Reader; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.core.LowerCaseFilter; -import org.apache.lucene.analysis.core.WhitespaceTokenizer; - -/** - * VersionAnalyzer is a Lucene Analyzer used to analyze version information. - * - * @author Jeremy Long - * @deprecated version information is no longer stored in lucene - */ -@Deprecated -public class VersionAnalyzer extends Analyzer { - //TODO consider implementing payloads/custom attributes... - // use custom attributes for major, minor, x, x, x, rcx - // these can then be used to weight the score for searches on the version. - // see http://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/analysis/package-summary.html#package_description - // look at this article to implement - // http://www.codewrecks.com/blog/index.php/2012/08/25/index-your-blog-using-tags-and-lucene-net/ - - /** - * Creates a new VersionAnalyzer. - * - */ - public VersionAnalyzer() {} - - /** - * Creates the TokenStreamComponents - * - * @param fieldName the field name being analyzed - * @param reader the reader containing the input - * @return the TokenStreamComponents - */ - @Override - protected TokenStreamComponents createComponents(String fieldName, Reader reader) { - final Tokenizer source = new WhitespaceTokenizer(reader); - TokenStream stream = source; - stream = new LowerCaseFilter(stream); - return new TokenStreamComponents(source, stream); - } -} diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionTokenizingFilter.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionTokenizingFilter.java deleted file mode 100644 index 3b4d8bf48..000000000 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/VersionTokenizingFilter.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of dependency-check-core. - * - * Licensed 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. - * - * Copyright (c) 2012 Jeremy Long. All Rights Reserved. - */ -package org.owasp.dependencycheck.data.lucene; - -import java.io.IOException; -import java.util.LinkedList; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; - -/** - *

- * Takes a TokenStream and splits or adds tokens to correctly index version numbers.

- *

- * Example: "3.0.0.RELEASE" -> "3 3.0 3.0.0 RELEASE 3.0.0.RELEASE".

- * - * @author Jeremy Long - * @deprecated version information is no longer stored in lucene - */ -@Deprecated -public final class VersionTokenizingFilter extends AbstractTokenizingFilter { - - /** - * Constructs a new VersionTokenizingFilter. - * - * @param stream the TokenStream that this filter will process - */ - public VersionTokenizingFilter(TokenStream stream) { - super(stream); - } - - /** - * Increments the underlying TokenStream and sets CharTermAttributes to construct an expanded set of tokens by - * concatenating tokens with the previous token. - * - * @return whether or not we have hit the end of the TokenStream - * @throws IOException is thrown when an IOException occurs - */ - @Override - public boolean incrementToken() throws IOException { - final LinkedList tokens = getTokens(); - final CharTermAttribute termAtt = getTermAtt(); - if (tokens.size() == 0 && input.incrementToken()) { - final String version = new String(termAtt.buffer(), 0, termAtt.length()); - final String[] toAnalyze = version.split("[_-]"); - //ensure we analyze the whole string as one too - analyzeVersion(version); - for (String str : toAnalyze) { - analyzeVersion(str); - } - } - return addTerm(); - } - - /** - *

- * Analyzes the version and adds several copies of the version as different tokens. For example, the version 1.2.7 - * would create the tokens 1 1.2 1.2.7. This is useful in discovering the correct version - sometimes a maintenance - * or build number will throw off the version identification.

- * - *

- * expected format:&nbps;major.minor[.maintenance[.build]]

- * - * @param version the version to analyze - */ - private void analyzeVersion(String version) { - //todo should we also be splitting on dash or underscore? we would need - // to incorporate the dash or underscore back in... - final LinkedList tokens = getTokens(); - final String[] versionParts = version.split("\\."); - String dottedVersion = null; - for (String current : versionParts) { - if (!current.matches("^/d+$")) { - tokens.add(current); - } - if (dottedVersion == null) { - dottedVersion = current; - } else { - dottedVersion = dottedVersion + "." + current; - } - tokens.add(dottedVersion); - } - } -}