JaRMoS
1.1
Java Reduced Model Simulations
|
This class serves as base class for accessing various types of models at different locations. More...
Classes | |
class | ModelManagerException |
This Exception gets thrown when an error occurs regarding the functionality of the ModelManager. More... | |
Public Member Functions | |
AModelManager () | |
Constructs a new ModelManager and a private DocumentBuilder and SchemaFactory. More... | |
void | addMessageHandler (IMessageHandler h) |
Object | loadModelClass (String name) throws ModelManagerException |
Loads a class available in the precompiled classes associated with the current model. More... | |
BufferedReader | getBufReader (String filename) throws IOException |
ClassLoader | getClassLoader () |
This method yields access to any specialized class loaders in subclasses. More... | |
final InputStream | getInStream (String filename) throws IOException |
Returns an InputStream instance streaming the contents of the file given by filename. More... | |
MathObjectReader | getMathObjReader () |
Use this method in order to get a MathObjectReader instance fitted for the current selected model. More... | |
List< ModelDescriptor > | getModelDescriptors () throws ModelManagerException |
Scans all directories given by getFolderList() for valid models and returns a list of model descriptors for each valid model. More... | |
List< ModelDescriptor > | getModelDescriptors (IProgressReporter pr) throws ModelManagerException |
Scans all directories given by getFolderList() for valid models and returns a list of model descriptors for each valid model. More... | |
String | getModelDir () |
FieldDescriptor[] | getModelFieldTypes () |
ModelType | getModelType () |
Returns the model type as given in the model.xml attribute "type" of the "model" tag. More... | |
abstract URI | getModelURI () |
Returns an URI for the current model location/directory. More... | |
String | getModelXMLAttribute (String attrib_name) |
Returns the attribute value of any attributes of the "model" tag in the model.xml file. More... | |
String | getModelXMLAttribute (String attrib_name, String tagname) |
Returns the attribute value of any attributes of the tag given by tagname in the model.xml file. More... | |
String | getModelXMLTagValue (String tagname) |
Works as the overload with default value, but returns null if no matchin element is found. More... | |
String | getModelXMLTagValue (String tagname, String default_value) |
Returns the text content of a tag inside the model.xml file. More... | |
String | getModelPackageStr () |
Returns the package of any java source files associated with this model. More... | |
Parameters | getParameters () |
Reads the parameters from the model XML file and returns a Parameters object. More... | |
boolean | isValidModelDir (String dir) |
Checks if a model.xml file exists in the specified directory and performs xsd-validation. More... | |
abstract boolean | modelFileExists (String filename) |
Returns whether the specified file exists in the current model folder. More... | |
void | removeMessageHandler (IMessageHandler h) |
void | useModel (String location) throws ModelManagerException |
Sets the specified source as current model path. More... | |
boolean | xmlTagExists (String tagname) |
Checks if a specified tag exists inside the current models model.xml file. More... | |
Static Public Attributes | |
static final String | CLASSES_JARFILE = "classes.jar" |
The name of the jar file inside a models directory containing .class files in java bytecode. More... | |
static final String | info_filename = "site_info.html" |
The model's info html file name (imported from rbappmit, might change later) More... | |
Protected Member Functions | |
abstract String[] | getFolderList () throws IOException |
Returns the list of all models directories available at the ModelManagers source location. More... | |
abstract String | getLoadingMessage () |
A short message that writes "loading SD models" dependent on the actual instance. More... | |
abstract InputStream | getInStreamImpl (String filename) throws IOException |
Template method. More... | |
void | sendMessage (String msg) |
This class serves as base class for accessing various types of models at different locations.
Implementing classes implement the abstract members in order to reflect necessary adoptions to different input sources like the file system, websites or others like Android-Assets.
Implemented in JKerMor are jarmos.io.WebModelManager and jarmos.io.FileModelManager.
Each manager has a root directory which must be, depending on the type, either provided at instantiation or are given implicitly. The model system is organized in a way that the root directory contains folders which each contain a single model. Within each such folder, a model.xml-file must be present that describes the model.
The allowed XML file structure is determined by the model.xsd file in the JaRMoSBase project.
Definition at line 61 of file AModelManager.java.
jarmos.io.AModelManager.AModelManager | ( | ) |
Constructs a new ModelManager and a private DocumentBuilder and SchemaFactory.
Unfortunately, the Android 8 API does not seem to support the W3C XML Schema, so no validation is performed on an android :-(
See "http://stackoverflow.com/questions/3129934/schemafactory-doesnt-support-w3c-xml-schema-in-platform-level-8" or "http://developer.android.com/reference/javax/xml/validation/SchemaFactory.html#newInstance%28java.lang.String%29" on how it SHOULD be..
Definition at line 124 of file AModelManager.java.
void jarmos.io.AModelManager.addMessageHandler | ( | IMessageHandler | h | ) |
h |
Definition at line 160 of file AModelManager.java.
BufferedReader jarmos.io.AModelManager.getBufReader | ( | String | filename | ) | throws IOException |
filename |
IOException |
Definition at line 192 of file AModelManager.java.
ClassLoader jarmos.io.AModelManager.getClassLoader | ( | ) |
This method yields access to any specialized class loaders in subclasses.
As the android platform works with different loaders then a JRE, for example, this interface is provided to enable custom classes loaded with whatever platform.
If subclasses do not override, the default system class loader is provided.
The class loader must be configured in a way that a call to loadClass(String name) must search also inside the current model's directory.
Definition at line 211 of file AModelManager.java.
|
protectedpure virtual |
Returns the list of all models directories available at the ModelManagers source location.
At this stage, no validity checks have to be performed regarding if a returned folder actually contains a valid model.
IOException |
Implemented in jarmos.io.CachingModelManager, jarmos.io.FileModelManager, jarmos.io.WebModelManager, and jarmos.app.io.AssetModelManager.
final InputStream jarmos.io.AModelManager.getInStream | ( | String | filename | ) | throws IOException |
Returns an InputStream instance streaming the contents of the file given by filename.
filename | The model file to return a stream for |
IOException |
Definition at line 240 of file AModelManager.java.
|
protectedpure virtual |
Template method.
Implementations of this method must locate the given file inside the current model directory and return an input stream pointing to it.
filename | The model file to return a stream for |
IOException |
Implemented in jarmos.io.CachingModelManager, jarmos.io.WebModelManager, jarmos.io.FileModelManager, and jarmos.app.io.AssetModelManager.
|
protectedpure virtual |
A short message that writes "loading SD models" dependent on the actual instance.
Implemented in jarmos.io.CachingModelManager, jarmos.io.FileModelManager, jarmos.io.WebModelManager, jarmos.app.io.AssetModelManager, jarmos.app.io.SDModelManager, and jarmos.app.io.WebModelManager.
MathObjectReader jarmos.io.AModelManager.getMathObjReader | ( | ) |
Use this method in order to get a MathObjectReader instance fitted for the current selected model.
This method returns an automatically configured reader (the old model data is encoded in little endian).
Definition at line 265 of file AModelManager.java.
List<ModelDescriptor> jarmos.io.AModelManager.getModelDescriptors | ( | ) | throws ModelManagerException |
Scans all directories given by getFolderList() for valid models and returns a list of model descriptors for each valid model.
ModelManagerException |
Definition at line 276 of file AModelManager.java.
List<ModelDescriptor> jarmos.io.AModelManager.getModelDescriptors | ( | IProgressReporter | pr | ) | throws ModelManagerException |
Scans all directories given by getFolderList() for valid models and returns a list of model descriptors for each valid model.
pr | A IProgressReporter instance to report process in the loading to. |
ModelManagerException |
Definition at line 290 of file AModelManager.java.
String jarmos.io.AModelManager.getModelDir | ( | ) |
Definition at line 341 of file AModelManager.java.
FieldDescriptor [] jarmos.io.AModelManager.getModelFieldTypes | ( | ) |
Definition at line 345 of file AModelManager.java.
String jarmos.io.AModelManager.getModelPackageStr | ( | ) |
Returns the package of any java source files associated with this model.
Defaults to the default package (="") if none is given.
Definition at line 482 of file AModelManager.java.
ModelType jarmos.io.AModelManager.getModelType | ( | ) |
Returns the model type as given in the model.xml attribute "type" of the "model" tag.
Definition at line 370 of file AModelManager.java.
|
pure virtual |
Returns an URI for the current model location/directory.
Implemented in jarmos.io.CachingModelManager, jarmos.io.FileModelManager, jarmos.io.WebModelManager, and jarmos.app.io.AssetModelManager.
String jarmos.io.AModelManager.getModelXMLAttribute | ( | String | attrib_name | ) |
Returns the attribute value of any attributes of the "model" tag in the model.xml file.
Returns null if no model directory has been set or the attribute does not exist.
attrib_name | The attribute's name |
Definition at line 389 of file AModelManager.java.
String jarmos.io.AModelManager.getModelXMLAttribute | ( | String | attrib_name, |
String | tagname | ||
) |
Returns the attribute value of any attributes of the tag given by tagname in the model.xml file.
Returns null if no model directory has been set or the attribute does not exist.
attrib_name | the attribute's name |
tagname | The xml tag whos attributes are to be searched. |
Definition at line 408 of file AModelManager.java.
String jarmos.io.AModelManager.getModelXMLTagValue | ( | String | tagname | ) |
Works as the overload with default value, but returns null if no matchin element is found.
tagname |
Definition at line 454 of file AModelManager.java.
String jarmos.io.AModelManager.getModelXMLTagValue | ( | String | tagname, |
String | default_value | ||
) |
Returns the text content of a tag inside the model.xml file.
The tag given may be separated by a dot, so that a clear position can be addressed. So "description.name" will look up any tags named "description" and search therein for any tags named "name". Always the first item with a corresponding name is returned.
tagname | The tag whos value should be returned. |
default_value | The default value if no matching element is found |
Definition at line 471 of file AModelManager.java.
Parameters jarmos.io.AModelManager.getParameters | ( | ) |
Reads the parameters from the model XML file and returns a Parameters object.
Definition at line 509 of file AModelManager.java.
boolean jarmos.io.AModelManager.isValidModelDir | ( | String | dir | ) |
Checks if a model.xml file exists in the specified directory and performs xsd-validation.
Note: On the current Android platform the validation using the xsd W3C Schema is somehow NOT implemented; so, validation is skipped on android platforms.
dir | The directory to check |
Definition at line 548 of file AModelManager.java.
Object jarmos.io.AModelManager.loadModelClass | ( | String | name | ) | throws ModelManagerException |
Loads a class available in the precompiled classes associated with the current model.
The model.xml-tag "package" is used if set to specify the package under which the class can be found; if not set the default package (="") is used.
name |
ModelManagerException |
Definition at line 173 of file AModelManager.java.
|
pure virtual |
Returns whether the specified file exists in the current model folder.
filename |
Implemented in jarmos.io.CachingModelManager, jarmos.io.WebModelManager, jarmos.io.FileModelManager, and jarmos.app.io.AssetModelManager.
void jarmos.io.AModelManager.removeMessageHandler | ( | IMessageHandler | h | ) |
h |
Definition at line 592 of file AModelManager.java.
|
protected |
Definition at line 596 of file AModelManager.java.
void jarmos.io.AModelManager.useModel | ( | String | location | ) | throws ModelManagerException |
Sets the specified source as current model path.
Requires the
location | The directory/path to change to |
ModelManagerException | The current model directory, path or location does not contain a valid model. |
Definition at line 615 of file AModelManager.java.
boolean jarmos.io.AModelManager.xmlTagExists | ( | String | tagname | ) |
Checks if a specified tag exists inside the current models model.xml file.
tagname | The tag to check |
Definition at line 651 of file AModelManager.java.
|
static |
The name of the jar file inside a models directory containing .class files in java bytecode.
This file name can be used inside custom implementations of getClassLoader, if directory searches are not permitted/implemented (e.g. WebModelManager)
Definition at line 95 of file AModelManager.java.
|
static |
The model's info html file name (imported from rbappmit, might change later)
Definition at line 100 of file AModelManager.java.