KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > tokens > TokenInteger


1 /*****************************************************************************
2  * Copyright (C) Zephyr Business Solutions Corp. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on 2004-11-15
10  *
11  * Author Ben Yu
12  */

13 package jfun.parsec.tokens;
14
15 import jfun.parsec.Tokenizer;
16
17 /**
18  * The token that represents any integer literal with arbitrary length.
19  * @author Ben Yu
20  *
21  * 2004-11-15
22  */

23 @Deprecated JavaDoc
24 public class TokenInteger extends TypedToken<TokenType>
25 implements java.io.Serializable JavaDoc{
26
27   /**
28    * @param raw the string representation.
29    */

30   TokenInteger(final String JavaDoc raw) {
31     super(raw, TokenType.Integer);
32   }
33
34
35   /**
36    * gets the string representation of the decimal.
37    * @return the integral part.
38    */

39   public final String JavaDoc getString(){return getText();}
40
41   private static final Tokenizer tn = new Tokenizer(){
42     public Object JavaDoc toToken(final CharSequence JavaDoc cs,
43         final int from, final int len){
44       return new TokenInteger(cs.subSequence(from, from+len).toString());
45     }
46   };
47   /**
48    * Creates a Tokenizer that's gonna tokenize any valid decimal literal string to a TokenDecimal object.
49    * @return the Tokenizer instance.
50    */

51   public static Tokenizer getTokenizer(){return tn;}
52 }
53
Popular Tags