shared
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends
Static Public Member Functions | List of all members
Common Class Reference

A static utility class for common operations. More...

#include <Common.hpp>

Static Public Member Functions

template<class T >
static T sum (T *values, jint len, T zero)
 Takes the sum of an array of values. More...
 
template<class T >
static T product (T *values, jint len, T one)
 Takes the product of an array of values. More...
 
static void throwNew (JNIEnv *env, std::exception &exception)
 Throws a new Java RuntimeException. More...
 
static jclass findClass (JNIEnv *env, const char *name)
 Finds and loads a class. More...
 
static jfieldID getFieldId (JNIEnv *env, jclass clazz, const char *name, const char *type)
 Gets a field identifier. More...
 
static jfieldID getStaticFieldId (JNIEnv *env, jclass clazz, const char *name, const char *type)
 Gets a static field identifier. More...
 
static jmethodID getMethodId (JNIEnv *env, jclass clazz, const char *name, const char *type)
 Gets a method identifier. More...
 
static jmethodID getStaticMethodId (JNIEnv *env, jclass clazz, const char *name, const char *type)
 Gets a static method identifier. More...
 
static jweak newWeakGlobalRef (JNIEnv *env, jobject object)
 Creates a global weak reference to the given object. More...
 
static void deleteWeakGlobalRef (JNIEnv *env, jweak weak)
 Deletes a global weak reference. More...
 
static jdoubleArray newDoubleArray (JNIEnv *env, jint len)
 Creates a Java array of type double[]. More...
 
static jintArray newIntArray (JNIEnv *env, jint len)
 Creates a Java array of type int[]. More...
 
static jbyteArray newByteArray (JNIEnv *env, jint len)
 Creates a Java array of type byte[]. More...
 
static jobjectArray newObjectArray (JNIEnv *env, jint len, jclass clazz)
 Creates a Java array of the given component type. More...
 
static jstring newStringUtf (JNIEnv *env, const char *utf)
 Creates a Java string. More...
 

Detailed Description

A static utility class for common operations.

Member Function Documentation

void Common::deleteWeakGlobalRef ( JNIEnv *  env,
jweak  weak 
)
static

Deletes a global weak reference.

Parameters
envthe JNI environment.
weakthe weak reference.
jclass Common::findClass ( JNIEnv *  env,
const char *  name 
)
static

Finds and loads a class.

Parameters
envthe JNI environment.
namethe class name.
Returns
the class.
jfieldID Common::getFieldId ( JNIEnv *  env,
jclass  clazz,
const char *  name,
const char *  type 
)
static

Gets a field identifier.

Parameters
envthe JNI environment.
clazzthe class.
namethe class name.
typethe type.
Returns
the field identifier.
jmethodID Common::getMethodId ( JNIEnv *  env,
jclass  clazz,
const char *  name,
const char *  type 
)
static

Gets a method identifier.

Parameters
envthe JNI environment.
clazzthe class.
namethe class name.
typethe type.
Returns
the method identifier.
jfieldID Common::getStaticFieldId ( JNIEnv *  env,
jclass  clazz,
const char *  name,
const char *  type 
)
static

Gets a static field identifier.

Parameters
envthe JNI environment.
clazzthe class.
namethe class name.
typethe type.
Returns
the static field identifier.
jmethodID Common::getStaticMethodId ( JNIEnv *  env,
jclass  clazz,
const char *  name,
const char *  type 
)
static

Gets a static method identifier.

Parameters
envthe JNI environment.
clazzthe class.
namethe class name.
typethe type.
Returns
the static method identifier.
jbyteArray Common::newByteArray ( JNIEnv *  env,
jint  len 
)
static

Creates a Java array of type byte[].

Parameters
envthe JNI environment.
lenthe length.
Returns
the newly allocated byte array.
jdoubleArray Common::newDoubleArray ( JNIEnv *  env,
jint  len 
)
static

Creates a Java array of type double[].

Parameters
envthe JNI environment.
lenthe length.
Returns
the newly allocated double array.
jintArray Common::newIntArray ( JNIEnv *  env,
jint  len 
)
static

Creates a Java array of type int[].

Parameters
envthe JNI environment.
lenthe length.
Returns
the newly allocated int array.
jobjectArray Common::newObjectArray ( JNIEnv *  env,
jint  len,
jclass  clazz 
)
static

Creates a Java array of the given component type.

Parameters
envthe JNI environment.
lenthe length.
clazzthe component type.
Returns
the newly allocated Object array.
jstring Common::newStringUtf ( JNIEnv *  env,
const char *  utf 
)
static

Creates a Java string.

Parameters
envthe JNI environment.
utfthe null-terminated string.
Returns
the Java string.
jweak Common::newWeakGlobalRef ( JNIEnv *  env,
jobject  object 
)
static

Creates a global weak reference to the given object.

Parameters
envthe JNI environment.
objectthe referent.
Returns
the global weak reference.
template<class T >
static T Common::product ( T *  values,
jint  len,
one 
)
inlinestatic

Takes the product of an array of values.

Parameters
valuesthe values.
lenthe length.
onethe representation of 1.
Returns
the product.
template<class T >
static T Common::sum ( T *  values,
jint  len,
zero 
)
inlinestatic

Takes the sum of an array of values.

Parameters
valuesthe values.
lenthe length.
zerothe representation of 0.
Returns
the sum.
void Common::throwNew ( JNIEnv *  env,
std::exception &  exception 
)
static

Throws a new Java RuntimeException.

Parameters
envthe JNI environment.
exceptionthe exception.