Project

Profile

Help

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

he / latest10 / hec / Saxon.C.API / XdmItem.h @ 250c5839

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
    virtual bool isNode();
54

    
55
    virtual bool isFunction();
56

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

    
63

    
64

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

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

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

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

    
103

    
104

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

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

    
115

    
116
#endif
(29-29/52)