Mercurial > octave
annotate scripts/java/org/octave/ClassHelper.java @ 32632:2e484f9f1f18 stable
maint: update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Dec 2023 12:08:17 -0500 |
parents | 597f3ee61a48 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 // Copyright (C) 2007-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 package org.octave; |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 import java.lang.reflect.*; |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 public class ClassHelper |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
32 private static OctClassLoader loader; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
34 static |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
35 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
36 ClassLoader l = ClassHelper.class.getClassLoader (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
37 loader = (l instanceof OctClassLoader ? (OctClassLoader) l : |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
38 new OctClassLoader (l)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
39 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
42 /** |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
43 * Add the given path to the classpath. |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
44 * @param name String - path to add to the classpath |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
45 * @param append boolean - if true, append path to classpath, otherwise prepend it. |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
46 * @return boolean - true if the given path exists and was added to the classpath. |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
47 * @throws Exception if an error occurs |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
48 */ |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
49 public static boolean addClassPath (String name, boolean append) |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
50 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
51 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
52 boolean found = false; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
53 java.io.File f = new java.io.File (name); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
54 if (f.exists ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
56 found = true; |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
57 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
58 if (append) |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
59 { |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
60 loader.addClassPath (name); |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
61 } |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
62 else |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
63 { |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
64 // create a completely new class loader because java.net.URLClassLoader appears to have no method to prepend directories to the existing classpath |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
65 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
66 // FIXME: is there a more efficient way to do this job? |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
67 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
68 java.net.URL[] urls = loader.getURLs (); |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
69 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
70 ClassLoader l = ClassHelper.class.getClassLoader (); |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
71 loader = (l instanceof OctClassLoader ? (OctClassLoader) l : |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
72 new OctClassLoader (l)); |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
73 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
74 loader.addClassPath (name); |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
75 |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
76 for (int i = 0; i < urls.length; i++) |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
77 { |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
78 loader.addURL (urls[i]); |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
79 } |
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
80 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 } |
27875
1ebfa73565fe
javaaddpath: prepend dirs by default, accept "-end" arg (bug #57487)
John W. Eaton <jwe@octave.org>
parents:
26952
diff
changeset
|
82 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
83 return (found); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
84 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
87 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
88 /** |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
89 * |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
90 * @param name String - path to remove from classpath. |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
91 * @return boolean - true if the given path existed in the classpath before it was removed. |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
92 * @throws Exception if an error occurs |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
93 */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
94 public static boolean removeClassPath (String name) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
95 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
96 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
97 boolean found = false; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
98 java.io.File f = new java.io.File (name); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
99 java.net.URL urlToRemove = f.toURI ().toURL (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
100 // save urls in current class path |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
101 java.net.URL[] urls = loader.getURLs (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
103 // create a completely new class loader because java.net.URLClassLoader has no removeClassPath() method |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
104 ClassLoader l = ClassHelper.class.getClassLoader (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
105 loader = (l instanceof OctClassLoader ? (OctClassLoader) l : |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
106 new OctClassLoader (l)); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
108 // add the previous urls back, except for the one |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
109 for (int i = 0; i < urls.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
111 java.net.URL url = urls[i]; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
112 if (!url.equals (urlToRemove)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
113 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
114 loader.addURL (url); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
115 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
116 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
117 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 // path to remove |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 found = true; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
120 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 } |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
123 return (found); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
124 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
127 public static String getClassPath () |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
128 { |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
129 StringBuilder buf = new StringBuilder(); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
130 String pathSep = System.getProperty ("path.separator"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
131 java.net.URL[] urls = loader.getURLs (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
133 for (int i = 0; i < urls.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
135 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
136 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
137 java.io.File f = new java.io.File (urls[i].toURI ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
138 if (buf.length () > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
139 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
140 buf.append (pathSep); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
141 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
142 buf.append (f.toString ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
143 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
144 catch (java.net.URISyntaxException ex) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
145 {} |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
147 return buf.toString (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
148 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
151 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
152 // return list of methods for given class name |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
153 public static String getMethods (String classname) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
154 throws ClassNotFoundException |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
155 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
156 return (getMethods (Class.forName (classname))); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
157 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
160 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
161 // return list of methods for given class instance |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
162 public static String getMethods (Object obj) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
163 throws ClassNotFoundException |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
164 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
165 return (getMethods (obj.getClass ())); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
166 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
169 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
170 // return list of methods for given class |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
171 public static String getMethods (Class klass) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
172 { |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
173 StringBuilder sb = new StringBuilder(); |
26952
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
174 boolean first = true; |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
175 |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
176 Constructor theConstructor[] = klass.getConstructors (); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
177 for (int i = 0; i < theConstructor.length; i++) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
178 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
179 if (first) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
180 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
181 first = false; |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
182 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
183 else |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
184 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
185 sb.append (";"); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
186 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
187 |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
188 sb.append (theConstructor[i].getName ()); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
189 sb.append ("("); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
190 |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
191 Class theParameter[] = theConstructor[i].getParameterTypes (); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
192 for (int j = 0; j < theParameter.length; j++) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
193 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
194 if (j > 0) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
195 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
196 sb.append (", "); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
197 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
198 sb.append (theParameter[j].getCanonicalName ()); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
199 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
200 sb.append (")"); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
201 |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
202 Class theExceptions[] = theConstructor[i].getExceptionTypes (); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
203 if (theExceptions.length > 0) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
204 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
205 sb.append (" throws "); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
206 for (int j = 0; j < theExceptions.length; j++) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
207 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
208 if (j > 0) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
209 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
210 sb.append (", "); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
211 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
212 sb.append (theExceptions[j].getCanonicalName ()); |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
213 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
214 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
215 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
217 Method theMethod[] = klass.getMethods (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
218 for (int i = 0; i < theMethod.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 { |
26952
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
220 if (first) |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
221 { |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
222 first = false; |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
223 } |
ca8c2696af62
include Java constructors in methods output (bug #55858)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
224 else |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
225 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
226 sb.append (";"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
227 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
228 sb.append (theMethod[i].getReturnType ().getCanonicalName ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
229 sb.append (" "); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
230 sb.append (theMethod[i].getName ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
231 sb.append ("("); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
233 Class theParameter[] = theMethod[i].getParameterTypes (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
234 for (int j = 0; j < theParameter.length; j++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
235 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
236 if (j > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
237 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
238 sb.append (", "); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
239 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
240 sb.append (theParameter[j].getCanonicalName ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
241 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
242 sb.append (")"); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
244 Class theExceptions[] = theMethod[i].getExceptionTypes (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
245 if (theExceptions.length > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
246 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
247 sb.append (" throws "); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
248 for (int j = 0; j < theExceptions.length; j++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
249 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
250 if (j > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
251 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
252 sb.append (", "); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
253 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
254 sb.append (theExceptions[j].getCanonicalName ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
255 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
256 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 } |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
259 return (sb.toString ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
260 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
263 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
264 // return list of fields for given class |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
265 public static String getFields (Class klass) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
266 { |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
267 StringBuilder sb = new StringBuilder(); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
269 Field theField[] = klass.getFields (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
270 for (int i = 0; i < theField.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
272 if (i > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
273 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
274 sb.append (";"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
275 } |
18902
e6872e945553
fieldnames: return only field names of java objects instead of description.
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
276 sb.append (theField[i].getName ()); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 } |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
279 return (sb.toString ()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
280 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
283 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
284 // return list of fields for given class name |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
285 public static String getFields (String classname) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
286 throws ClassNotFoundException |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
287 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
288 return (getFields (Class.forName (classname))); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
289 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
292 // new -MH- |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
293 // return list of fields for given class instance |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
294 public static String getFields (Object obj) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
295 throws ClassNotFoundException |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
296 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
297 return (getFields (obj.getClass ())); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
298 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
301 public static Method findMethod (Class<?> cls, String name, Class<?>[] argTypes) |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
302 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
303 try |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
305 return cls.getMethod (name, argTypes); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
307 catch (Exception e) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
309 Method[] mList = cls.getMethods (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
310 Method m; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
311 for (int i = 0; i < mList.length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
312 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 m = mList[i]; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
314 if (m.getName ().equals (name) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
315 && m.getParameterTypes ().length == argTypes.length |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
316 && isCallableFrom (m, argTypes)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
317 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
318 return m; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
319 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
320 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
321 return null; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
323 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
326 public static Constructor findConstructor (Class<?> cls, Class<?>[] argTypes) |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
327 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
328 try |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
330 return cls.getConstructor (argTypes); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
332 catch (Exception e) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
334 Constructor[] cList = cls.getConstructors (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
335 //System.out.println("# constructors: " + cList.length); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
336 Constructor c; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
337 for (int i = 0; i < cList.length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
338 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 //System.out.println("Considering constructor: " + cList[i]); |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 c = cList[i]; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
341 if (c.getParameterTypes ().length == argTypes.length |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
342 && isCallableFrom (c, argTypes)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
343 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
344 return c; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
345 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
346 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
347 return null; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
349 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
352 private static Object invokeMethod (Method m, Object target, Object[] args) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
353 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
354 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
355 try |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
357 return m.invoke (target, args); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
359 catch (IllegalAccessException ex) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
361 String mName = m.getName (); |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
362 Class<?>[] pTypes = m.getParameterTypes (); |
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
363 Class<?> currClass = target.getClass (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
365 while (currClass != null) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
366 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 try |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
368 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
369 Method meth = currClass.getMethod (mName, pTypes); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
370 if (!meth.equals (m)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
371 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
372 return meth.invoke (target, args); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
373 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
374 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
375 catch (NoSuchMethodException ex2) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
376 {} |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
377 catch (IllegalAccessException ex2) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
378 {} |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
380 Class<?>[] ifaceList = currClass.getInterfaces (); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
381 for (int i = 0; i < ifaceList.length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
382 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
383 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
384 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
385 Method meth = ifaceList[i].getMethod (mName, pTypes); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
386 return meth.invoke (target, args); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
387 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
388 catch (NoSuchMethodException ex2) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
389 {} |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
390 catch (IllegalAccessException ex2) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
391 {} |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
392 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 currClass = currClass.getSuperclass (); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
395 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
397 throw ex; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
399 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
402 public static Object invokeMethod (Object target, String name, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
403 Object[] args, Class[] argTypes) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
404 throws Throwable |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
405 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
406 Method m = findMethod (target.getClass (), name, argTypes); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
407 if (m != null) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
409 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
410 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
411 Object result = invokeMethod (m, target, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
412 castArguments (args, argTypes, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
413 m.getParameterTypes ())); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 return result; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
415 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
416 catch (InvocationTargetException ex) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
417 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 throw ex.getCause (); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
419 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
421 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
423 throw new NoSuchMethodException (name); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
425 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
428 public static Object invokeStaticMethod (String cls, String name, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
429 Object[] args, Class[] argTypes) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
430 throws Throwable |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
431 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
432 Method m = findMethod (Class.forName (cls, true, loader), name, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
433 argTypes); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
434 if (m != null) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
436 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
437 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
438 Object result = m.invoke (null, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
439 castArguments (args, argTypes, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
440 m.getParameterTypes ())); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 return result; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
442 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
443 catch (InvocationTargetException ex) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
444 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
445 throw ex.getCause (); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
446 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
448 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
450 throw new NoSuchMethodException (name); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
452 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
455 public static Object invokeConstructor (String cls, Object[] args, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
456 Class[] argTypes) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
457 throws Throwable |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
458 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
459 Constructor c = findConstructor (Class.forName (cls, true, loader), |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
460 argTypes); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
461 if (c != null) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
463 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
464 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
465 Object result = c.newInstance (castArguments (args, argTypes, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
466 c.getParameterTypes ())); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 return result; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
468 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
469 catch (InvocationTargetException ex) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
470 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 throw ex.getCause (); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
472 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
474 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
476 throw new NoSuchMethodException (cls); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
478 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
481 public static Object getField (Object target, String name) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
482 throws Throwable |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
483 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
484 try |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
486 Field f = target.getClass ().getField (name); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
487 return f.get (target); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
489 catch (NoSuchFieldException ex) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
491 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
492 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
493 return invokeMethod (target, name, new Object[0], new Class[0]); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
494 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
495 catch (NoSuchMethodException ex2) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
496 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 throw ex; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
498 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
500 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
503 public static Object getStaticField (String cls, String name) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
504 throws Throwable |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
505 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
506 try |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
508 Field f = Class.forName (cls, true, loader).getField (name); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
509 return f.get (null); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
511 catch (NoSuchFieldException ex) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
513 try |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
514 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
515 return invokeStaticMethod (cls, name, new Object[0], new Class[0]); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
516 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
517 catch (NoSuchMethodException ex2) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
518 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 throw ex; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
520 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
522 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
525 public static void setField (Object target, String name, Object value) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
526 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
527 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
528 Field f = target.getClass ().getField (name); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
529 f.set (target, castArgument (value, value.getClass (), f.getType ())); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
530 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
533 public static void setStaticField (String cls, String name, Object value) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
534 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
535 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
536 Field f = Class.forName (cls, true, loader).getField (name); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
537 f.set (null, castArgument (value, value.getClass (), f.getType ())); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
538 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
541 private static boolean isCallableFrom (Method m, Class[] argTypes) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
542 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
543 Class[] expTypes = m.getParameterTypes (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
544 for (int i = 0; i < argTypes.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
546 if (!isCallableFrom (expTypes[i], argTypes[i])) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
547 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 return false; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
549 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
551 return true; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
552 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
555 private static boolean isCallableFrom (Constructor c, Class[] argTypes) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
556 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
557 Class[] expTypes = c.getParameterTypes (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
558 for (int i = 0; i < argTypes.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
560 if (!isCallableFrom (expTypes[i], argTypes[i])) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
561 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 return false; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
563 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
565 return true; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
566 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
567 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
569 private static boolean isCallableFrom (Class<?> expCls, Class<?> argCls) |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
570 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
571 //System.out.println("isCallableFrom: "+expCls.getCanonicalName() + " <=? " + argCls.getCanonicalName()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
572 if (argCls == null) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
574 return!expCls.isPrimitive (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
575 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
576 else if (expCls.isAssignableFrom (argCls)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
577 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
578 return true; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
580 else if ((isNumberClass (expCls) || isBooleanClass (expCls)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
581 && isNumberClass (argCls)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
583 return true; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
585 else if (isCharClass (expCls) && argCls.equals (Character.class)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
586 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
587 /* |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 modified into a more strict check to avoid char to string matching |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 to avoid matching method signatureslike |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 java_method(char) with octave_call('a String') |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
591 */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
592 return true; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
594 else if (isStringClass (expCls) && argCls.equals (String.class)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
596 /* |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 added for strict String to String matching |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 java_method(String) with octave_call('a String') |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 but not |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 java_method(char) with octave_call('a String') |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
601 */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
602 return true; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
604 else if (expCls.isArray () && argCls.isArray () |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
605 && isCallableFrom (expCls.getComponentType (), |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
606 argCls.getComponentType ())) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
608 return true; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
610 else if (expCls.equals (Object.class) && argCls.isPrimitive ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
612 return true; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
614 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
616 return false; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
618 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
621 private static boolean isNumberClass (Class cls) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
622 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
623 return (cls.equals (Integer.TYPE) || cls.equals (Integer.class) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
624 || cls.equals (Short.TYPE) || cls.equals (Short.class) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
625 || cls.equals (Long.TYPE) || cls.equals (Long.class) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
626 || cls.equals (Float.TYPE) || cls.equals (Float.class) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
627 || cls.equals (Double.TYPE) || cls.equals (Double.class)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
628 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
631 private static boolean isBooleanClass (Class cls) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
632 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
633 return (cls.equals (Boolean.class) || cls.equals (Boolean.TYPE)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
634 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
637 private static boolean isCharClass (Class cls) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
638 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
639 return (cls.equals (Character.class) || cls.equals (Character.TYPE)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
640 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
643 /** |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
644 * Check whether the supplied class is a String class. |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
645 * |
27985
9f9ac219896d
maint: Remove remaining "Author:" instances from code base.
Rik <rik@octave.org>
parents:
27957
diff
changeset
|
646 * Added for more strict char/string matching of method signatures |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
647 * @param cls Class - the class to check |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
648 * @return boolean - true if clas is of class java.lang.String |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
649 */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
650 private static boolean isStringClass (Class cls) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
651 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
652 return ( |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
653 cls.equals (String.class) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
654 ); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
655 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
658 private static Object[] castArguments (Object[] args, Class[] argTypes, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
659 Class[] expTypes) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
660 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
661 for (int i = 0; i < args.length; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
662 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
663 args[i] = castArgument (args[i], argTypes[i], expTypes[i]); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
665 return args; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
666 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 |
25536
075b9f8a32d8
Eliminate -Xlint warnings during Java compilation (bug #53550).
Andrew Janke <andrew@apjanke.net>
parents:
25054
diff
changeset
|
669 private static Object castArgument (Object obj, Class<?> type, Class<?> expType) |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
670 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
671 // System.out.println("expType:"+expType.getCanonicalName() + " <= type:" + type.getCanonicalName()); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
672 if (type == null || expType.isAssignableFrom (type)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
674 return obj; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
676 else if (isNumberClass (expType)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
678 if (expType.equals (Integer.TYPE) || expType.equals (Integer.class)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
679 { |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
680 return Integer.valueOf (((Number) obj).intValue ()); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
681 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
682 else if (expType.equals (Double.TYPE) || expType.equals (Double.class)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
683 { |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
684 return Double.valueOf (((Number) obj).doubleValue ()); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
685 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
686 else if (expType.equals (Short.TYPE) || expType.equals (Short.class)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
687 { |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
688 return Short.valueOf (((Number) obj).shortValue ()); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
689 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
690 else if (expType.equals (Long.TYPE) || expType.equals (Long.class)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
691 { |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
692 return Long.valueOf (((Number) obj).longValue ()); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
693 } |
17665
78e9bfdc544e
* scripts/java/org/octave/ClassHelper.java (castArgument): Handle conversion of float.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15753
diff
changeset
|
694 else if (expType.equals (Float.TYPE) || expType.equals (Float.class)) |
78e9bfdc544e
* scripts/java/org/octave/ClassHelper.java (castArgument): Handle conversion of float.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15753
diff
changeset
|
695 { |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
696 return Float.valueOf (((Number) obj).floatValue ()); |
17665
78e9bfdc544e
* scripts/java/org/octave/ClassHelper.java (castArgument): Handle conversion of float.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15753
diff
changeset
|
697 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
699 else if (isBooleanClass (expType)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 { |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
701 return Boolean.valueOf (((Number) obj).intValue () != 0); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
702 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
703 else if (isCharClass (expType)) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
705 String s = obj.toString (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
706 if (s.length () != 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
707 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
708 throw new ClassCastException ("cannot cast " + s + " to character"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
709 } |
31367
a448b8a0ffff
build: Silence compilation warning about deprecated constructor in ClassHelper.java (bug #63210)
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
710 return Character.valueOf (s.charAt (0)); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
711 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
712 else if (expType.isArray () && type.isArray ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
713 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
714 return castArray (obj, type.getComponentType (), |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
715 expType.getComponentType ()); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
716 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
717 else if (type.isPrimitive ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
718 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
719 return obj; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
720 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
721 return null; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
722 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
723 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
725 private static Object castArray (Object obj, Class elemType, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
726 Class elemExpType) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
727 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
728 int len = Array.getLength (obj); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
729 Object result = Array.newInstance (elemExpType, len); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
730 for (int i = 0; i < len; i++) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
732 Array.set (result, i, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
733 castArgument (Array.get (obj, i), elemType, elemExpType)); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
735 return result; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
736 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
739 private static int getArrayClassNDims (Class cls) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
740 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
741 if (cls != null && cls.isArray ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
743 return (1 + getArrayClassNDims (cls.getComponentType ())); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
745 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
747 return 0; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
749 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
750 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
752 private static Class getArrayElemClass (Class cls) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
753 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
754 if (cls.isArray ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
756 return getArrayElemClass (cls.getComponentType ()); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
757 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
758 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
760 return cls; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
762 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
763 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
765 private static Object getArrayElements (Object array, int[][] idx, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
766 int offset, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
767 int ndims, Class elemType) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
768 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
769 if (offset >= ndims) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
770 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
771 Object elem = Array.get (array, idx[offset][0]); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
772 if (offset < idx.length - 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
773 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
774 return getArrayElements (elem, idx, offset + 1, ndims, elemType); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
775 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
776 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
777 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
778 return elem; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
779 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
780 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
781 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
782 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
783 Class compType = elemType.getComponentType (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
784 Object retval = Array.newInstance (compType, idx[offset].length); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
785 for (int i = 0; i < idx[offset].length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
786 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
787 Object elem = Array.get (array, idx[offset][i]); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
788 if (offset < idx.length - 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
789 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
790 elem = getArrayElements (elem, idx, offset + 1, ndims, compType); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
791 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
792 Array.set (retval, i, elem); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
793 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
794 return retval; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
795 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
796 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
797 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
798 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
799 public static Object arraySubsref (Object obj, int[][] idx) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
800 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
801 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
802 if (!obj.getClass ().isArray ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
803 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
804 throw new IllegalArgumentException ("not a Java array"); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
805 } |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
806 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
807 if (idx.length == 1) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
808 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
809 if (idx[0].length == 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
810 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
811 return Array.get (obj, idx[0][0]); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
812 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
813 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
814 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
815 Object retval = Array.newInstance (obj.getClass (). |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
816 getComponentType (), |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
817 idx[0].length); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
818 for (int i = 0; i < idx[0].length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
819 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
820 Array.set (retval, i, Array.get (obj, idx[0][i])); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
821 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
822 return retval; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
823 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
824 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
825 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
827 int[] dims = new int[idx.length]; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
828 for (int i = 0; i < idx.length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
829 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
830 dims[i] = idx[i].length; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
831 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
832 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
833 if (dims.length != getArrayClassNDims (obj.getClass ())) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
834 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
835 throw new IllegalArgumentException ("index size mismatch"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
836 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
838 /* resolve leading singletons */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
839 Object theObj = obj; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
840 int offset = 0; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
841 while (dims[offset] == 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
842 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
843 theObj = Array.get (theObj, idx[offset][0]); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
844 offset = offset + 1; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
845 if (offset >= dims.length) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
846 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
847 return theObj; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
848 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
849 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
850 if (offset > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
851 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
852 int[][] new_idx = new int[idx.length - offset][]; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
853 System.arraycopy (idx, offset, new_idx, 0, idx.length - offset); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
854 return arraySubsref (theObj, new_idx); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
855 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
856 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
857 /* chop trailing singletons */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
858 int ndims = dims.length; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
859 while (ndims > 1 && dims[ndims - 1] == 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
860 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
861 ndims--; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
862 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
864 /* create result array */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
865 Class elemClass = theObj.getClass (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
866 for (int i = 0; i <= (dims.length - ndims); i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
867 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
868 elemClass = elemClass.getComponentType (); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
869 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
870 Object retval = Array.newInstance (elemClass, dims[0]); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
871 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
872 /* fill-in array */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
873 for (int i = 0; i < idx[0].length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
874 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
875 Object elem = getArrayElements (Array.get (theObj, idx[0][i]), |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
876 idx, 1, ndims, elemClass); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
877 Array.set (retval, i, elem); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
878 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
879 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
880 return retval; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
881 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
882 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
883 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
884 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
885 private static Object setArrayElements (Object array, int[][] idx, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
886 int offset, int ndims, Object rhs) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
887 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
888 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
889 if (offset >= ndims) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
890 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
891 if (offset < idx.length - 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
892 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
893 setArrayElements (Array.get (array, idx[offset][0]), idx, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
894 offset + 1, ndims, rhs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
895 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
896 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
897 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
898 Array.set (array, idx[offset][0], rhs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
899 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
900 return array; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
901 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
902 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
903 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
904 for (int i = 0; i < idx[offset].length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
905 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
906 if (offset < idx.length - 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
907 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
908 setArrayElements (Array.get (array, idx[offset][i]), idx, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
909 offset + 1, ndims, Array.get (rhs, i)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
910 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
911 else |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
912 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
913 Array.set (array, idx[offset][i], Array.get (rhs, i)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
914 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
915 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
916 return array; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
917 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
918 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
919 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
920 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
921 public static Object arraySubsasgn (Object obj, int[][] idx, Object rhs) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
922 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
923 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
924 if (!obj.getClass ().isArray ()) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
925 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
926 throw new IllegalArgumentException ("not a Java array"); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
927 } |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
928 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
929 if (idx.length == 1) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
930 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
931 if (idx[0].length == 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
932 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
933 Array.set (obj, idx[0][0], rhs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
934 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
935 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
936 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
937 for (int i = 0; i < idx[0].length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
938 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
939 Array.set (obj, idx[0][i], Array.get (rhs, i)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
940 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
941 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
942 return obj; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
943 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
944 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
945 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
946 int[] dims = new int[idx.length]; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
947 for (int i = 0; i < idx.length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
948 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
949 dims[i] = idx[i].length; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
950 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
951 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
952 if (dims.length != getArrayClassNDims (obj.getClass ())) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
953 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
954 throw new IllegalArgumentException ("index size mismatch"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
955 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
956 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
957 /* resolve leading singletons */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
958 Object theObj = obj; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
959 int offset = 0; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
960 while (dims[offset] == 1 && offset < (dims.length - 1)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
961 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
962 theObj = Array.get (theObj, idx[offset][0]); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
963 offset = offset + 1; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
964 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
965 if (offset > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
966 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
967 int[][] new_idx = new int[idx.length - offset][]; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
968 System.arraycopy (idx, offset, new_idx, 0, idx.length - offset); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
969 arraySubsasgn (theObj, new_idx, rhs); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
970 return obj; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
971 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
972 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
973 /* chop trailing singletons */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
974 int ndims = dims.length; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
975 while (ndims > 1 && dims[ndims - 1] == 1) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
976 { |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
977 ndims--; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
978 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
979 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
980 for (int i = 0; i < idx[0].length; i++) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
981 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
982 setArrayElements (Array.get (theObj, idx[0][i]), idx, 1, ndims, |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
983 Array.get (rhs, i)); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
984 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
985 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
986 return obj; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
987 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
988 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
989 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
990 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
991 public static Object createArray (Object cls, int[] dims) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
992 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
993 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
994 Class theClass; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
995 if (cls instanceof Class) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
996 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
997 theClass = (Class) cls; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
998 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
999 else if (cls instanceof String) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1000 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1001 theClass = Class.forName ((String) cls, true, loader); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1003 else |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1004 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1005 throw new IllegalArgumentException ("invalid class specification " + |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1006 cls); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1007 } |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1008 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1009 return Array.newInstance (theClass, dims); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1010 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1011 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1012 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1013 public static Object createArray (Object cls, int length) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1014 throws Exception |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1015 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1016 return createArray (cls, new int[] {length}); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15625
diff
changeset
|
1017 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 } |