Class PipeFileType

    • Constructor Summary

      Constructors 
      Constructor Description
      PipeFileType()
      Creates a pipe file.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      FileType checkConnection()
      Tests if an InputStream can be opened for this FileType.
      protected java.io.InputStream createInputStream()
      Creates an InputStream for the underlying file.
      protected java.io.OutputStream createOutputStream()
      Creates an OutputStream for the underlying file.
      java.io.Reader createReader()
      Creates a Reader for this FileType.
      java.io.Writer createWriter​(java.lang.String encoding)
      A PipeFileType does not create backups.
      java.io.Writer createWriter​(java.lang.String encoding, int numberOfBackups)
      A PipeFileType does not create backups.
      java.lang.String getEncoding()
      This method tries to find the encoding tag in the CR file.
      java.io.File getFile()
      Returns null.
      java.lang.String getInnerName()
      Returns an empty string.
      java.lang.String getName()
      Returns an empty string.
      boolean isBZIP2File()
      Determines, whether a file is a BZIP2 filetype by Jonathan 20060917 (Fiete)
      boolean isCRFile()
      Deprecated.
      we don't seem to need any of this any more
      boolean isGZIPFile()
      Determines, whether a file is a GZIP filetype by Jonathan 20060917 (Fiete)
      boolean isXMLFile()
      Determines, whether a file is of XML filetype, moved from com.eressea.io.GameDataReader by Jonathan 20060917 (Fiete)
      boolean isZIPFile()
      Determines, whether a file is a ZIP filetype by Jonathan 20060917 (Fiete)
      void setCreateBackup​(boolean createBackup)
      Enables or disables creation of backup files.
      void setEncoding​(java.lang.String _encoding)
      Changes the encoding.
      void setReadonly​(boolean readonly)
      Sets whether file is readonly.
      java.lang.String toString()
      Returns a String representation of the FileType.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PipeFileType

        public PipeFileType()
                     throws java.io.IOException
        Creates a pipe file. Everything written to the reader given by createReader() will be directly written to the writer given by createWriter(String). There is no actual file involved.
        Throws:
        java.io.IOException - if an I/O error occurs.
    • Method Detail

      • createInputStream

        protected java.io.InputStream createInputStream()
                                                 throws java.io.IOException
        Description copied from class: FileType
        Creates an InputStream for the underlying file.
        Overrides:
        createInputStream in class FileType
        Returns:
        an InputStream of the underlying file.
        Throws:
        java.io.IOException - If the file cannot be opened for reading
        See Also:
        FileType.createInputStream()
      • createOutputStream

        protected java.io.OutputStream createOutputStream()
                                                   throws java.io.IOException
        Description copied from class: FileType
        Creates an OutputStream for the underlying file.
        Overrides:
        createOutputStream in class FileType
        Returns:
        an OutputStream of the underlying file.
        Throws:
        java.io.IOException - If the file cannot be opened for writing
        See Also:
        FileType.createOutputStream()
      • checkConnection

        public FileType checkConnection()
                                 throws java.io.IOException
        Description copied from class: FileType
        Tests if an InputStream can be opened for this FileType.
        Overrides:
        checkConnection in class FileType
        Returns:
        this
        Throws:
        java.io.IOException - If the file cannot be opened for the required operation (reading or writing).
      • createWriter

        public java.io.Writer createWriter​(java.lang.String encoding)
                                    throws java.io.IOException
        A PipeFileType does not create backups.
        Overrides:
        createWriter in class FileType
        Parameters:
        encoding - The name of a supported charset
        Returns:
        a Writer of the underlying File.
        Throws:
        FileType.ReadOnlyException - If file is marked as readonly or cannot be opened
        java.io.IOException - If another IOException occured
        See Also:
        FileType.createWriter(java.lang.String)
      • createWriter

        public java.io.Writer createWriter​(java.lang.String encoding,
                                           int numberOfBackups)
                                    throws java.io.IOException
        A PipeFileType does not create backups.
        Overrides:
        createWriter in class FileType
        Parameters:
        encoding - The name of a supported charset
        numberOfBackups - This many backup files (marked with ~#~ will) be created.
        Returns:
        a Writer of the underlying File.
        Throws:
        FileType.ReadOnlyException - If file is marked as readonly or cannot be opened
        java.io.IOException - If the file cannot be created
        See Also:
        FileType.createWriter(java.lang.String, int)
      • createReader

        public java.io.Reader createReader()
                                    throws java.io.IOException
        Description copied from class: FileType
        Creates a Reader for this FileType.
        Overrides:
        createReader in class FileType
        Returns:
        a Reader of the underlying File.
        Throws:
        java.io.IOException - Never
      • getEncoding

        public java.lang.String getEncoding()
        Description copied from class: FileType
        This method tries to find the encoding tag in the CR file.
        Overrides:
        getEncoding in class FileType
      • setEncoding

        public void setEncoding​(java.lang.String _encoding)
        Changes the encoding.
        Parameters:
        _encoding -
      • getFile

        public java.io.File getFile()
                             throws java.io.IOException
        Returns null.
        Overrides:
        getFile in class FileType
        Returns:
        a File object
        Throws:
        java.io.IOException - if file cannot be determined, e.g. for an url pointing to an InputStream.
        See Also:
        FileType.getFile()
      • getName

        public java.lang.String getName()
        Returns an empty string.
        Overrides:
        getName in class FileType
        Returns:
        the name of the FileType
        See Also:
        FileType.getName()
      • isBZIP2File

        public boolean isBZIP2File()
                            throws java.io.IOException
        Description copied from class: FileType
        Determines, whether a file is a BZIP2 filetype by Jonathan 20060917 (Fiete)
        Overrides:
        isBZIP2File in class FileType
        Returns:
        true, if the file is of BZIP2 type
        Throws:
        java.io.IOException
      • isCRFile

        @Deprecated
        public boolean isCRFile()
                         throws java.io.IOException
        Deprecated.
        we don't seem to need any of this any more
        Description copied from class: FileType
        Determines, whether a file is of CR filetype, moved from com.eressea.io.GameDataReader by Jonathan 20060917 (Fiete)
        Overrides:
        isCRFile in class FileType
        Returns:
        true, if the file is of CR type or of unknown type
        Throws:
        java.io.IOException
        See Also:
        FileType.isCRFile()
      • isGZIPFile

        public boolean isGZIPFile()
                           throws java.io.IOException
        Description copied from class: FileType
        Determines, whether a file is a GZIP filetype by Jonathan 20060917 (Fiete)
        Overrides:
        isGZIPFile in class FileType
        Returns:
        true, if the file is of GZIP type
        Throws:
        java.io.IOException
      • isXMLFile

        public boolean isXMLFile()
                          throws java.io.IOException
        Description copied from class: FileType
        Determines, whether a file is of XML filetype, moved from com.eressea.io.GameDataReader by Jonathan 20060917 (Fiete)
        Overrides:
        isXMLFile in class FileType
        Returns:
        true, if the file is of XML type
        Throws:
        java.io.IOException
      • isZIPFile

        public boolean isZIPFile()
                          throws java.io.IOException
        Description copied from class: FileType
        Determines, whether a file is a ZIP filetype by Jonathan 20060917 (Fiete)
        Overrides:
        isZIPFile in class FileType
        Returns:
        true, if the file is of ZIP type
        Throws:
        java.io.IOException
      • setCreateBackup

        public void setCreateBackup​(boolean createBackup)
        Description copied from class: FileType
        Enables or disables creation of backup files.
        Overrides:
        setCreateBackup in class FileType
        Parameters:
        createBackup - true if backups shall be created
      • setReadonly

        public void setReadonly​(boolean readonly)
        Description copied from class: FileType
        Sets whether file is readonly.
        Overrides:
        setReadonly in class FileType
      • toString

        public java.lang.String toString()
        Description copied from class: FileType
        Returns a String representation of the FileType.
        Overrides:
        toString in class FileType
        Returns:
        a String representation of the FileType.