Mercurial > hg > octave-lyh
comparison scripts/java/javaclasspath.m @ 15772:0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Update docstrings. Use Octave coding conventions. Use default arguments
where possible. Match variable names in docstring to variable names in
function.
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Rik <rik@octave.org>
HG: branch 'default'
* errordlg.m, helpdlg.m, inputdlg.m, javaArray.m, javaaddpath.m,
javaclasspath.m, javafields.m, javamem.m, javamethods.m, javarmpath.m,
listdlg.m, msgbox.m, questdlg.m, warndlg.m: Overhaul functions.
Update docstrings. Use Octave coding conventions. Use default arguments
where possible. Match variable names in docstring to variable names in
function.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 12 Dec 2012 13:48:47 -0800 |
parents | 05c781cca57e |
children | 921912c92102 |
comparison
equal
deleted
inserted
replaced
15771:4698ea77aa75 | 15772:0f1a143e5002 |
---|---|
16 ## You should have received a copy of the GNU General Public License | 16 ## You should have received a copy of the GNU General Public License |
17 ## along with Octave; see the file COPYING. If not, see | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | 18 ## <http://www.gnu.org/licenses/>. |
19 | 19 |
20 ## -*- texinfo -*- | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function file} {} javaclasspath () | 21 ## @deftypefn {Function File} {} javaclasspath () |
22 ## @deftypefnx {Function file} {@var{static} =} javaclasspath () | 22 ## @deftypefnx {Function File} {@var{dpath} =} javaclasspath () |
23 ## @deftypefnx {Function file} {[@var{static}, @var{dynamic}] =} javaclasspath () | 23 ## @deftypefnx {Function File} {[@var{dpath}, @var{spath}] =} javaclasspath () |
24 ## @deftypefnx {Function file} {@var{path} =} javaclasspath (@var{what}) | 24 ## @deftypefnx {Function File} {@var{clspath} =} javaclasspath (@var{what}) |
25 ## Return the class path of the Java virtual machine in | 25 ## Return the class path of the Java virtual machine in the form of a cell |
26 ## the form of a cell array of strings. | 26 ## array of strings. |
27 ## | 27 ## |
28 ## If called without input parameter:@* | 28 ## If called with no inputs: |
29 ## | |
29 ## @itemize | 30 ## @itemize |
30 ## @item If no output is requested, the result is simply printed | 31 ## @item If no output is requested, the dynamic and static classpaths are printed |
31 ## on the standard output. | 32 ## to the standard output. |
32 ## @item If one output value @var{STATIC} is requested, the result is | 33 ## |
33 ## the static classpath. | 34 ## @item If one output value @var{dpath} is requested, the result is |
34 ## @item If two output values@var{STATIC} and @var{DYNAMIC} are | 35 ## the dynamic classpath. |
35 ## requested, the first variable will contain the static classpath, | 36 ## |
36 ## the second will be filled with the dynamic classpath. | 37 ## @item If two output values@var{dpath} and @var{spath} are |
38 ## requested, the first variable will contain the dynamic classpath and | |
39 ## the second will be contain the static classpath. | |
37 ## @end itemize | 40 ## @end itemize |
38 ## | 41 ## |
39 ## If called with a single input parameter @var{what}:@* | 42 ## If called with a single input parameter @var{what}: |
40 ## @itemize | 43 ## |
41 ## @item If @var{what} is @code{"-static"} return the static classpath | 44 ## @table @asis |
42 ## @item If @var{what} is @code{"-dynamic"} return the dynamic classpath | 45 ## @item "-dynamic" |
43 ## @item If @var{what} is @code{"-all"} return both the static and | 46 ## Return the dynamic classpath. |
44 ## dynamic classpath | 47 ## |
45 ## @end itemize | 48 ## @item "-static" |
49 ## Return the static classpath. | |
50 ## | |
51 ## @item "-all" | |
52 ## Return both the static and dynamic classpath in a single cellstr. | |
53 ## @end table | |
46 ## @seealso{javaaddpath, javarmpath} | 54 ## @seealso{javaaddpath, javarmpath} |
47 ## @end deftypefn | 55 ## @end deftypefn |
48 | 56 |
49 function varargout = javaclasspath (which) | 57 function varargout = javaclasspath (which) |
50 | 58 |
55 ## static classpath | 63 ## static classpath |
56 static_path = java_invoke ("java.lang.System", "getProperty", "java.class.path"); | 64 static_path = java_invoke ("java.lang.System", "getProperty", "java.class.path"); |
57 static_path_list = strsplit (static_path, pathsep ()); | 65 static_path_list = strsplit (static_path, pathsep ()); |
58 if (numel (static_path_list) > 1) | 66 if (numel (static_path_list) > 1) |
59 ## remove first element (which is .../octave.jar) | 67 ## remove first element (which is .../octave.jar) |
60 static_path_list = static_path_list(2:numel (static_path_list)); | 68 static_path_list(1) = []; |
61 else | 69 else |
62 static_path_list = {}; | 70 static_path_list = {}; |
63 endif | 71 endif |
64 | 72 |
65 switch nargin | 73 switch (nargin) |
66 case 0 | 74 case 0 |
67 switch nargout | 75 switch (nargout) |
68 case 0 | 76 case 0 |
69 disp_path_list ( "STATIC", static_path_list ) | 77 disp_path_list ("STATIC", static_path_list) |
70 disp (""); | 78 disp (""); |
71 disp_path_list ( "DYNAMIC", dynamic_path_list ) | 79 disp_path_list ("DYNAMIC", dynamic_path_list) |
72 | 80 |
73 case 1 | 81 case 1 |
74 varargout{1} = cellstr (dynamic_path_list); | 82 varargout{1} = cellstr (dynamic_path_list); |
75 | 83 |
76 case 2 | 84 case 2 |
77 varargout{1} = cellstr (dynamic_path_list); | 85 varargout{1} = cellstr (dynamic_path_list); |
78 varargout{2} = cellstr (static_path_list); | 86 varargout{2} = cellstr (static_path_list); |
79 endswitch | 87 endswitch |
80 | 88 |
81 case 1 | 89 case 1 |
82 switch nargout | 90 switch (nargout) |
83 case 0 | 91 case 0 |
84 if (strcmp (which, "-static") == 1) | 92 if (strcmp (which, "-static")) |
85 disp_path_list ( "STATIC", static_path_list ) | 93 disp_path_list ("STATIC", static_path_list) |
86 elseif (strcmp (which, "-dynamic") == 1) | 94 elseif (strcmp (which, "-dynamic")) |
87 disp_path_list ( "DYNAMIC", dynamic_path_list ) | 95 disp_path_list ("DYNAMIC", dynamic_path_list) |
96 elseif (strcmp (which, "-all") == 1) | |
97 disp_path_list ("STATIC", static_path_list) | |
98 disp (""); | |
99 disp_path_list ("DYNAMIC", dynamic_path_list) | |
88 endif | 100 endif |
89 | 101 |
90 case 1 | 102 case 1 |
91 if (strcmp (which, "-static") == 1) | 103 if (strcmp (which, "-static") == 1) |
92 varargout{1} = cellstr (static_path_list); | 104 varargout{1} = cellstr (static_path_list); |
100 | 112 |
101 endfunction | 113 endfunction |
102 | 114 |
103 ## Display cell array of paths | 115 ## Display cell array of paths |
104 | 116 |
105 function disp_path_list ( which, path_list ) | 117 function disp_path_list (which, path_list) |
106 printf (" %s JAVA PATH\n\n", which); | 118 printf (" %s JAVA PATH\n\n", which); |
107 if (numel (path_list) > 0) | 119 if (numel (path_list) > 0) |
108 printf (" %s\n", path_list{:}); | 120 printf (" %s\n", path_list{:}); |
109 else | 121 else |
110 printf (" - empty -\n"); | 122 printf (" - empty -\n"); |
111 endif | 123 endif |
112 endfunction | 124 endfunction |
125 |