4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.FileOutputStream;
7 import java.io.IOException;
8 import java.io.InputStream;
9 import java.net.MalformedURLException;
12 import java.net.URLClassLoader;
26 public static final String
MODEL_DIR =
"/home/dwirtz/aghhome/Software/Eclipse/JaRMoS/JaRMoSModels";
42 File r =
new File(root);
44 throw new IllegalArgumentException(
"Directory does not exist: '" + root +
"'");
56 return new URLClassLoader(
new URL[] { url }, super.getClassLoader());
57 }
catch (MalformedURLException e) {
58 throw new RuntimeException(
"Creating a file with path '" + root +
"/" +
getModelDir() +
"/"
69 protected InputStream
getInStreamImpl(String filename)
throws FileNotFoundException {
79 return new File(root).list();
87 return new File(root + File.separator +
getModelDir() + File.separator + filename).exists();
91 return root + File.separator +
getModelDir() + File.separator;
109 FileOutputStream out =
new FileOutputStream(file);
110 byte[] buffer =
new byte[1024];
112 while ((bytes_read = in.read(buffer)) > 0) {
113 out.write(buffer, 0, bytes_read);
127 private boolean deleteDir(File dir) {
128 if (dir.isDirectory()) {
129 String[] children = dir.list();
130 for (
int i = 0; i < children.length; i++) {
131 boolean success = deleteDir(
new File(dir, children[i]));
157 return "Reading models";
String getLoadingMessage()
A short message that writes "loading SD models" dependent on the actual instance. ...
String getRoot()
Returns the root folder for the model directories.
Manages models loaded from the file system available via the java.io classes.
static final String CLASSES_JARFILE
The name of the jar file inside a models directory containing .class files in java bytecode...
This class serves as base class for accessing various types of models at different locations...
FileModelManager()
Calls the constructor with the FileModelManager.MODEL_DIR static string as root.
boolean clearCurrentModel()
Removes.
String getFullModelPath()
URI getModelURI()
Returns an URI for the current model location/directory.
void writeModelFile(String filename, InputStream in)
Writes the given inputstream to the file specified by filename to the current model directory...
static final String MODEL_DIR
ClassLoader getClassLoader()
FileModelManager(String root)
boolean modelFileExists(String filename)
InputStream getInStreamImpl(String filename)
Template method.