Package csv

Class CSVFactory

java.lang.Object
csv.CSVFactory

public class CSVFactory
extends java.lang.Object
This factory returns correct reader and writer implementations for given files.
Author:
RalphSchuster
  • Constructor Details

    • CSVFactory

      protected CSVFactory()
      Creates the factory and initializes.
  • Method Details

    • getFactory

      public static CSVFactory getFactory()
      Returns the factory for rading/writing tables.
      Returns:
      factory factory object (singleton)
    • init

      protected void init()
      Initializes the factory.
    • initReaderMap

      protected void initReaderMap()
      Initializes the reader map.
    • initWriterMap

      protected void initWriterMap()
      Initializes the writer map.
    • register

      public void register​(MimeTypeInfo mimeTypeInfo)
      Registers a new MIME type.
      Parameters:
      mimeTypeInfo - the info to register
    • getReader

      public TableReader getReader​(java.lang.String file) throws java.io.IOException
      Returns the correct reader for the given file.
      Parameters:
      file - filename
      Returns:
      reader class instance to be used
      Throws:
      java.io.IOException - when the file cannot be read
    • getReader

      public TableReader getReader​(java.io.File file) throws java.io.IOException
      Returns the correct reader for the given file.
      Parameters:
      file - file
      Returns:
      reader class instance to be used
      Throws:
      java.io.IOException - when the file cannot be read
    • getMimeTypeReader

      public AbstractStreamTableReader getMimeTypeReader​(java.lang.String mimeType)
      Returns a reader for the given MIME type.
      Parameters:
      mimeType - MIME type
      Returns:
      reader to be used
    • getWriter

      public AbstractStreamTableWriter getWriter​(java.lang.String file) throws java.io.IOException
      Returns the correct reader for the given file.
      Parameters:
      file - filename
      Returns:
      reader class instance to be used
      Throws:
      java.io.IOException - when the file cannot be written
    • getWriter

      public AbstractStreamTableWriter getWriter​(java.io.File file) throws java.io.IOException
      Returns the correct reader for the given file.
      Parameters:
      file - file
      Returns:
      reader class instance to be used
      Throws:
      java.io.IOException - when the file cannot be written
    • getMimeTypeWriter

      public AbstractStreamTableWriter getMimeTypeWriter​(java.lang.String mimeType)
      Returns a writer for the given MIME type.
      Parameters:
      mimeType - MIME type
      Returns:
      writer to be used
    • getMimeType

      public java.lang.String getMimeType​(java.io.File file)
      Returns the MIME type for the given file.
      Parameters:
      file - file to check
      Returns:
      MIME type of file