Klasse ReaderFactory

java.lang.Object
edu.hm.hafner.analysis.ReaderFactory
Bekannte direkte Unterklassen:
FileReaderFactory

public abstract class ReaderFactory extends Object
Provides several useful helper methods to read the contents of a resource that is given by a Reader.
Autor:
Ullrich Hafner
  • Konstruktordetails

    • ReaderFactory

      public ReaderFactory(Charset charset)
      Creates a new factory to read a resource with a given charset.
      Parameter:
      charset - the charset to use when reading the file
    • ReaderFactory

      public ReaderFactory(Charset charset, Function<String,String> lineMapper)
      Creates a new factory to read a resource with a given charset.
      Parameter:
      charset - the charset to use when reading the file
      lineMapper - provides a mapper to transform each of the resource lines
  • Methodendetails

    • getFileName

      public abstract String getFileName()
      Returns the name of the resource.
      Gibt zurück:
      the file name
    • create

      @MustBeClosed public abstract Reader create()
      Creates a new Reader for the file.
      Gibt zurück:
      a reader
    • readStream

      @MustBeClosed public Stream<String> readStream()
      Provides the lines of the file as a Stream of strings.
      Gibt zurück:
      the file content as stream
      Löst aus:
      ParsingException - if the file could not be read
    • readString

      public String readString()
      Reads the whole file into a String.
      Gibt zurück:
      the file content as string
      Löst aus:
      ParsingException - if the file could not be read
    • readDocument

      public Document readDocument()
      Parses the whole file into a Document.
      Gibt zurück:
      the file content as document
      Löst aus:
      ParsingException - if the file could not be parsed
    • getCharset

      public Charset getCharset()
      Returns the character set that is used to read the stream.
      Gibt zurück:
      the character set
    • parse

      public void parse(DefaultHandler handler)
      Parses the whole file with the specified SAX DefaultHandler.
      Parameter:
      handler - the SAX handler to parse the file
      Löst aus:
      ParsingException - if the file could not be parsed