Commit 8eeedab0 authored by Ryan Berkheimer's avatar Ryan Berkheimer
Browse files

updated Boolean types and associated conversions in IField to boolean (part of...

updated Boolean types and associated conversions in IField to boolean (part of the overall Boolean to bool conversion in the C/C++ API)
parent f918042c
......@@ -41,12 +41,16 @@ const char *FieldUtils::getType(struct field *field)
bool FieldUtils::isValid(struct field *field)
{
return (bool)this->jvm->CallBooleanMethod(field->jfield, this->isValidMethodId);
jboolean jBoolVal = this->jvm->CallBooleanMethod(field->jfield, this->isValidMethodId);
bool boolVal = (bool)(jBoolVal != JNI_FALSE);
return boolVal;
}
bool FieldUtils::isRequired(struct field *field)
{
return (bool)this->jvm->CallBooleanMethod(field->jfield, this->isRequiredMethodId);
jboolean jBoolVal = this->jvm->CallBooleanMethod(field->jfield, this->isRequiredMethodId);
bool boolVal = (bool)(jBoolVal != JNI_FALSE);
return boolVal;
}
bool FieldUtils::isNull(struct field *field)
......@@ -190,7 +194,6 @@ void FieldUtils::setStringVal(struct field *field, const char *value)
{
jstring jStringVal = this->typeUtils->toJavaString(value);
this->jvm->CallVoidMethod(field->jfield, this->setValueMethodId, jStringVal);
//this->jvm->DeleteLocalRef(jStringVal);
}
void FieldUtils::setBoolVal(struct field *field, bool value)
......@@ -254,11 +257,11 @@ const char *FieldUtils::getMethodSignature(const char *methodName)
}
else if (strcmp(methodName, "isValid") == 0)
{
return "()Ljava/lang/Boolean;";
return "()Z";
}
else if (strcmp(methodName, "isRequired") == 0)
{
return "()Ljava/lang/Boolean;";
return "()Z";
}
else if (strcmp(methodName, "setValue") == 0)
{
......
......@@ -33,6 +33,11 @@ ResponseUtils::~ResponseUtils()
/* Public API */
/**
* As request/response pairs are asynchronous by nature, this method provides callers with the status of the response.
* It will only be 'true' when the response has completed all requested processing (whether successful or not).
* Until then, this method will return 'false'.
**/
bool ResponseUtils::isComplete(struct response *response)
{
jboolean jBoolVal = this->jvm->CallBooleanMethod(response->jresponse, this->isCompleteMethodId);
......@@ -40,6 +45,11 @@ bool ResponseUtils::isComplete(struct response *response)
return boolVal;
}
/**
* This method will return the request struct associated with the given response. As a single request can be submitted
* multiple times to produce different responses, this method will return the idempotent request that was used to produce a
* given response.
**/
struct request *ResponseUtils::getRequest(struct response *response)
{
jobject jrequest = this->jvm->CallObjectMethod(response->jresponse, this->getRequestMethodId);
......
......@@ -68,11 +68,11 @@ public class DefaultField implements IField {
return this.type;
}
public Boolean isRequired() {
public boolean isRequired() {
return this.required;
}
public Boolean isValid() {
public boolean isValid() {
return this.valid;
}
......
......@@ -34,14 +34,14 @@ public interface IField {
* Used contextually to determine whether
* or not this field is required for subsequent processing.
*/
public Boolean isRequired();
public boolean isRequired();
/**
* Used contextually to determine whether or not
* this field is valid. This could be used in type validation
* or some other way.
*/
public Boolean isValid();
public boolean isValid();
/**
* Returns the value of the field.
......
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