Class RandomAccessScanner

  • All Implemented Interfaces:
    Iterator<String>

    public class RandomAccessScanner
    extends Scanner
    This class adds random access capabilities to the repast.simphony.integration.Scanner class. This contains a mark stack, meaning you can have multiple marks set at once, and jump back up them.
    Version:
    $Revision$ $Date$
    Author:
    Jerry Vos
    • Constructor Detail

      • RandomAccessScanner

        public RandomAccessScanner​(FileChannel channel,
                                   String charset)
      • RandomAccessScanner

        public RandomAccessScanner​(FileChannel channel)
      • RandomAccessScanner

        public RandomAccessScanner​(String source)
    • Method Detail

      • getPosition

        public long getPosition()
                         throws IOException
        Returns the current position of the channel. This accounts for any buffered data, therefore it returns the true position the scanner is at, not just the position the channel is at.
        Returns:
        the position the scanner is at in the channel's data.
        Throws:
        IOException
      • getBufferLength

        protected int getBufferLength()
      • syncToSource

        protected void syncToSource()
      • popMark

        public Long popMark()
        Removes a mark from the mark stack. This does not position the stream to the location of the pop'd mark.
        Returns:
        the value of the mark
      • reset

        public void reset()
                   throws IOException
        Positions the stream to the position last marked. This does not pop the mark off the mark stack.
        Throws:
        IOException
      • position

        public void position​(long position)
                      throws IOException
        Positions the stream to the specified location. This results in a clearing of the internal buffer and a refilling of it starting at the specified location.
        Parameters:
        position - the position to put the stream at
        Throws:
        IOException