public class ModelUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static com.comsol.model.util.impl.IModelUtilImpl |
clientImpl
Implementation delegate.
|
private static com.comsol.model.util.impl.IModelUtilImpl |
serverImpl
Implementation delegate.
|
Modifier | Constructor and Description |
---|---|
private |
ModelUtil()
Static class not intended to be instantiated.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkoutLicense(java.lang.String... product)
Check out one license for each of the specified products.
|
static boolean |
checkoutLicenseForFile(java.lang.String file)
Check out required products for an mph file.
|
static boolean |
checkoutLicenseForFileOnServer(java.lang.String file)
Check out required products for an mph file located on the server filesystem.
|
static void |
clear()
Tries to remove all models.
|
static void |
closeWindow(java.lang.String tag)
Closes a specific graphics window on the server.
|
static void |
closeWindows()
Closes all graphics windows on the server.
|
static void |
connect()
Connects to a server.
|
static void |
connect(java.lang.String host,
int port)
Connects to a server using the specified host and port.
|
static void |
connect(java.lang.String host,
int port,
boolean encryption)
Connects to a server using the specified host, port, and encryption.
|
static void |
connect(java.lang.String host,
int port,
boolean encryption,
java.lang.String user,
java.lang.String passWord)
Connects to a server using the specified host, port, encryption, user, and password.
|
static void |
connect(java.lang.String host,
int port,
java.lang.String user,
java.lang.String passWord)
Connects to a server using the specified host, port, user, and password.
|
static Model |
create(java.lang.String tag)
Create a model.
|
static Model |
createUnique(java.lang.String prefix)
Create a model with a unique tag that begins with a prefix.
|
static void |
disconnect()
Disconnects from the server.
|
static java.lang.String |
getComsolVersion()
Returns the current version of COMSOL.
|
static java.lang.String |
getDefaultGeometryKernel()
Return the default geometry kernel.
|
static java.lang.String |
getEntityPath(PrimitiveModelEntity entity,
java.lang.String divider)
Creates the path from the root of the model object for the given entity.
|
static java.lang.String |
getOpenGeometryKernel()
Returns the geometry kernel to use when opening a model.
|
static java.lang.String |
getPreference(java.lang.String prefName)
Returns the value of a preference.
|
static java.lang.String |
getRecoveryDir(java.lang.String tag)
Returns a path to the recovery directory for a model.
|
static boolean |
hasProduct(java.lang.String... product)
Return true if the license allows to run the specified products.
|
static boolean |
hasProductForFile(java.lang.String file)
Return true if the license contains products required to open an mph file.
|
static boolean |
hasProductForFileOnServer(java.lang.String file)
Return true if the license contains products required to open an mph file
located on the server filesystem.
|
(package private) static com.comsol.model.util.impl.IModelUtilImpl |
impl() |
static void |
initStandalone(boolean guiSupport)
Initializes the environment for using the COMSOL API from a
Java application.
|
static void |
initStandalone(boolean guiInSupport,
java.lang.String graphicsToolkit)
Initializes the environment for using the COMSOL API from a
Java application.
|
static java.lang.String |
listPreferences()
Returns a string which lists the preferences's names and their description.
|
static Model |
load(java.lang.String tag,
java.lang.String filename)
Load a model.
|
static Model |
loadCopy(java.lang.String tag,
java.lang.String filename)
Load a copy of a model.
|
static Model |
loadOnServer(java.lang.String tag,
java.lang.String filename)
Load a model from a server file.
|
static void |
loadPreferences()
Loads the COMSOL preferences file.
|
static Model |
loadProtected(java.lang.String tag,
java.lang.String filename,
java.lang.String password)
Load a model with password protection.
|
static Model |
loadProtectedOnServer(java.lang.String tag,
java.lang.String filename,
java.lang.String password)
Load a model with password protection from a server file.
|
static Model |
loadRecovery(java.lang.String tag,
java.lang.String foldername)
Load a model from a recovery directory/folder structure.
|
static Model |
model(java.lang.String tag)
Returns the model with a specified tag.
|
static java.lang.String[] |
modelsUsedByOtherClients()
Returns the tags of the models in use by other clients.
|
static void |
remove(java.lang.String tag)
Tries to remove the model with the specified tag.
|
static void |
savePreferences()
Saves the COMSOL preferences file.
|
static java.lang.String[][] |
scanModel(java.lang.String filename,
java.lang.String type,
java.lang.String... extraAttributes)
Scans the model file for a certain node type and collect the tag and label of all
found nodes.
|
static java.lang.String[][] |
scanProtectedModel(java.lang.String filename,
java.lang.String type,
java.lang.String password,
java.lang.String... extraAttributes)
Scans the protected model file for a certain node type.
|
static void |
serverDisplay(java.lang.String message)
Prints a message in the server terminal window.
|
static void |
serverLog(java.lang.String message)
Prints a message in COMSOL's log file on the server.
|
static void |
setDefaultGeometryKernel(java.lang.String defaultKernel)
Specifies the default geometry kernel to use.
|
static void |
setModelChangedHandler(ModelChangedHandler modelChangedHandler)
Register a handler of changes to models made by other clients.
|
static void |
setOpenGeometryKernel(java.lang.String openKernel)
Specifies geometry kernel to use when opening a model.
|
static void |
setPreference(java.lang.String prefName,
java.lang.String value)
Sets a preference value.
|
static void |
setServerBusyHandler(ServerBusyHandler serverBusyHandler)
Several clients can be connected to the same server, but only one client
at a time can ask the server to perform an operation.
|
static void |
showPlots(boolean show)
Specifies whether to show plots when connected to a graphics server.
|
static boolean |
showProgress(boolean progress)
Specifies if progress should be shown on the server.
|
static void |
showProgress(java.lang.String fileName)
Specifies file to log progress to.
|
static java.lang.String[] |
tags()
Return the tags of all models.
|
static java.lang.String |
uniquetag(java.lang.String prefix)
Create a tag that is not in use by any model.
|
static boolean |
useRecovery()
Checks if usage of recovery file is enabled.
|
private static com.comsol.model.util.impl.IModelUtilImpl clientImpl
private static com.comsol.model.util.impl.IModelUtilImpl serverImpl
static com.comsol.model.util.impl.IModelUtilImpl impl()
public static Model create(java.lang.String tag)
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.public static Model createUnique(java.lang.String prefix)
prefix
- The tag prefix.public static void remove(java.lang.String tag)
tag
- The model's tag.public static void clear()
public static java.lang.String[] tags()
public static java.lang.String uniquetag(java.lang.String prefix)
prefix
- The prefix which the tag should begin with.public static java.lang.String getEntityPath(PrimitiveModelEntity entity, java.lang.String divider)
entity
- The entity to get the path for.divider
- Divider to use between entities in path.public static java.lang.String[] modelsUsedByOtherClients()
public static Model model(java.lang.String tag)
tag
- The model's tag.public static Model load(java.lang.String tag, java.lang.String filename) throws java.io.IOException
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.filename
- The model file path.java.io.IOException
- if the file cannot be read.public static Model loadOnServer(java.lang.String tag, java.lang.String filename) throws java.io.IOException
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.filename
- The model file path on the server.java.io.IOException
- if the file cannot be read.public static Model loadProtected(java.lang.String tag, java.lang.String filename, java.lang.String password) throws java.io.IOException
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.filename
- The model file path.password
- The password required to load the model.java.io.IOException
- if the file cannot be read.public static Model loadProtectedOnServer(java.lang.String tag, java.lang.String filename, java.lang.String password) throws java.io.IOException
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.filename
- The model file path on the server.password
- The password required to load the model.java.io.IOException
- if the file cannot be read.public static Model loadCopy(java.lang.String tag, java.lang.String filename) throws java.io.IOException
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.filename
- The model file path.java.io.IOException
- if the file cannot be read.public static Model loadRecovery(java.lang.String tag, java.lang.String foldername) throws java.io.IOException
tag
- The model's tag. If there is already another model with this tag, that model will be removed.
This unless the old model is in use by another client. If that is the case an exception is thrown.foldername
- The recovery folder path.java.io.IOException
- if the file cannot be read.public static void connect()
public static void connect(java.lang.String host, int port)
host
- The server host computer.port
- The port to use.public static void connect(java.lang.String host, int port, boolean encryption)
host
- The server host computer.port
- The port to use.encryption
- If true
, use a secure connection.public static void connect(java.lang.String host, int port, java.lang.String user, java.lang.String passWord)
host
- The server host computer.port
- The port.user
- The user name.passWord
- The password.public static void connect(java.lang.String host, int port, boolean encryption, java.lang.String user, java.lang.String passWord)
host
- The server host computer.port
- The port.encryption
- If true
, use a secure connection.user
- The user name.passWord
- The password.public static void disconnect()
public static void closeWindows()
public static void closeWindow(java.lang.String tag)
tag
- The window's tag.public static boolean showProgress(boolean progress)
progress
- Whether to show progress.true
if change of progress display was applied successfully.public static void showProgress(java.lang.String fileName)
fileName
- name of file.public static void showPlots(boolean show)
ModelUtil.showPlots(false)
does not close any open windows.
To close windows, use closeWindow(String)
or closeWindows()
.
show
- Whether or not to show plots.public static void setOpenGeometryKernel(java.lang.String openKernel)
openKernel
- The geometry kernel.public static java.lang.String getOpenGeometryKernel()
public static void setDefaultGeometryKernel(java.lang.String defaultKernel)
defaultKernel
- The geometry kernel.public static java.lang.String getDefaultGeometryKernel()
public static void setServerBusyHandler(ServerBusyHandler serverBusyHandler)
ServerBusyHandler
it is possible to make the
client wait until the server is free again, and to set a time-out for how long
to wait.serverBusyHandler
- The server busy handler.public static void setModelChangedHandler(ModelChangedHandler modelChangedHandler)
modelChangedHandler
- The handler of model changes.public static void initStandalone(boolean guiSupport)
guiSupport
- is true if support for plotting in a GUI should be available.
The GUI will support creating widgets using Swing components.public static void initStandalone(boolean guiInSupport, java.lang.String graphicsToolkit)
guiInSupport
- is true if support for plotting in a GUI should be available.graphicsToolkit
- "swing" or "swt" depending on if creating a Swing or a
SWT GUI should be supported.public static void loadPreferences()
public static void savePreferences()
public static java.lang.String getPreference(java.lang.String prefName)
prefName
- The preference name. For a list of the preferences names, use
listPreferences()
.public static void setPreference(java.lang.String prefName, java.lang.String value)
prefName
- The preference name. For a list of the preferences names, use
listPreferences()
.value
- The new preference value.public static java.lang.String listPreferences()
public static void serverDisplay(java.lang.String message)
message
- The message to print.public static void serverLog(java.lang.String message)
message
- The message to print.public static boolean hasProduct(java.lang.String... product)
product
- The names of the license features to test.public static boolean hasProductForFile(java.lang.String file) throws java.io.IOException
file
- The mph file specifying the license features to test.java.io.IOException
- if the file cannot be read.public static boolean hasProductForFileOnServer(java.lang.String file) throws java.io.IOException
file
- The mph file specifying the license features to test.java.io.IOException
- if the file cannot be read.public static boolean checkoutLicense(java.lang.String... product)
product
- The names of the license features to check out.public static boolean checkoutLicenseForFile(java.lang.String file) throws java.io.IOException
file
- The mph file to check out licenses for.java.io.IOException
- if the file cannot be read.public static boolean checkoutLicenseForFileOnServer(java.lang.String file) throws java.io.IOException
file
- The mph file to check out licenses for.java.io.IOException
- if the file cannot be read.public static boolean useRecovery()
public static java.lang.String getRecoveryDir(java.lang.String tag) throws java.io.IOException
tag
- The model's tag.java.io.IOException
- if failed to create the directorypublic static java.lang.String getComsolVersion()
public static java.lang.String[][] scanModel(java.lang.String filename, java.lang.String type, java.lang.String... extraAttributes)
String[][] materials = scanModel("mymodel.mph", "Material", "op");will produce an output like:
[["mat1", "Material 1", "Common"],["mat2", "Material 2", "Common"]]
filename
- The file path to the modeltype
- The type of the node to search forextraAttributes
- A list of attributes in addition to the tag and label
to include in the result.public static java.lang.String[][] scanProtectedModel(java.lang.String filename, java.lang.String type, java.lang.String password, java.lang.String... extraAttributes)
filename
- The file path to the model.type
- The type of the node to search for.password
- The password required to open the file.extraAttributes
- A list of attributes in addition to the tag and label
to include in the result.scanModel(String, String, String...)