Commit 46072df2 authored by Ryan Berkheimer's avatar Ryan Berkheimer

completed basic methods for transformation class

parent 701c8a38
Pipeline #5772 failed with stages
in 0 seconds
......@@ -11,9 +11,9 @@
*/
/* Default Constructor */
TransformationUtils::TransformationUtils(JNIEnv *jvm, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils)
TransformationUtils::TransformationUtils(JNIEnv *jvm, jobject transformation, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils)
{
this->loadGlobalRefs(jvm, typeUtils, mapUtils, listUtils);
this->loadGlobalRefs(jvm, transformation, typeUtils, mapUtils, listUtils);
this->loadMethodIds();
}
......@@ -30,12 +30,20 @@ TransformationUtils::~TransformationUtils()
/* Public API */
struct val_map *TransformationUtils::getConstructor() {
jobject jMap = this->jvm->CallObjectMethod(this->transformation, this->getConstructorMethodId);
struct val_map *map = (struct val_map *)malloc(sizeof(struct val_map));
map->jmap = jMap;
return map;
}
/* Private Methods */
void TransformationUtils::loadGlobalRefs(JNIEnv *jvm, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils)
void TransformationUtils::loadGlobalRefs(JNIEnv *jvm, jobject transformation, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils)
{
this->jvm = jvm;
this->transformation = transformation;
this->typeUtils = typeUtils;
this->mapUtils = mapUtils;
this->listUtils = listUtils;
......@@ -45,16 +53,16 @@ void TransformationUtils::loadMethodIds()
{
jclass transformationClass = JniUtils::getNamedClass(this->jvm, "gov/noaa/messageapi/interfaces/ITransformation");
/*this->createRequestMethodId = JniUtils::getMethod(this->jvm, sessionClass, "createRequest", this->getMethodSignature("createRequest"), false);*/
this->getConstructorMethodId = JniUtils::getMethod(this->jvm, transformationClass, "getConstructor", this->getMethodSignature("getConstructor"), false);
jvm->DeleteLocalRef(transformationClass);
}
const char *TransformationUtils::getMethodSignature(const char *methodName)
{
/*if (strcmp(methodName, "createRequest") == 0)
if (strcmp(methodName, "getConstructor") == 0)
{
return "()Lgov/noaa/messageapi/interfaces/IRequest;";
}*/
return "()Ljava/util/Map;";
}
return NULL;
}
\ No newline at end of file
......@@ -23,21 +23,27 @@ class TransformationUtils
public:
/*Default constructor */
TransformationUtils(JNIEnv *jvm, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils);
TransformationUtils(JNIEnv *jvm, jobject transformation, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils);
/*Default Destructor */
~TransformationUtils();
/* Transformation API */
struct val_map *getConstructor();
private:
/*Vars*/
JNIEnv *jvm;
jobject transformation;
TypeUtils *typeUtils;
MapUtils *mapUtils;
ListUtils *listUtils;
jmethodID getConstructorMethodId;
/*Load method IDS for reuse. MethodIDS do not count against the jref count and do need to be released.*/
void loadMethodIds();
void loadGlobalRefs(JNIEnv *env, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils);
void loadGlobalRefs(JNIEnv *env, jobject transformation, TypeUtils *typeUtils, MapUtils *mapUtils, ListUtils *listUtils);
/*Grouped methods for returning the matching method signature string for a given interface*/
const char *getMethodSignature(const char *methodName);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment