eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * CDDL HEADER START
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * The contents of this file are subject to the terms of the
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * Common Development and Distribution License (the "License").
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * You may not use this file except in compliance with the License.
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * See LICENSE.txt included in this distribution for the specific
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * language governing permissions and limitations under the License.
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * When distributing Covered Code, include this CDDL HEADER in each
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * file and include the License file at LICENSE.txt.
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * If applicable, add the following below this CDDL HEADER, with the
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * fields enclosed by brackets "[]" replaced with your own identifying
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * information: Portions Copyright [yyyy] [name of copyright owner]
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * CDDL HEADER END
4083abf043fbc87feef12bde4afb75b046200dbaLubos Kosco * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
6d7c6f82e644c205bc679ee5b1fa2929ec949963Lubos Koscoimport org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
b645988bdc1cf4f2f82b8c00ed041ddddd822c24Lubos Koscoimport org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
b645988bdc1cf4f2f82b8c00ed041ddddd822c24Lubos Koscoimport org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
80c87d7e9c9b9ce372265f9d7eccee40dced7463Lubos Kosco * Generally this is a "template" for all new Tokenizers, so be careful when
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco * changing it, it will impact almost ALL symbol tokenizers in OpenGrok ...
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * Created on August 24, 2009
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Kosco * @author Lubos Kosco
eb32a77fdb57f20c042b7b79b28a4fb4060cb949Lubos Koscopublic abstract class JFlexTokenizer extends Tokenizer {
b645988bdc1cf4f2f82b8c00ed041ddddd822c24Lubos Kosco // default jflex scanner methods and variables
bfc104f8240fac5b59d4347db4c27be705f6dfc2Knut Anders Hatlen abstract public boolean yylex() throws IOException;
4750e1be4c1b2ba11705d5b73b86dd1b9dd4e1acKnut Anders Hatlen abstract public void yyreset(Reader reader);
bfc104f8240fac5b59d4347db4c27be705f6dfc2Knut Anders Hatlen abstract public void yyclose() throws IOException;
6602c01097c66d242046fb0490e0a5dcc1ca36c5Lubos Kosco //TODO can be removed once we figure out jflex generation of empty constructor
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco * Reinitialize the tokenizer with new reader.
4083abf043fbc87feef12bde4afb75b046200dbaLubos Kosco * @throws java.io.IOException in case of I/O error
bfc104f8240fac5b59d4347db4c27be705f6dfc2Knut Anders Hatlen public final void close() throws IOException {
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco protected CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco protected OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco protected PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco * This will re-initalize internal AttributeImpls, or it returns false if
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco * end of input Reader ...
b645988bdc1cf4f2f82b8c00ed041ddddd822c24Lubos Kosco * @return false if no more tokens, otherwise true
4083abf043fbc87feef12bde4afb75b046200dbaLubos Kosco * @throws IOException in case of I/O error
d2e3f3641cebe445e5a99af0e33c455b16140b2bKnut Anders Hatlen public final boolean incrementToken() throws IOException {
ff5eba819da0cf7964d884630fb13262ef12c505Trond Norbye return this.yylex();
817883e9f0d419428e8236a09b77cdeeaa034df7Knut Anders Hatlen protected void setAttribs(String str, int start, int end) {
be5cdf850da5383468637c6937c016f26bd339cfLubos Kosco //FIXME increasing below by one(default) might be tricky, need more analysis
f9fd2b96d1c5ea62664f74da0e34a04b6511a8ffLubos Kosco // after lucene upgrade to 3.5 below is most probably not even needed