dk.brics.string.java
Class Automatons

java.lang.Object
  extended by dk.brics.string.java.Automatons
All Implemented Interfaces:
AutomatonProvider

public class Automatons
extends Object
implements AutomatonProvider

Provides automatons for common Java types. All automatons are defined to accept the possible output of a toString method, so integer literals like -0 and float literals .45 are not accepted!


Constructor Summary
Automatons()
           
 
Method Summary
static Automaton fromType(String name)
          Gets an automaton accepting values of the specified type converted to a string.
 Automaton getAutomaton(String name)
           
static Automaton getBoolean()
          Gets an automaton accepting the possible return values of Boolean.toString(), which are the strings "true" and "false".
static Automaton getFloat()
          Gets an automaton accepting the possible return values of Float.toString() and Double.toString().
static Automaton getInteger()
          Gets an automaton accepting the possible return values of Integer.toString(), Long.toString(), Byte.toString() and Short.toString().
static Automaton getNull()
          Gets an automaton accepting only the string "null".
static Automaton getUnsignedInteger()
          Gets an automaton accepting the possible return values of Integer.toString() and Long.toString() for non-negative integers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Automatons

public Automatons()
Method Detail

fromType

public static Automaton fromType(String name)
Gets an automaton accepting values of the specified type converted to a string.

Parameters:
name - name of a primitive type or a wrapper type. For example, int or java.lang.Boolean.
Returns:
an automaton accepting values of the specified type converted to a string, or null if the name was not a primitive or wrapper type.

getAutomaton

public Automaton getAutomaton(String name)
Specified by:
getAutomaton in interface AutomatonProvider

getBoolean

public static Automaton getBoolean()
Gets an automaton accepting the possible return values of Boolean.toString(), which are the strings "true" and "false". Does not accept the string "null".


getFloat

public static Automaton getFloat()
Gets an automaton accepting the possible return values of Float.toString() and Double.toString(). Does not accept the string "null".

Note that this includes the strings "NaN", "Infinity" and "-Infinity" (without the quotes).


getInteger

public static Automaton getInteger()
Gets an automaton accepting the possible return values of Integer.toString(), Long.toString(), Byte.toString() and Short.toString(). Does not accept the string "null".

Integer literals like -0 and 034 are not accepted, because such literals cannot be returned by the toString method.


getNull

public static Automaton getNull()
Gets an automaton accepting only the string "null".


getUnsignedInteger

public static Automaton getUnsignedInteger()
Gets an automaton accepting the possible return values of Integer.toString() and Long.toString() for non-negative integers. Does not accept the string "null".

Integer literals like 034 are not accepted, because such literals cannot be returned by the toString method.



Copyright © 2003-2009 Anders Møller, Aske Simon Christensen, Asger Feldthaus.