Package mgui.io

Class FileLoader

java.lang.Object
mgui.io.FileLoader
All Implemented Interfaces:
InterfaceIO, IconObject
Direct Known Subclasses:
CaminoPipelineLoader, CaminoProjectLoader, ColourMapLoader, CorticalNetworkMatrixLoader, DataSourceDriverLoader, DataSourceLoader, GraphFileLoader, ImageFileLoader, ImportDataTableLoader, InterfaceShapeLoader, JsonFileLoader, MatrixFileLoader, MatrixTransformLoader, MincTransformLoader, NameMapLoader, PipelineLoader, PipelineProcessLibraryLoader, Point2DShapeLoader, PointSet3DDataLoader, PointSet3DLoader, PolygonSet3DLoader, ShapeDataLoader, ShapeModel3DLoader, StringVectorLoader, SurfaceDataFileLoader, Vector3DFileLoader, VectorSet3DLoader, VideoLoader, View3DLoader

public abstract class FileLoader
extends java.lang.Object
implements InterfaceIO
Base class for all file loader classes.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.io.File dataFile  
    protected java.net.URL dataURL  
    protected InterfaceIOOptions options  
  • Constructor Summary

    Constructors
    Constructor Description
    FileLoader()  
  • Method Summary

    Modifier and Type Method Description
    InterfaceIOType getComplementIOType()
    Returns an InterfaceIOType specifying the InterfaceIO which performs the complementary operation to this one.
    java.lang.String getFailureMessage()
    Returns a message to indicate that loading failed.
    java.io.File getFile()
    Returns the current data file for this loader.
    InterfaceIOType getIOType()
    Returns the registered IO type for this object, if one exists
    javax.swing.Icon getObjectIcon()
    Returns the Icon associated with this object.
    InterfaceIOOptions getOptions()
    Gets the InterfaceIOOptions specifying this I/O operation, if options have been set; otherwise returns null.
    java.lang.String getProgressMessage()
    Returns a message for the progress updater, while loading is in progress.
    java.lang.String getSuccessMessage()
    Returns a message to indicate that loading was successful.
    java.util.ArrayList<java.lang.Class<?>> getSupportedObjects()
    Returns a list of classes for objects which are supported by this I/O interface
    java.lang.String getTitle()  
    InterfaceIOType getWriterComplement()
    Returns the InterfaceIOType of a FileWriter which is the complement of this loader; i.e., writes what this loader reads with identical encoding.
    boolean load()
    Loads data from the set of files or URLs specified by options.
    boolean load​(ProgressUpdater progress_bar)
    Loads data from the set of files or URLs specified by options.
    abstract boolean load​(InterfaceIOOptions options, ProgressUpdater progress_bar)
    Loads data from the set of files or URLs specified by options.
    java.lang.Object loadObject()
    Loads data into an instance of the object corresponding to this loader.
    java.lang.Object loadObject​(ProgressUpdater progress_bar)
    Loads data into an instance of the object corresponding to this loader.
    java.lang.Object loadObject​(ProgressUpdater progress_bar, InterfaceIOOptions options)
    Loads data into an instance of the object corresponding to this loader.
    java.lang.Object loadObject​(InterfaceIOOptions options)
    Loads data into an instance of the object corresponding to this loader.
    void setFile​(java.io.File file)
    Sets the current File for this loader.
    void setOptions​(InterfaceIOOptions options)
    Sets the InterfaceIOOptions specifying this I/O operation
    void setURL​(java.net.URL url)
    Sets the current URL for this loader.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • dataFile

      protected java.io.File dataFile
    • dataURL

      protected java.net.URL dataURL
    • options

      protected InterfaceIOOptions options
  • Constructor Details

    • FileLoader

      public FileLoader()
  • Method Details

    • setFile

      public void setFile​(java.io.File file)
      Sets the current File for this loader. Sets the URL to null.
      Specified by:
      setFile in interface InterfaceIO
    • setURL

      public void setURL​(java.net.URL url)
      Sets the current URL for this loader. Sets the File to null.
      Specified by:
      setURL in interface InterfaceIO
    • getFile

      public java.io.File getFile()
      Returns the current data file for this loader.
      Returns:
    • setOptions

      public void setOptions​(InterfaceIOOptions options)
      Description copied from interface: InterfaceIO
      Sets the InterfaceIOOptions specifying this I/O operation
      Specified by:
      setOptions in interface InterfaceIO
    • getOptions

      public InterfaceIOOptions getOptions()
      Description copied from interface: InterfaceIO
      Gets the InterfaceIOOptions specifying this I/O operation, if options have been set; otherwise returns null.
      Specified by:
      getOptions in interface InterfaceIO
    • load

      public boolean load()
      Loads data from the set of files or URLs specified by options. Loading is controlled by the specifications of options.

      This method should also set the URL reference and writer and loader attributes to match this one and its complement.

      Returns:
    • load

      public boolean load​(ProgressUpdater progress_bar)
      Loads data from the set of files or URLs specified by options. Loading is controlled by the specifications of options.

      This method should also set the URL reference and writer and loader attributes to match this one and its complement.

      Parameters:
      progress_bar -
      Returns:
    • load

      public abstract boolean load​(InterfaceIOOptions options, ProgressUpdater progress_bar)
      Loads data from the set of files or URLs specified by options. Loading is controlled by the specifications of options. If loaded object is of type PersistentObject, this method should also set the file loader and reference URL for the object.

      This method should also set the URL reference and writer and loader attributes to match this one and its complement.

      Parameters:
      options -
      progress_bar - An optional progress updater. Can be null.
      Returns:
    • loadObject

      public java.lang.Object loadObject() throws java.io.IOException
      Loads data into an instance of the object corresponding to this loader. If loaded object is of type PersistentObject, this method should also set the file loader and reference URL for the object. TODO: make generic?
      Returns:
      Throws:
      java.io.IOException
    • loadObject

      public java.lang.Object loadObject​(InterfaceIOOptions options) throws java.io.IOException
      Loads data into an instance of the object corresponding to this loader. If loaded object is of type PersistentObject, this method should also set the file loader and reference URL for the object. TODO: make generic?
      Parameters:
      options -
      Returns:
      Throws:
      java.io.IOException
    • getIOType

      public InterfaceIOType getIOType()
      Description copied from interface: InterfaceIO
      Returns the registered IO type for this object, if one exists
      Specified by:
      getIOType in interface InterfaceIO
      Returns:
      the registered IO type, or null if none exists
    • loadObject

      public java.lang.Object loadObject​(ProgressUpdater progress_bar, InterfaceIOOptions options) throws java.io.IOException
      Loads data into an instance of the object corresponding to this loader. If loaded object is of type PersistentObject, this method should also set the file loader and reference URL for the object. TODO: make generic?
      Parameters:
      progress_bar - An optional progress updater. Can be null.
      options - Options defining the loading process
      Returns:
      Throws:
      java.io.IOException
    • loadObject

      public java.lang.Object loadObject​(ProgressUpdater progress_bar) throws java.io.IOException
      Loads data into an instance of the object corresponding to this loader. If loaded object is of type PersistentObject, this method should also set the file loader and reference URL for the object. TODO: make generic?
      Parameters:
      progress_bar - An optional progress updater. Can be null.
      Returns:
      Throws:
      java.io.IOException
    • getProgressMessage

      public java.lang.String getProgressMessage()
      Returns a message for the progress updater, while loading is in progress.
      Specified by:
      getProgressMessage in interface InterfaceIO
      Returns:
      Progress message
    • getSuccessMessage

      public java.lang.String getSuccessMessage()
      Returns a message to indicate that loading was successful.
      Specified by:
      getSuccessMessage in interface InterfaceIO
      Returns:
      Progress message
    • getFailureMessage

      public java.lang.String getFailureMessage()
      Returns a message to indicate that loading failed.
      Returns:
      Progress message
    • getTitle

      public java.lang.String getTitle()
      Specified by:
      getTitle in interface InterfaceIO
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getWriterComplement

      public InterfaceIOType getWriterComplement()
      Returns the InterfaceIOType of a FileWriter which is the complement of this loader; i.e., writes what this loader reads with identical encoding. Transfer between loader and writer should be lossless.

      Returns null if no complement is defined.

      Returns:
    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Specified by:
      getObjectIcon in interface IconObject
      Returns:
    • getSupportedObjects

      public java.util.ArrayList<java.lang.Class<?>> getSupportedObjects()
      Description copied from interface: InterfaceIO
      Returns a list of classes for objects which are supported by this I/O interface
      Specified by:
      getSupportedObjects in interface InterfaceIO
      Returns:
    • getComplementIOType

      public InterfaceIOType getComplementIOType()
      Description copied from interface: InterfaceIO
      Returns an InterfaceIOType specifying the InterfaceIO which performs the complementary operation to this one. I.e., loaders should specify their complementary writers.
      Specified by:
      getComplementIOType in interface InterfaceIO
      Returns:
      The complementary class, or null if none is defined