Coverage Report - org.owasp.dependencycheck.data.lucene.VersionAnalyzer
 
Classes in this File Line Coverage Branch Coverage Complexity
VersionAnalyzer
0%
0/4
N/A
1
 
 1  
 /*
 2  
  * This file is part of dependency-check-core.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  *
 16  
  * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
 17  
  */
 18  
 package org.owasp.dependencycheck.data.lucene;
 19  
 
 20  
 import java.io.Reader;
 21  
 import org.apache.lucene.analysis.Analyzer;
 22  
 import org.apache.lucene.analysis.TokenStream;
 23  
 import org.apache.lucene.analysis.Tokenizer;
 24  
 import org.apache.lucene.analysis.core.LowerCaseFilter;
 25  
 import org.apache.lucene.analysis.core.WhitespaceTokenizer;
 26  
 import org.apache.lucene.util.Version;
 27  
 
 28  
 /**
 29  
  * VersionAnalyzer is a Lucene Analyzer used to analyze version information.
 30  
  *
 31  
  * @author Jeremy Long <jeremy.long@owasp.org>
 32  
  * @deprecated version information is no longer stored in lucene
 33  
  */
 34  
 @Deprecated
 35  
 public class VersionAnalyzer extends Analyzer {
 36  
     //TODO consider implementing payloads/custom attributes...
 37  
     // use custom attributes for major, minor, x, x, x, rcx
 38  
     // these can then be used to weight the score for searches on the version.
 39  
     // see http://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/analysis/package-summary.html#package_description
 40  
     // look at this article to implement
 41  
     // http://www.codewrecks.com/blog/index.php/2012/08/25/index-your-blog-using-tags-and-lucene-net/
 42  
 
 43  
     /**
 44  
      * The Lucene Version used.
 45  
      */
 46  
     private final Version version;
 47  
 
 48  
     /**
 49  
      * Creates a new VersionAnalyzer.
 50  
      *
 51  
      * @param version the Lucene version
 52  
      */
 53  
     public VersionAnalyzer(Version version) {
 54  
         this.version = version;
 55  
     }
 56  
 
 57  
     /**
 58  
      * Creates the TokenStreamComponents
 59  
      *
 60  
      * @param fieldName the field name being analyzed
 61  
      * @param reader the reader containing the input
 62  
      * @return the TokenStreamComponents
 63  
      */
 64  
     @Override
 65  
     protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
 66  0
         final Tokenizer source = new WhitespaceTokenizer(version, reader);
 67  0
         TokenStream stream = source;
 68  0
         stream = new LowerCaseFilter(version, stream);
 69  0
         return new TokenStreamComponents(source, stream);
 70  
     }
 71  
 }