Package repast.simphony.util
Class RandomAccessScanner
java.lang.Object
repast.simphony.util.Scanner
repast.simphony.util.RandomAccessScanner
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
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRandomAccessScanner(String source) RandomAccessScanner(FileChannel channel) RandomAccessScanner(FileChannel channel, String charset) -
Method Summary
Modifier and TypeMethodDescriptionprotected intlongReturns the current position of the channel.voidmark()Adds a mark to the mark stack.popMark()Removes a mark from the mark stack.voidposition(long position) Positions the stream to the specified location.voidreset()Positions the stream to the position last marked.protected voidMethods inherited from class repast.simphony.util.Scanner
buffer, bufferMore, delimiter, getNextDelimited, getNextLength, getNextPattern, handleIOException, hasNext, ioException, next, remove, useDelimiter, useDelimiterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
fileChannel
-
markStack
-
-
Constructor Details
-
RandomAccessScanner
-
RandomAccessScanner
-
RandomAccessScanner
-
-
Method Details
-
getPosition
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() -
mark
Adds a mark to the mark stack.- Throws:
IOException
-
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
Positions the stream to the position last marked. This does not pop the mark off the mark stack.- Throws:
IOException
-
position
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
-