Enum Class Platform

java.lang.Object
java.lang.Enum<Platform>
edu.wisc.ssec.mcidasv.startupmanager.Platform
All Implemented Interfaces:
Serializable, Comparable<Platform>, Constable

public enum Platform extends Enum<Platform>
Represents platform specific details used by McIDAS-V. In particular, there are useful methods related to the McIDAS-V "userpath".

Currently McIDAS-V distinguishes between "Unix-like", macOS, and "Windows"; these can be accessed using Platform.UNIXLIKE, Platform.WINDOWS, or Platform.MAC.

  • Enum Constant Details

    • UNIXLIKE

      public static final Platform UNIXLIKE
      Instance of unix-specific platform information.
    • MAC

      public static final Platform MAC
      macOS-specicfic platform information.
    • WINDOWS

      public static final Platform WINDOWS
      Instance of windows-specific platform information.
  • Field Details

    • userDirectory

      Path to the user's "userpath" directory.
    • userPrefs

      private String userPrefs
      The path to the user's copy of the startup preferences.
    • defaultPrefs

      private final String defaultPrefs
      Path to the preference file that ships with McIDAS-V.
    • newLine

      private final String newLine
      Holds the platform's representation of a new line.
    • userBundles

      private final String userBundles
      Path to the bundles subdirectory within userDirectory.
    • availableMemory

      private int availableMemory
      Total amount of memory avilable in megabytes
  • Constructor Details

    • Platform

      private Platform(String defaultPrefs, String newLine)
      Initializes the platform-specific paths to the different files required by the startup manager.
      Parameters:
      defaultPrefs - Path to the preferences file that ships with McIDAS-V. Cannot be null or empty.
      newLine - Character(s!) that represent a new line for this platform. Cannot be null or empty.
      Throws:
      NullPointerException - if either defaultPrefs or newLine are null.
      IllegalArgumentException - if either defaultPrefs or newLine are an empty string.
  • Method Details

    • values

      public static Platform[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Platform valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • setUserDirectory

      Sets the path to the user's "userpath" directory explicitly. If the specified path does not yet exist, this method will first attempt to create it. The method will then attempt to verify whether or not McIDAS-V can use the path.
      Parameters:
      path - New path. Cannot be null, but does not have to exist prior to running this method. Be aware that this method will attempt to create path if it does not already exist.
      Throws:
      IllegalArgumentException - if path is not a directory, or if it not both readable and writable.
    • setAvailableMemory

      public void setAvailableMemory(String megabytes)
      Deprecated.
      There's not really a need for this method; the JVM can tell us the amount of memory.
      Sets the amount of available memory. megabytes must be greater than or equal to zero.
      Parameters:
      megabytes - Memory in megabytes.
      Throws:
      NullPointerException - if megabytes is null.
      IllegalArgumentException - if megabytes is less than zero or does not represent an integer.
      See Also:
    • getUserDirectory

      Returns the path to the user's "userpath" directory.
      Returns:
      Path to the user's directory.
    • getUserFile

      public String getUserFile(String filename)
      Returns the path to a file in the user's "userpath" directory.
      Parameters:
      filename - Filename within the userpath. Cannot be null, but does not need to be a filename that already exists within the userpath.
      Returns:
      Path to a file in the user's directory. Note: the file may not yet exist.
    • getUserBundles

      Returns the path to the user's bundles directory. Note: this should be a directory within getUserDirectory().
      Returns:
      Path to the user's bundles directory.
    • getAvailableMemory

      public int getAvailableMemory()
      Returns the amount of available memory in megabytes.
      Returns:
      Available memory in megabytes.
    • getUserPrefs

      public String getUserPrefs()
      Returns the path of user's copy of the startup preferences.
      Returns:
      Path to the user's startup preferences file.
    • getDefaultPrefs

      Returns the path of the startup preferences included in the McIDAS-V distribution. Mostly useful for normalizing the user directory.
      Returns:
      Path to the default startup preferences.
      See Also:
    • getNewLine

      public String getNewLine()
      Returns the platform's notion of a new line.
      Returns:
      Unix-like: \n; Windows: \r\n.
    • toString

      public String toString()
      Returns a brief summary of the platform specific file locations. Please note that the format and contents are subject to change.
      Overrides:
      toString in class Enum<Platform>
      Returns:
      String that looks like [Platform@HASHCODE: defaultPrefs=..., userDirectory=..., userPrefs=...]