Class DataStorage


  • public class DataStorage
    extends Object
    This class define a data storage.
    Since:
    3.0
    Author:
    Laurent Jourdren
    • Constructor Detail

      • DataStorage

        public DataStorage​(String machine,
                           String path)
        Constructor.
        Parameters:
        machine - machine of the data storage
        path - path of the data storage
      • DataStorage

        public DataStorage​(String machine,
                           String path,
                           SequencerSource source)
        Constructor.
        Parameters:
        machine - machine of the data storage
        path - path of the data storage
        source - sequencer source
      • DataStorage

        public DataStorage​(String machine,
                           Path path)
        Constructor.
        Parameters:
        machine - machine of the data storage
        path - path of the data storage
      • DataStorage

        public DataStorage​(String machine,
                           Path path,
                           SequencerSource source)
        Constructor.
        Parameters:
        machine - machine of the data storage
        path - path of the data storage
        source - sequencer source
    • Method Detail

      • getMachine

        public String getMachine()
        Get the machine of the storage
        Returns:
        the machine of the storage
      • getPath

        public Path getPath()
        Get the path of the storage.
        Returns:
        the path of the storage
      • isWritable

        public boolean isWritable()
        Returns if the storage is writable.
        Returns:
        true if the storage is writable
      • getTotalSpace

        public long getTotalSpace()
                           throws IOException
        Get the total space of the storage.
        Returns:
        the total space in bytes of the storage
        Throws:
        IOException - if an error occurs while getting the information
      • getUsableSpace

        public long getUsableSpace()
                            throws IOException
        Get the usable space of the storage.
        Returns:
        the usable space in bytes of the storage
        Throws:
        IOException - if an error occurs while getting the information
      • getUnallocatedSpace

        public long getUnallocatedSpace()
                                 throws IOException
        Get the unallocated space of the storage.
        Returns:
        the unallocated space in bytes of the storage
        Throws:
        IOException - if an error occurs while getting the information
      • isEnoughSpace

        public boolean isEnoughSpace​(long size)
                              throws IOException
        Test if there is enough space on the storage for a required amount of disk space.
        Parameters:
        size - the required amount of disk space
        Returns:
        true if there is enough space on the storage for the required amount of disk space
        Throws:
        IOException - if an error occurs while getting disk space information
      • checkIfEnoughSpace

        public void checkIfEnoughSpace​(long size,
                                       String errorMessage)
                                throws IOException
        Check if there is enough space on the storage for a required amount of disk space.
        Parameters:
        size - the required amount of disk space
        errorMessage - error message
        Throws:
        IOException - if there is enough space on the storage for the required amount of disk space
      • checkIfEnoughSpace

        public void checkIfEnoughSpace​(long size)
                                throws IOException
        Check if there is enough space on the storage for a required amount of disk space.
        Parameters:
        size - the required amount of disk space
        Throws:
        IOException - if there is enough space on the storage for the required amount of disk space
      • newDataLocation

        public DataLocation newDataLocation​(String name)
        Create a data location.
        Parameters:
        name - name of the data location
        Returns:
        a data location
      • deSerializeFromJson

        public static DataStorage deSerializeFromJson​(String json)
        Deserialize a DataStorage from JSON.
        Parameters:
        json - JSON string
        Returns:
        a new DataStorage
      • toJson

        public String toJson()
        Serialize the object into a JSON string
        Returns: