GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-java.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2007-2017 Michael Goffioul
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_ov_java_h)
24 #define octave_ov_java_h 1
25 
26 #include "octave-config.h"
27 
28 #include <ovl.h>
29 #include <ov.h>
30 
31 typedef void *voidptr;
32 
34 {
35 public:
36 
37  octave_java (void);
38 
39  octave_java (const voidptr& obj, void *cls = 0);
40 
41  octave_java (const octave_java& jobj)
42  : octave_base_value (jobj), java_object (0), java_class (0)
43  {
44  init (jobj.java_object, jobj.java_class);
45  }
46 
47  ~octave_java (void) { release (); }
48 
49  void *to_java (void) const { return java_object; }
50  void *to_class (void) const { return java_class; }
51 
52  std::string java_class_name (void) const { return java_classname; }
53 
54  octave_base_value* clone (void) const { return new octave_java (*this); }
55  octave_base_value* empty_clone (void) const { return new octave_java (); }
56 
57  bool is_instance_of (const std::string&) const;
58 
59  bool is_defined (void) const { return true; }
60 
61  bool is_constant (void) const { return true; }
62 
63  bool is_map (void) const { return false; }
64 
65  bool is_java (void) const { return true; }
66 
67  string_vector map_keys (void) const;
68 
69  dim_vector dims (void) const;
70 
71  void print (std::ostream& os, bool pr_as_read_syntax = false);
72 
73  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
74 
75  bool save_ascii (std::ostream& os);
76 
77  bool load_ascii (std::istream& is);
78 
79  bool save_binary (std::ostream& os, bool& save_as_floats);
80 
81  bool load_binary (std::istream& is, bool swap,
83 
84  bool save_hdf5 (octave_hdf5_id loc_id, const char *name,
85  bool save_as_floats);
86 
87  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
88 
90  subsref (const std::string& type,
91  const std::list<octave_value_list>& idx, int nargout);
92 
94  subsref (const std::string& type, const std::list<octave_value_list>& idx)
95  {
96  octave_value_list retval = subsref (type, idx, 1);
97  return (retval.length () > 0 ? retval(0) : octave_value ());
98  }
99 
101  const std::list<octave_value_list>& idx,
102  const octave_value& rhs);
103 
104  octave_value convert_to_str_internal (bool pad, bool force, char type) const;
105 
106  bool is_java_string (void) const;
107 
108  octave_value do_javaMethod (void *jni_env, const std::string& name,
109  const octave_value_list& args);
110 
112  do_javaMethod (const std::string& name, const octave_value_list& args);
113 
114  static octave_value
115  do_javaMethod (void *jni_env, const std::string& class_name,
116  const std::string& name, const octave_value_list& args);
117 
118  static octave_value
119  do_javaMethod (const std::string& class_name, const std::string& name,
120  const octave_value_list& args);
121 
122  static octave_value
123  do_javaObject (void *jni_env, const std::string& name,
124  const octave_value_list& args);
125 
126  static octave_value
127  do_javaObject (const std::string& name, const octave_value_list& args);
128 
129  octave_value do_java_get (void *jni_env, const std::string& name);
130 
131  octave_value do_java_get (const std::string& name);
132 
133  static octave_value
134  do_java_get (void *jni_env, const std::string& class_name,
135  const std::string& name);
136 
137  static octave_value
138  do_java_get (const std::string& class_name, const std::string& name);
139 
140  octave_value do_java_set (void *jni_env, const std::string& name,
141  const octave_value& val);
142 
143  octave_value do_java_set (const std::string& name, const octave_value& val);
144 
145  static octave_value
146  do_java_set (void *jni_env, const std::string& class_name,
147  const std::string& name, const octave_value& val);
148 
149  static octave_value
150  do_java_set (const std::string& class_name, const std::string& name,
151  const octave_value& val);
152 
153 private:
154 
155  void init (void *jobj, void *jcls);
156 
157  void release (void);
158 
159 private:
160 
161  void *java_object;
162 
163  void *java_class;
164 
166 
167 public:
168 
169  int type_id (void) const { return t_id; }
170  std::string type_name (void) const { return t_name; }
171  std::string class_name (void) const { return java_classname; }
172 
173  static int static_type_id (void) { return t_id; }
174  static std::string static_type_name (void) { return t_name; }
175  static std::string static_class_name (void) { return "<unknown>"; }
176  static void register_type (void);
177 
178 private:
179 
180  static int t_id;
181  static const std::string t_name;
182 };
183 
185 
187 
188 extern OCTINTERP_API bool Vdebug_java;
189 
190 #endif
virtual dim_vector dims(void) const
Definition: ov-base.h:310
bool is_defined(void) const
Definition: ov-java.h:59
static std::string static_class_name(void)
Definition: ov-java.h:175
virtual bool save_binary(std::ostream &os, bool &save_as_floats)
Definition: ov-base.cc:996
~octave_java(void)
Definition: ov-java.h:47
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
octave_idx_type length(void) const
Definition: ovl.h:96
static std::string static_type_name(void)
Definition: ov-java.h:174
OCTINTERP_API bool Vjava_unsigned_autoconversion
Definition: ov-java.cc:182
static int static_type_id(void)
Definition: ov-java.h:173
bool is_map(void) const
Definition: ov-java.h:63
virtual bool save_ascii(std::ostream &os)
Definition: ov-base.cc:984
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-base.cc:217
virtual string_vector map_keys(void) const
Definition: ov-base.cc:887
virtual octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-base.cc:281
virtual void print(std::ostream &os, bool pr_as_read_syntax=false)
Definition: ov-base.cc:444
bool swap
Definition: load-save.cc:725
JNIEnv void * args
Definition: ov-java.cc:67
octave_base_value * empty_clone(void) const
Definition: ov-java.h:55
bool is_constant(void) const
Definition: ov-java.h:61
octave_java(const octave_java &jobj)
Definition: ov-java.h:41
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
#define OCTINTERP_API
Definition: mexproto.h:69
void * java_object
Definition: ov-java.h:161
bool is_java(void) const
Definition: ov-java.h:65
bool save_as_floats
Definition: load-save.cc:1581
static int t_id
Definition: ov-base.h:857
static const std::string t_name
Definition: ov-base.h:857
int type_id(void) const
Definition: ov-java.h:169
octave_value retval
Definition: data.cc:6294
int64_t octave_hdf5_id
virtual bool is_instance_of(const std::string &) const
Definition: ov-base.h:608
octave_base_value * clone(void) const
Definition: ov-java.h:54
idx type
Definition: ov.cc:3129
static void register_type(void)
Definition: ov-base.cc:115
virtual bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-base.cc:1009
virtual bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-base.cc:1015
std::string type_name(void) const
Definition: ov-java.h:170
friend class octave_value
Definition: ov-base.h:211
OCTINTERP_API bool Vdebug_java
Definition: ov-java.cc:183
static const std::string t_name
Definition: ov-java.h:181
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-java.h:94
std::string class_name(void) const
Definition: ov-java.h:171
void * voidptr
Definition: ov-java.h:31
virtual bool load_ascii(std::istream &is)
Definition: ov-base.cc:990
std::string java_class_name(void) const
Definition: ov-java.h:52
std::string java_classname
Definition: ov-java.h:165
virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const
Definition: ov-base.cc:430
OCTINTERP_API bool Vjava_matrix_autoconversion
Definition: ov-java.cc:181
static int t_id
Definition: ov-java.h:180
void * java_class
Definition: ov-java.h:163
virtual void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-base.cc:450
virtual bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-base.cc:1002
write the output to stdout if nargout is
Definition: load-save.cc:1576
void release(void)
Definition: ov-base.h:807
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
void * to_class(void) const
Definition: ov-java.h:50
void * to_java(void) const
Definition: ov-java.h:49