Project

Profile

Help

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

he / latest9.9 / hec / Saxon.C.API / XdmItem.h @ 5401a5ae

1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright (c) 2015 Saxonica Limited.
3
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7

    
8
#ifndef SAXON_XDMITEM_h
9
#define SAXON_XDMITEM_h
10

    
11
#include "XdmValue.h"
12

    
13
class SaxonProcessor;
14

    
15
class XdmItem : public XdmValue
16
{
17

    
18
public:
19

    
20
     XdmItem();
21

    
22
     XdmItem(jobject);
23

    
24
    XdmItem(const XdmItem &item);
25

    
26
        
27
    virtual ~XdmItem(){
28
        //std::cerr<<std::endl<<"XdmItem destructor called, refCount"<<getRefCount()<<std::endl;
29
        if(getRefCount()<1){
30
          if(value !=NULL && proc != NULL && SaxonProcessor::jvmCreatedCPP>0) {
31
                        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(value->xdmvalue);
32
          }
33
          free(value);
34
          if(stringValue.empty()) {
35
            stringValue.clear();
36
          }
37
        }
38
    }
39

    
40
virtual void incrementRefCount() {
41
                refCount++;
42
                //std::cerr<<"refCount-inc-xdmItem="<<refCount<<" ob ref="<<(this)<<std::endl;
43
        }
44

    
45
virtual void decrementRefCount() {
46
                if (refCount > 0)
47
                        refCount--;
48
                //std::cerr<<"refCount-dec-xdmItem="<<refCount<<" ob ref="<<(this)<<std::endl;
49
        }
50
    
51
    virtual bool isAtomic();
52

    
53
//TODO: isNode
54
//TODO: isFunction
55

    
56
    /**
57
     * Get Java XdmValue object.
58
     * @return jobject - The Java object of the XdmValue in its JNI representation
59
     */
60
     virtual  jobject getUnderlyingValue();
61

    
62
     sxnc_value * getUnderlyingCValue(){
63
        return value;
64
     }
65

    
66

    
67
    /**
68
     * Get the string value of the item. For a node, this gets the string value
69
     * of the node. For an atomic value, it has the same effect as casting the value
70
     * to a string. In all cases the result is the same as applying the XPath string()
71
     * function.
72
     * <p>For atomic values, the result is the same as the result of calling
73
     * <code>toString</code>. This is not the case for nodes, where <code>toString</code>
74
     * returns an XML serialization of the node.</p>
75
     *
76
     * @return the result of converting the item to a string.
77
     * @deprecated the SaxonProcessor argument. It has been removed from release version 1.2.1
78
     */
79
     virtual const char * getStringValue();
80

    
81
 /**
82
     * Get the first item in the sequence
83
     * @return XdmItem or null if sequence is empty
84
     */
85
        XdmItem * getHead();
86

    
87
  /**
88
     * Get the n'th item in the value, counting from zero.
89
     *
90
     * @param n the item that is required, counting the first item in the sequence as item zero
91
     * @return the n'th item in the sequence making up the value, counting from zero
92
     * return NULL  if n is less than zero or greater than or equal to the number
93
     *                                    of items in the value
94
     * return NULL if the value is lazily evaluated and the delayed
95
     *                                    evaluation fails with a dynamic error.
96
     */
97
        XdmItem * itemAt(int n);
98

    
99
    /**
100
     * Get the number of items in the sequence
101
     *
102
     */
103
      int size();
104

    
105

    
106

    
107
        /**
108
        * Get the type of the object
109
        */
110
        virtual XDM_TYPE getType();
111

    
112
 protected:  
113
        sxnc_value* value;
114
        std::string stringValue;  /*!< Cached. String representation of the XdmValue, if available */
115
};
116

    
117

    
118
#endif
(29-29/52)