JFlexTokenizer.java revision d2e3f3641cebe445e5a99af0e33c455b16140b2b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * CDDL HEADER START
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * The contents of this file are subject to the terms of the
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * Common Development and Distribution License (the "License").
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * You may not use this file except in compliance with the License.
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * See LICENSE.txt included in this distribution for the specific
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * language governing permissions and limitations under the License.
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * When distributing Covered Code, include this CDDL HEADER in each
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * file and include the License file at LICENSE.txt.
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * If applicable, add the following below this CDDL HEADER, with the
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * fields enclosed by brackets "[]" replaced with your own identifying
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * information: Portions Copyright [yyyy] [name of copyright owner]
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * CDDL HEADER END
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
e5b34f0166ae61468e53f369578e691ddb09cdd0Pavel Březina * Generally this is a "template" for all new Tokenizers, so be carefull when
c47e9d522f0d87259e5074ea643daaa3dfcb8d92Pavel Březina * changing it, it will impact almost ALL symbol tokenizers in OpenGrok ...
76db25eab9010a33657f35e5afc8477c996df7a3Pavel Březina * Created on August 24, 2009
76db25eab9010a33657f35e5afc8477c996df7a3Pavel Březina * @author Lubos Kosco
76db25eab9010a33657f35e5afc8477c996df7a3Pavel Březinapublic abstract class JFlexTokenizer extends Tokenizer {
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina protected Stack<Integer> stack = new Stack<Integer>();
2a25713afc6beefb11a799903a43f695c5d7a4f9Adam Tkac // default jflex scanner methods and variables
2a25713afc6beefb11a799903a43f695c5d7a4f9Adam Tkac abstract public boolean yylex() throws IOException;
41ef946f3f74a46b9e26118116e4811e259b30efPavel Březina abstract public void yyclose() throws IOException;
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina abstract public int yystate();
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina * Reinitialize the tokenizer with new reader.
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina public final void close() throws IOException {
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina protected CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina protected OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina protected PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina protected int finalOffset;
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina * This will re-initalize internal AttributeImpls, or it returns false if
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina * end of input Reader ...
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina * @return false if no more tokens, otherwise true
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina * @throws IOException
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina public final boolean incrementToken() throws IOException {
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina return this.yylex();
5ff1c3c5a12930692cb6284d14f7fda3a974af8ePavel Březina protected void setAttribs(String str, int start, int end) {
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina //FIXME increasing below by one(default) might be tricky, need more analysis
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina // after lucene upgrade to 3.5 below is most probably not even needed
3b09b74bf65867d882af87ec60e2a517b15264a6Jakub Hrozek public void yypop() {