com.holub.text
Class SimpleToken

java.lang.Object
  extended by com.holub.text.SimpleToken
All Implemented Interfaces:
Token

public class SimpleToken
extends Object
implements Token

Matches a simple symbol that doesn't have to be on a "word" boundary; punctuation, for example. SimpleToken is very efficient, but does not recognize characters in a case-insensitive way, as does WordToken and RegexToken.

©2004 Allen I. Holub. All rights reserved.

This code may be used freely by yourself with the following restrictions:

  1. Your splash screen, about box, or equivalent, must include Allen Holub's name, copyright, and URL. For example:

    This program contains Allen Holub's SQL package.
    (c) 2005 Allen I. Holub. All Rights Reserved.
    http://www.holub.com


    If your program does not run interactively, then the foregoing notice must appear in your documentation.
  2. You may not redistribute (or mirror) the source code.
  3. You must report any bugs that you find to me. Use the form at http://www.holub.com/company/contact.html or send email.
  4. The software is supplied as is. Neither Allen Holub nor Holub Associates are responsible for any bugs (or any problems caused by bugs, including lost productivity or data) in any of this code.

Constructor Summary
SimpleToken(String pattern)
          Create a token.
 
Method Summary
 String lexeme()
          Returns the input string that matched the token specification.
 boolean match(String input, int offset)
          Returns true if the sequence at the indicated offset from the beginning of the indicated input string matches the current token.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleToken

public SimpleToken(String pattern)
Create a token.

Parameters:
pattern - a string that defines a literal-match lexeme.
Method Detail

match

public boolean match(String input,
                     int offset)
Description copied from interface: Token
Returns true if the sequence at the indicated offset from the beginning of the indicated input string matches the current token.

Specified by:
match in interface Token

lexeme

public String lexeme()
Description copied from interface: Token
Returns the input string that matched the token specification.

Specified by:
lexeme in interface Token

toString

public String toString()
Overrides:
toString in class Object