Mercurial > hg > octave-lyh
comparison scripts/miscellaneous/usejava.m @ 13826:847812137666
Implement new usejava function for Matlab compatability.
* usejava.m: New function for Matlab compatability.
* NEWS: Announce new function availability in 3.6.0
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 04 Nov 2011 19:58:38 -0700 |
parents | |
children | 050bc580cb60 |
comparison
equal
deleted
inserted
replaced
13825:45f4ff9a6247 | 13826:847812137666 |
---|---|
1 ## Copyright (C) 2011 Rik Wehbring | |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} usejava (@var{feature}) | |
21 ## Return true if the specific Sun Java element @var{feature} is available. | |
22 ## | |
23 ## Possible features are: | |
24 ## | |
25 ## @table @asis | |
26 ## @item "awt" | |
27 ## Abstract Window Toolkit for GUIs. | |
28 ## | |
29 ## @item "desktop" | |
30 ## Interactive desktop is running. | |
31 ## | |
32 ## @item "jvm" | |
33 ## Java Virtual Machine. | |
34 ## | |
35 ## @item "swing" | |
36 ## Swing components for lightweight GUIs. | |
37 ## @end table | |
38 ## | |
39 ## This function is provided for compatability with @sc{matlab} scripts which | |
40 ## may alter their behavior based on the availability of Java. Octave does | |
41 ## not implement an interface to Java and this function always returns | |
42 ## @code{false}. | |
43 ## @end deftypefn | |
44 | |
45 function retval = usejava (feature) | |
46 | |
47 if (nargin != 1 || ! ischar (feature)) | |
48 print_usage (); | |
49 endif | |
50 | |
51 if (! any (strcmp (feature, {"awt", "desktop", "jvm", "swing"}))) | |
52 error ("usejava: unrecognized feature '%s'", feature); | |
53 endif | |
54 | |
55 retval = false; | |
56 | |
57 endfunction | |
58 | |
59 | |
60 %!assert (usejava ("awt"), false) | |
61 | |
62 %% Test input validation | |
63 %!error usejava () | |
64 %!error usejava (1, 2) | |
65 %!error usejava (1) | |
66 %!error <unrecognized feature> usejava ("abc") | |
67 |