Package jmri.profile
Class NullProfile
- java.lang.Object
-
- jmri.profile.Profile
-
- jmri.profile.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 thename
andid
fields to remove protections and restrictions on those fields.
-
-
Field Summary
-
Fields inherited from class jmri.profile.Profile
CONFIG, CONFIG_FILENAME, EXTENSION, ID, NAME, PATH, PROFILE, PROPERTIES, SHARED_CONFIG, SHARED_PROPERTIES, SHARED_UI_CONFIG, UI_CONFIG, UI_CONFIG_FILENAME
-
-
Constructor Summary
Constructors Constructor Description NullProfile(java.io.File path)
Create a NullProfile object given just a path to it.NullProfile(java.io.File path, java.lang.String id)
Create a NullProfile object given just a path to it.NullProfile(java.lang.String name, java.lang.String id, java.io.File path)
Create a Profile object and a profile in storage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
This tests for equal ID valuesjava.lang.String
getUniqueId()
Return the uniqueness portion of the Profile Id.int
hashCode()
boolean
isComplete()
Test if the profile is complete.java.lang.String
toString()
-
-
-
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 directoryid
- 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
-
isComplete
public boolean isComplete()
Test if the profile is complete.- Overrides:
isComplete
in classProfile
- Returns:
- always true for a NullProfile.
-
getUniqueId
public java.lang.String getUniqueId()
Return the uniqueness portion of the Profile Id.- Overrides:
getUniqueId
in classProfile
- Returns:
- The complete Id of a NullProfile.
-
-