1 /* 2 * Copyright (C) 2006 uguu@users.sourceforge.jp, All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without prior written permission. For written 18 * permission, please contact clarkware@clarkware.com. 19 * 20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 26 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 package jp.sourceforge.tokenizer; 33 34 import java.util.regex.Pattern; 35 36 /** 37 * <p> 38 * {@link Tokenizer}クラスが文字列から切り出すトークンの情報を持ちます。{@link Tokenizer}クラスは、{@link #getTokenPattern()}メソッドが返すパターンで入力文字列から部分文字列を切り出し、{@link #createToken(String, int, int)}メソッドを呼び出して{@link Token}インスタンスを生成します。 39 * </p> 40 * 41 * @author uguu@users.sourceforge.jp 42 */ 43 public interface TokenInfo { 44 45 /** 46 * <p> 47 * 切り出すトークンの正規表現を返してください。{@link Tokenizer}クラスは、この正規表現を用いてトークンを識別します。 48 * </p> 49 * 50 * @return 切り出すトークンの正規表現。nullを返した場合、{@link Tokenizer}クラスは{@link NullPointerException}例外をスローします。 51 */ 52 Pattern getTokenPattern(); 53 54 /** 55 * <p> 56 * トークンを切り出したときに、{@link Tokenizer}クラスによって呼び出されます。切り出した文字列、行番号、列番号の情報が渡されるので、その情報を元に{@link Token}インスタンスを生成して返してください。 57 * </p> 58 * 59 * @param token 60 * 切り出した文字列。 61 * @param line 62 * 行番号。0から始まる。 63 * @param column 64 * 列番号。0から始まる。 65 * @return 引数の情報を元に生成した{@link Token}インスタンス。 66 */ 67 Token createToken(String token, int line, int column); 68 }