pobs
Interface PScanner

All Known Implementing Classes:
PReverseScanner, PStringScanner, PTextScanner

public interface PScanner

Provides the standard interface to which all iterators must conform. The use of a generic iterator allows any parser to be linked to any source of input and enables the iterator implementor to optimize where required. The PScanner defines only the output of an iterator to be in the form of a standard Java Character or String, it makes no demands as to the input. It is upto the class implementing this interface to make any necessary conversions to support these output formats.

Note, that during parsing the index for charAt(long)might not increase monotonically!

Author:
Martijn W. van der Lee

Method Summary
 char charAt(long index)
          Returns the character at the specified location.
 long length()
          Gives the length of this scanners' content.
 java.lang.String substring(long beginIndex, long endIndex)
          Returns the part of the input from the beginning upto the ending index locations.
 

Method Detail

charAt

public char charAt(long index)
            throws java.lang.IndexOutOfBoundsException
Returns the character at the specified location.

Parameters:
index - position of the character to return
Returns:
character at the specified index
Throws:
java.lang.IndexOutOfBoundsException - when the specified index is either less than zero or equal or more than the length

length

public long length()
Gives the length of this scanners' content. That is; the last position which can be indexed.

Returns:
the length of this iterator.

substring

public java.lang.String substring(long beginIndex,
                                  long endIndex)
Returns the part of the input from the beginning upto the ending index locations.

Parameters:
beginIndex - starting offset from which to extract the substring
endIndex - ending offset at which the substring ends
Returns:
the substring
See Also:
String