Class AsciiFeatureCodec<T extends Feature>

  • Type Parameters:
    T - The feature type this codec reads
    All Implemented Interfaces:
    FeatureCodec<T,​LineIterator>
    Direct Known Subclasses:
    AbstractVCFCodec, BEDCodec, IntervalListCodec

    public abstract class AsciiFeatureCodec<T extends Feature>
    extends AbstractFeatureCodec<T,​LineIterator>
    A convenience base class for codecs that want to read in features from ASCII lines.

    This class overrides the general decode locs for streams and presents instead Strings to decode(String) and readHeader(LineReader) functions.

    • Constructor Detail

      • AsciiFeatureCodec

        protected AsciiFeatureCodec​(Class<T> myClass)
    • Method Detail

      • isDone

        public boolean isDone​(LineIterator lineIterator)
        Description copied from interface: FeatureCodec
        Adapter method that assesses whether the provided FeatureCodec has more data. True if it does, false otherwise.
      • makeSourceFromStream

        public LineIterator makeSourceFromStream​(InputStream bufferedInputStream)
        Description copied from interface: FeatureCodec
        Generates a reader of type FeatureCodec appropriate for use by this codec from the generic input stream. Implementers should assume the stream is buffered.
      • decode

        public T decode​(LineIterator lineIterator)
        Convenience method. Decoding in ASCII files operates line-by-line, so obviate the need to call Iterator.next() in implementing classes and, instead, have them implement decode(String).
        Parameters:
        lineIterator - the input stream from which to decode the next record
        Returns:
        Return the Feature encoded by the line, or null if the line does not represent a feature (e.g. is a comment)
      • readHeader

        public FeatureCodecHeader readHeader​(LineIterator lineIterator)
                                      throws IOException
        Description copied from interface: FeatureCodec
        Read and return the header, or null if there is no header. Note: Implementers of this method must be careful to read exactly as much from FeatureCodec as needed to parse the header, and no more. Otherwise, data that might otherwise be fed into parsing a Feature may be lost.
        Parameters:
        lineIterator - the source from which to decode the header
        Returns:
        header object
        Throws:
        IOException
      • readActualHeader

        public abstract Object readActualHeader​(LineIterator reader)
        Read and return the header, or null if there is no header.
        Returns:
        the actual header data in the file, or null if none is available