| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AlphaNumericTokenizer |
|
| 1.3333333333333333;1.333 |
| 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) 2013 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.util.CharTokenizer; | |
| 23 | import org.apache.lucene.util.Version; | |
| 24 | ||
| 25 | /** | |
| 26 | * Tokenizes the input breaking it into tokens when non-alpha/numeric characters | |
| 27 | * are found. | |
| 28 | * | |
| 29 | * @author Jeremy Long (jeremy.long@owasp.org) | |
| 30 | */ | |
| 31 | public class AlphaNumericTokenizer extends CharTokenizer { | |
| 32 | ||
| 33 | /** | |
| 34 | * Constructs a new AlphaNumericTokenizer. | |
| 35 | * | |
| 36 | * @param matchVersion the lucene version | |
| 37 | * @param in the Reader | |
| 38 | */ | |
| 39 | public AlphaNumericTokenizer(Version matchVersion, Reader in) { | |
| 40 | 47 | super(matchVersion, in); |
| 41 | 47 | } |
| 42 | ||
| 43 | /** | |
| 44 | * Constructs a new AlphaNumericTokenizer. | |
| 45 | * | |
| 46 | * @param matchVersion the lucene version | |
| 47 | * @param factory the AttributeFactory | |
| 48 | * @param in the Reader | |
| 49 | */ | |
| 50 | public AlphaNumericTokenizer(Version matchVersion, AttributeFactory factory, Reader in) { | |
| 51 | 0 | super(matchVersion, factory, in); |
| 52 | 0 | } |
| 53 | ||
| 54 | /** | |
| 55 | * Determines if the char passed in is part of a token. | |
| 56 | * | |
| 57 | * @param c the char being analyzed | |
| 58 | * @return true if the char is a letter or digit, otherwise false | |
| 59 | */ | |
| 60 | @Override | |
| 61 | protected boolean isTokenChar(int c) { | |
| 62 | 5451773 | return Character.isLetter(c) || Character.isDigit(c); |
| 63 | } | |
| 64 | } |