Coverage Report - org.owasp.dependencycheck.data.lucene.VersionAnalyzer
 
Classes in this File Line Coverage Branch Coverage Complexity
VersionAnalyzer
0%
0/7
N/A
1
 
 1  
 /*
 2  
  * This file is part of dependency-check-core.
 3  
  *
 4  
  * Dependency-check-core is free software: you can redistribute it and/or modify it
 5  
  * under the terms of the GNU General Public License as published by the Free
 6  
  * Software Foundation, either version 3 of the License, or (at your option) any
 7  
  * later version.
 8  
  *
 9  
  * Dependency-check-core is distributed in the hope that it will be useful, but
 10  
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 12  
  * details.
 13  
  *
 14  
  * You should have received a copy of the GNU General Public License along with
 15  
  * dependency-check-core. If not, see http://www.gnu.org/licenses/.
 16  
  *
 17  
  * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
 18  
  */
 19  
 package org.owasp.dependencycheck.data.lucene;
 20  
 
 21  
 import java.io.Reader;
 22  
 import org.apache.lucene.analysis.Analyzer;
 23  
 import org.apache.lucene.analysis.TokenStream;
 24  
 import org.apache.lucene.analysis.Tokenizer;
 25  
 import org.apache.lucene.analysis.core.LowerCaseFilter;
 26  
 import org.apache.lucene.analysis.core.WhitespaceTokenizer;
 27  
 import org.apache.lucene.util.Version;
 28  
 
 29  
 /**
 30  
  * VersionAnalyzer is a Lucene Analyzer used to analyze version information.
 31  
  *
 32  
  * @author Jeremy Long (jeremy.long@owasp.org)
 33  
  * @deprecated version information is no longer stored in lucene
 34  
  */
 35  
 @Deprecated
 36  
 public class VersionAnalyzer extends Analyzer {
 37  
     //TODO consider implementing payloads/custom attributes...
 38  
     // use custom attributes for major, minor, x, x, x, rcx
 39  
     // these can then be used to weight the score for searches on the version.
 40  
     // see http://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/analysis/package-summary.html#package_description
 41  
     // look at this article to implement
 42  
     // http://www.codewrecks.com/blog/index.php/2012/08/25/index-your-blog-using-tags-and-lucene-net/
 43  
 
 44  
     /**
 45  
      * The Lucene Version used.
 46  
      */
 47  
     private final Version version;
 48  
 
 49  
     /**
 50  
      * Creates a new VersionAnalyzer.
 51  
      *
 52  
      * @param version the Lucene version
 53  
      */
 54  0
     public VersionAnalyzer(Version version) {
 55  0
         this.version = version;
 56  0
     }
 57  
 
 58  
     /**
 59  
      * Creates the TokenStreamComponents
 60  
      *
 61  
      * @param fieldName the field name being analyzed
 62  
      * @param reader the reader containing the input
 63  
      * @return the TokenStreamComponents
 64  
      */
 65  
     @Override
 66  
     protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
 67  0
         final Tokenizer source = new WhitespaceTokenizer(version, reader);
 68  0
         TokenStream stream = source;
 69  0
         stream = new LowerCaseFilter(version, stream);
 70  0
         return new TokenStreamComponents(source, stream);
 71  
     }
 72  
 }