Package jmri.profile

Class NullProfile

  • All Implemented Interfaces:
    java.lang.Comparable<Profile>

    public class NullProfile
    extends Profile
    An empty JMRI application profile. Profiles allow a JMRI application to load completely separate set of preferences at each launch without relying on host OS-specific tricks to ensure this happens.

    A NullProfile allows an application using JMRI as a library to set the active JMRI profile to an identity set by that application, if the use of a standard JMRI profile is not acceptable.

    This class deliberately overrides all methods of Profile that access the name and id fields to remove protections and restrictions on those fields.

    See Also:
    ProfileManager.setActiveProfile(jmri.profile.Profile)
    • Constructor Detail

      • NullProfile

        public NullProfile​(@Nonnull
                           java.io.File path)
                    throws java.io.IOException
        Create a NullProfile object given just a path to it. The Profile must exist in storage on the computer. Uses a random identity for the Profile.
        Parameters:
        path - The Profile's directory
        Throws:
        java.io.IOException - If path is not readable
      • NullProfile

        public NullProfile​(@Nonnull
                           java.io.File path,
                           @Nonnull
                           java.lang.String id)
                    throws java.io.IOException
        Create a NullProfile object given just a path to it. The Profile must exist in storage on the computer.
        Parameters:
        path - The Profile's directory
        id - The Profile's id
        Throws:
        java.io.IOException - If path is not readable
      • NullProfile

        public NullProfile​(java.lang.String name,
                           java.lang.String id,
                           @Nonnull
                           java.io.File path)
                    throws java.io.IOException
        Create a Profile object and a profile in storage. A Profile cannot exist in storage on the computer at the path given. Since this is a new profile, the id must match the last element in the path.

        This is the only time the id can be set on a Profile, as the id becomes a read-only property of the Profile. The ProfileManager will only load a single profile with a given id.

        Parameters:
        name - The name of the profile.
        id - If null, ProfileManager.createUniqueId() will be used to generate the id.
        path - The path where the profile is stored.
        Throws:
        java.io.IOException - If path is not readable.
        java.lang.IllegalArgumentException - If a profile already exists at or within path
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from class: Profile
        This tests for equal ID values
        Overrides:
        equals in class Profile
      • isComplete

        public boolean isComplete()
        Test if the profile is complete.
        Overrides:
        isComplete in class Profile
        Returns:
        always true for a NullProfile.
      • getUniqueId

        public java.lang.String getUniqueId()
        Return the uniqueness portion of the Profile Id.
        Overrides:
        getUniqueId in class Profile
        Returns:
        The complete Id of a NullProfile.