edu.umd.cfar.lamp.viper.gui.data
Class StringParserFSM

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.gui.data.StringParserFSM
Direct Known Subclasses:
IntegerFSM, IntegerListFSM

public abstract class StringParserFSM
extends java.lang.Object

Provides an interface for my kind of text field - the kind that won't even let you type something that isn't valid. Although I usually use FSMs to implement this, thus the name, it is by no means a constraint on the implementation. Feel free to consult whatever psychic necessary.

Since:
Jul 10, 2003
Author:
davidm@cfar.umd.edu

Constructor Summary
StringParserFSM()
           
 
Method Summary
 boolean addString(java.lang.String s)
           
 java.lang.String getValidString()
          Gets a valid version from the current state.
abstract  boolean pushDown(char c)
          Parse the next character.
abstract  void reset()
          Reset to the start state.
abstract  java.lang.String toString()
          Gets the current parsed characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringParserFSM

public StringParserFSM()
Method Detail

pushDown

public abstract boolean pushDown(char c)
Parse the next character. This isn't terribly Unicode safe, now, is it?

Parameters:
c - the character to push onto the stack
Returns:
true if the character was added to the stack

reset

public abstract void reset()
Reset to the start state.


toString

public abstract java.lang.String toString()
Gets the current parsed characters. It should be a valid string of the language the FSM represents, or an empty string. It is up to the implementor to decide what to do with a partial string.

Returns:
the current parsed characters

getValidString

public java.lang.String getValidString()
Gets a valid version from the current state. For example, a floating point with toString as "12e" would return the valid part "12", or a bounding box parsed as "12 13 4" might return "12 13 4 0" or "".

Returns:
Default is to return the value of 'toString' method

addString

public boolean addString(java.lang.String s)
Parameters:
s - the characters to try to push down
Returns:
false if any characters were not added