Class SysUtils


  • public final class SysUtils
    extends java.lang.Object
    The SysUtils class provides utility methods to interact with the environment.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MICROTESK_HOME
      Name of the environment variable that stores the path to MicroTESK home folder.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getCurrentDir()
      Results current directory path.
      static java.lang.String getHomeDir()
      Returns the path to MicroTESK home folder, which is stored in the MICROTESK_HOME environment variable.
      static java.nio.file.Path getModelsJarPath()
      Returns absolute path to the models.jar file that stores compiled microprocessor models.
      static java.net.URL getResourceUrl​(java.lang.String resourceName)
      Returns an URL for the specified resource file stored in microtesk.jar.
      static java.lang.Object loadFromModel​(java.lang.String className)
      Loads a class with the specified name from models.jar.
      static Model loadModel​(java.lang.String modelName)
      Loads a model with the specified name from models.jar.
      static Plugin loadPlugin​(java.lang.String className)
      Loads a plug-in implemented by the specified class from microtesk.jar.
      static java.nio.file.Path searchArchSettingsPath​(java.lang.String archDirs, java.lang.String archName)
      Searching for path to the settings file for the architecture specified.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MICROTESK_HOME

        public static final java.lang.String MICROTESK_HOME
        Name of the environment variable that stores the path to MicroTESK home folder.
        See Also:
        Constant Field Values
    • Method Detail

      • getHomeDir

        public static java.lang.String getHomeDir()
        Returns the path to MicroTESK home folder, which is stored in the MICROTESK_HOME environment variable.
        Returns:
        Path to MicroTESK home folder.
        Throws:
        java.lang.IllegalStateException - if the MICROTESK_HOME environment variable is not defined.
      • getCurrentDir

        public static java.lang.String getCurrentDir()
        Results current directory path.
        Returns:
        Results current directory path.
      • getModelsJarPath

        public static java.nio.file.Path getModelsJarPath()
        Returns absolute path to the models.jar file that stores compiled microprocessor models. The file's relative file is $MICROTESK_HOME/lib/jars/models.jar.
        Returns:
        Absolute path to the models.jar file.
        Throws:
        java.lang.IllegalStateException - if the MICROTESK_HOME environment variable is not defined.
      • loadModel

        public static Model loadModel​(java.lang.String modelName)
        Loads a model with the specified name from models.jar.
        Parameters:
        modelName - Model name.
        Returns:
        New model instance.
        Throws:
        java.lang.IllegalArgumentException - if the model name is null or if for some reason it cannot be loaded.
      • loadFromModel

        public static java.lang.Object loadFromModel​(java.lang.String className)
        Loads a class with the specified name from models.jar.
        Parameters:
        className - Name of the class to be loaded.
        Returns:
        New instance of the specified class.
        Throws:
        java.lang.IllegalArgumentException - if the class name is null or if for some reason the class cannot be loaded.
      • loadPlugin

        public static Plugin loadPlugin​(java.lang.String className)
        Loads a plug-in implemented by the specified class from microtesk.jar.
        Parameters:
        className - Name of the plug-in class.
        Returns:
        New plug-in instance.
        Throws:
        java.lang.IllegalArgumentException - if the class name is null or if for some reason the class cannot be loaded.
      • getResourceUrl

        public static java.net.URL getResourceUrl​(java.lang.String resourceName)
        Returns an URL for the specified resource file stored in microtesk.jar.
        Parameters:
        resourceName - Resource file name.
        Returns:
        URL for the specified resource file.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • searchArchSettingsPath

        public static java.nio.file.Path searchArchSettingsPath​(java.lang.String archDirs,
                                                                java.lang.String archName)
        Searching for path to the settings file for the architecture specified.

        The path is extracted from a string that stores a map of architecture names and corresponding paths. The string has the following format: name1=path1:name2=path2:...:nameN=pathN

        Parameters:
        archDirs - String that stores a map of architectures and their directories.
        archName - Architecture name.
        Returns:
        Path to arch-specific settings file or null if no such path is found.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments is null.
        java.lang.IllegalStateException - if the MICROTESK_HOME environment variable is undefined.