Class LocalDataFile

  • All Implemented Interfaces:
    DataFileItem, FolderItem

    public class LocalDataFile
    extends LocalFolderItem
    implements DataFileItem
    LocalDataFile provides a FolderItem implementation for a local serialized data file. This implementation supports a non-versioned file-system only.

    This item utilizes a data directory for storing the serialized data file.

    • Constructor Detail

      • LocalDataFile

        public LocalDataFile​(LocalFileSystem fileSystem,
                             PropertyFile propertyFile)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • LocalDataFile

        public LocalDataFile​(LocalFileSystem fileSystem,
                             PropertyFile propertyFile,
                             java.io.InputStream istream,
                             java.lang.String contentType,
                             TaskMonitor monitor)
                      throws java.io.IOException,
                             CancelledException
        Create a new local data file item.
        Parameters:
        fileSystem - file system
        propertyFile - serialized data property file
        istream - data source input stream (should be a start of data and will be read to end of file). The invoker of this constructor is responsible for closing istream.
        contentType - user content type
        monitor - progress monitor (used for cancel support, progress not used since length of input stream is unknown)
        Throws:
        java.io.IOException - if an IO Error occurs
        CancelledException - if monitor cancels operation
    • Method Detail

      • length

        public long length()
                    throws java.io.IOException
        Description copied from interface: FolderItem
        Returns the length of this domain file. This size is the minimum disk space used for storing this file, but does not account for additional storage space used to tracks changes, etc.
        Specified by:
        length in interface FolderItem
        Returns:
        file length
        Throws:
        java.io.IOException - thrown if IO or access error occurs
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.FileNotFoundException
        Description copied from interface: DataFileItem
        Open the current version of this item for reading.
        Specified by:
        getInputStream in interface DataFileItem
        Returns:
        input stream
        Throws:
        java.io.FileNotFoundException
      • getInputStream

        public java.io.InputStream getInputStream​(int version)
                                           throws java.io.FileNotFoundException
        Description copied from interface: DataFileItem
        Open a specific version of this item for reading.
        Specified by:
        getInputStream in interface DataFileItem
        Returns:
        input stream
        Throws:
        java.io.FileNotFoundException
      • getOutputStream

        public java.io.OutputStream getOutputStream()
                                             throws java.io.FileNotFoundException
        Description copied from interface: DataFileItem
        Open a new version of this item for writing.
        Specified by:
        getOutputStream in interface DataFileItem
        Returns:
        output stream.
        Throws:
        java.io.FileNotFoundException
      • updateCheckout

        public void updateCheckout​(FolderItem versionedFolderItem,
                                   boolean updateItem,
                                   TaskMonitor monitor)
                            throws java.io.IOException
        Description copied from class: LocalFolderItem
        Update this non-versioned item with the latest version of the specified versioned item.
        Specified by:
        updateCheckout in class LocalFolderItem
        Parameters:
        versionedFolderItem - versioned item which corresponds to this non-versioned item.
        updateItem - if true this items content is updated using the versionedFolderItem
        monitor - progress monitor for update
        Throws:
        java.io.IOException - if this file is not a checked-out non-versioned file or an IO error occurs.
      • updateCheckout

        public void updateCheckout​(FolderItem item,
                                   int checkoutVersion)
                            throws java.io.IOException
        Description copied from class: LocalFolderItem
        Update this non-versioned item with the contents of the specified item which must be within the same non-versioned fileSystem. If successful, the specified item will be removed after its content has been moved into this item.
        Specified by:
        updateCheckout in class LocalFolderItem
        Throws:
        java.io.IOException - if this file is not a checked-out non-versioned file or an IO error occurs.
      • output

        public void output​(java.io.File outputFile,
                           int version,
                           TaskMonitor monitor)
                    throws java.io.IOException
        Description copied from interface: FolderItem
        Serialize (i.e., pack) this item into the specified outputFile.
        Specified by:
        output in interface FolderItem
        Parameters:
        outputFile - packed output file to be created
        version - if this item is versioned, specifies the version to be output, otherwise -1 should be specified.
        monitor - progress monitor
        Throws:
        java.io.IOException
      • getCurrentVersion

        public int getCurrentVersion()
        Description copied from interface: FolderItem
        Return the latest/current version.
        Specified by:
        getCurrentVersion in interface FolderItem
      • canRecover

        public boolean canRecover()
        Description copied from interface: FolderItem
        Returns true if unsaved file changes can be recovered.
        Specified by:
        canRecover in interface FolderItem