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
-
Constructor Summary
ConstructorDescriptionRandomAccessScanner
(String source) RandomAccessScanner
(FileChannel channel) RandomAccessScanner
(FileChannel channel, String charset) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
long
Returns the current position of the channel.void
mark()
Adds a mark to the mark stack.popMark()
Removes a mark from the mark stack.void
position
(long position) Positions the stream to the specified location.void
reset()
Positions the stream to the position last marked.protected void
Methods inherited from class repast.simphony.util.Scanner
buffer, bufferMore, delimiter, getNextDelimited, getNextLength, getNextPattern, handleIOException, hasNext, ioException, next, remove, useDelimiter, useDelimiter
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
-