Building Parsers with Java

sjm.examples.string
Class Substring

java.lang.Object
  |
  +--sjm.examples.string.StringFunction
        |
        +--sjm.examples.string.Substring

public class Substring
extends StringFunction

This class wraps a substring function around an instance of another StringFunction class.


Field Summary
protected  int from
           
protected  boolean rest
           
protected  int to
           
 
Fields inherited from class sjm.examples.string.StringFunction
source
 
Constructor Summary
Substring(StringFunction source, int from)
          Construct a Substring function that will wrap itself around the supplied source, returning the portion of a string from the given index to the string's end.
Substring(StringFunction source, int from, int to)
          Construct a Substring function that will wrap itself around the supplied source, returning the portion of a string from the given from index to the given to index.
 
Method Summary
 java.lang.String f(java.lang.String s)
          Return a substring of the value of source.f(s) , where s is the supplied string, and source is this function's source function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

from

protected int from

to

protected int to

rest

protected boolean rest
Constructor Detail

Substring

public Substring(StringFunction source,
                 int from)
Construct a Substring function that will wrap itself around the supplied source, returning the portion of a string from the given index to the string's end.

Substring

public Substring(StringFunction source,
                 int from,
                 int to)
Construct a Substring function that will wrap itself around the supplied source, returning the portion of a string from the given from index to the given to index.
Method Detail

f

public java.lang.String f(java.lang.String s)
Return a substring of the value of source.f(s) , where s is the supplied string, and source is this function's source function.
Overrides:
f in class StringFunction

by Steve Metsker