Package ru.ispras.microtesk
Class SysUtils
- java.lang.Object
-
- ru.ispras.microtesk.SysUtils
-
public final class SysUtils extends java.lang.Object
TheSysUtils
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
getArchDir(java.lang.String archDirs, java.lang.String archName)
Gets the path to the directory of that holds files related to the specified architecture.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 theMICROTESK_HOME
environment variable.static java.lang.String
getModelsJarPath()
Returns absolute path to themodels.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 inmicrotesk.jar
.static java.lang.Object
loadFromModel(java.lang.String className)
Loads a class with the specified name frommodels.jar
.static Model
loadModel(java.lang.String modelName)
Loads a model with the specified name frommodels.jar
.static Plugin
loadPlugin(java.lang.String className)
Loads a plug-in implemented by the specified class frommicrotesk.jar
.
-
-
-
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 theMICROTESK_HOME
environment variable.- Returns:
- Path to MicroTESK home folder.
- Throws:
java.lang.IllegalStateException
- if theMICROTESK_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.lang.String getModelsJarPath()
Returns absolute path to themodels.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 theMICROTESK_HOME
environment variable is not defined.
-
loadModel
public static Model loadModel(java.lang.String modelName)
Loads a model with the specified name frommodels.jar
.- Parameters:
modelName
- Model name.- Returns:
- New model instance.
- Throws:
java.lang.IllegalArgumentException
- if the model name isnull
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 frommodels.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 isnull
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 frommicrotesk.jar
.- Parameters:
className
- Name of the plug-in class.- Returns:
- New plug-in instance.
- Throws:
java.lang.IllegalArgumentException
- if the class name isnull
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 inmicrotesk.jar
.- Parameters:
resourceName
- Resource file name.- Returns:
- URL for the specified resource file.
- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
getArchDir
public static java.lang.String getArchDir(java.lang.String archDirs, java.lang.String archName)
Gets the path to the directory of that holds files related to the specified architecture.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:
- Architecture directory path or
null
if no such path is found. - Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
.java.lang.IllegalStateException
- if theMICROTESK_HOME
environment variable is undefined.
-
-