Class SampleSkipStream<T>

java.lang.Object
opennlp.tools.formats.leipzig.SampleSkipStream<T>
Type Parameters:
T - The template parameter which represents the Sample type.
All Implemented Interfaces:
AutoCloseable, ObjectStream<T>

class SampleSkipStream<T> extends Object implements ObjectStream<T>
A specialization of ObjectStream that skips a number of samples.
  • Field Details

    • samples

      private final ObjectStream<T> samples
    • samplesToSkip

      private final int samplesToSkip
  • Constructor Details

    • SampleSkipStream

      SampleSkipStream(ObjectStream<T> samples, int samplesToSkip) throws IOException
      Initializes a SampleSkipStream with the specified parameters.
      Parameters:
      samples - The ObjectStream to process.
      samplesToSkip - The number of samples to skip. Must be greater than 0.
      Throws:
      IOException - Thrown if IO errors occurred during skip operation.
  • Method Details

    • read

      public T read() throws IOException
      Description copied from interface: ObjectStream
      Returns the next T object. Calling this method repeatedly until it returns null will return each object from the underlying source exactly once.
      Specified by:
      read in interface ObjectStream<T>
      Returns:
      The next object or null to signal that the stream is exhausted.
      Throws:
      IOException - Thrown if there is an error during reading.
    • reset

      public void reset() throws IOException, UnsupportedOperationException
      Description copied from interface: ObjectStream
      Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly. This method can be used to re-read the stream if multiple passes over the objects are required.

      The implementation of this method is optional.

      Specified by:
      reset in interface ObjectStream<T>
      Throws:
      IOException - Thrown if there is an error during resetting the stream.
      UnsupportedOperationException - Thrown if the reset() is not supported. By default, this is the case.
    • skipSamples

      private void skipSamples() throws IOException
      Throws:
      IOException