Package jmri.profile

Class NullProfile

java.lang.Object
jmri.profile.Profile
jmri.profile.NullProfile
All Implemented Interfaces:
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:
  • Constructor Details

    • NullProfile

      public NullProfile(@Nonnull File path) throws 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:
      IOException - If path is not readable
    • NullProfile

      public NullProfile(@Nonnull File path, @Nonnull String id) throws 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:
      IOException - If path is not readable
    • NullProfile

      public NullProfile(String name, String id, @Nonnull File path) throws 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:
      IOException - If path is not readable.
      IllegalArgumentException - If a profile already exists at or within path
  • Method Details