Class FileLocation

  • All Implemented Interfaces:
    Location
    Direct Known Subclasses:
    URLLocation

    class FileLocation
    extends java.lang.Object
    implements Location
    file location implementation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.nio.channels.FileChannel channel  
      private java.io.File file  
      private java.lang.String specification  
      private java.io.FileInputStream stream  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileLocation​(java.io.File file, java.lang.String specification)  
      FileLocation​(java.lang.String specification)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the location.
      java.io.File getFile()  
      java.io.InputStream getInputStream()  
      java.lang.String getSpecification()  
      protected void initFile()
      initialize file.
      void open()
      Open the location.
      int read​(byte[] buffer)  
      int read​(java.nio.ByteBuffer buffer)  
      protected void setFile​(java.io.File file)  
      (package private) java.io.File unsafeGetFile()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • file

        private java.io.File file
      • channel

        private java.nio.channels.FileChannel channel
      • specification

        private final java.lang.String specification
      • stream

        private java.io.FileInputStream stream
    • Constructor Detail

      • FileLocation

        FileLocation​(java.io.File file,
                     java.lang.String specification)
        Parameters:
        file - File
        specification - spec
      • FileLocation

        FileLocation​(java.lang.String specification)
        Parameters:
        specification - spec
    • Method Detail

      • close

        public void close()
        Description copied from interface: Location
        Close the location.
        Specified by:
        close in interface Location
      • getFile

        public java.io.File getFile()
                             throws java.io.IOException
        Specified by:
        getFile in interface Location
        Returns:
        File
        Throws:
        java.io.IOException - in case of an error
      • unsafeGetFile

        java.io.File unsafeGetFile()
        Returns:
        File
      • initFile

        protected void initFile()
                         throws java.io.IOException
        initialize file.
        Throws:
        java.io.IOException - in case of error
      • setFile

        protected void setFile​(java.io.File file)
        Parameters:
        file - File
      • getSpecification

        public java.lang.String getSpecification()
        Specified by:
        getSpecification in interface Location
        Returns:
        spec
      • open

        public void open()
                  throws java.io.IOException
        Description copied from interface: Location
        Open the location.
        Specified by:
        open in interface Location
        Throws:
        java.io.IOException - in case of an error
      • read

        public int read​(java.nio.ByteBuffer buffer)
                 throws java.io.IOException
        Specified by:
        read in interface Location
        Parameters:
        buffer - The buffer
        Returns:
        number of read bytes
        Throws:
        java.io.IOException - in case of an error
      • read

        public int read​(byte[] buffer)
                 throws java.io.IOException
        Specified by:
        read in interface Location
        Parameters:
        buffer - the buffer
        Returns:
        number of read bytes
        Throws:
        java.io.IOException - in case of an error
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Specified by:
        getInputStream in interface Location
        Returns:
        the resulting input stream.
        Throws:
        java.io.IOException - in case of an error