Class Package

  • Direct Known Subclasses:
    JavaPackage

    public class Package
    extends java.lang.Object
    Class describing a binary package as a set of files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Set<File> files
      List of files that will be installed into this package.
      private java.lang.String id
      Package ID (a unique string).
      static java.lang.String MAIN
      ID of main package.
    • Constructor Summary

      Constructors 
      Constructor Description
      Package​(java.lang.String id)
      Create an empty package with given ID.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFile​(File file)
      Add a file to this package.
      void addFileIfNotExists​(File file)
      Add a file to this package if id doesn't already exist in the package.
      boolean equals​(java.lang.Object rhs)  
      java.util.Set<File> getFiles()
      Get files contained in this package.
      java.lang.String getId()
      Get unique string identifying this package.
      int hashCode()  
      void install​(java.nio.file.Path installRoot)
      Install this package into specified root.
      java.lang.String toString()  
      void writeDescriptor​(java.nio.file.Path descriptorPath)
      Write package descriptor (aka mfiles) into specified file.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • id

        private final java.lang.String id
        Package ID (a unique string).
      • files

        private final java.util.Set<File> files
        List of files that will be installed into this package.
    • Constructor Detail

      • Package

        public Package​(java.lang.String id)
        Create an empty package with given ID.
        Parameters:
        id - package ID
    • Method Detail

      • getId

        public java.lang.String getId()
        Get unique string identifying this package.
        Returns:
        package ID
      • getFiles

        public java.util.Set<File> getFiles()
        Get files contained in this package.
        Returns:
        list view of files that will be installed with this package
      • addFile

        public void addFile​(File file)
        Add a file to this package. The package must not already contains the file.
        Parameters:
        file - file to be added
      • addFileIfNotExists

        public void addFileIfNotExists​(File file)
        Add a file to this package if id doesn't already exist in the package.
        Parameters:
        file - file to be added
      • install

        public void install​(java.nio.file.Path installRoot)
                     throws java.io.IOException
        Install this package into specified root.

        Package installation is equivalent to installation of all files it contains.

        Target directory won't be overwritten if it already exists, which allows installation of multiple packages into the same directory.

        Parameters:
        installRoot - target directory where package files will be installed
        Throws:
        java.io.IOException
      • writeDescriptor

        public void writeDescriptor​(java.nio.file.Path descriptorPath)
                             throws java.io.IOException
        Write package descriptor (aka mfiles) into specified file.

        If target file exists then it shall be overwritten.

        Parameters:
        descriptorPath - path to file into which descriptor shall be written
        Throws:
        java.io.IOException
      • toString

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object rhs)
        Overrides:
        equals in class java.lang.Object