Package jmri.profile

Class ProfileUtils


  • public class ProfileUtils
    extends java.lang.Object
    Utility methods to get information about Profiles.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProfileUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copy​(Profile source, Profile destination)
      Copy one profile configuration to another profile.
      static boolean copyPrivateContentToCurrentIdentity​(Profile profile)
      Copy the most recently modified former identity, if any, for the current computer in the given profile to the current storage identity of the current computer for the given profile.
      static AuxiliaryConfiguration getAuxiliaryConfiguration​(Profile project)
      Get the XMl configuration container for a given configuration profile.
      static java.io.File getCacheDirectory​(Profile project, java.lang.Class<?> owner)
      Get the local cache directory for the given profile.
      static java.util.prefs.Preferences getPreferences​(Profile project, java.lang.Class<?> clazz, boolean shared)
      Get the preferences needed by a class for a given configuration profile.
      static AuxiliaryConfiguration getUserInterfaceConfiguration​(Profile project)
      Get the XMl configuration container for a given configuration profile's user interface state.
      • Methods inherited from class java.lang.Object

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

      • getAuxiliaryConfiguration

        public static AuxiliaryConfiguration getAuxiliaryConfiguration​(Profile project)
        Get the XMl configuration container for a given configuration profile.
        Parameters:
        project - The project to get the configuration container for, or null to get a configuration container that can apply to all projects on this computer
        Returns:
        An XML configuration container, possibly empty
      • getPreferences

        public static java.util.prefs.Preferences getPreferences​(Profile project,
                                                                 java.lang.Class<?> clazz,
                                                                 boolean shared)
        Get the preferences needed by a class for a given configuration profile.
        Parameters:
        project - The project to get the configuration for, or null to get a preferences object that can apply to all projects on this computer
        clazz - The class requesting preferences
        shared - True if the preferences are for all nodes (computers) this project may run on, false if the preferences are only for this node; ignored if the value of project is null
        Returns:
        The preferences
      • getUserInterfaceConfiguration

        public static AuxiliaryConfiguration getUserInterfaceConfiguration​(Profile project)
        Get the XMl configuration container for a given configuration profile's user interface state.
        Parameters:
        project - The project to get the configuration container for, or null to get a configuration container that can apply to all projects on this computer
        Returns:
        An XML configuration container, possibly empty
      • getCacheDirectory

        public static java.io.File getCacheDirectory​(Profile project,
                                                     java.lang.Class<?> owner)
        Get the local cache directory for the given profile.

        This cache is outside the profile for which the cache exists to prevent the possibility that different JMRI installations have different contents that would invalidate the cache if copied from one computer to another.

        Parameters:
        project - the project to get the cache directory for, or null to get the cache directory for all projects on this computer
        owner - The class owning the cached information, or null to get the cache directory for the project
        Returns:
        a directory in which data can be cached
      • copy

        public static void copy​(@Nonnull
                                Profile source,
                                @Nonnull
                                Profile destination)
                         throws java.lang.IllegalArgumentException,
                                java.io.IOException
        Copy one profile configuration to another profile.
        Parameters:
        source - The source profile.
        destination - The destination profile.
        Throws:
        java.lang.IllegalArgumentException - If the destination profile is the active profile.
        java.io.IOException - If the copy cannot be completed.
      • copyPrivateContentToCurrentIdentity

        public static boolean copyPrivateContentToCurrentIdentity​(@Nonnull
                                                                  Profile profile)
                                                           throws java.io.IOException
        Copy the most recently modified former identity, if any, for the current computer in the given profile to the current storage identity of the current computer for the given profile.
        Parameters:
        profile - the profile containing identities to copy
        Returns:
        true if an existing identity is copied, false otherwise
        Throws:
        java.io.IOException - if unable to a copy an existing identity