Class Profile
- All Implemented Interfaces:
Comparable<Profile>
- Direct Known Subclasses:
NullProfile
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final String"ProfileConfig.xml" may be present in older profilesstatic final StringThe filename extension for JMRI profile directories.protected static final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String"UserPrefsProfileConfig.xml" may be present in older profiles -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate a Profile object given just a path to it.protectedCreate a Profile object given just a path to it.protectedCreate a Profile object given just a path to it.Create a Profile object and a profile in storage. -
Method Summary
Modifier and TypeMethodDescriptionintstatic booleancontainsProfile(File path) Test if the given path or subdirectories contains a Profile.booleanThis tests for equal ID valuesgetId()getName()getPath()Return the uniqueness portion of the Profile Id.inthashCode()static booleanTest if the given path is within a directory that is a Profile.booleanTest if the profile is complete.static booleanTest if the given path is a Profile.protected final voidsave()voidSet the name for this profile.protected final voidsetNameInConstructor(String name) Set the name for this profile while constructing the profile.toString()
-
Field Details
-
PROFILE
- See Also:
-
ID
- See Also:
-
NAME
- See Also:
-
PATH
- See Also:
-
PROPERTIES
- See Also:
-
CONFIG
- See Also:
-
SHARED_PROPERTIES
- See Also:
-
SHARED_CONFIG
- See Also:
-
CONFIG_FILENAME
"ProfileConfig.xml" may be present in older profiles- See Also:
-
UI_CONFIG
- See Also:
-
SHARED_UI_CONFIG
- See Also:
-
UI_CONFIG_FILENAME
"UserPrefsProfileConfig.xml" may be present in older profiles- See Also:
-
EXTENSION
The filename extension for JMRI profile directories. This is needed for external applications on some operating systems to recognize JMRI profiles.- See Also:
-
-
Constructor Details
-
Profile
Create a Profile object given just a path to it. The Profile must exist in storage on the computer.- Parameters:
path- The Profile's directory- Throws:
IOException- If unable to read the Profile from path
-
Profile
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
ProfileManagerwill only load a single profile with a given id.- Parameters:
name- Name of the profile. Will not be used to enforce uniqueness constraints.id- Id of the profile. Will be prepended to a random String to enforce uniqueness constraints.path- Location to store the profile; ".jmri" will be appended to this path if needed.- Throws:
IOException- If unable to create the profile at pathIllegalArgumentException- If a profile already exists at or within path
-
Profile
Create a Profile object given just a path to it. If isReadable is true, the Profile must exist in storage on the computer. Generates a random id for the profile.This method exists purely to support subclasses.
- Parameters:
path- The Profile's directoryisReadable- True if the profile has storage. SeeNullProfilefor a Profile subclass where this is not true.- Throws:
IOException- If the profile's preferences cannot be read.
-
Profile
Create a Profile object given just a path to it. If isReadable is true, the Profile must exist in storage on the computer.This method exists purely to support subclasses.
- Parameters:
path- The Profile's directoryid- The Profile's idisReadable- True if the profile has storage. SeeNullProfilefor a Profile subclass where this is not true.- Throws:
IOException- If the profile's preferences cannot be read.
-
-
Method Details
-
save
-
getName
- Returns:
- the name
-
setName
Set the name for this profile.Overriding classing must use
setNameInConstructor(java.lang.String)to set the name in a constructor since this method passes this Profile object to an object excepting a completely constructed Profile.- Parameters:
name- the new name
-
setNameInConstructor
Set the name for this profile while constructing the profile.Overriding classing must use this method to set the name in a constructor since
setName(java.lang.String)passes this Profile object to an object expecting a completely constructed Profile.- Parameters:
name- the new name
-
getId
- Returns:
- the id
-
getPath
- Returns:
- the path
-
toString
-
hashCode
-
equals
This tests for equal ID values -
isComplete
Test if the profile is complete. A profile is considered complete if it can be instantiated usingProfile(java.io.File)and has a profile.properties file within its "profile" directory.- Returns:
- true if profile.properties exists where expected.
-
getUniqueId
Return the uniqueness portion of the Profile Id.This portion of the Id is automatically generated when the profile is created.
- Returns:
- An eight-character String of alphanumeric characters.
-
containsProfile
Test if the given path or subdirectories contains a Profile.- Parameters:
path- Path to test.- Returns:
- true if path or subdirectories contains a Profile.
- Since:
- 3.9.4
-
inProfile
Test if the given path is within a directory that is a Profile.- Parameters:
path- Path to test.- Returns:
- true if path or parent directories is a Profile.
- Since:
- 3.9.4
-
isProfile
Test if the given path is a Profile.- Parameters:
path- Path to test.- Returns:
- true if path is a Profile.
- Since:
- 3.9.4
-
compareTo
- Specified by:
compareToin interfaceComparable<Profile>
-