Project

Profile

Help

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

he / latest9.6 / hec / Saxon.C.API / XdmAtomicValue.cpp @ 4e3fba42

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, string ty):XdmItem(obj){
20
        valType = ty;
21
    }
22

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

    
27
    string XdmAtomicValue::getPrimitiveTypeName(){
28
        if(!valType.empty()) {
29
                return valType;        
30
        }
31
        
32
        if(proc != NULL) {
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
                                        NULL);
45
                
46
                //SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
47

    
48
                        return stri;
49
                }
50

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

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

    
78
    double XdmAtomicValue::getDoubleValue(){
79
        if(proc != NULL) {
80
                jclass xdmNodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
81
                jmethodID bmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(xdmNodeClass,
82
                                        "getDoubleValue",
83
                                        "()D");
84
                if (!bmID) {
85
                        std::cerr << "Error: MyClassInDll." << "getDecimalValue"
86
                                << " not found\n" << std::endl;
87
                        return 0;
88
                } else {
89
                        jdouble result = (jdouble)(SaxonProcessor::sxn_environ->env->CallDoubleMethod(value->xdmvalue, bmID));
90
                        if(result) {
91
                                return (double)result;
92
                        }
93
checkForException(*(SaxonProcessor::sxn_environ), xdmNodeClass, NULL);
94
                }
95
        } else {
96
                std::cerr<<"Error: Processor not set in XdmAtomicValue"<<std::endl;
97
        }
98
        return 0;
99
    }
100

    
101

    
102

    
103
    const char * XdmAtomicValue::getStringValue(){
104
        if(proc != NULL) {
105
                return XdmItem::getStringValue(proc);
106
        }
107
        return NULL;
108
    }
109

    
110
    long XdmAtomicValue::getLongValue(){
111
                if(proc != NULL) {
112
                jclass xdmNodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
113
                jmethodID bmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(xdmNodeClass,
114
                                        "getLongValue",
115
                                        "()J");
116
                if (!bmID) {
117
                        std::cerr << "Error: MyClassInDll." << "getLongValue"
118
                                << " not found\n" << std::endl;
119
                        return 0;
120
                } else {
121
                        jlong result = (jlong)(SaxonProcessor::sxn_environ->env->CallObjectMethod(value->xdmvalue, bmID));
122
                        if(result) {
123
                                return (long)result;
124
                        }
125
                }
126
        } else {
127
                std::cerr<<"Error: Processor not set in XdmAtomicValue"<<std::endl;
128
        }
129
        return 0;
130
     }
(18-18/37)