KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Java.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 class Java
18  :public handle {
37  public:
38 
79  char Package = "";
122  public: /* ( Constant ) */
123 
124  static const JavaJarFile = "classes.jar";
125 
126 
127  static const AndroidJarFile = "dexclasses.jar";
128 
129 
130  public: /* ( Constant ) */
131 
132 
133  function exportFunctions() {
134  if isempty(this.Sources)
135  error(" Sourcefile must be set ");
136  end
137 
138  outjava = cell.empty(1,0);
139  outdex = cell.empty(1,0);
140  for sidx = 1:length(this.Sources)
141  src = this.Sources[sidx];
142  pkgdir = strrep(this.Package," . ",filesep);
143  if isempty(this.JProjectSource)
144  cmd = sprintf(" javac -d %s %s ", this.TargetFolder, [src " .java "]);
145  else
146  jfile = fullfile(fullfile(this.JProjectSource,pkgdir),[src " .java "]);
147  cp = this.JProjectSource;
148  if ~isempty(this.AdditionalClassPath)
149  cp = Utils.implode([[cp], this.AdditionalClassPath],pathsep," %s ");
150  end
151  cmd = sprintf(" javac -classpath '%s' -d %s %s ", cp, this.TargetFolder, jfile);
152  end
153 
154  fprintf(" Compiling and exporting class '%s'...\n ",src);
155  system(cmd);
156 
157  relpath = fullfile(pkgdir,[src " .class "]);
158  if this.CreateJVM
159  outjava[sidx] = sprintf(" -C %s %s ",this.TargetFolder,relpath);
160  end
161  if this.CreateAndroid
162  outdex[sidx] = fullfile(this.TargetFolder,relpath);
163  end
164  end
165 
166  /* Create normal jar file for Java VMs */
167  if this.CreateJVM
168  javajar = fullfile(this.TargetFolder,this.JavaJarFile);
169  system(sprintf(" jar -cf %s %s ",javajar,...
170  Utils.implode(outjava," "," %s ")));
171  end
172  /* Create dex files for Android DalvikVM */
173  if this.CreateAndroid
174  dexjar = fullfile(this.TargetFolder,this.AndroidJarFile);
175  /* system(sprintf('dx --dex --output="dexclasses.jar" %s',outcl)); */
176  system(sprintf(" dx --dex --no-strict --output='%s' %s ",dexjar,...
177  Utils.implode(outdex," "," %s ")));
178  end
179 
180  /* Remove .class file - we're tidy :-) */
181  if ~isempty(this.Package)
182  folder = this.Package(1:strfind(this.Package," . ")-1);
183  if isempty(folder)
184  folder = this.Package;
185  end
186  rmdir(fullfile(this.TargetFolder,folder)," s ");
187  else
188  delete(outcl);
189  end
190  }
199 #if 0 //mtoc++: 'set.CreateJVM'
200 function CreateJVM(value) {
201  if system(" javac ") == 1
202  error(" Error checking for javac compiler. ");
203  end
204  this.CreateJVM= value;
205  }
206 
207 #endif
208 
209 
210 
211 #if 0 //mtoc++: 'set.CreateAndroid'
212 function CreateAndroid(value) {
213  this.CreateAndroid= value;
214  }
215 
216 #endif
217 
226 #if 0 //mtoc++: 'set.TargetFolder'
227 function TargetFolder(value) {
228  if (isunix && value(1) ~= " / ") || ispc && isempty(strfind(value," : "))
229  value = fullfile(pwd,value);
230  end
231  this.TargetFolder= value;
232  }
233 
234 #endif
235 
236 
237 
251 };
252 
Collection of generally useful functions.
Definition: Utils.m:17
logical CreateAndroid
Create a class for the Dalvik VM (Android dex required)
Definition: Java.m:112
static const JavaJarFile
Definition: Java.m:124
char Package
The classes package (optional, required if it has one but the default package)
Definition: Java.m:79
logical CreateJVM
Create a class for java virtual machine.
Definition: Java.m:102
cell< char > AdditionalClassPath
An additional cell of paths for the java classpath.
Definition: Java.m:66
Matlab's base handle class (documentation generation substitute)
A boolean value.
Java: Java utils like compiling classes out of matlab.
Definition: Java.m:17
function exportFunctions()
Compile AffFcns class. JProjectSource needed for JRB/JKerMor models.
Definition: Java.m:133
cell< char > Sources
The names of the source files.
Definition: Java.m:39
static function char str = implode(char|rowvec data,char glue,char format)
Implodes the elements of data using glue.
Definition: Utils.m:208
A MatLab character array.
static const AndroidJarFile
Definition: Java.m:127
char TargetFolder
The target folder for the class output.
Definition: Java.m:89
char JProjectSource
An additional JProjectSource for inclusion.
Definition: Java.m:53