#include <JNIObject.h>
Public Member Functions | |
JNIObject (JNIEnv *env, jobject obj) | |
Constructs new JNIObject object. | |
virtual | ~JNIObject () |
Destructs JNIObject object. | |
JNIEnv * | env () const |
Returns JNIEnv pointer. | |
jweak | ref () const |
Returns weak reference to the Java object. | |
bool | isSameThread (JNIEnv *env) const |
Returns true if the specified JNIEnv pointer is same as m_env. | |
bool | isLive () |
Returns true if the JNI object is alive (not collected). | |
void | checkException () |
Checks for JNI exceptions. | |
bool | testException () |
Test if an exception has occurred. | |
void | fatalError (const char *errorMessage) |
Prints the error message and terminates virtual machine. | |
void | throwInternalError (const char *errorMessage=0) |
Throws java's internal error. | |
void | throwOutOfMemoryError (const char *errorMessage=0) |
Throws java's out of memory error. | |
void | throwRuntimeExcpetion (const char *exceptionMessage=0) |
Throws java's runtime exception. | |
jfieldID | getFieldID (const char *name, const char *sig) |
Returns the fieldID. | |
jmethodID | getMethodID (const char *name, const char *sig) |
Returns the jmethodID. | |
jobject | getObjectField (jfieldID fieldID) |
Returns the value of the object field. | |
void | setObjectField (jfieldID fieldID, jobject val) |
Sets the value of the object field. | |
jboolean | getBooleanField (jfieldID fieldID) |
Returns the value of the boolean field. | |
void | setBooleanField (jfieldID fieldID, jboolean val) |
Sets the value of the boolean field. | |
jbyte | getByteField (jfieldID fieldID) |
Returns the value of the byte field. | |
void | setByteField (jfieldID fieldID, jbyte val) |
Sets the value of the byte field. | |
jchar | getCharField (jfieldID fieldID) |
Returns the value of the char field. | |
void | setCharField (jfieldID fieldID, jchar val) |
Sets the value of the char field. | |
jshort | getShortField (jfieldID fieldID) |
Returns the value of the short field. | |
void | setShortField (jfieldID fieldID, jshort val) |
Sets the value of the short field. | |
jint | getIntField (jfieldID fieldID) |
Returns the value of the int field. | |
void | setIntField (jfieldID fieldID, jint val) |
Sets the value of the int field. | |
jlong | getLongField (jfieldID fieldID) |
Returns the value of the long field. | |
void | setLongField (jfieldID fieldID, jlong val) |
Sets the value of the long field. | |
jfloat | getFloatField (jfieldID fieldID) |
Returns the value of the float field. | |
void | setFloatField (jfieldID fieldID, jfloat val) |
Sets the value of the float field. | |
jdouble | getDoubleField (jfieldID fieldID) |
Returns the value of the double field. | |
void | setDoubleField (jfieldID fieldID, jdouble val) |
Sets the value of the double field. | |
jclass | getObjectClass () |
Returns JNI object class. | |
bool | callObjectMethod (jobject &result, jmethodID methodID,...) |
Calls JNI object method. | |
bool | callBooleanMethod (jboolean &result, jmethodID methodID,...) |
Calls JNI boolean method. | |
bool | callByteMethod (jbyte &result, jmethodID methodID,...) |
Calls JNI byte method. | |
bool | callCharMethod (jchar &result, jmethodID methodID,...) |
Calls JNI char method. | |
bool | callShortMethod (jshort &result, jmethodID methodID,...) |
Calls JNI short method. | |
bool | callIntMethod (jint &result, jmethodID methodID,...) |
Calls JNI int method. | |
bool | callLongMethod (jlong &result, jmethodID methodID,...) |
Calls JNI long method. | |
bool | callFloatMethod (jfloat &result, jmethodID methodID,...) |
Calls JNI float method. | |
bool | callDoubleMethod (jdouble &result, jmethodID methodID,...) |
Calls JNI doble method. | |
bool | callVoidMethod (jmethodID methodID,...) |
Calls JNI void method. | |
jstring | toJString () |
Returns jstring representation of the specified object. | |
jstring | newJString (const jchar *uchars, jsize len) |
Creates new java string. | |
jstring | newJStringUTF (const char *bytes) |
Creates new java string. |
JNIObject::JNIObject | ( | JNIEnv * | env, | |
jobject | obj | |||
) |
JNIEnv * JNIObject::env | ( | ) | const [inline] |
Returns JNIEnv pointer.
jweak JNIObject::ref | ( | ) | const [inline] |
Returns weak reference to the Java object.
bool JNIObject::isSameThread | ( | JNIEnv * | env | ) | const [inline] |
Returns true
if the specified JNIEnv pointer is same as m_env.
true
if JNIEnv pointer env is same as m_env bool JNIObject::isLive | ( | ) |
Returns true
if the JNI object is alive (not collected).
true
if if the JNI object is alive bool JNIObject::testException | ( | ) |
Test if an exception has occurred.
true
if the exception has occurred void JNIObject::fatalError | ( | const char * | errorMessage | ) |
Prints the error message and terminates virtual machine.
NOTE: This method does not return.
errorMessage | the error message |
void JNIObject::throwInternalError | ( | const char * | errorMessage = 0 |
) |
Throws java's internal error.
errorMessage | the error message |
void JNIObject::throwOutOfMemoryError | ( | const char * | errorMessage = 0 |
) |
Throws java's out of memory error.
errorMessage | the error message |
void JNIObject::throwRuntimeExcpetion | ( | const char * | exceptionMessage = 0 |
) |
Throws java's runtime exception.
exceptionMessage | the exception message |
jfieldID JNIObject::getFieldID | ( | const char * | name, | |
const char * | sig | |||
) |
Returns the fieldID.
name | the field name | |
sig | the field signature |
jmethodID JNIObject::getMethodID | ( | const char * | name, | |
const char * | sig | |||
) |
Returns the jmethodID.
name | the method name | |
sig | the method signature |
jobject JNIObject::getObjectField | ( | jfieldID | fieldID | ) |
Returns the value of the object field.
fieldID | the field ID |
void JNIObject::setObjectField | ( | jfieldID | fieldID, | |
jobject | val | |||
) |
Sets the value of the object field.
fieldID | the field ID | |
val | the new value |
jboolean JNIObject::getBooleanField | ( | jfieldID | fieldID | ) |
Returns the value of the boolean field.
fieldID | the field ID |
void JNIObject::setBooleanField | ( | jfieldID | fieldID, | |
jboolean | val | |||
) |
Sets the value of the boolean field.
fieldID | the field ID | |
val | the new value |
jbyte JNIObject::getByteField | ( | jfieldID | fieldID | ) |
Returns the value of the byte field.
fieldID | the field ID |
void JNIObject::setByteField | ( | jfieldID | fieldID, | |
jbyte | val | |||
) |
Sets the value of the byte field.
fieldID | the field ID | |
val | the new value |
jchar JNIObject::getCharField | ( | jfieldID | fieldID | ) |
Returns the value of the char field.
fieldID | the field ID |
void JNIObject::setCharField | ( | jfieldID | fieldID, | |
jchar | val | |||
) |
Sets the value of the char field.
fieldID | the field ID | |
val | the new value |
jshort JNIObject::getShortField | ( | jfieldID | fieldID | ) |
Returns the value of the short field.
fieldID | the field ID |
void JNIObject::setShortField | ( | jfieldID | fieldID, | |
jshort | val | |||
) |
Sets the value of the short field.
fieldID | the field ID | |
val | the new value |
jint JNIObject::getIntField | ( | jfieldID | fieldID | ) |
Returns the value of the int field.
fieldID | the field ID |
void JNIObject::setIntField | ( | jfieldID | fieldID, | |
jint | val | |||
) |
Sets the value of the int field.
fieldID | the field ID | |
val | the new value |
jlong JNIObject::getLongField | ( | jfieldID | fieldID | ) |
Returns the value of the long field.
fieldID | the field ID |
void JNIObject::setLongField | ( | jfieldID | fieldID, | |
jlong | val | |||
) |
Sets the value of the long field.
fieldID | the field ID | |
val | the new value |
jfloat JNIObject::getFloatField | ( | jfieldID | fieldID | ) |
Returns the value of the float field.
fieldID | the field ID |
void JNIObject::setFloatField | ( | jfieldID | fieldID, | |
jfloat | val | |||
) |
Sets the value of the float field.
fieldID | the field ID | |
val | the new value |
jdouble JNIObject::getDoubleField | ( | jfieldID | fieldID | ) |
Returns the value of the double field.
fieldID | the field ID |
void JNIObject::setDoubleField | ( | jfieldID | fieldID, | |
jdouble | val | |||
) |
Sets the value of the double field.
fieldID | the field ID | |
val | the new value |
jclass JNIObject::getObjectClass | ( | ) |
Returns JNI object class.
bool JNIObject::callObjectMethod | ( | jobject & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI object method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callBooleanMethod | ( | jboolean & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI boolean method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callByteMethod | ( | jbyte & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI byte method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callCharMethod | ( | jchar & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI char method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callShortMethod | ( | jshort & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI short method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callIntMethod | ( | jint & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI int method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callLongMethod | ( | jlong & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI long method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callFloatMethod | ( | jfloat & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI float method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callDoubleMethod | ( | jdouble & | result, | |
jmethodID | methodID, | |||
... | ||||
) |
Calls JNI doble method.
result | the result | |
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown bool JNIObject::callVoidMethod | ( | jmethodID | methodID, | |
... | ||||
) |
Calls JNI void method.
methodID | the method ID | |
... | the method arguments |
true
if no exception is thrown jstring JNIObject::toJString | ( | ) |
Returns jstring representation of the specified object.
jstring JNIObject::newJString | ( | const jchar * | uchars, | |
jsize | len | |||
) |
Creates new java string.
uchars | the unicode char array | |
len | the length of the char array |
jstring JNIObject::newJStringUTF | ( | const char * | bytes | ) |
Creates new java string.
bytes | the UTF-8 char array |