Project

Profile

Help

How to connect?
Download (3.28 KB) Statistics
| Branch: | Tag: | Revision:

he / latest10 / hec / Saxon.C.API / XdmAtomicValue.cpp @ 61000456

1

    
2
//
3

    
4
#include "XdmAtomicValue.h"
5

    
6
    XdmAtomicValue::XdmAtomicValue():XdmItem(){}
7

    
8
    XdmAtomicValue::XdmAtomicValue(const XdmAtomicValue &aVal): XdmItem(aVal){
9
        valType = aVal.valType;
10

    
11
    }
12

    
13
   
14
        
15

    
16
    XdmAtomicValue::XdmAtomicValue(jobject obj):XdmItem(obj){
17
    }
18

    
19
    XdmAtomicValue::XdmAtomicValue(jobject obj, const char* ty):XdmItem(obj){
20
        valType = std::string(ty);
21
    }
22

    
23
    void XdmAtomicValue::setType(const char * ty){
24
        valType = std::string(ty);
25
    }
26

    
27
    const char* XdmAtomicValue::getPrimitiveTypeName(){
28
        if(!valType.empty()) {
29
                return valType.c_str();        
30
        }
31
        
32
        if(proc != nullptr) {
33
                jclass xdmUtilsClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/option/cpp/XdmUtils");
34
                jmethodID xmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(xdmUtilsClass,"getPrimitiveTypeName",
35
                                        "(Lnet/sf/saxon/s9api/XdmAtomicValue;)Ljava/lang/String;");
36
                if (!xmID) {
37
                        std::cerr << "Error: SaxonDll." << "getPrimitiveTypeName"
38
                                << " not found\n" << std::endl;
39
                        return "";
40
                }
41
                jstring result = (jstring)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,value->xdmvalue));
42
                if(result) {
43
                        const char * stri = SaxonProcessor::sxn_environ->env->GetStringUTFChars(result,
44
                                        nullptr);
45
                
46
                //SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
47
                        valType = std::string(stri);
48
                        return stri;
49
                }
50

    
51
        } 
52
        return "Q{http://www.w3.org/2001/XMLSchema}anyAtomicType";        
53
        
54
    }
55

    
56
    bool XdmAtomicValue::getBooleanValue(){
57
                jclass xdmNodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
58
                jmethodID bmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(xdmNodeClass,
59
                                        "getBooleanValue",
60
                                        "()Z");
61
                if (!bmID) {
62
                        std::cerr << "Error: MyClassInDll." << "getBooleanValue"
63
                                << " not found\n" << std::endl;
64
                        return false;
65
                } else {
66
                        jboolean result = (jboolean)(SaxonProcessor::sxn_environ->env->CallBooleanMethod(value, bmID));
67
                        if(result) {
68
                                return (bool)result;
69
                        }
70
                }
71
        return false;
72
    }
73

    
74
    double XdmAtomicValue::getDoubleValue(){
75
                jclass xdmNodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
76
                jmethodID bmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(xdmNodeClass,
77
                                        "getDoubleValue",
78
                                        "()D");
79
                if (!bmID) {
80
                        std::cerr << "Error: MyClassInDll." << "getDecimalValue"
81
                                << " not found\n" << std::endl;
82
                        return 0;
83
                } else {
84
                        jdouble result = (jdouble)(SaxonProcessor::sxn_environ->env->CallDoubleMethod(value, bmID));
85
                        if(result) {
86
                                return (double)result;
87
                        }
88
//checkForException(*(SaxonProcessor::sxn_environ), nullptr);
89
                }
90

    
91
        return 0;
92
    }
93

    
94

    
95

    
96
    const char * XdmAtomicValue::getStringValue(){
97
                return XdmItem::getStringValue();
98
    }
99

    
100
    long XdmAtomicValue::getLongValue(){
101
                jclass xdmNodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
102
                jmethodID bmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(xdmNodeClass,
103
                                        "getLongValue",
104
                                        "()J");
105
                if (!bmID) {
106
                        std::cerr << "Error: MyClassInDll." << "getLongValue"
107
                                << " not found\n" << std::endl;
108
                        return 0;
109
                } else {
110
                        jlong result = (jlong)(SaxonProcessor::sxn_environ->env->CallObjectMethod(value, bmID));
111
                        if(result) {
112
                                return (long)result;
113
                        }
114
                }
115

    
116
        return 0;
117
     }
(23-23/53)