23 #if !defined (octave_ov_java_h)
24 #define octave_ov_java_h 1
53 operator T () {
return jobj; }
93 box (JNIEnv* jni_env, jobject jobj, jclass jcls = 0);
96 box_more (JNIEnv* jni_env, jobject jobj, jclass jcls = 0);
134 jobject
to_java (
void)
const {
return java_object; }
135 jclass
to_class (
void)
const {
return java_class; }
148 bool is_map (
void)
const {
return false; }
156 void print (std::ostream& os,
bool pr_as_read_syntax =
false);
158 void print_raw (std::ostream& os,
bool pr_as_read_syntax =
false)
const;
162 const std::list<octave_value_list>& idx,
int nargout);
165 subsref (
const std::string&
type,
const std::list<octave_value_list>& idx)
172 const std::list<octave_value_list>& idx,
177 bool is_java_string (
void)
const;
179 static JNIEnv* thread_jni_env (
void);
181 octave_value do_javaMethod (JNIEnv* jni_env,
const std::string& name,
187 return do_javaMethod(thread_jni_env (), name, args);
191 do_javaMethod (JNIEnv* jni_env,
const std::string& class_name,
198 return do_javaMethod(thread_jni_env (), class_name, name, args);
202 do_javaObject (JNIEnv* jni_env,
const std::string& name,
208 return do_javaObject (thread_jni_env (), name, args);
211 octave_value do_java_get (JNIEnv* jni_env,
const std::string& name);
215 return do_java_get (thread_jni_env (), name);
219 do_java_get (JNIEnv* jni_env,
const std::string& class_name,
220 const std::string& name);
223 do_java_get (
const std::string& class_name,
const std::string& name)
225 return do_java_get (thread_jni_env (), class_name, name);
228 octave_value do_java_set (JNIEnv* jni_env,
const std::string& name,
233 return do_java_set (thread_jni_env (), name, val);
237 do_java_set (JNIEnv* jni_env,
const std::string& class_name,
241 do_java_set (
const std::string& class_name,
const std::string& name,
244 return do_java_set (thread_jni_env (), class_name, name, val);
249 void init (jobject jobj, jclass jcls)
251 JNIEnv *current_env = thread_jni_env ();
256 java_object = current_env->NewGlobalRef (jobj);
259 java_class =
reinterpret_cast<jclass
> (current_env->NewGlobalRef (jcls));
260 else if (java_object)
262 jclass_ref ocls (current_env, current_env->GetObjectClass (java_object));
263 java_class =
reinterpret_cast<jclass
> (current_env->NewGlobalRef (jclass (ocls)));
268 jclass_ref clsCls (current_env, current_env->GetObjectClass (java_class));
269 jmethodID mID = current_env->GetMethodID (clsCls,
"getCanonicalName",
"()Ljava/lang/String;");
270 jobject_ref resObj (current_env, current_env->CallObjectMethod (java_class, mID));
278 JNIEnv *current_env = thread_jni_env ();
283 current_env->DeleteGlobalRef (java_object);
286 current_env->DeleteGlobalRef (java_class);
305 std::string
class_name (
void)
const {
return java_classname; }
java_local_ref< jobject > jobject_ref
virtual dim_vector dims(void) const
java_local_ref(JNIEnv *_env, T obj)
static octave_value do_java_set(const std::string &class_name, const std::string &name, const octave_value &val)
bool is_defined(void) const
java_local_ref< jthrowable > jthrowable_ref
static std::string static_class_name(void)
static octave_value do_java_get(const std::string &class_name, const std::string &name)
octave_java(const jobject &obj, jclass cls=0)
OCTINTERP_API octave_value box(JNIEnv *jni_env, jobject jobj, jclass jcls=0)
octave_idx_type length(void) const
static std::string static_type_name(void)
OCTINTERP_API bool Vjava_unsigned_autoconversion
static int static_type_id(void)
java_local_ref< jintArray > jintArray_ref
octave_value do_java_set(const std::string &name, const octave_value &val)
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
virtual string_vector map_keys(void) const
virtual octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
OCTINTERP_API std::string jstring_to_string(JNIEnv *jni_env, jstring s)
virtual void print(std::ostream &os, bool pr_as_read_syntax=false)
java_local_ref< jobjectArray > jobjectArray_ref
java_local_ref< jdoubleArray > jdoubleArray_ref
octave_base_value * empty_clone(void) const
jobject to_java(void) const
bool is_constant(void) const
octave_java(const octave_java &jobj)
octave_value do_java_get(const std::string &name)
static const std::string t_name
virtual bool is_instance_of(const std::string &) const
octave_base_value * clone(void) const
static void register_type(void)
static octave_value do_javaMethod(const std::string &class_name, const std::string &name, const octave_value_list &args)
java_local_ref(JNIEnv *_env)
static octave_value do_javaObject(const std::string &name, const octave_value_list &args)
java_local_ref< jclass > jclass_ref
std::string type_name(void) const
friend class octave_value
OCTINTERP_API bool Vdebug_java
OCTINTERP_API bool unbox(JNIEnv *jni_env, const octave_value &val, jobject_ref &jobj, jclass_ref &jcls)
octave_value do_javaMethod(const std::string &name, const octave_value_list &args)
static const std::string t_name
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
std::string class_name(void) const
std::string java_class_name(void) const
java_local_ref< jstring > jstring_ref
std::string java_classname
virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const
OCTINTERP_API bool Vjava_matrix_autoconversion
virtual void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
java_local_ref< jbyteArray > jbyteArray_ref
jclass to_class(void) const
OCTINTERP_API octave_value box_more(JNIEnv *jni_env, jobject jobj, jclass jcls=0)
void init(jobject jobj, jclass jcls)