MCPcopy Create free account
hub / github.com/MariaDB/server / MakeObject

Method MakeObject

storage/connect/jmgoconn.cpp:597–647  ·  view source on GitHub ↗

/ MakeObject. */ /

Source from the content-addressed store, hash-verified

595/* MakeObject. */
596/***********************************************************************/
597jobject JMgoConn::MakeObject(PGLOBAL g, PCOL colp, bool&error )
598{
599 jclass cls;
600 jmethodID cns = nullptr; // Constructor
601 jobject val = nullptr;
602 PVAL valp = colp->GetValue();
603
604 error = false;
605
606 if (valp->IsNull())
607 return NULL;
608
609 try {
610 switch (valp->GetType()) {
611 case TYPE_STRING:
612 val = env->NewStringUTF(valp->GetCharValue());
613 break;
614 case TYPE_INT:
615 case TYPE_SHORT:
616 cls = env->FindClass("java/lang/Integer");
617 cns = env->GetMethodID(cls, "<init>", "(I)V");
618 val = env->NewObject(cls, cns, valp->GetIntValue());
619 break;
620 case TYPE_TINY:
621 cls = env->FindClass("java/lang/Boolean");
622 cns = env->GetMethodID(cls, "<init>", "(Z)V");
623 val = env->NewObject(cls, cns, (valp->GetIntValue() != 0));
624 break;
625 case TYPE_BIGINT:
626 cls = env->FindClass("java/lang/Long");
627 cns = env->GetMethodID(cls, "<init>", "(J)V");
628 val = env->NewObject(cls, cns, valp->GetBigintValue());
629 break;
630 case TYPE_DOUBLE:
631 cls = env->FindClass("java/lang/Double");
632 cns = env->GetMethodID(cls, "<init>", "(D)V");
633 val = env->NewObject(cls, cns, valp->GetFloatValue());
634 break;
635 default:
636 snprintf(g->Message, sizeof(g->Message), "Cannot make object from %d type", valp->GetType());
637 error = true;
638 break;
639 } // endswitch Type
640
641 } catch (...) {
642 snprintf(g->Message, sizeof(g->Message), "Cannot make object from %s value", colp->GetName());
643 error = true;
644 } // end try/catch
645
646 return val;
647} // end of MakeObject
648
649/***********************************************************************/
650/* Stringify. */

Callers

nothing calls this directly

Calls 8

GetValueMethod · 0.45
IsNullMethod · 0.45
GetTypeMethod · 0.45
GetCharValueMethod · 0.45
GetIntValueMethod · 0.45
GetBigintValueMethod · 0.45
GetFloatValueMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected