Class ManifestFile


  • public class ManifestFile
    extends java.lang.Object
    Stores the default manifest file as a static reference, or optionally can be used for creating custom manifest files. A local and system copy of the manifest file are stored. By storing manifest entries as class files, this should remove any classpath problems occurring for plugins using the install/uninstall feature.
    Author:
    senseneyj
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String DELIMITER
      Standard delimiter after manifest file.
      private static java.lang.String DEPENDENT_ENTRY
      Signifies manifest file lists a dependent after delimiter.
      private static java.lang.String LINE_DELIM
      System-dependent line delimiter.
      private java.io.File manifest  
      static java.lang.String MANIFEST_LOC  
      private java.util.HashMap<java.lang.Class,​java.util.ArrayList<java.lang.Class>> manifestInfo
      The manifest file as a set of class files.
      private static java.lang.String PLUGIN_ENTRY
      Signifies manifest file lists a plugin after delimiter.
      private static ManifestFile staticRef  
      private long timeLoaded  
    • Constructor Summary

      Constructors 
      Constructor Description
      ManifestFile()
      Gets/creates manifest file in default location.
      ManifestFile​(java.lang.String alternateLoc)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntry​(java.lang.Class c, java.lang.Class... dependents)
      Adds an entry to the manifest file, does in fact write to the file.
      private void addToFile​(java.lang.Class c, java.util.ArrayList<java.lang.Class> dependents)  
      private void createManifestFile()  
      java.util.ArrayList<java.lang.Class> getEntry​(java.lang.Class c)
      Gets the dependents of class c.
      static ManifestFile getReference()
      Gets the default manifest, guaranteed to be latest default version unless working in threaded environment.
      private void init()  
      java.util.ArrayList<java.lang.Class> modifyEntry​(java.lang.Class c, java.lang.Class... dependents)
      Inserts all the dependents that are not currently a dependent into c's entry into the manifest.
      private java.util.HashMap<java.lang.Class,​java.util.ArrayList<java.lang.Class>> parseManifestInfo()  
      void refresh()
      Rereads the manifest to load any changes, whether or not any changes have been made.
      java.util.ArrayList<java.lang.Class> removeEntry​(java.lang.Class c)
      Removes class c and its dependents from the manifest, does in fact write to the file.
      private void removeFromFile​(java.lang.Class c)
      Helper method for removing c from the manifest file on the file system.
      private void writeTmpToManifest​(java.io.File temp)  
      • Methods inherited from class java.lang.Object

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

      • MANIFEST_LOC

        public static final java.lang.String MANIFEST_LOC
      • PLUGIN_ENTRY

        private static final java.lang.String PLUGIN_ENTRY
        Signifies manifest file lists a plugin after delimiter.
        See Also:
        Constant Field Values
      • DEPENDENT_ENTRY

        private static final java.lang.String DEPENDENT_ENTRY
        Signifies manifest file lists a dependent after delimiter.
        See Also:
        Constant Field Values
      • DELIMITER

        private static final java.lang.String DELIMITER
        Standard delimiter after manifest file.
        See Also:
        Constant Field Values
      • LINE_DELIM

        private static final java.lang.String LINE_DELIM
        System-dependent line delimiter.
      • manifest

        private java.io.File manifest
      • timeLoaded

        private long timeLoaded
      • manifestInfo

        private java.util.HashMap<java.lang.Class,​java.util.ArrayList<java.lang.Class>> manifestInfo
        The manifest file as a set of class files.
    • Constructor Detail

      • ManifestFile

        public ManifestFile()
        Gets/creates manifest file in default location.
      • ManifestFile

        public ManifestFile​(java.lang.String alternateLoc)
        Parameters:
        alternateLoc - where the manifest file is/should be created
    • Method Detail

      • getReference

        public static ManifestFile getReference()
        Gets the default manifest, guaranteed to be latest default version unless working in threaded environment.
      • refresh

        public void refresh()
        Rereads the manifest to load any changes, whether or not any changes have been made.
      • init

        private void init()
      • parseManifestInfo

        private java.util.HashMap<java.lang.Class,​java.util.ArrayList<java.lang.Class>> parseManifestInfo()
      • addEntry

        public void addEntry​(java.lang.Class c,
                             java.lang.Class... dependents)
        Adds an entry to the manifest file, does in fact write to the file. If the entry errantly exists, this method modifies the entry.
        Parameters:
        c - the plugin class
        dependents - the classes that a given plugin uses
      • addToFile

        private void addToFile​(java.lang.Class c,
                               java.util.ArrayList<java.lang.Class> dependents)
      • getEntry

        public java.util.ArrayList<java.lang.Class> getEntry​(java.lang.Class c)
        Gets the dependents of class c. Does not write to the file. If c does not appear to be in the manifest, refreshes. Returns null if c cannot be found.
        Parameters:
        c - the plugin class
        Returns:
        the classes that a given plugin uses
      • removeEntry

        public java.util.ArrayList<java.lang.Class> removeEntry​(java.lang.Class c)
        Removes class c and its dependents from the manifest, does in fact write to the file. If c does not appear to be a plugin in the manifest, refreshes and returns null if not found. Returns all dependents that are not currently used by another entry in the manifest (either as a plugin or one of a plugin's dependents).
        Parameters:
        c -
        Returns:
      • removeFromFile

        private void removeFromFile​(java.lang.Class c)
        Helper method for removing c from the manifest file on the file system.
        Parameters:
        c - the class to be removed.
      • writeTmpToManifest

        private void writeTmpToManifest​(java.io.File temp)
      • modifyEntry

        public java.util.ArrayList<java.lang.Class> modifyEntry​(java.lang.Class c,
                                                                java.lang.Class... dependents)
        Inserts all the dependents that are not currently a dependent into c's entry into the manifest. If entry c doesn't appear to exist in the manifest, reloads the manifest and performs an addEntry if necessary.
        Parameters:
        c -
        dependents -
        Returns:
        The full entry for c
        See Also:
        addEntry(java.lang.Class,java.lang.Class...)
      • createManifestFile

        private void createManifestFile()