Forum Navigation
stream parsing
Posted: 01/05/09 15:39:23I am writing a stream parser, this is quite similar to the iterators that inherit tango.io.stream.Iterator.
the source.next method is quite nice, but I miss some more control, basically knowing if the slice that I get from the buffer is a (possibly) partial slice, a slice to EOF, or a maximal slice (due to buffer capacity).
I want to know this because I want to parse things (like numbers) that are not explicitly terminated, so if I parse a number that ends at the end of the slice I do not know if I should ask to load more data or not (returning Eof if the file ends there would fail the match, even if it is actually ok).
The basic interface is flexible enough, so at the moment I have solved this by writing my next method that takes a scanner that has an extra argument (Partial,Maximal,End) and creating a delegate without that argument to pass on, and using some extra logic.
Still I wonder if something like that should not be part of the default interface (or I have missed something and there is a better way to do this).