to.etc.domui.converter
Class MiniScanner

java.lang.Object
  extended by to.etc.domui.converter.MiniScanner

public class MiniScanner
extends java.lang.Object

A helper class which handles string scanning for converters.

Author:
Frits Jalvingh Created on Jul 29, 2009

Constructor Summary
MiniScanner()
           
 
Method Summary
 boolean accept()
          Move past the "current" character to the next one; return false if eof.
 boolean copy()
          Accept the current character and copy it to the buffer; return eof if we are at eof after the accept.
 void copy(int i)
           
 boolean eof()
          Return T if at eof.
 boolean eofSkipWS()
          Returns T if all that is left is whitespace before eof.
static MiniScanner getInstance()
          Get a miniscanner instance.
 java.lang.String getStringResult()
          Returns the string built in the buffer and clears the buffer in the process.
 void init(java.lang.String in)
          Reset the scanner for a next string to scan.
 int LA()
          Return the character at the current location, or -1 if at end of the string.
 int LA(int ix)
          Return the nth char after the current location, or -1 if that is past the end of the string.
 boolean match(java.lang.String s)
           
 long scanDuration(java.lang.String in)
           
 boolean scanLaxNumber(java.lang.String in)
          FIXME THIS IS WRONG - for any real type we cannot distinguish between the use of decimal point or comma as either separator or fraction indicator.
 boolean scanLaxWithCurrencySign(java.lang.String in)
          Scans the input as a lax euro string and leave the buffer to hold a parseable numeric string for one of the to-java-type converters.
 boolean skip(char c)
          If the current character equals the specified one skip it by accept() and return true, else do nothing and return false.
 void skipWs()
          Skip till the 1st non-ws character.
 int val()
          Returns the last integer "value" scanned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MiniScanner

public MiniScanner()
Method Detail

getInstance

public static MiniScanner getInstance()
Get a miniscanner instance. This is the preferred method to allocate one if you need it a lot (it caches an instance in a threadlocal).

Returns:

init

public void init(java.lang.String in)
Reset the scanner for a next string to scan.

Parameters:
in -

LA

public int LA()
Return the character at the current location, or -1 if at end of the string.

Returns:

LA

public int LA(int ix)
Return the nth char after the current location, or -1 if that is past the end of the string.

Parameters:
ix -
Returns:

accept

public boolean accept()
Move past the "current" character to the next one; return false if eof.


copy

public boolean copy()
Accept the current character and copy it to the buffer; return eof if we are at eof after the accept.

Returns:

copy

public void copy(int i)

skip

public boolean skip(char c)
If the current character equals the specified one skip it by accept() and return true, else do nothing and return false.

Parameters:
c -
Returns:

eof

public boolean eof()
Return T if at eof.

Returns:

getStringResult

public java.lang.String getStringResult()
Returns the string built in the buffer and clears the buffer in the process.

Returns:

eofSkipWS

public boolean eofSkipWS()
Returns T if all that is left is whitespace before eof.

Returns:

scanLaxWithCurrencySign

public boolean scanLaxWithCurrencySign(java.lang.String in)
                                throws ValidationException
Scans the input as a lax euro string and leave the buffer to hold a parseable numeric string for one of the to-java-type converters.

Throws:
ValidationException

scanLaxNumber

public boolean scanLaxNumber(java.lang.String in)
                      throws ValidationException
FIXME THIS IS WRONG - for any real type we cannot distinguish between the use of decimal point or comma as either separator or fraction indicator.

Parameters:
in -
Returns:
Throws:
ValidationException

val

public int val()
Returns the last integer "value" scanned.

Returns:

scanDuration

public long scanDuration(java.lang.String in)

skipWs

public void skipWs()
Skip till the 1st non-ws character.


match

public boolean match(java.lang.String s)