Building Parsers with Java

sjm.examples.string
Class StringFunction

java.lang.Object
  |
  +--sjm.examples.string.StringFunction
Direct Known Subclasses:
Identity, LowerCase, Substring, Trim, UpperCase

public abstract class StringFunction
extends java.lang.Object

A StringFunction implements the method f() to accept a string, apply a function to it, and return a string. This class is abstract, and each subclass represents a different function to apply. The functions wrap each other, to allow runtime composition of new functions.


Field Summary
protected  StringFunction source
           
 
Constructor Summary
StringFunction()
          Construct a function whose source function is identity, which does not change a string.
StringFunction(StringFunction source)
          Construct a function whose source is the given function.
 
Method Summary
abstract  java.lang.String f(java.lang.String s)
          Each subclass should implement this method in manner that applies a function to the input string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected StringFunction source
Constructor Detail

StringFunction

public StringFunction()
Construct a function whose source function is identity, which does not change a string.

StringFunction

public StringFunction(StringFunction source)
Construct a function whose source is the given function.
Method Detail

f

public abstract java.lang.String f(java.lang.String s)
Each subclass should implement this method in manner that applies a function to the input string. The class name should represent the function applied here.

by Steve Metsker