|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--noope.input.BlockReader | +--noope.input.ArrayBlockReader
This class implements the simplest possible BlockReader. I wrote it because I needed something to test Entity with. It is called ArrayBlockReader, because the constructor is passed an array of entries and an array of subblocks, and that's how they're stored. N.B.: Locations and contexts are not implemented (and presumably, won't be, because this is only intended for testing). All other methods are overridden and do exactly what they should according to the specification of BlockReader. If you try to read beyond the end of the Entry/Subblock list, you get an Array:IndexOutOfBounds exception.
Constructor Summary | |
ArrayBlockReader(java.lang.String h,
java.lang.String p,
java.lang.String[][] e,
BlockReader[] sub)
Construct an ArrayBlockReader from strings and string arrays. |
Method Summary | |
BlockReaderLocation |
getBlockLocation()
Similar to getEntryLocation |
BlockReaderContext |
getContext(BlockReaderLocation loc)
Converts a Location into a fully-qualified Context object. |
BlockReaderLocation |
getEntryLocation()
Returns a BlockReaderLocation object describing the current Entry location. |
java.lang.String |
getHeader()
Returns the header of this block. |
BlockReader |
getNextBlock()
Returns the next subblock, which is an instance of BlockReader. |
java.lang.String[] |
getNextEntry()
Returns the next Entry, as a string array. |
java.lang.String |
getParameter()
Returns the parameter of this block. |
boolean |
hasMoreBlocks()
Returns TRUE if this block has more Blocks after the one that was last returned |
boolean |
hasMoreEntries()
Returns TRUE if this block has more Entries after the one that was last returned |
BlockReader |
peekNextBlock()
This method acts as getNextBlock() but does not advance position |
java.lang.String[] |
peekNextEntry()
This method acts as getNextEntry() but does not advance position |
void |
seekFirstBlock()
Resets the subblock position to the beginning, so that the next call to getNextBlock() will return the first subblock (unless there are no subblocks, in which case an exception is thrown, of course. |
void |
seekFirstEntry()
Moves the "entry pointer" back to the first Entry, so that the next call to getNextEntry() will return the first one in the block |
java.lang.String |
toString()
This method lists the contents of the BlockReader. |
Methods inherited from class noope.input.BlockReader |
assertEmpty |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ArrayBlockReader(java.lang.String h, java.lang.String p, java.lang.String[][] e, BlockReader[] sub)
h
- the header of the blockp
- the parameter of the block.e
- is the array of entries; each entry is an array of size 2 of Strings.sub
- is the array of subblocks, each of which is a BlockReader.Method Detail |
public java.lang.String getHeader()
BlockReader
getHeader
in class BlockReader
public java.lang.String getParameter()
BlockReader
getParameter
in class BlockReader
public boolean hasMoreEntries()
BlockReader
hasMoreEntries
in class BlockReader
public java.lang.String[] getNextEntry()
BlockReader
getNextEntry
in class BlockReader
public java.lang.String[] peekNextEntry()
BlockReader
peekNextEntry
in class BlockReader
public void seekFirstEntry()
BlockReader
seekFirstEntry
in class BlockReader
public BlockReaderLocation getEntryLocation()
BlockReader
getEntryLocation
in class BlockReader
public boolean hasMoreBlocks()
BlockReader
hasMoreBlocks
in class BlockReader
public BlockReader getNextBlock()
BlockReader
getNextBlock
in class BlockReader
public BlockReader peekNextBlock()
BlockReader
peekNextBlock
in class BlockReader
public void seekFirstBlock()
BlockReader
seekFirstBlock
in class BlockReader
public BlockReaderLocation getBlockLocation()
BlockReader
getBlockLocation
in class BlockReader
public BlockReaderContext getContext(BlockReaderLocation loc)
BlockReader
getContext
in class BlockReader
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |