Merge lp:~zorba-coders/zorba/bug928987 into lp:zorba

Proposed by Rodolfo Ochoa on 2012-03-26
Status: Merged
Approved by: Rodolfo Ochoa on 2012-04-19
Approved revision: 10744
Merged at revision: 10784
Proposed branch: lp:~zorba-coders/zorba/bug928987
Merge into: lp:zorba
Diff against target: 7958 lines (+7759/-1)
28 files modified
ChangeLog (+1/-0)
doc/CMakeLists.txt (+1/-0)
doc/xqj/CMakeLists.txt (+35/-0)
doc/xqj/doxy.config.in (+1207/-0)
doc/xqj/manual/indexpage.dox (+18/-0)
src/context/dynamic_loader.cpp (+1/-1)
swig/CMakeLists.txt (+1/-0)
swig/Item.h (+3/-0)
swig/Item.i (+14/-0)
swig/Zorba.h (+1/-0)
swig/Zorba.i (+7/-0)
swig/xqj/CMakeLists.txt (+76/-0)
swig/xqj/XQConnection.java (+1446/-0)
swig/xqj/XQDataSource.java (+171/-0)
swig/xqj/XQExpression.java (+454/-0)
swig/xqj/XQItem.java (+642/-0)
swig/xqj/XQItemType.java (+743/-0)
swig/xqj/XQMetaData.java (+204/-0)
swig/xqj/XQPreparedExpression.java (+675/-0)
swig/xqj/XQResultItem.java (+42/-0)
swig/xqj/XQResultSequence.java (+464/-0)
swig/xqj/XQResultSequenceScrollable.java (+464/-0)
swig/xqj/XQSequence.java (+471/-0)
swig/xqj/XQSequenceType.java (+85/-0)
swig/xqj/XQStaticContext.java (+427/-0)
swig/xqj/tck/xqj_test.bat.in (+46/-0)
swig/xqj/tck/xqj_test.sh.in (+58/-0)
swig/xqj/tck/zorba.properties (+2/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug928987
Reviewer Review Type Date Requested Status
Cezar Andrei 2012-03-26 Approve on 2012-04-16
Matthias Brantner 2012-03-26 Approve on 2012-04-13
Review via email: mp+99445@code.launchpad.net

Commit message

Added XQJ support.
New clean branch.

Description of the change

Added XQJ support.
New clean branch.

To post a comment you must log in.
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug928987-2012-03-26T23-13-00.63Z is finished. The final status was:

All tests succeeded!

Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Pending.

The PROJECT_NAME in doc/xqj/doxy.config.in needs to be quoted.

review: Needs Fixing

CMake says it's building Zorba but I'm unable to find any compiled files. Also, running the test suite gives me:

test 3901
    Start 3901: swig_xqj

3901: Test command: /home/mbrantner/zorba/build/swig/xqj/xqj_test.sh
3901: Test timeout computed to be: 1500
3901: xqj_test.bat: Deleting old Java API if found...
3901: rm: cannot remove `/home/mbrantner/zorba/build/swig/xqj/tck/org': No such file or directory
3901: java_test.sh: Compile Java API ...
3901: /home/mbrantner/zorba/build/swig/java/IStream.java:32: cannot find symbol
3901: symbol : method delete_IStream(long)
3901: location: class org.zorbaxquery.api.zorba_apiJNI
3901: zorba_apiJNI.delete_IStream(swigCPtr);
3901: ^
3901: /home/mbrantner/zorba/build/swig/java/IStream.java:39: cannot find symbol
3901: symbol : method IStream_readToString(long,org.zorbaxquery.api.IStream)
3901: location: class org.zorbaxquery.api.zorba_apiJNI
3901: return zorba_apiJNI.IStream_readToString(swigCPtr, this);
3901: ^
3901: /home/mbrantner/zorba/build/swig/java/IStream.java:43: cannot find symbol
3901: symbol : method IStream_read(long,org.zorbaxquery.api.IStream,byte[],int)
3901: location: class org.zorbaxquery.api.zorba_apiJNI
3901: return zorba_apiJNI.IStream_read(swigCPtr, this, BYTE, LENGTH);
3901: ^
3901: /home/mbrantner/zorba/build/swig/java/IStream.java:47: cannot find symbol
3901: symbol : method new_IStream()
3901: location: class org.zorbaxquery.api.zorba_apiJNI
3901: this(zorba_apiJNI.new_IStream(), true);

What am I doing wrong?

Cezar Andrei (cezar-andrei) wrote :

Matthias, for me it's working, the test passes.

The diff below in this page is missing some files, seems like a launchpad bug.

Rodolfo Ochoa (rodolfo-ochoa) wrote :

Matthias, there isn't any IStream.java file on the branch... make sure you do a clean build from the branch located in: lp:~zorba-coders/zorba/bug928987

Cezar Andrei (cezar-andrei) wrote :

Cleanup swig/xqj/XQExpression.java:3215
TimeZone getImplicitTimeZone()

File a bug for optimizing parsing, avoid using string as much as possible.

review: Needs Fixing
Rodolfo Ochoa (rodolfo-ochoa) wrote :

I can adjust the offset for a TimeZone object, but the ID is always a string, so, if I create a TimeZone object from default it will acquire the default ID instead the one provided from Zorba, so, there is no way to create a TimeZone from Zorba without implying a String.

review: Approve
Cezar Andrei (cezar-andrei) wrote :

1. swig/xqj/XQItem.java: public URI getNodeUri() throws XQException
3762 + try {
3763 + namespace = item.getNamespace();
3764 + } catch (Exception ex) {
3765 + //throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
3766 + }

Most of the times it's wrong to catch exceptions and do nothing, please review and add comment on why that is the case.

2. Same file: these types are commented out, shouldn't the method return something for them?
3790 + switch (itemType.getBaseType()) {
3791 + /*
3792 + case XQItemType.XQBASETYPE_ANYATOMICTYPE:
3793 + break;
3794 + case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
3795 + break;
3796 + case XQItemType.XQBASETYPE_ANYTYPE:
3797 + break;
3798 + *
3799 + */

3. Also, do add the default clause for switch blocks. Most of the time is more useful to throw an exception if the kind of the object is not recognized instead of returning null.

4. swig/xqj/XQItemType.java
4167 + case XQITEMKIND_ATTRIBUTE:
4168 + // TODO: fix uriWildcard, localNameWildcard
4169 + result = TypeIdentifier.createAttributeType(...
and
4179 + case XQITEMKIND_ELEMENT:
4180 + // TODO: fix uriWildcard, localNameWildcard
4181 + result = TypeIdentifier.createElementType(...
Please fix or file bugs to track it or remove the comment if nothing to be done here.

5. swig/xqj/XQMetaData.java
4949 + public boolean isXQueryXSupported() throws XQException {
4950 + isClosedXQException();
4951 + return false; //depends on compilation directive
4952 + }
Same comment as 4.

review: Needs Fixing
Cezar Andrei (cezar-andrei) wrote :

Looks good.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug928987 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug928987-2012-04-16T20-46-06.764Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug928987 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug928987-2012-04-17T06-19-09.575Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug928987 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug928987-2012-04-17T22-44-19.426Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

lp:~zorba-coders/zorba/bug928987 updated on 2012-04-19
10740. By Rodolfo Ochoa on 2012-04-19

Adding getNamespaceBindings method to Item object in the API

10741. By Rodolfo Ochoa on 2012-04-19

Merge from trunk

10742. By Rodolfo Ochoa on 2012-04-19

Fix for Namespace test on items from XQJ

10743. By Rodolfo Ochoa on 2012-04-19

Merge from trunk

10744. By Rodolfo Ochoa on 2012-04-19

Fix for XQueryX detection.

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug928987-2012-04-19T22-35-58.124Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-04-18 21:11:57 +0000
3+++ ChangeLog 2012-04-19 22:34:19 +0000
4@@ -11,6 +11,7 @@
5 * Extended API for Python, Java, PHP and Ruby.
6 * Add jvm classpath to zorbacmd and to Zorba API. Tracked by #931816
7 * Added support for NO_ICU (to not use ICU for unicode processing)
8+ * Added XQJ support.
9
10 Optimization:
11
12
13=== modified file 'doc/CMakeLists.txt'
14--- doc/CMakeLists.txt 2012-04-16 20:56:43 +0000
15+++ doc/CMakeLists.txt 2012-04-19 22:34:19 +0000
16@@ -40,6 +40,7 @@
17
18 IF (SWIG_FOUND)
19 ADD_SUBDIRECTORY(java)
20+ ADD_SUBDIRECTORY(xqj)
21 ADD_SUBDIRECTORY(python)
22 ADD_SUBDIRECTORY(ruby)
23 ADD_SUBDIRECTORY(php)
24
25=== added directory 'doc/xqj'
26=== added file 'doc/xqj/CMakeLists.txt'
27--- doc/xqj/CMakeLists.txt 1970-01-01 00:00:00 +0000
28+++ doc/xqj/CMakeLists.txt 2012-04-19 22:34:19 +0000
29@@ -0,0 +1,35 @@
30+# Copyright 2006-2008 The FLWOR Foundation.
31+#
32+# Licensed under the Apache License, Version 2.0 (the "License");
33+# you may not use this file except in compliance with the License.
34+# You may obtain a copy of the License at
35+#
36+# http://www.apache.org/licenses/LICENSE-2.0
37+#
38+# Unless required by applicable law or agreed to in writing, software
39+# distributed under the License is distributed on an "AS IS" BASIS,
40+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41+# See the License for the specific language governing permissions and
42+# limitations under the License.
43+
44+ZORBA_DOXYGEN ("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "xqjdocs")
45+
46+IF (DOXYGEN_FOUND)
47+ ADD_DEPENDENCIES (doc "xqjdocs")
48+
49+ CONFIGURE_FILE (
50+ ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_b.gif
51+ ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_b.gif
52+ COPYONLY
53+ )
54+ CONFIGURE_FILE (
55+ ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_r.gif
56+ ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_r.gif
57+ COPYONLY
58+ )
59+ CONFIGURE_FILE (
60+ ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_l.gif
61+ ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_l.gif
62+ COPYONLY
63+ )
64+ENDIF (DOXYGEN_FOUND)
65
66=== added file 'doc/xqj/doxy.config.in'
67--- doc/xqj/doxy.config.in 1970-01-01 00:00:00 +0000
68+++ doc/xqj/doxy.config.in 2012-04-19 22:34:19 +0000
69@@ -0,0 +1,1207 @@
70+# Doxyfile 1.4.5
71+
72+# This file describes the settings to be used by the documentation system
73+# doxygen (www.doxygen.org) for a project
74+#
75+# All text after a hash (#) is considered a comment and will be ignored
76+# The format is:
77+# TAG = value [value, ...]
78+# For lists items can also be appended using:
79+# TAG += value [value, ...]
80+# Values that contain spaces should be placed between quotes (" ")
81+
82+#---------------------------------------------------------------------------
83+# Project related configuration options
84+#---------------------------------------------------------------------------
85+
86+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
87+# by quotes) that should identify the project.
88+
89+PROJECT_NAME = "Zorba XQJ-API"
90+
91+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
92+# This could be handy for archiving the generated documentation or
93+# if some version control system is used.
94+
95+PROJECT_NUMBER = @ZORBA_MAJOR_NUMBER@.@ZORBA_MINOR_NUMBER@.@ZORBA_PATCH_NUMBER@
96+
97+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
98+# base path where the generated documentation will be put.
99+# If a relative path is entered, it will be relative to the location
100+# where doxygen was started. If left blank the current directory will be used.
101+
102+OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@
103+
104+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
105+# 4096 sub-directories (in 2 levels) under the output directory of each output
106+# format and will distribute the generated files over these directories.
107+# Enabling this option can be useful when feeding doxygen a huge amount of
108+# source files, where putting all generated files in the same directory would
109+# otherwise cause performance problems for the file system.
110+
111+CREATE_SUBDIRS = NO
112+
113+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
114+# documentation generated by doxygen is written. Doxygen will use this
115+# information to generate all constant output in the proper language.
116+# The default language is English, other supported languages are:
117+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish,
118+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese,
119+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian,
120+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish,
121+# Swedish, and Ukrainian.
122+
123+OUTPUT_LANGUAGE = English
124+
125+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
126+# include brief member descriptions after the members that are listed in
127+# the file and class documentation (similar to JavaDoc).
128+# Set to NO to disable this.
129+
130+BRIEF_MEMBER_DESC = YES
131+
132+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
133+# the brief description of a member or function before the detailed description.
134+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
135+# brief descriptions will be completely suppressed.
136+
137+REPEAT_BRIEF = YES
138+
139+# This tag implements a quasi-intelligent brief description abbreviator
140+# that is used to form the text in various listings. Each string
141+# in this list, if found as the leading text of the brief description, will be
142+# stripped from the text and the result after processing the whole list, is
143+# used as the annotated text. Otherwise, the brief description is used as-is.
144+# If left blank, the following values are used ("$name" is automatically
145+# replaced with the name of the entity): "The $name class" "The $name widget"
146+# "The $name file" "is" "provides" "specifies" "contains"
147+# "represents" "a" "an" "the"
148+
149+ABBREVIATE_BRIEF =
150+
151+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
152+# Doxygen will generate a detailed section even if there is only a brief
153+# description.
154+
155+ALWAYS_DETAILED_SEC = NO
156+
157+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
158+# inherited members of a class in the documentation of that class as if those
159+# members were ordinary class members. Constructors, destructors and assignment
160+# operators of the base classes will not be shown.
161+
162+INLINE_INHERITED_MEMB = YES
163+
164+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
165+# path before files name in the file list and in the header files. If set
166+# to NO the shortest path that makes the file name unique will be used.
167+
168+FULL_PATH_NAMES = NO
169+
170+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
171+# can be used to strip a user-defined part of the path. Stripping is
172+# only done if one of the specified strings matches the left-hand part of
173+# the path. The tag can be used to show relative paths in the file list.
174+# If left blank the directory from which doxygen is run is used as the
175+# path to strip.
176+
177+STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/src
178+
179+
180+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
181+# the path mentioned in the documentation of a class, which tells
182+# the reader which header file to include in order to use a class.
183+# If left blank only the name of the header file containing the class
184+# definition is used. Otherwise one should specify the include paths that
185+# are normally passed to the compiler using the -I flag.
186+
187+STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@/include @CMAKE_BINARY_DIR@/include
188+
189+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
190+# (but less readable) file names. This can be useful is your file systems
191+# doesn't support long names like on DOS, Mac, or CD-ROM.
192+
193+SHORT_NAMES = NO
194+
195+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
196+# will interpret the first line (until the first dot) of a JavaDoc-style
197+# comment as the brief description. If set to NO, the JavaDoc
198+# comments will behave just like the Qt-style comments (thus requiring an
199+# explicit @brief command for a brief description.
200+
201+JAVADOC_AUTOBRIEF = YES
202+
203+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
204+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
205+# comments) as a brief description. This used to be the default behaviour.
206+# The new default is to treat a multi-line C++ comment block as a detailed
207+# description. Set this tag to YES if you prefer the old behaviour instead.
208+
209+MULTILINE_CPP_IS_BRIEF = NO
210+
211+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
212+# will output the detailed description near the top, like JavaDoc.
213+# If set to NO, the detailed description appears after the member
214+# documentation.
215+
216+DETAILS_AT_TOP = NO
217+
218+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
219+# member inherits the documentation from any documented member that it
220+# re-implements.
221+
222+INHERIT_DOCS = YES
223+
224+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
225+# a new page for each member. If set to NO, the documentation of a member will
226+# be part of the file/class/namespace that contains it.
227+
228+SEPARATE_MEMBER_PAGES = NO
229+
230+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
231+# Doxygen uses this value to replace tabs by spaces in code fragments.
232+
233+TAB_SIZE = 2
234+
235+# This tag can be used to specify a number of aliases that acts
236+# as commands in the documentation. An alias has the form "name=value".
237+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
238+# put the command \sideeffect (or @sideeffect) in the documentation, which
239+# will result in a user-defined paragraph with heading "Side Effects:".
240+# You can put \n's in the value part of an alias to insert newlines.
241+
242+ALIASES =
243+
244+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
245+# sources only. Doxygen will then generate output that is more tailored for C.
246+# For instance, some of the names that are used will be different. The list
247+# of all members will be omitted, etc.
248+
249+OPTIMIZE_OUTPUT_FOR_C = YES
250+
251+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
252+# sources only. Doxygen will then generate output that is more tailored for Java.
253+# For instance, namespaces will be presented as packages, qualified scopes
254+# will look different, etc.
255+
256+OPTIMIZE_OUTPUT_JAVA = NO
257+
258+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
259+# include (a tag file for) the STL sources as input, then you should
260+# set this tag to YES in order to let doxygen match functions declarations and
261+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
262+# func(std::string) {}). This also make the inheritance and collaboration
263+# diagrams that involve STL classes more complete and accurate.
264+
265+# BUILTIN_STL_SUPPORT = NO
266+
267+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
268+# tag is set to YES, then doxygen will reuse the documentation of the first
269+# member in the group (if any) for the other members of the group. By default
270+# all members of a group must be documented explicitly.
271+
272+DISTRIBUTE_GROUP_DOC = NO
273+
274+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
275+# the same type (for instance a group of public functions) to be put as a
276+# subgroup of that type (e.g. under the Public Functions section). Set it to
277+# NO to prevent subgrouping. Alternatively, this can be done per class using
278+# the \nosubgrouping command.
279+
280+SUBGROUPING = YES
281+
282+#---------------------------------------------------------------------------
283+# Build related configuration options
284+#---------------------------------------------------------------------------
285+
286+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
287+# documentation are documented, even if no documentation was available.
288+# Private class members and static file members will be hidden unless
289+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
290+
291+EXTRACT_ALL = YES
292+
293+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
294+# will be included in the documentation.
295+
296+EXTRACT_PRIVATE = NO
297+
298+# If the EXTRACT_STATIC tag is set to YES all static members of a file
299+# will be included in the documentation.
300+
301+EXTRACT_STATIC = NO
302+
303+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
304+# defined locally in source files will be included in the documentation.
305+# If set to NO only classes defined in header files are included.
306+
307+EXTRACT_LOCAL_CLASSES = YES
308+
309+# This flag is only useful for Objective-C code. When set to YES local
310+# methods, which are defined in the implementation section but not in
311+# the interface are included in the documentation.
312+# If set to NO (the default) only methods in the interface are included.
313+
314+EXTRACT_LOCAL_METHODS = NO
315+
316+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
317+# undocumented members of documented classes, files or namespaces.
318+# If set to NO (the default) these members will be included in the
319+# various overviews, but no documentation section is generated.
320+# This option has no effect if EXTRACT_ALL is enabled.
321+
322+HIDE_UNDOC_MEMBERS = YES
323+
324+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
325+# undocumented classes that are normally visible in the class hierarchy.
326+# If set to NO (the default) these classes will be included in the various
327+# overviews. This option has no effect if EXTRACT_ALL is enabled.
328+
329+HIDE_UNDOC_CLASSES = YES
330+
331+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
332+# friend (class|struct|union) declarations.
333+# If set to NO (the default) these declarations will be included in the
334+# documentation.
335+
336+HIDE_FRIEND_COMPOUNDS = NO
337+
338+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
339+# documentation blocks found inside the body of a function.
340+# If set to NO (the default) these blocks will be appended to the
341+# function's detailed documentation block.
342+
343+HIDE_IN_BODY_DOCS = NO
344+
345+# The INTERNAL_DOCS tag determines if documentation
346+# that is typed after a \internal command is included. If the tag is set
347+# to NO (the default) then the documentation will be excluded.
348+# Set it to YES to include the internal documentation.
349+
350+INTERNAL_DOCS = NO
351+
352+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
353+# file names in lower-case letters. If set to YES upper-case letters are also
354+# allowed. This is useful if you have classes or files whose names only differ
355+# in case and if your file system supports case sensitive file names. Windows
356+# and Mac users are advised to set this option to NO.
357+
358+CASE_SENSE_NAMES = YES
359+
360+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
361+# will show members with their full class and namespace scopes in the
362+# documentation. If set to YES the scope will be hidden.
363+
364+HIDE_SCOPE_NAMES = NO
365+
366+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
367+# will put a list of the files that are included by a file in the documentation
368+# of that file.
369+
370+SHOW_INCLUDE_FILES = YES
371+
372+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
373+# is inserted in the documentation for inline members.
374+
375+INLINE_INFO = YES
376+
377+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
378+# will sort the (detailed) documentation of file and class members
379+# alphabetically by member name. If set to NO the members will appear in
380+# declaration order.
381+
382+SORT_MEMBER_DOCS = YES
383+
384+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
385+# brief documentation of file, namespace and class members alphabetically
386+# by member name. If set to NO (the default) the members will appear in
387+# declaration order.
388+
389+SORT_BRIEF_DOCS = YES
390+
391+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
392+# sorted by fully-qualified names, including namespaces. If set to
393+# NO (the default), the class list will be sorted only by class name,
394+# not including the namespace part.
395+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
396+# Note: This option applies only to the class list, not to the
397+# alphabetical list.
398+
399+SORT_BY_SCOPE_NAME = NO
400+
401+# The GENERATE_TODOLIST tag can be used to enable (YES) or
402+# disable (NO) the todo list. This list is created by putting \todo
403+# commands in the documentation.
404+
405+GENERATE_TODOLIST = YES
406+
407+# The GENERATE_TESTLIST tag can be used to enable (YES) or
408+# disable (NO) the test list. This list is created by putting \test
409+# commands in the documentation.
410+
411+GENERATE_TESTLIST = YES
412+
413+# The GENERATE_BUGLIST tag can be used to enable (YES) or
414+# disable (NO) the bug list. This list is created by putting \bug
415+# commands in the documentation.
416+
417+GENERATE_BUGLIST = YES
418+
419+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
420+# disable (NO) the deprecated list. This list is created by putting
421+# \deprecated commands in the documentation.
422+
423+GENERATE_DEPRECATEDLIST= YES
424+
425+# The ENABLED_SECTIONS tag can be used to enable conditional
426+# documentation sections, marked by \if sectionname ... \endif.
427+
428+ENABLED_SECTIONS =
429+
430+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
431+# the initial value of a variable or define consists of for it to appear in
432+# the documentation. If the initializer consists of more lines than specified
433+# here it will be hidden. Use a value of 0 to hide initializers completely.
434+# The appearance of the initializer of individual variables and defines in the
435+# documentation can be controlled using \showinitializer or \hideinitializer
436+# command in the documentation regardless of this setting.
437+
438+MAX_INITIALIZER_LINES = 30
439+
440+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
441+# at the bottom of the documentation of classes and structs. If set to YES the
442+# list will mention the files that were used to generate the documentation.
443+
444+SHOW_USED_FILES = YES
445+
446+# If the sources in your project are distributed over multiple directories
447+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
448+# in the documentation. The default is YES.
449+
450+SHOW_DIRECTORIES = YES
451+
452+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
453+# doxygen should invoke to get the current version for each file (typically from the
454+# version control system). Doxygen will invoke the program by executing (via
455+# popen()) the command <command> <input-file>, where <command> is the value of
456+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
457+# provided by doxygen. Whatever the program writes to standard output
458+# is used as the file version. See the manual for examples.
459+
460+FILE_VERSION_FILTER =
461+
462+#---------------------------------------------------------------------------
463+# configuration options related to warning and progress messages
464+#---------------------------------------------------------------------------
465+
466+# The QUIET tag can be used to turn on/off the messages that are generated
467+# by doxygen. Possible values are YES and NO. If left blank NO is used.
468+
469+QUIET = NO
470+
471+# The WARNINGS tag can be used to turn on/off the warning messages that are
472+# generated by doxygen. Possible values are YES and NO. If left blank
473+# NO is used.
474+
475+WARNINGS = YES
476+
477+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
478+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
479+# automatically be disabled.
480+
481+WARN_IF_UNDOCUMENTED = YES
482+
483+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
484+# potential errors in the documentation, such as not documenting some
485+# parameters in a documented function, or documenting parameters that
486+# don't exist or using markup commands wrongly.
487+
488+WARN_IF_DOC_ERROR = YES
489+
490+# This WARN_NO_PARAMDOC option can be abled to get warnings for
491+# functions that are documented, but have no documentation for their parameters
492+# or return value. If set to NO (the default) doxygen will only warn about
493+# wrong or incomplete parameter documentation, but not about the absence of
494+# documentation.
495+
496+WARN_NO_PARAMDOC = NO
497+
498+# The WARN_FORMAT tag determines the format of the warning messages that
499+# doxygen can produce. The string should contain the $file, $line, and $text
500+# tags, which will be replaced by the file and line number from which the
501+# warning originated and the warning text. Optionally the format may contain
502+# $version, which will be replaced by the version of the file (if it could
503+# be obtained via FILE_VERSION_FILTER)
504+
505+WARN_FORMAT = @DOXY_WARN_FORMAT@
506+
507+# The WARN_LOGFILE tag can be used to specify a file to which warning
508+# and error messages should be written. If left blank the output is written
509+# to stderr.
510+
511+WARN_LOGFILE = Doc/doxy.log
512+
513+#---------------------------------------------------------------------------
514+# configuration options related to the input files
515+#---------------------------------------------------------------------------
516+
517+# The INPUT tag can be used to specify the files and/or directories that contain
518+# documented source files. You may enter file names like "myfile.cpp" or
519+# directories like "/usr/src/myproject". Separate the files or directories
520+# with spaces.
521+
522+INPUT = @CMAKE_CURRENT_SOURCE_DIR@/manual
523+
524+# If the value of the INPUT tag contains directories, you can use the
525+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
526+# and *.h) to filter out the source-files in the directories. If left
527+# blank the following patterns are tested:
528+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
529+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
530+
531+FILE_PATTERNS = *.java *.dox
532+
533+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
534+# should be searched for input files as well. Possible values are YES and NO.
535+# If left blank NO is used.
536+
537+RECURSIVE = YES
538+
539+# The EXCLUDE tag can be used to specify files and/or directories that should
540+# excluded from the INPUT source files. This way you can easily exclude a
541+# subdirectory from a directory tree whose root is specified with the INPUT tag.
542+
543+EXCLUDE =
544+
545+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
546+# directories that are symbolic links (a Unix filesystem feature) are excluded
547+# from the input.
548+
549+EXCLUDE_SYMLINKS = NO
550+
551+# If the value of the INPUT tag contains directories, you can use the
552+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
553+# certain files from those directories. Note that the wildcards are matched
554+# against the file with absolute path, so to exclude all test directories
555+# for example use the pattern */test/*
556+
557+EXCLUDE_PATTERNS = */.svn \
558+ */.svn/*
559+
560+# The EXAMPLE_PATH tag can be used to specify one or more files or
561+# directories that contain example code fragments that are included (see
562+# the \include command).
563+
564+EXAMPLE_PATH = @CMAKE_CURRENT_BINARY_DIR@/examples
565+
566+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
567+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
568+# and *.h) to filter out the source-files in the directories. If left
569+# blank all files are included.
570+
571+EXAMPLE_PATTERNS = *.java
572+
573+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
574+# searched for input files to be used with the \include or \dontinclude
575+# commands irrespective of the value of the RECURSIVE tag.
576+# Possible values are YES and NO. If left blank NO is used.
577+
578+EXAMPLE_RECURSIVE = YES
579+
580+# The IMAGE_PATH tag can be used to specify one or more files or
581+# directories that contain image that are included in the documentation (see
582+# the \image command).
583+
584+IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@
585+
586+
587+# The INPUT_FILTER tag can be used to specify a program that doxygen should
588+# invoke to filter for each input file. Doxygen will invoke the filter program
589+# by executing (via popen()) the command <filter> <input-file>, where <filter>
590+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
591+# input file. Doxygen will then use the output that the filter program writes
592+# to standard output. If FILTER_PATTERNS is specified, this tag will be
593+# ignored.
594+
595+INPUT_FILTER =
596+
597+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
598+# basis. Doxygen will compare the file name with each pattern and apply the
599+# filter if there is a match. The filters are a list of the form:
600+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
601+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
602+# is applied to all files.
603+
604+FILTER_PATTERNS =
605+
606+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
607+# INPUT_FILTER) will be used to filter the input files when producing source
608+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
609+
610+FILTER_SOURCE_FILES = NO
611+
612+#---------------------------------------------------------------------------
613+# configuration options related to source browsing
614+#---------------------------------------------------------------------------
615+
616+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
617+# be generated. Documented entities will be cross-referenced with these sources.
618+# Note: To get rid of all source code in the generated output, make sure also
619+# VERBATIM_HEADERS is set to NO.
620+
621+SOURCE_BROWSER = YES
622+
623+# Setting the INLINE_SOURCES tag to YES will include the body
624+# of functions and classes directly in the documentation.
625+
626+INLINE_SOURCES = NO
627+
628+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
629+# doxygen to hide any special comment blocks from generated source code
630+# fragments. Normal C and C++ comments will always remain visible.
631+
632+STRIP_CODE_COMMENTS = NO
633+
634+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
635+# then for each documented function all documented
636+# functions referencing it will be listed.
637+
638+REFERENCED_BY_RELATION = YES
639+
640+# If the REFERENCES_RELATION tag is set to YES (the default)
641+# then for each documented function all documented entities
642+# called/used by that function will be listed.
643+
644+REFERENCES_RELATION = YES
645+
646+# If the USE_HTAGS tag is set to YES then the references to source code
647+# will point to the HTML generated by the htags(1) tool instead of doxygen
648+# built-in source browser. The htags tool is part of GNU's global source
649+# tagging system (see http://www.gnu.org/software/global/global.html). You
650+# will need version 4.8.6 or higher.
651+
652+USE_HTAGS = NO
653+
654+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
655+# will generate a verbatim copy of the header file for each class for
656+# which an include is specified. Set to NO to disable this.
657+
658+VERBATIM_HEADERS = YES
659+
660+#---------------------------------------------------------------------------
661+# configuration options related to the alphabetical class index
662+#---------------------------------------------------------------------------
663+
664+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
665+# of all compounds will be generated. Enable this if the project
666+# contains a lot of classes, structs, unions or interfaces.
667+
668+ALPHABETICAL_INDEX = YES
669+
670+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
671+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
672+# in which this list will be split (can be a number in the range [1..20])
673+
674+COLS_IN_ALPHA_INDEX = 2
675+
676+# In case all classes in a project start with a common prefix, all
677+# classes will be put under the same header in the alphabetical index.
678+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
679+# should be ignored while generating the index headers.
680+
681+IGNORE_PREFIX =
682+
683+#---------------------------------------------------------------------------
684+# configuration options related to the HTML output
685+#---------------------------------------------------------------------------
686+
687+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
688+# generate HTML output.
689+
690+GENERATE_HTML = YES
691+
692+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
693+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
694+# put in front of it. If left blank `html' will be used as the default path.
695+
696+HTML_OUTPUT = html
697+
698+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
699+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
700+# doxygen will generate files with .html extension.
701+
702+HTML_FILE_EXTENSION = .html
703+
704+# The HTML_HEADER tag can be used to specify a personal HTML header for
705+# each generated HTML page. If it is left blank doxygen will generate a
706+# standard header.
707+HTML_HEADER = @CMAKE_CURRENT_SOURCE_DIR@/../style/header.html
708+
709+
710+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
711+# each generated HTML page. If it is left blank doxygen will generate a
712+# standard footer.
713+
714+HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/../style/footer.html
715+
716+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
717+# style sheet that is used by each HTML page. It can be used to
718+# fine-tune the look of the HTML output. If the tag is left blank doxygen
719+# will generate a default style sheet. Note that doxygen will try to copy
720+# the style sheet file to the HTML output directory, so don't put your own
721+# stylesheet in the HTML output directory as well, or it will be erased!
722+
723+HTML_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/../style/stylesheet.css
724+
725+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
726+# files or namespaces will be aligned in HTML using tables. If set to
727+# NO a bullet list will be used.
728+
729+HTML_ALIGN_MEMBERS = YES
730+
731+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
732+# will be generated that can be used as input for tools like the
733+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
734+# of the generated HTML documentation.
735+
736+GENERATE_HTMLHELP = YES
737+
738+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
739+# be used to specify the file name of the resulting .chm file. You
740+# can add a path in front of the file if the result should not be
741+# written to the html output directory.
742+
743+CHM_FILE =
744+
745+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
746+# be used to specify the location (absolute path including file name) of
747+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
748+# the HTML help compiler on the generated index.hhp.
749+
750+HHC_LOCATION =
751+
752+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
753+# controls if a separate .chi index file is generated (YES) or that
754+# it should be included in the master .chm file (NO).
755+
756+GENERATE_CHI = NO
757+
758+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
759+# controls whether a binary table of contents is generated (YES) or a
760+# normal table of contents (NO) in the .chm file.
761+
762+BINARY_TOC = NO
763+
764+# The TOC_EXPAND flag can be set to YES to add extra items for group members
765+# to the contents of the HTML help documentation and to the tree view.
766+
767+TOC_EXPAND = NO
768+
769+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
770+# top of each HTML page. The value NO (the default) enables the index and
771+# the value YES disables it.
772+
773+DISABLE_INDEX = NO
774+
775+# This tag can be used to set the number of enum values (range [1..20])
776+# that doxygen will group on one line in the generated HTML documentation.
777+
778+ENUM_VALUES_PER_LINE = 4
779+
780+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
781+# generated containing a tree-like index structure (just like the one that
782+# is generated for HTML Help). For this to work a browser that supports
783+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
784+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
785+# probably better off using the HTML help feature.
786+
787+GENERATE_TREEVIEW = NO
788+
789+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
790+# used to set the initial width (in pixels) of the frame in which the tree
791+# is shown.
792+
793+TREEVIEW_WIDTH = 250
794+
795+#---------------------------------------------------------------------------
796+# configuration options related to the LaTeX output
797+#---------------------------------------------------------------------------
798+
799+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
800+# generate Latex output.
801+
802+GENERATE_LATEX = NO
803+
804+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
805+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
806+# put in front of it. If left blank `latex' will be used as the default path.
807+
808+LATEX_OUTPUT = latex
809+
810+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
811+# invoked. If left blank `latex' will be used as the default command name.
812+
813+#LATEX_CMD_NAME = latex
814+LATEX_CMD_NAME = @LATEX_COMPILER@
815+
816+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
817+# generate index for LaTeX. If left blank `makeindex' will be used as the
818+# default command name.
819+
820+#MAKEINDEX_CMD_NAME = makeindex
821+MAKEINDEX_CMD_NAME = @MAKEINDEX_COMPILER@
822+
823+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
824+# LaTeX documents. This may be useful for small projects and may help to
825+# save some trees in general.
826+
827+COMPACT_LATEX = NO
828+
829+# The PAPER_TYPE tag can be used to set the paper type that is used
830+# by the printer. Possible values are: a4, a4wide, letter, legal and
831+# executive. If left blank a4wide will be used.
832+
833+PAPER_TYPE = a4
834+
835+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
836+# packages that should be included in the LaTeX output.
837+
838+EXTRA_PACKAGES =
839+
840+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
841+# the generated latex document. The header should contain everything until
842+# the first chapter. If it is left blank doxygen will generate a
843+# standard header. Notice: only use this tag if you know what you are doing!
844+
845+LATEX_HEADER =
846+
847+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
848+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
849+# contain links (just like the HTML output) instead of page references
850+# This makes the output suitable for online browsing using a pdf viewer.
851+
852+PDF_HYPERLINKS = YES
853+
854+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
855+# plain latex in the generated Makefile. Set this option to YES to get a
856+# higher quality PDF documentation.
857+
858+USE_PDFLATEX = YES
859+
860+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
861+# command to the generated LaTeX files. This will instruct LaTeX to keep
862+# running if errors occur, instead of asking the user for help.
863+# This option is also used when generating formulas in HTML.
864+
865+LATEX_BATCHMODE = YES
866+
867+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
868+# include the index chapters (such as File Index, Compound Index, etc.)
869+# in the output.
870+
871+LATEX_HIDE_INDICES = NO
872+
873+#---------------------------------------------------------------------------
874+# configuration options related to the RTF output
875+#---------------------------------------------------------------------------
876+
877+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
878+# The RTF output is optimized for Word 97 and may not look very pretty with
879+# other RTF readers or editors.
880+
881+GENERATE_RTF = NO
882+
883+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
884+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
885+# put in front of it. If left blank `rtf' will be used as the default path.
886+
887+RTF_OUTPUT = rtf
888+
889+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
890+# RTF documents. This may be useful for small projects and may help to
891+# save some trees in general.
892+
893+COMPACT_RTF = NO
894+
895+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
896+# will contain hyperlink fields. The RTF file will
897+# contain links (just like the HTML output) instead of page references.
898+# This makes the output suitable for online browsing using WORD or other
899+# programs which support those fields.
900+# Note: wordpad (write) and others do not support links.
901+
902+RTF_HYPERLINKS = NO
903+
904+# Load stylesheet definitions from file. Syntax is similar to doxygen's
905+# config file, i.e. a series of assignments. You only have to provide
906+# replacements, missing definitions are set to their default value.
907+
908+RTF_STYLESHEET_FILE =
909+
910+# Set optional variables used in the generation of an rtf document.
911+# Syntax is similar to doxygen's config file.
912+
913+RTF_EXTENSIONS_FILE =
914+
915+#---------------------------------------------------------------------------
916+# configuration options related to the man page output
917+#---------------------------------------------------------------------------
918+
919+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
920+# generate man pages
921+
922+GENERATE_MAN = NO
923+
924+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
925+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
926+# put in front of it. If left blank `man' will be used as the default path.
927+
928+MAN_OUTPUT = man
929+
930+# The MAN_EXTENSION tag determines the extension that is added to
931+# the generated man pages (default is the subroutine's section .3)
932+
933+MAN_EXTENSION = .3
934+
935+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
936+# then it will generate one additional man file for each entity
937+# documented in the real man page(s). These additional files
938+# only source the real man page, but without them the man command
939+# would be unable to find the correct page. The default is NO.
940+
941+MAN_LINKS = NO
942+
943+#---------------------------------------------------------------------------
944+# configuration options related to the XML output
945+#---------------------------------------------------------------------------
946+
947+# If the GENERATE_XML tag is set to YES Doxygen will
948+# generate an XML file that captures the structure of
949+# the code including all documentation.
950+
951+GENERATE_XML = NO
952+
953+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
954+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
955+# put in front of it. If left blank `xml' will be used as the default path.
956+
957+XML_OUTPUT = xml
958+
959+# The XML_SCHEMA tag can be used to specify an XML schema,
960+# which can be used by a validating XML parser to check the
961+# syntax of the XML files.
962+
963+XML_SCHEMA =
964+
965+# The XML_DTD tag can be used to specify an XML DTD,
966+# which can be used by a validating XML parser to check the
967+# syntax of the XML files.
968+
969+XML_DTD =
970+
971+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
972+# dump the program listings (including syntax highlighting
973+# and cross-referencing information) to the XML output. Note that
974+# enabling this will significantly increase the size of the XML output.
975+
976+XML_PROGRAMLISTING = YES
977+
978+#---------------------------------------------------------------------------
979+# configuration options for the AutoGen Definitions output
980+#---------------------------------------------------------------------------
981+
982+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
983+# generate an AutoGen Definitions (see autogen.sf.net) file
984+# that captures the structure of the code including all
985+# documentation. Note that this feature is still experimental
986+# and incomplete at the moment.
987+
988+GENERATE_AUTOGEN_DEF = NO
989+
990+#---------------------------------------------------------------------------
991+# configuration options related to the Perl module output
992+#---------------------------------------------------------------------------
993+
994+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
995+# generate a Perl module file that captures the structure of
996+# the code including all documentation. Note that this
997+# feature is still experimental and incomplete at the
998+# moment.
999+
1000+GENERATE_PERLMOD = NO
1001+
1002+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
1003+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
1004+# to generate PDF and DVI output from the Perl module output.
1005+
1006+PERLMOD_LATEX = NO
1007+
1008+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
1009+# nicely formatted so it can be parsed by a human reader. This is useful
1010+# if you want to understand what is going on. On the other hand, if this
1011+# tag is set to NO the size of the Perl module output will be much smaller
1012+# and Perl will parse it just the same.
1013+
1014+PERLMOD_PRETTY = YES
1015+
1016+# The names of the make variables in the generated doxyrules.make file
1017+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
1018+# This is useful so different doxyrules.make files included by the same
1019+# Makefile don't overwrite each other's variables.
1020+
1021+PERLMOD_MAKEVAR_PREFIX =
1022+
1023+#---------------------------------------------------------------------------
1024+# Configuration options related to the preprocessor
1025+#---------------------------------------------------------------------------
1026+
1027+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
1028+# evaluate all C-preprocessor directives found in the sources and include
1029+# files.
1030+
1031+ENABLE_PREPROCESSING = YES
1032+
1033+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
1034+# names in the source code. If set to NO (the default) only conditional
1035+# compilation will be performed. Macro expansion can be done in a controlled
1036+# way by setting EXPAND_ONLY_PREDEF to YES.
1037+
1038+MACRO_EXPANSION = YES
1039+
1040+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
1041+# then the macro expansion is limited to the macros specified with the
1042+# PREDEFINED and EXPAND_AS_DEFINED tags.
1043+
1044+EXPAND_ONLY_PREDEF = YES
1045+
1046+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
1047+# in the INCLUDE_PATH (see below) will be search if a #include is found.
1048+
1049+SEARCH_INCLUDES = YES
1050+
1051+# The INCLUDE_PATH tag can be used to specify one or more directories that
1052+# contain include files that are not input files but should be processed by
1053+# the preprocessor.
1054+
1055+INCLUDE_PATH =
1056+
1057+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
1058+# patterns (like *.h and *.hpp) to filter out the header-files in the
1059+# directories. If left blank, the patterns specified with FILE_PATTERNS will
1060+# be used.
1061+
1062+INCLUDE_FILE_PATTERNS =
1063+
1064+# The PREDEFINED tag can be used to specify one or more macro names that
1065+# are defined before the preprocessor is started (similar to the -D option of
1066+# gcc). The argument of the tag is a list of macros of the form: name
1067+# or name=definition (no spaces). If the definition and the = are
1068+# omitted =1 is assumed. To prevent a macro definition from being
1069+# undefined via #undef or recursively expanded use the := operator
1070+# instead of the = operator.
1071+
1072+PREDEFINED =
1073+
1074+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
1075+# this tag can be used to specify a list of macro names that should be expanded.
1076+# The macro definition that is found in the sources will be used.
1077+# Use the PREDEFINED tag if you want to use a different macro definition.
1078+
1079+EXPAND_AS_DEFINED =
1080+
1081+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
1082+# doxygen's preprocessor will remove all function-like macros that are alone
1083+# on a line, have an all uppercase name, and do not end with a semicolon. Such
1084+# function macros are typically used for boiler-plate code, and will confuse
1085+# the parser if not removed.
1086+
1087+SKIP_FUNCTION_MACROS = YES
1088+
1089+#---------------------------------------------------------------------------
1090+# Configuration::additions related to external references
1091+#---------------------------------------------------------------------------
1092+
1093+# The TAGFILES option can be used to specify one or more tagfiles.
1094+# Optionally an initial location of the external documentation
1095+# can be added for each tagfile. The format of a tag file without
1096+# this location is as follows:
1097+# TAGFILES = file1 file2 ...
1098+# Adding location for the tag files is done as follows:
1099+# TAGFILES = file1=loc1 "file2 = loc2" ...
1100+# where "loc1" and "loc2" can be relative or absolute paths or
1101+# URLs. If a location is present for each tag, the installdox tool
1102+# does not have to be run to correct the links.
1103+# Note that each tag file must have a unique name
1104+# (where the name does NOT include the path)
1105+# If a tag file is not located in the directory in which doxygen
1106+# is run, you must also specify the path to the tagfile here.
1107+
1108+TAGFILES =
1109+
1110+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
1111+# a tag file that is based on the input files it reads.
1112+
1113+GENERATE_TAGFILE = html/@PROJECT_NAME@.TAGFILE
1114+
1115+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
1116+# in the class index. If set to NO only the inherited external classes
1117+# will be listed.
1118+
1119+ALLEXTERNALS = YES
1120+
1121+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
1122+# in the modules index. If set to NO, only the current project's groups will
1123+# be listed.
1124+
1125+EXTERNAL_GROUPS = YES
1126+
1127+# The PERL_PATH should be the absolute path and name of the perl script
1128+# interpreter (i.e. the result of `which perl').
1129+
1130+PERL_PATH = /usr/bin/perl
1131+
1132+#---------------------------------------------------------------------------
1133+# Configuration options related to the dot tool
1134+#---------------------------------------------------------------------------
1135+
1136+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
1137+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
1138+# or super classes. Setting the tag to NO turns the diagrams off. Note that
1139+# this option is superseded by the HAVE_DOT option below. This is only a
1140+# fallback. It is recommended to install and use dot, since it yields more
1141+# powerful graphs.
1142+
1143+CLASS_DIAGRAMS = YES
1144+
1145+# If set to YES, the inheritance and collaboration graphs will hide
1146+# inheritance and usage relations if the target is undocumented
1147+# or is not a class.
1148+
1149+HIDE_UNDOC_RELATIONS = YES
1150+
1151+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
1152+# available from the path. This tool is part of Graphviz, a graph visualization
1153+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
1154+# have no effect if this option is set to NO (the default)
1155+
1156+HAVE_DOT = @DOXYGEN_DOT_FOUND@
1157+
1158+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
1159+# will generate a graph for each documented class showing the direct and
1160+# indirect inheritance relations. Setting this tag to YES will force the
1161+# the CLASS_DIAGRAMS tag to NO.
1162+
1163+CLASS_GRAPH = YES
1164+
1165+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
1166+# will generate a graph for each documented class showing the direct and
1167+# indirect implementation dependencies (inheritance, containment, and
1168+# class references variables) of the class with other documented classes.
1169+
1170+COLLABORATION_GRAPH = YES
1171+
1172+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
1173+# will generate a graph for groups, showing the direct groups dependencies
1174+
1175+GROUP_GRAPHS = YES
1176+
1177+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
1178+# collaboration diagrams in a style similar to the OMG's Unified Modeling
1179+# Language.
1180+
1181+UML_LOOK = NO
1182+# UML_LOOK = YES
1183+
1184+# If set to YES, the inheritance and collaboration graphs will show the
1185+# relations between templates and their instances.
1186+
1187+TEMPLATE_RELATIONS = YES
1188+
1189+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
1190+# tags are set to YES then doxygen will generate a graph for each documented
1191+# file showing the direct and indirect include dependencies of the file with
1192+# other documented files.
1193+
1194+INCLUDE_GRAPH = YES
1195+
1196+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
1197+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
1198+# documented header file showing the documented files that directly or
1199+# indirectly include this file.
1200+
1201+INCLUDED_BY_GRAPH = YES
1202+
1203+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
1204+# generate a call dependency graph for every global function or class method.
1205+# Note that enabling this option will significantly increase the time of a run.
1206+# So in most cases it will be better to enable call graphs for selected
1207+# functions only using the \callgraph command.
1208+
1209+CALL_GRAPH = NO
1210+
1211+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
1212+# will graphical hierarchy of all classes instead of a textual one.
1213+
1214+GRAPHICAL_HIERARCHY = YES
1215+
1216+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
1217+# then doxygen will show the dependencies a directory has on other directories
1218+# in a graphical way. The dependency relations are determined by the #include
1219+# relations between the files in the directories.
1220+
1221+DIRECTORY_GRAPH = YES
1222+
1223+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
1224+# generated by dot. Possible values are png, jpg, or gif
1225+# If left blank png will be used.
1226+
1227+DOT_IMAGE_FORMAT = png
1228+
1229+# The tag DOT_PATH can be used to specify the path where the dot tool can be
1230+# found. If left blank, it is assumed the dot tool can be found in the path.
1231+
1232+DOT_PATH = @DOXYGEN_DOT_EXECUTABLE_PATH@
1233+
1234+# The DOTFILE_DIRS tag can be used to specify one or more directories that
1235+# contain dot files that are included in the documentation (see the
1236+# \dotfile command).
1237+
1238+DOTFILE_DIRS =
1239+
1240+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
1241+# background. This is disabled by default, which results in a white background.
1242+# Warning: Depending on the platform used, enabling this option may lead to
1243+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
1244+# read).
1245+
1246+DOT_TRANSPARENT = NO
1247+
1248+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
1249+# files in one run (i.e. multiple -o and -T options on the command line). This
1250+# makes dot run faster, but since only newer versions of dot (>1.8.10)
1251+# support this, this feature is disabled by default.
1252+# JW
1253+# DOT_MULTI_TARGETS = NO
1254+DOT_MULTI_TARGETS = YES
1255+
1256+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
1257+# generate a legend page explaining the meaning of the various boxes and
1258+# arrows in the dot generated graphs.
1259+
1260+GENERATE_LEGEND = YES
1261+
1262+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
1263+# remove the intermediate dot files that are used to generate
1264+# the various graphs.
1265+
1266+DOT_CLEANUP = YES
1267+
1268+#---------------------------------------------------------------------------
1269+# Configuration::additions related to the search engine
1270+#---------------------------------------------------------------------------
1271+
1272+# The SEARCHENGINE tag specifies whether or not a search engine should be
1273+# used. If set to NO the values of all tags below this one will be ignored.
1274+
1275+# JW SEARCHENGINE = NO
1276+SEARCHENGINE = YES
1277
1278=== added directory 'doc/xqj/manual'
1279=== added file 'doc/xqj/manual/indexpage.dox'
1280--- doc/xqj/manual/indexpage.dox 1970-01-01 00:00:00 +0000
1281+++ doc/xqj/manual/indexpage.dox 2012-04-19 22:34:19 +0000
1282@@ -0,0 +1,18 @@
1283+/*! \mainpage XQJ API Documentation
1284+
1285+ Zorba ships with a XQJ binding that provides basic features in order to prepare and execute queries
1286+ with Zorba.
1287+
1288+ For the moment, we provide a <a class="en" href="examples.html">TCK set</a> that show how this language binding can be used.
1289+
1290+ \section note Note for garbage collected languages
1291+ Zorba requires that objects must be deleted in a certain order, which Garbage Collectors are not aware of. For that reason,
1292+ the Iterators created with XQuery.iterator() must be explicitly deleted with iterator.delete() before the XQuery
1293+ object is deleted.
1294+
1295+
1296+ \example Test_Zorba.java
1297+ This is a simple example that demonstrate how to use the Zorba XQuery Engine to
1298+ create, compile, and execute queries.
1299+ */
1300+
1301
1302=== modified file 'src/context/dynamic_loader.cpp'
1303--- src/context/dynamic_loader.cpp 2012-04-17 15:35:48 +0000
1304+++ src/context/dynamic_loader.cpp 2012-04-19 22:34:19 +0000
1305@@ -180,7 +180,7 @@
1306 ExternalModule* (*createModuleFunction)() = NULL;
1307
1308 #ifdef WIN32
1309- createModule = (ExternalModule* (*)())GetProcAddress(handle, "createModule");
1310+ createModuleFunction = (ExternalModule* (*)())GetProcAddress(handle, "createModule");
1311 if (createModuleFunction == NULL)
1312 throw ZORBA_EXCEPTION(
1313 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
1314
1315=== modified file 'swig/CMakeLists.txt'
1316--- swig/CMakeLists.txt 2012-04-16 20:56:43 +0000
1317+++ swig/CMakeLists.txt 2012-04-19 22:34:19 +0000
1318@@ -36,6 +36,7 @@
1319 ADD_SUBDIRECTORY (python)
1320 ADD_SUBDIRECTORY (php)
1321 ADD_SUBDIRECTORY (java)
1322+ ADD_SUBDIRECTORY (xqj)
1323
1324 IF (APPLE AND UNIVERSAL)
1325 MESSAGE (STATUS "Ruby module can't be built Universal")
1326
1327=== modified file 'swig/Item.h'
1328--- swig/Item.h 2012-03-27 00:56:11 +0000
1329+++ swig/Item.h 2012-04-19 22:34:19 +0000
1330@@ -49,6 +49,9 @@
1331 long long getLongValue () const;
1332 std::string getLocalName () const;
1333 std::string getNamespace () const;
1334+
1335+ std::vector< std::pair< std::string, std::string > > getNamespaceBindings ();
1336+
1337 bool getNodeName (Item &aNodeName) const;
1338 Item getParent () const;
1339 std::string getPrefix () const;
1340
1341=== modified file 'swig/Item.i'
1342--- swig/Item.i 2012-03-27 00:56:11 +0000
1343+++ swig/Item.i 2012-04-19 22:34:19 +0000
1344@@ -72,6 +72,20 @@
1345 std::string Item::getNamespace () const
1346 { return std::string(theItem.getNamespace().c_str()); }
1347
1348+ std::vector< std::pair< std::string, std::string > > Item::getNamespaceBindings () {
1349+ std::vector< std::pair< zorba::String, zorba::String > > items;
1350+ std::vector< std::pair< std::string, std::string > > result;
1351+ theItem.getNamespaceBindings(items);
1352+ std::vector< std::pair< zorba::String, zorba::String > >::iterator iter;
1353+ for(iter = items.begin(); iter != items.end(); iter++) {
1354+ std::pair< std::string, std::string > pair;
1355+ pair.first = (*iter).first.c_str();
1356+ pair.second = (*iter).second.c_str();
1357+ result.push_back(pair);
1358+ }
1359+ return result;
1360+ }
1361+
1362 bool Item::getNodeName (Item &aNodeName) const
1363 { return theItem.getNodeName( aNodeName.theItem ); }
1364
1365
1366=== modified file 'swig/Zorba.h'
1367--- swig/Zorba.h 2012-04-18 03:47:08 +0000
1368+++ swig/Zorba.h 2012-04-19 22:34:19 +0000
1369@@ -44,6 +44,7 @@
1370 int getMajorVersion();
1371 int getMinorVersion();
1372 int getPatchVersion();
1373+ bool isXQueryXSupported();
1374
1375 }; // class Zorba
1376
1377
1378=== modified file 'swig/Zorba.i'
1379--- swig/Zorba.i 2012-04-18 15:10:14 +0000
1380+++ swig/Zorba.i 2012-04-19 22:34:19 +0000
1381@@ -124,6 +124,13 @@
1382 int Zorba::getPatchVersion() {
1383 return zorba::Zorba::version().getPatchVersion();
1384 }
1385+ bool Zorba::isXQueryXSupported() {
1386+ #ifdef ZORBA_XQUERYX
1387+ return true;
1388+ #else //ZORBA_XQUERYX
1389+ return false;
1390+ #endif //ZORBA_XQUERYX
1391+ }
1392
1393 %} // end Implementation
1394
1395
1396=== added directory 'swig/xqj'
1397=== added file 'swig/xqj/CMakeLists.txt'
1398--- swig/xqj/CMakeLists.txt 1970-01-01 00:00:00 +0000
1399+++ swig/xqj/CMakeLists.txt 2012-04-19 22:34:19 +0000
1400@@ -0,0 +1,76 @@
1401+# Copyright 2006-2008 The FLWOR Foundation.n
1402+#
1403+# Licensed under the Apache License, Version 2.0 (the "License");
1404+# you may not use this file except in compliance with the License.
1405+# You may obtain a copy of the License at
1406+#
1407+# http://www.apache.org/licenses/LICENSE-2.0
1408+#
1409+# Unless required by applicable law or agreed to in writing, software
1410+# distributed under the License is distributed on an "AS IS" BASIS,
1411+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1412+# See the License for the specific language governing permissions and
1413+# limitations under the License.
1414+
1415+FIND_PACKAGE ( Java )
1416+INCLUDE ( ${CMAKE_SOURCE_DIR}/cmake_modules/FindJNI.cmake )
1417+
1418+STRING ( COMPARE NOTEQUAL ${JAVA_INCLUDE_PATH} "JAVA_INCLUDE_PATH-NOTFOUND" JNI_FOUND )
1419+
1420+IF (JAVA_INCLUDE_PATH)
1421+ INCLUDE (CMakeJavaInformation )
1422+ MESSAGE(STATUS "SWIG Java: Generating XQJ API")
1423+
1424+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQConnection.java" "${CMAKE_CURRENT_BINARY_DIR}/XQConnection.java")
1425+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQDataSource.java" "${CMAKE_CURRENT_BINARY_DIR}/XQDataSource.java")
1426+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQExpression.java" "${CMAKE_CURRENT_BINARY_DIR}/XQExpression.java")
1427+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQItem.java" "${CMAKE_CURRENT_BINARY_DIR}/XQItem.java")
1428+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQItemType.java" "${CMAKE_CURRENT_BINARY_DIR}/XQItemType.java")
1429+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQMetaData.java" "${CMAKE_CURRENT_BINARY_DIR}/XQMetaData.java")
1430+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQPreparedExpression.java" "${CMAKE_CURRENT_BINARY_DIR}/XQPreparedExpression.java")
1431+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQResultItem.java" "${CMAKE_CURRENT_BINARY_DIR}/XQResultItem.java")
1432+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQResultSequence.java" "${CMAKE_CURRENT_BINARY_DIR}/XQResultSequence.java")
1433+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQResultSequenceScrollable.java" "${CMAKE_CURRENT_BINARY_DIR}/XQResultSequenceScrollable.java")
1434+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQSequence.java" "${CMAKE_CURRENT_BINARY_DIR}/XQSequence.java")
1435+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQSequenceType.java" "${CMAKE_CURRENT_BINARY_DIR}/XQSequenceType.java")
1436+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQStaticContext.java" "${CMAKE_CURRENT_BINARY_DIR}/XQStaticContext.java")
1437+
1438+ MESSAGE(STATUS "SWIG Java: Generating XQJ TCK Tests")
1439+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/junit-4.9.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/junit-4.9.jar" COPYONLY)
1440+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/xqjapi.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjapi.jar" COPYONLY)
1441+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/xqjtck.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjtck.jar" COPYONLY)
1442+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/zorba.properties" "${CMAKE_CURRENT_BINARY_DIR}/tck/zorba.properties" COPYONLY)
1443+
1444+ SET (XQJ_LOAD_PATH "${CMAKE_BINARY_DIR}/swig/xqj")
1445+ SET (JAVA_LOAD_PATH "${CMAKE_BINARY_DIR}/swig/java")
1446+
1447+ MESSAGE (STATUS "Path for XQJ tests ${XQJ_LOAD_PATH}/tck")
1448+ IF(WIN32)
1449+ #Convert to backslashes for windows
1450+ STRING(REGEX REPLACE "/" "\\\\" XQJ_LOAD_PATH ${XQJ_LOAD_PATH})
1451+ STRING(REGEX REPLACE "/" "\\\\" JAVA_LOAD_PATH ${JAVA_LOAD_PATH})
1452+ MESSAGE (STATUS "Copying tck batch...")
1453+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/tck/xqj_test.bat.in ${CMAKE_CURRENT_BINARY_DIR}/xqj_test.bat)
1454+ ADD_TEST ("swig_xqj" xqj_test.bat)
1455+ SET_TESTS_PROPERTIES("swig_xqj" PROPERTIES PASS_REGULAR_EXPRESSION "254 tests")
1456+ ELSE(WIN32)
1457+ MESSAGE (STATUS "Copying tck batch...")
1458+ IF (NOT DEFINED Java_JAVA_EXECUTABLE)
1459+ SET(Java_JAVA_EXECUTABLE ${JAVA_RUNTIME})
1460+ SET(Java_JAR_EXECUTABLE ${JAVA_ARCHIVE})
1461+ SET(Java_JAVAC_EXECUTABLE ${JAVA_COMPILE})
1462+ ENDIF (NOT DEFINED Java_JAVA_EXECUTABLE)
1463+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/tck/xqj_test.sh.in ${CMAKE_CURRENT_BINARY_DIR}/xqj_test.sh)
1464+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/xqj_test.sh")
1465+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/junit-4.9.jar")
1466+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjapi.jar")
1467+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjtck.jar")
1468+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/zorba.properties")
1469+ ADD_TEST ("swig_xqj" xqj_test.sh)
1470+ SET_TESTS_PROPERTIES("swig_xqj" PROPERTIES PASS_REGULAR_EXPRESSION "254 tests")
1471+ ENDIF(WIN32)
1472+
1473+
1474+ELSE (JAVA_INCLUDE_PATH)
1475+ MESSAGE ( STATUS "SWIG Java: Not generating XQJ API because JNI headers not found.")
1476+ENDIF (JAVA_INCLUDE_PATH)
1477\ No newline at end of file
1478
1479=== added file 'swig/xqj/XQConnection.java'
1480--- swig/xqj/XQConnection.java 1970-01-01 00:00:00 +0000
1481+++ swig/xqj/XQConnection.java 2012-04-19 22:34:19 +0000
1482@@ -0,0 +1,1446 @@
1483+/*
1484+ * Copyright 2006-2012 The FLWOR Foundation.
1485+ *
1486+ * Licensed under the Apache License, Version 2.0 (the "License");
1487+ * you may not use this file except in compliance with the License.
1488+ * You may obtain a copy of the License at
1489+ *
1490+ * http://www.apache.org/licenses/LICENSE-2.0
1491+ *
1492+ * Unless required by applicable law or agreed to in writing, software
1493+ * distributed under the License is distributed on an "AS IS" BASIS,
1494+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1495+ * See the License for the specific language governing permissions and
1496+ * limitations under the License.
1497+ */
1498+package org.zorbaxquery.api.xqj;
1499+
1500+import java.io.IOException;
1501+import java.io.InputStream;
1502+import java.io.Reader;
1503+import java.io.StringWriter;
1504+import java.io.Writer;
1505+import java.math.BigDecimal;
1506+import java.math.BigInteger;
1507+import java.net.URI;
1508+import java.util.Iterator;
1509+import java.nio.CharBuffer;
1510+import java.util.ArrayList;
1511+import java.util.Collection;
1512+import java.util.Properties;
1513+import javax.xml.datatype.DatatypeConstants;
1514+import javax.xml.datatype.Duration;
1515+import javax.xml.datatype.XMLGregorianCalendar;
1516+import javax.xml.namespace.QName;
1517+import javax.xml.stream.XMLOutputFactory;
1518+import javax.xml.stream.XMLStreamReader;
1519+import javax.xml.stream.XMLStreamWriter;
1520+import javax.xml.transform.OutputKeys;
1521+import javax.xml.transform.Source;
1522+import javax.xml.transform.Transformer;
1523+import javax.xml.transform.TransformerException;
1524+import javax.xml.transform.TransformerFactory;
1525+import javax.xml.transform.dom.DOMSource;
1526+import javax.xml.transform.sax.SAXSource;
1527+import javax.xml.transform.stax.StAXResult;
1528+import javax.xml.transform.stax.StAXSource;
1529+import javax.xml.transform.stream.StreamResult;
1530+import javax.xml.transform.stream.StreamSource;
1531+import javax.xml.xquery.XQException;
1532+import javax.xml.xquery.XQExpression;
1533+import javax.xml.xquery.XQItem;
1534+import javax.xml.xquery.XQItemType;
1535+import javax.xml.xquery.XQMetaData;
1536+import javax.xml.xquery.XQPreparedExpression;
1537+import javax.xml.xquery.XQSequence;
1538+import javax.xml.xquery.XQSequenceType;
1539+import javax.xml.xquery.XQStaticContext;
1540+import org.w3c.dom.Attr;
1541+import org.w3c.dom.Comment;
1542+import org.w3c.dom.Document;
1543+import org.w3c.dom.DocumentFragment;
1544+import org.w3c.dom.Element;
1545+import org.w3c.dom.Node;
1546+import org.w3c.dom.ProcessingInstruction;
1547+import org.w3c.dom.Text;
1548+import org.zorbaxquery.api.InMemoryStore;
1549+import org.zorbaxquery.api.Item;
1550+import org.zorbaxquery.api.ItemFactory;
1551+import org.zorbaxquery.api.StringVector;
1552+import org.zorbaxquery.api.XmlDataManager;
1553+import org.zorbaxquery.api.Zorba;
1554+
1555+public class XQConnection implements javax.xml.xquery.XQConnection {
1556+ private InMemoryStore store;
1557+ private Zorba zorba;
1558+ private boolean autocommit;
1559+ private boolean closed;
1560+ private Collection<XQExpression> cExpression;
1561+ private Collection<XQPreparedExpression> cPreparedExpression;
1562+ private Collection<XQMetaData> cMetadata;
1563+ private XQStaticContext lStaticContext;
1564+ private Properties properties;
1565+ private StringVector uriPaths;
1566+ private StringVector libPaths;
1567+ private StringVector modulePaths;
1568+
1569+ //TODO: Rodolfo ALL CASES should return an exception("Not implemented yet")
1570+ protected Zorba getZorbaInstance() throws XQException {
1571+ if (zorba!=null) {
1572+ return zorba;
1573+ } else {
1574+ throw new XQException("Error returning Zorba Instance");
1575+ }
1576+ }
1577+ public XQConnection() {
1578+ cExpression = new ArrayList<XQExpression>();
1579+ cPreparedExpression = new ArrayList<XQPreparedExpression>();
1580+ store = InMemoryStore.getInstance();
1581+ zorba = Zorba.getInstance ( store );
1582+ autocommit = true;
1583+ closed = false;
1584+ }
1585+ public XQConnection(Properties aProperties) {
1586+ cExpression = new ArrayList<XQExpression>();
1587+ cPreparedExpression = new ArrayList<XQPreparedExpression>();
1588+ store = InMemoryStore.getInstance();
1589+ zorba = Zorba.getInstance ( store );
1590+ autocommit = true;
1591+ closed = false;
1592+ properties = aProperties;
1593+ for (String prop :properties.stringPropertyNames()) {
1594+ if (prop.equalsIgnoreCase(XQDataSource.ZORBA_PROPERTIES_URI_PATHS)) {
1595+ String[] paths = properties.getProperty(prop).split("[;,]");
1596+ uriPaths = new StringVector();
1597+ for (String path: paths) {
1598+ uriPaths.add(path);
1599+ }
1600+ }
1601+ if (prop.equalsIgnoreCase(XQDataSource.ZORBA_PROPERTIES_LIB_PATHS)) {
1602+ String[] paths = properties.getProperty(prop).split("[;,]");
1603+ libPaths = new StringVector();
1604+ for (String path: paths) {
1605+ libPaths.add(path);
1606+ }
1607+ }
1608+ if (prop.equalsIgnoreCase(XQDataSource.ZORBA_PROPERTIES_MODULE_PATHS)) {
1609+ String[] paths = properties.getProperty(prop).split("[;,]");
1610+ modulePaths = new StringVector();
1611+ for (String path: paths) {
1612+ modulePaths.add(path);
1613+ }
1614+ }
1615+ }
1616+ lStaticContext = new org.zorbaxquery.api.xqj.XQStaticContext(zorba);
1617+ if (uriPaths!=null) {
1618+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setURIPaths(uriPaths);
1619+ }
1620+ if (libPaths!=null) {
1621+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setLIBPaths(libPaths);
1622+ }
1623+ if (modulePaths!=null) {
1624+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setMODPaths(modulePaths);
1625+ }
1626+
1627+ }
1628+
1629+
1630+ @Override
1631+ public void close() throws XQException {
1632+ if (closed) return; // already closed
1633+ try {
1634+ for (XQExpression exp : cExpression ){
1635+ exp.close(); // Notify the dependents objects to close
1636+ }
1637+ for (XQPreparedExpression exp : cPreparedExpression ){
1638+ exp.close(); // Notify the dependents objects to close
1639+ }
1640+ } catch (XQException e) {
1641+ throw new XQException("Error closing connection: " + e.getLocalizedMessage());
1642+ }
1643+
1644+ if (lStaticContext != null ) {
1645+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).getZorbaStaticContext().destroy();
1646+ }
1647+ zorba.shutdown();
1648+ InMemoryStore.shutdown ( store );
1649+ closed = true;
1650+ }
1651+
1652+ @Override
1653+ public void setAutoCommit(boolean bln) throws XQException {
1654+ isClosedXQException();
1655+ autocommit = bln;
1656+ }
1657+
1658+ @Override
1659+ public boolean getAutoCommit() throws XQException {
1660+ isClosedXQException();
1661+ return autocommit;
1662+ }
1663+
1664+ @Override
1665+ public void commit() throws XQException {
1666+ isClosedXQException();
1667+ throw new UnsupportedOperationException("Zorba does not support transactions... yet...");
1668+ /*
1669+ if (!autocommit) {
1670+ try {
1671+ query.execute();
1672+ } catch (Exception e) {
1673+ throw new XQException("Error executing query");
1674+ }
1675+ } else {
1676+ throw new XQException("Autocommit was specified");
1677+ }
1678+
1679+ */
1680+ }
1681+
1682+ @Override
1683+ public XQExpression createExpression() throws XQException {
1684+ isClosedXQException();
1685+ XQExpression expression;
1686+ if (lStaticContext == null) {
1687+ expression = new org.zorbaxquery.api.xqj.XQExpression(this);
1688+ } else {
1689+ expression = new org.zorbaxquery.api.xqj.XQExpression(this, lStaticContext);
1690+ }
1691+ cExpression.add(expression);
1692+ return expression;
1693+ }
1694+
1695+ @Override
1696+ public XQExpression createExpression(XQStaticContext value) throws XQException {
1697+ isClosedXQException();
1698+ isNullXQException(value);
1699+ XQExpression expression = new org.zorbaxquery.api.xqj.XQExpression(this, value);
1700+ cExpression.add(expression);
1701+ return expression;
1702+ }
1703+
1704+ @Override
1705+ public XQMetaData getMetaData() throws XQException {
1706+ isClosedXQException();
1707+ return new org.zorbaxquery.api.xqj.XQMetaData(this);
1708+ }
1709+
1710+ @Override
1711+ public boolean isClosed() {
1712+ return closed;
1713+ }
1714+
1715+ @Override
1716+ public XQPreparedExpression prepareExpression(String value) throws XQException {
1717+ isClosedXQException();
1718+ isNullXQException(value);
1719+ XQPreparedExpression expression;
1720+ try {
1721+ if (lStaticContext == null) {
1722+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, value);
1723+ } else {
1724+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, value, lStaticContext);
1725+ }
1726+ cPreparedExpression.add(expression);
1727+ } catch (Exception e) {
1728+ throw new XQException("Error preparing expression: "+e.getLocalizedMessage());
1729+ }
1730+ return expression;
1731+ }
1732+
1733+ @Override
1734+ public XQPreparedExpression prepareExpression(String string, XQStaticContext xqsc) throws XQException {
1735+ isClosedXQException();
1736+ isNullXQException(string);
1737+ isNullXQException(xqsc);
1738+ XQPreparedExpression expression = null;
1739+ try {
1740+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, string, xqsc);
1741+ cPreparedExpression.add(expression);
1742+ } catch (Exception e) {
1743+ throw new XQException("Error preparing expression");
1744+ }
1745+ return expression;
1746+ }
1747+
1748+ @Override
1749+ public XQPreparedExpression prepareExpression(Reader reader) throws XQException {
1750+ isClosedXQException();
1751+ isNullXQException(reader);
1752+
1753+ StringBuffer string = new StringBuffer();
1754+ CharBuffer buffer = CharBuffer.allocate(1024);
1755+ Writer writer = new StringWriter();
1756+
1757+ try {
1758+ while( reader.read(buffer) >= 0 ) {
1759+ buffer.flip();
1760+ writer.append(buffer);
1761+ buffer.clear();
1762+ }
1763+ reader.close();
1764+ } catch (Exception ex) {
1765+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1766+ }
1767+
1768+ XQPreparedExpression expression;
1769+ if (lStaticContext == null) {
1770+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, writer.toString());
1771+ } else {
1772+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, writer.toString(), lStaticContext);
1773+ }
1774+ cPreparedExpression.add(expression);
1775+ return expression;
1776+ }
1777+
1778+ @Override
1779+ public XQPreparedExpression prepareExpression(Reader reader, XQStaticContext xqsc) throws XQException {
1780+ isClosedXQException();
1781+ isNullXQException(reader);
1782+ isNullXQException(xqsc);
1783+ StringBuffer string = new StringBuffer();
1784+ CharBuffer buffer = CharBuffer.allocate(1024);
1785+ Writer writer = new StringWriter();
1786+ try {
1787+ while( reader.read(buffer) >= 0 ) {
1788+ buffer.flip();
1789+ writer.append(buffer);
1790+ buffer.clear();
1791+ }
1792+ reader.close();
1793+ } catch (Exception ex) {
1794+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1795+ }
1796+
1797+ XQPreparedExpression expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, writer.toString(), xqsc);
1798+
1799+ cPreparedExpression.add(expression);
1800+ return expression;
1801+ }
1802+
1803+ @Override
1804+ public XQPreparedExpression prepareExpression(InputStream in) throws XQException {
1805+ isClosedXQException();
1806+ isNullXQException(in);
1807+ StringBuffer out = new StringBuffer ();
1808+ try {
1809+ byte[] b = new byte[4096];
1810+ for (int n; (n = in.read(b)) != -1;) {
1811+ out.append(new String(b, 0, n));
1812+ }
1813+ } catch (Exception ex) {
1814+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1815+ }
1816+
1817+ XQPreparedExpression expression;
1818+ if (lStaticContext == null) {
1819+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, out.toString());
1820+ } else {
1821+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, out.toString(), lStaticContext);
1822+ }
1823+ try {
1824+ cPreparedExpression.add(expression);
1825+ } catch (Exception ex) {
1826+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1827+ }
1828+
1829+ return expression;
1830+ }
1831+
1832+ @Override
1833+ public XQPreparedExpression prepareExpression(InputStream in, XQStaticContext xqsc) throws XQException {
1834+ isClosedXQException();
1835+ isNullXQException(in);
1836+ isNullXQException(xqsc);
1837+ StringBuffer out = new StringBuffer ();
1838+ try {
1839+ byte[] b = new byte[4096];
1840+ for (int n; (n = in.read(b)) != -1;) {
1841+ out.append(new String(b, 0, n));
1842+ }
1843+ } catch (IOException ex) {
1844+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1845+ }
1846+
1847+ XQPreparedExpression expression = null;
1848+ try {
1849+ expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, out.toString(), xqsc);
1850+ cPreparedExpression.add(expression);
1851+ } catch (Exception ex) {
1852+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1853+ }
1854+ return expression;
1855+ }
1856+
1857+ @Override
1858+ public void rollback() throws XQException {
1859+ throw new UnsupportedOperationException("Zorba does not support transactions... yet...");
1860+ }
1861+
1862+ @Override
1863+ public XQStaticContext getStaticContext() throws XQException {
1864+ isClosedXQException();
1865+ lStaticContext = new org.zorbaxquery.api.xqj.XQStaticContext(zorba);
1866+ if (uriPaths!=null) {
1867+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setURIPaths(uriPaths);
1868+ }
1869+ if (libPaths!=null) {
1870+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setLIBPaths(libPaths);
1871+ }
1872+ if (modulePaths!=null) {
1873+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setMODPaths(modulePaths);
1874+ }
1875+ return lStaticContext;
1876+ }
1877+
1878+ @Override
1879+ public void setStaticContext(XQStaticContext xqsc) throws XQException {
1880+ isClosedXQException();
1881+ isNullXQException(xqsc);
1882+ if ((lStaticContext!=null) && (lStaticContext!=xqsc)) { // delete previous static context
1883+ ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).getZorbaStaticContext().delete();
1884+ }
1885+ lStaticContext = xqsc;
1886+ }
1887+
1888+ @Override
1889+ public XQItem createItemFromAtomicValue(String value, XQItemType type) throws XQException {
1890+ isClosedXQException();
1891+ isNullXQException(value);
1892+ isNullXQException(type);
1893+ if (type.getItemKind()!=XQItemType.XQITEMKIND_ATOMIC) {
1894+ throw new XQException("ItemType is not Atomic");
1895+ }
1896+ XQItem item = null;
1897+ try {
1898+ item = this.createItemFromString(value, type);
1899+ } catch (Exception e) {
1900+ throw new XQException("Error creating item of this type " + e.getLocalizedMessage());
1901+ }
1902+ return item;
1903+ }
1904+
1905+ @Override
1906+ public XQItem createItemFromString(String value, XQItemType type) throws XQException {
1907+ isClosedXQException();
1908+ isNullXQException(value);
1909+ if (type==null) {
1910+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_STRING);
1911+ }
1912+ ItemFactory itemFactory = zorba.getItemFactory();
1913+ XQItem item = null;
1914+ try {
1915+ switch (type.getBaseType()) {
1916+ case XQItemType.XQBASETYPE_BOOLEAN:
1917+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBoolean(Boolean.parseBoolean(value)), type);
1918+ break;
1919+ case XQItemType.XQBASETYPE_ANYURI:
1920+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createAnyURI(value), type);
1921+ break;
1922+ case XQItemType.XQBASETYPE_BASE64BINARY:
1923+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBase64Binary(value, value.length()), type);
1924+ break;
1925+ case XQItemType.XQBASETYPE_BYTE:
1926+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte(value.charAt(0)), type);
1927+ break;
1928+ case XQItemType.XQBASETYPE_DATE:
1929+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDate(value), type);
1930+ break;
1931+ case XQItemType.XQBASETYPE_DATETIME:
1932+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDateTime(value), type);
1933+ break;
1934+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
1935+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value), type);
1936+ break;
1937+ case XQItemType.XQBASETYPE_DECIMAL:
1938+ BigDecimal dec = new BigDecimal(value);
1939+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimal(value), type);
1940+ break;
1941+ case XQItemType.XQBASETYPE_DOUBLE:
1942+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDouble(Double.parseDouble(value)), type);
1943+ break;
1944+ case XQItemType.XQBASETYPE_DURATION:
1945+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value), type);
1946+ break;
1947+ case XQItemType.XQBASETYPE_FLOAT:
1948+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createFloat(value), type);
1949+ break;
1950+ case XQItemType.XQBASETYPE_GDAY:
1951+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGDay(value), type);
1952+ break;
1953+ case XQItemType.XQBASETYPE_GMONTH:
1954+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonth(value), type);
1955+ break;
1956+ case XQItemType.XQBASETYPE_GMONTHDAY:
1957+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonthDay(value), type);
1958+ break;
1959+ case XQItemType.XQBASETYPE_GYEAR:
1960+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYear(value), type);
1961+ break;
1962+ case XQItemType.XQBASETYPE_GYEARMONTH:
1963+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYearMonth(value), type);
1964+ break;
1965+ case XQItemType.XQBASETYPE_HEXBINARY:
1966+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createHexBinary(value, value.length()), type);
1967+ break;
1968+ case XQItemType.XQBASETYPE_INT:
1969+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInt(Integer.parseInt(value)), type);
1970+ break;
1971+ case XQItemType.XQBASETYPE_INTEGER:
1972+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(Integer.parseInt(value)), type);
1973+ break;
1974+ case XQItemType.XQBASETYPE_LONG:
1975+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createLong(Long.parseLong(value)), type);
1976+ break;
1977+ case XQItemType.XQBASETYPE_NCNAME:
1978+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNCName(value), type);
1979+ break;
1980+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
1981+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNegativeInteger(Long.parseLong(value)), type);
1982+ break;
1983+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
1984+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonNegativeInteger(new BigInteger(value)), type);
1985+ break;
1986+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
1987+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonPositiveInteger(Long.parseLong(value)), type);
1988+ break;
1989+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
1990+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createPositiveInteger(new BigInteger(value)), type);
1991+ break;
1992+ case XQItemType.XQBASETYPE_QNAME:
1993+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName(value), type);
1994+ break;
1995+ case XQItemType.XQBASETYPE_SHORT:
1996+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort(Short.parseShort(value)), type);
1997+ break;
1998+ case XQItemType.XQBASETYPE_STRING:
1999+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createString(value), type);
2000+ break;
2001+ case XQItemType.XQBASETYPE_TIME:
2002+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createTime(value), type);
2003+ break;
2004+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
2005+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedByte(Short.parseShort(value)), type);
2006+ break;
2007+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
2008+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedInt(Long.parseLong(value)), type);
2009+ break;
2010+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
2011+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedLong(new BigInteger(value)), type);
2012+ break;
2013+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
2014+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedShort(Integer.parseInt(value)), type);
2015+ break;
2016+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
2017+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value), type);
2018+ break;
2019+ // TODO: revisit this posibilities
2020+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
2021+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
2022+ case XQItemType.XQBASETYPE_ENTITY:
2023+ case XQItemType.XQBASETYPE_ENTITIES:
2024+ case XQItemType.XQBASETYPE_ANYTYPE:
2025+ case XQItemType.XQBASETYPE_LANGUAGE:
2026+ case XQItemType.XQBASETYPE_ID:
2027+ case XQItemType.XQBASETYPE_IDREF:
2028+ case XQItemType.XQBASETYPE_IDREFS:
2029+ case XQItemType.XQBASETYPE_NAME:
2030+ case XQItemType.XQBASETYPE_NMTOKEN:
2031+ case XQItemType.XQBASETYPE_NMTOKENS:
2032+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
2033+ case XQItemType.XQBASETYPE_NOTATION:
2034+ case XQItemType.XQBASETYPE_TOKEN:
2035+ case XQItemType.XQBASETYPE_UNTYPED:
2036+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
2037+ throw new UnsupportedOperationException("Not supported yet.");
2038+ default:
2039+
2040+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createString(value), type);
2041+ break;
2042+ }
2043+ } catch (Exception e) {
2044+ throw new XQException ("Error parsing value" + e.getLocalizedMessage());
2045+ }
2046+ return item;
2047+ }
2048+
2049+ @Override
2050+ public XQItem createItemFromDocument(String value, String baseURI, XQItemType type) throws XQException {
2051+ isClosedXQException();
2052+ isNullXQException(value);
2053+ if (type!=null) {
2054+ if ( ! ((type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_ELEMENT)||(type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT)) ) {
2055+ throw new XQException("Invalid type");
2056+ }
2057+ } else {
2058+ type = this.createElementType(null, XQItemType.XQBASETYPE_UNTYPED);
2059+ }
2060+
2061+ XmlDataManager dm = null;
2062+ Item doc = null;
2063+ XQItem item = null;
2064+ try {
2065+ dm = zorba.getXmlDataManager();
2066+ doc = new Item();
2067+ org.zorbaxquery.api.Iterator iterator = dm.parseXML(value);
2068+ iterator.open();
2069+ iterator.next(doc);
2070+ iterator.close();
2071+ iterator.delete();
2072+ item = new org.zorbaxquery.api.xqj.XQItem(doc);
2073+ } catch (Exception e) {
2074+ throw new XQException("Error creating Item" + e.getLocalizedMessage());
2075+ }
2076+ return item;
2077+ }
2078+
2079+ @Override
2080+ public XQItem createItemFromDocument(Reader value, String baseURI, XQItemType type) throws XQException {
2081+ isClosedXQException();
2082+ isNullXQException(value);
2083+
2084+ StringBuffer string = new StringBuffer();
2085+ CharBuffer buffer = CharBuffer.allocate(1024);
2086+ Writer writer = new StringWriter();
2087+
2088+ try {
2089+ while( value.read(buffer) >= 0 ) {
2090+ buffer.flip();
2091+ writer.append(buffer);
2092+ buffer.clear();
2093+ }
2094+ value.close();
2095+ } catch (Exception ex) {
2096+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
2097+ }
2098+
2099+ XQItem item = createItemFromDocument(writer.toString(), baseURI, type);
2100+ return item;
2101+ }
2102+
2103+ @Override
2104+ public XQItem createItemFromDocument(InputStream value, String baseURI, XQItemType type) throws XQException {
2105+ isClosedXQException();
2106+ isNullXQException(value);
2107+ // TODO: Rodolfo: optimize this, not good to have a string
2108+ StringBuffer out = new StringBuffer ();
2109+ try {
2110+ byte[] b = new byte[4096];
2111+ for (int n; (n = value.read(b)) != -1;) {
2112+ out.append(new String(b, 0, n));
2113+ }
2114+ } catch (Exception ex) {
2115+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
2116+ }
2117+ XQItem item = createItemFromDocument(out.toString(), baseURI, type);
2118+ return item;
2119+ }
2120+
2121+ @Override
2122+ public XQItem createItemFromDocument(XMLStreamReader value, XQItemType type) throws XQException {
2123+ isClosedXQException();
2124+ isNullXQException(value);
2125+ TransformerFactory tf = TransformerFactory.newInstance();
2126+ Transformer t;
2127+ StAXSource source;
2128+ StAXResult result;
2129+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
2130+ Writer writer = new StringWriter();
2131+ try {
2132+ XMLStreamWriter xmlStreamWriter = xof.createXMLStreamWriter(writer);
2133+ t = tf.newTransformer();
2134+ source = new StAXSource(value);
2135+ result = new StAXResult(xmlStreamWriter);
2136+ t.transform(source, result);
2137+ } catch (Exception ex) {
2138+ throw new XQException("Error transforming xml expression" + ex.getLocalizedMessage());
2139+ }
2140+ XQItem item = createItemFromDocument(writer.toString(), "", type);
2141+ return item;
2142+ }
2143+
2144+ private String nodeToString(Node node) {
2145+ StringWriter sw = new StringWriter();
2146+ try {
2147+ Transformer t = TransformerFactory.newInstance().newTransformer();
2148+ t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
2149+ t.transform(new DOMSource(node), new StreamResult(sw));
2150+ } catch (TransformerException te) {
2151+ System.out.println("nodeToString Transformer Exception" + te.getLocalizedMessage());
2152+ }
2153+ return sw.toString();
2154+ }
2155+
2156+ @Override
2157+ public XQItem createItemFromDocument(Source value, XQItemType type) throws XQException {
2158+ isClosedXQException();
2159+ isNullXQException(value);
2160+ XQItem item = null;
2161+ if (value instanceof StreamSource) {
2162+ item = createItemFromDocument(((StreamSource)value).getReader(), "", type);
2163+ } else if (value instanceof SAXSource) {
2164+ item = createItemFromDocument(((SAXSource)value).getInputSource().getByteStream(), "", type);
2165+ } else if (value instanceof DOMSource) {
2166+ item = createItemFromDocument( nodeToString(((DOMSource)value).getNode()), "", type);
2167+ } else {
2168+ throw new UnsupportedOperationException("Not supported yet.");
2169+ }
2170+ return item;
2171+
2172+ }
2173+
2174+ @Override
2175+ public XQItem createItemFromObject(Object value, XQItemType type) throws XQException {
2176+ isClosedXQException();
2177+ isNullXQException(value);
2178+ if (value instanceof XQItem) {
2179+ return (XQItem)value;
2180+ }
2181+
2182+ ItemFactory itemFactory = zorba.getItemFactory();
2183+ XQItem item = null;
2184+ if (type==null) {
2185+
2186+ if (value instanceof Boolean) {
2187+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BOOLEAN);
2188+ } else if (value instanceof Byte) {
2189+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BYTE);
2190+ } else if (value instanceof Float) {
2191+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_FLOAT);
2192+ } else if (value instanceof Double) {
2193+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DOUBLE);
2194+ } else if (value instanceof Integer) {
2195+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INT);
2196+ } else if (value instanceof Long) {
2197+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_LONG);
2198+ } else if (value instanceof Short) {
2199+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_SHORT);
2200+ } else if (value instanceof String) {
2201+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_STRING);
2202+ } else if (value instanceof BigDecimal) {
2203+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DECIMAL);
2204+ } else if (value instanceof BigInteger) {
2205+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INTEGER);
2206+ } else if (value instanceof Duration) {
2207+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DURATION);
2208+ } else if (value instanceof XMLGregorianCalendar) {
2209+ QName schType = ((XMLGregorianCalendar)value).getXMLSchemaType();
2210+ if (schType.equals(DatatypeConstants.GDAY)) {
2211+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GDAY);
2212+ } else if (schType.equals(DatatypeConstants.GMONTHDAY)) {
2213+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GMONTHDAY);
2214+ } else if (schType.equals(DatatypeConstants.GMONTH)) {
2215+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GMONTH);
2216+ } else if (schType.equals(DatatypeConstants.GYEAR)) {
2217+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GYEAR);
2218+ } else if (schType.equals(DatatypeConstants.GYEARMONTH)) {
2219+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GYEARMONTH);
2220+ } else if (schType.equals(DatatypeConstants.DATETIME)) {
2221+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DATETIME);
2222+ } else if (schType.equals(DatatypeConstants.DATE)) {
2223+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DATE);
2224+ } else if (schType.equals(DatatypeConstants.TIME)) {
2225+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_TIME);
2226+ }
2227+ } else if (value instanceof QName) {
2228+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_QNAME);
2229+ } else if (value instanceof Document) {
2230+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT);
2231+ } else if (value instanceof DocumentFragment) {
2232+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT);
2233+ } else if (value instanceof Element){
2234+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ELEMENT);
2235+ } else if (value instanceof Attr) {
2236+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATTRIBUTE);
2237+ } else if (value instanceof Comment) {
2238+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_COMMENT);
2239+ } else if (value instanceof ProcessingInstruction) {
2240+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_PI);
2241+ } else if (value instanceof Text) {
2242+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_TEXT);
2243+ } else {
2244+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC);
2245+ }
2246+ }
2247+ try {
2248+ switch (type.getItemKind()) {
2249+ case XQItemType.XQITEMKIND_ATOMIC:
2250+ switch (type.getBaseType()) {
2251+ case XQItemType.XQBASETYPE_BOOLEAN:
2252+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBoolean((Boolean)value), type);
2253+ break;
2254+ case XQItemType.XQBASETYPE_ANYURI:
2255+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createAnyURI(value.toString()), type);
2256+ break;
2257+ case XQItemType.XQBASETYPE_BASE64BINARY:
2258+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBase64Binary(value.toString(), (value.toString()).length()), type);
2259+ break;
2260+ case XQItemType.XQBASETYPE_BYTE:
2261+ if (value instanceof Byte) {
2262+ byte tmpByte = ((Byte)value).byteValue();
2263+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte((char)tmpByte), type);
2264+ } else {
2265+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte((value.toString()).charAt(0)), type);
2266+ }
2267+ break;
2268+ case XQItemType.XQBASETYPE_DATE:
2269+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDate(value.toString()), type);
2270+ break;
2271+ case XQItemType.XQBASETYPE_DATETIME:
2272+ if (value.toString().contains(":")) {
2273+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDateTime(value.toString()), type);
2274+ } else {
2275+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDate(value.toString()), type);
2276+ }
2277+ break;
2278+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
2279+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
2280+ break;
2281+ case XQItemType.XQBASETYPE_DECIMAL:
2282+ if (value instanceof BigDecimal) {
2283+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimal(((BigDecimal)value).toPlainString()), type);
2284+ } else {
2285+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimal(value.toString()), type);
2286+ }
2287+ break;
2288+ case XQItemType.XQBASETYPE_DOUBLE:
2289+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDouble(value.toString()), type);
2290+ break;
2291+ case XQItemType.XQBASETYPE_DURATION:
2292+ if (value instanceof Duration) {
2293+ Duration duration = (Duration)value;
2294+ Boolean daytime = duration.isSet(DatatypeConstants.DAYS) || duration.isSet(DatatypeConstants.HOURS) ||
2295+ duration.isSet(DatatypeConstants.MINUTES) || duration.isSet(DatatypeConstants.SECONDS);
2296+ Boolean yearmonth = duration.isSet(DatatypeConstants.YEARS) || duration.isSet(DatatypeConstants.MONTHS);
2297+ if (daytime && yearmonth){
2298+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
2299+ } else if (yearmonth) {
2300+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createYearMonthDuration(value.toString()), type);
2301+ } else if (daytime) {
2302+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDayTimeDuration(value.toString()), type);
2303+ }
2304+ } else {
2305+ boolean yearMonth = value.toString().contains("Y") || value.toString().contains("M");
2306+ boolean dayTime = value.toString().contains("D") || value.toString().contains("T");
2307+ if (yearMonth && dayTime) {
2308+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
2309+ } else if (yearMonth) {
2310+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createYearMonthDuration(value.toString()), type);
2311+ } else if (dayTime) {
2312+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDayTimeDuration(value.toString()), type);
2313+ }
2314+ }
2315+ break;
2316+ case XQItemType.XQBASETYPE_FLOAT:
2317+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createFloat((Float)value), type);
2318+ break;
2319+ case XQItemType.XQBASETYPE_GDAY:
2320+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGDay(value.toString()), type);
2321+ break;
2322+ case XQItemType.XQBASETYPE_GMONTH:
2323+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonth(value.toString()), type);
2324+ break;
2325+ case XQItemType.XQBASETYPE_GMONTHDAY:
2326+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonthDay(value.toString()), type);
2327+ break;
2328+ case XQItemType.XQBASETYPE_GYEAR:
2329+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYear(value.toString()), type);
2330+ break;
2331+ case XQItemType.XQBASETYPE_GYEARMONTH:
2332+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYearMonth(value.toString()), type);
2333+ break;
2334+ case XQItemType.XQBASETYPE_HEXBINARY:
2335+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createHexBinary(value.toString(), (value.toString()).length()), type);
2336+ break;
2337+ case XQItemType.XQBASETYPE_INT:
2338+ case XQItemType.XQBASETYPE_INTEGER:
2339+ if (value instanceof BigInteger) {
2340+ BigInteger val = (BigInteger)value;
2341+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(val.longValue()), type);
2342+ } else if (value instanceof Integer) {
2343+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInt((Integer)value), type);
2344+ } else if (value instanceof String) {
2345+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(value.toString()), type);
2346+ } else {
2347+ throw new XQException ("Error parsing integer: " + value.toString());
2348+ }
2349+ break;
2350+ case XQItemType.XQBASETYPE_LONG:
2351+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createLong((Long)value), type);
2352+ break;
2353+ case XQItemType.XQBASETYPE_NCNAME:
2354+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNCName(value.toString()), type);
2355+ break;
2356+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
2357+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNegativeInteger((Long)value), type);
2358+ break;
2359+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
2360+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonNegativeInteger(new BigInteger(value.toString())), type);
2361+ break;
2362+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
2363+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonPositiveInteger((Long)value), type);
2364+ break;
2365+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
2366+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createPositiveInteger(new BigInteger(value.toString())), type);
2367+ break;
2368+ case XQItemType.XQBASETYPE_QNAME:
2369+ if (value instanceof QName) {
2370+ QName qname = (QName) value;
2371+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName(qname.getNamespaceURI(), qname.getPrefix(), qname.getLocalPart()), type);
2372+ } else if (value.toString().contains("{")) {
2373+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName(value.toString()), type);
2374+ } else {
2375+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName("", value.toString()), type);
2376+ }
2377+ break;
2378+ case XQItemType.XQBASETYPE_SHORT:
2379+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort((Short)value), type);
2380+ break;
2381+ case XQItemType.XQBASETYPE_STRING:
2382+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createString(value.toString()), type);
2383+ break;
2384+ case XQItemType.XQBASETYPE_TIME:
2385+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createTime(value.toString()), type);
2386+ break;
2387+ case XQItemType.XQBASETYPE_TOKEN:
2388+ break;
2389+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
2390+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedByte((Short)value), type);
2391+ break;
2392+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
2393+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedInt((Long)value), type);
2394+ break;
2395+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
2396+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedLong(new BigInteger(value.toString())), type);
2397+ break;
2398+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
2399+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedShort((Integer)value), type);
2400+ break;
2401+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
2402+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
2403+ break;
2404+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
2405+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
2406+ case XQItemType.XQBASETYPE_ANYTYPE:
2407+ case XQItemType.XQBASETYPE_ENTITIES:
2408+ case XQItemType.XQBASETYPE_ENTITY:
2409+ case XQItemType.XQBASETYPE_ID:
2410+ case XQItemType.XQBASETYPE_IDREF:
2411+ case XQItemType.XQBASETYPE_IDREFS:
2412+ case XQItemType.XQBASETYPE_LANGUAGE:
2413+ case XQItemType.XQBASETYPE_NAME:
2414+ case XQItemType.XQBASETYPE_NMTOKEN:
2415+ case XQItemType.XQBASETYPE_NMTOKENS:
2416+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
2417+ case XQItemType.XQBASETYPE_NOTATION:
2418+ case XQItemType.XQBASETYPE_UNTYPED:
2419+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
2420+ throw new XQException ("Base type not supported yet.");
2421+ default:
2422+ throw new XQException ("Unable to determine XQBASETYPE.");
2423+ }
2424+ break;
2425+ case XQItemType.XQITEMKIND_ATTRIBUTE:
2426+ if (value instanceof Attr){
2427+ Attr attribute = (Attr) value;
2428+ Item iEmpty = new Item();
2429+ Item nodeName = itemFactory.createQName(attribute.getNamespaceURI()==null?"":attribute.getNamespaceURI(),
2430+ attribute.getPrefix()==null?"":attribute.getPrefix(),
2431+ attribute.getName()==null?"":attribute.getName());
2432+ Item nodeValue = null;
2433+ if (!attribute.getValue().isEmpty()) {
2434+ nodeValue = itemFactory.createQName(attribute.getNamespaceURI()==null?"":attribute.getNamespaceURI(),
2435+ attribute.getPrefix()==null?"":attribute.getPrefix(),
2436+ attribute.getValue()==null?"":attribute.getValue());
2437+ } else {
2438+ nodeValue = new Item();
2439+ }
2440+ //TODO: Rodolfo: use centralized constants instead of strings
2441+ Item iUntyped = itemFactory.createQName("http://www.w3.org/2001/XMLSchema", "xs", "untyped");
2442+ Item attributeNode = itemFactory.createAttributeNode(iEmpty, nodeName, iUntyped, nodeValue);
2443+ item = new org.zorbaxquery.api.xqj.XQItem(attributeNode, type);
2444+ }
2445+ break;
2446+ case XQItemType.XQITEMKIND_COMMENT:
2447+ if (value instanceof Comment){
2448+ Comment comment = (Comment) value;
2449+ Item iEmpty = new Item();
2450+ Item elementNode = itemFactory.createCommentNode(iEmpty, comment.getTextContent());
2451+ item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
2452+ } else {
2453+ Item iEmpty = new Item();
2454+ Item elementNode = itemFactory.createCommentNode(iEmpty, value.toString());
2455+ item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
2456+ }
2457+ break;
2458+ case XQItemType.XQITEMKIND_DOCUMENT:
2459+ if ((value instanceof Document) || (value instanceof DocumentFragment)){
2460+ DOMSource source = null;
2461+ if (value instanceof Document) {
2462+ source = new DOMSource((Document)value);
2463+ } else {
2464+ source = new DOMSource((DocumentFragment)value);
2465+ }
2466+
2467+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
2468+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
2469+ StreamResult result = new StreamResult(new StringWriter());
2470+
2471+ transformer.transform(source, result);
2472+ String xmlString = result.getWriter().toString();
2473+ Item tmpItem = new Item();
2474+ if (xmlString.length()>0) {
2475+ XmlDataManager dataManager = zorba.getXmlDataManager();
2476+ org.zorbaxquery.api.Iterator iter = dataManager.parseXML(xmlString);
2477+ iter.open();
2478+ iter.next(tmpItem);
2479+ iter.close();
2480+ iter.delete();
2481+ } else {
2482+ tmpItem = itemFactory.createDocumentNode("", "");
2483+ }
2484+
2485+ item = new org.zorbaxquery.api.xqj.XQItem(tmpItem, type);
2486+ }
2487+
2488+ break;
2489+ case XQItemType.XQITEMKIND_ELEMENT:
2490+ if (value instanceof Element){
2491+ Element element = (Element) value;
2492+ Item iEmpty = new Item();
2493+ Item nodeName = itemFactory.createQName(element.getNamespaceURI()==null?"":element.getNamespaceURI(),
2494+ element.getPrefix()==null?"":element.getPrefix(),
2495+ element.getNodeName()==null?"":element.getNodeName());
2496+ Item iUntyped = itemFactory.createQName("http://www.w3.org/2001/XMLSchema", "xs", "untyped");
2497+ Item elementNode = itemFactory.createElementNode(iEmpty, nodeName, iUntyped, false, false);
2498+ item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
2499+ }
2500+ break;
2501+ case XQItemType.XQITEMKIND_PI:
2502+ if (value instanceof ProcessingInstruction){
2503+ ProcessingInstruction pi = (ProcessingInstruction) value;
2504+ Item iEmpty = new Item();
2505+ Item elementNode = itemFactory.createPiNode(iEmpty,
2506+ pi.getTarget(),
2507+ pi.getTextContent(),
2508+ pi.getBaseURI()==null?"":pi.getBaseURI());
2509+ item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
2510+ }
2511+ break;
2512+ case XQItemType.XQITEMKIND_TEXT:
2513+ if (value instanceof Text){
2514+ Text text = (Text) value;
2515+ Item iEmpty = new Item();
2516+ Item elementNode = itemFactory.createTextNode(iEmpty, text.getWholeText());
2517+ item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
2518+ }
2519+ break;
2520+ case XQItemType.XQITEMKIND_DOCUMENT_ELEMENT:
2521+ case XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
2522+ case XQItemType.XQITEMKIND_ITEM:
2523+ case XQItemType.XQITEMKIND_NODE:
2524+ case XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE:
2525+ case XQItemType.XQITEMKIND_SCHEMA_ELEMENT:
2526+ throw new XQException ("This item kind is currently unsupported.");
2527+ default:
2528+ throw new XQException ("Unable to determine XQITEMKIND.");
2529+ }
2530+ } catch (Exception e) {
2531+ throw new XQException ("Error parsing value" + e.getLocalizedMessage());
2532+ }
2533+ return item;
2534+ }
2535+
2536+ @Override
2537+ public XQItem createItemFromBoolean(boolean bln, XQItemType type) throws XQException {
2538+ isClosedXQException();
2539+ if (type == null) {
2540+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BOOLEAN);
2541+ }
2542+ if (type.getBaseType() != XQItemType.XQBASETYPE_BOOLEAN) {
2543+ throw new XQException("Type is not boolean, use proper method");
2544+ }
2545+
2546+ XQItem item = null;
2547+ try {
2548+ ItemFactory itemFactory = zorba.getItemFactory();
2549+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBoolean(bln));
2550+ } catch (Exception e) {
2551+ throw new XQException("Error creating new item");
2552+ }
2553+ return item;
2554+ }
2555+
2556+ // This method works for Decimal and all subtypes,
2557+ // verifies that the type is correct and create the Item
2558+ private XQItem createDecimal(BigDecimal value, XQItemType type) throws XQException {
2559+ XQItem item = null;
2560+ try {
2561+ ItemFactory itemFactory = zorba.getItemFactory();
2562+ switch (type.getBaseType()) {
2563+ case XQItemType.XQBASETYPE_BYTE:
2564+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte((char)value.byteValue()), type);
2565+ break;
2566+ case XQItemType.XQBASETYPE_INTEGER:
2567+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(value.longValue()), type);
2568+ break;
2569+ case XQItemType.XQBASETYPE_DECIMAL:
2570+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimalFromLong(value.longValue()), type);
2571+ break;
2572+ case XQItemType.XQBASETYPE_INT:
2573+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInt(value.intValue()), type);
2574+ break;
2575+ case XQItemType.XQBASETYPE_LONG:
2576+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createLong(value.longValue()), type);
2577+ break;
2578+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
2579+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNegativeInteger(value.longValue()), type);
2580+ break;
2581+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
2582+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonNegativeInteger(value.toBigInteger()), type);
2583+ break;
2584+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
2585+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonPositiveInteger(value.longValue()), type);
2586+ break;
2587+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
2588+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createPositiveInteger(value.toBigInteger()), type);
2589+ break;
2590+ case XQItemType.XQBASETYPE_SHORT:
2591+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort(value.shortValue()), type);
2592+ break;
2593+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
2594+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedByte(value.shortValue()), type);
2595+ break;
2596+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
2597+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedInt(value.longValue()), type);
2598+ break;
2599+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
2600+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedLong(value.toBigInteger()), type);
2601+ break;
2602+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
2603+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort(value.shortValue()), type);
2604+ break;
2605+ default:
2606+ throw new XQException("Type is not xs:decimal or a derivate.");
2607+ }
2608+ } catch (Exception e) {
2609+ throw new XQException("Error creating Item: " + e.getLocalizedMessage());
2610+ }
2611+ return item;
2612+ }
2613+
2614+ @Override
2615+ public XQItem createItemFromByte(byte b, XQItemType type) throws XQException {
2616+ isClosedXQException();
2617+ if (type == null) {
2618+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BYTE);
2619+ }
2620+ return createDecimal(new BigDecimal(b), type);
2621+ }
2622+
2623+ @Override
2624+ public XQItem createItemFromDouble(double value, XQItemType type) throws XQException {
2625+ isClosedXQException();
2626+ if (type == null) {
2627+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DOUBLE);
2628+ }
2629+ if (type.getBaseType() != XQItemType.XQBASETYPE_DOUBLE) {
2630+ throw new XQException("Type is not double, use proper method");
2631+ }
2632+ XQItem item = null;
2633+ try {
2634+ ItemFactory itemFactory = zorba.getItemFactory();
2635+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDouble(value), type);
2636+ } catch (Exception e) {
2637+ throw new XQException("Error Creating Item From Double" + e.getLocalizedMessage());
2638+ }
2639+ return item;
2640+ }
2641+
2642+ @Override
2643+ public XQItem createItemFromFloat(float value, XQItemType type) throws XQException {
2644+ isClosedXQException();
2645+ if (type == null) {
2646+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_FLOAT);
2647+ }
2648+ if (type.getBaseType() != XQItemType.XQBASETYPE_FLOAT) {
2649+ throw new XQException("Type is not float, use proper method");
2650+ }
2651+ XQItem item = null;
2652+ try {
2653+ ItemFactory itemFactory = zorba.getItemFactory();
2654+ item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createFloat(value), type);
2655+ } catch (Exception e) {
2656+ throw new XQException("Error Creating Item From Float" + e.getLocalizedMessage());
2657+ }
2658+ return item;
2659+ }
2660+
2661+ @Override
2662+ public XQItem createItemFromInt(int value, XQItemType type) throws XQException {
2663+ isClosedXQException();
2664+ if (type == null) {
2665+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INT);
2666+ }
2667+ switch (type.getBaseType()) {
2668+ case XQItemType.XQBASETYPE_BYTE:
2669+ case XQItemType.XQBASETYPE_SHORT:
2670+ throw new XQException("Can't downgrade the Base Type from an Int number");
2671+ default:
2672+ break;
2673+ }
2674+ return createDecimal(new BigDecimal(value), type);
2675+ }
2676+
2677+ @Override
2678+ public XQItem createItemFromLong(long value, XQItemType type) throws XQException {
2679+ isClosedXQException();
2680+ if (type == null) {
2681+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_LONG);
2682+ }
2683+ switch (type.getBaseType()) {
2684+ case XQItemType.XQBASETYPE_BYTE:
2685+ case XQItemType.XQBASETYPE_SHORT:
2686+ case XQItemType.XQBASETYPE_INT:
2687+ throw new XQException("Can't downgrade the Base Type from an Long number");
2688+ default:
2689+ break;
2690+ }
2691+ return createDecimal(new BigDecimal(value), type);
2692+ }
2693+
2694+ @Override
2695+ public XQItem createItemFromNode(Node value, XQItemType type) throws XQException {
2696+ isClosedXQException();
2697+ isNullXQException(value);
2698+
2699+ XQItem result = null;
2700+ try {
2701+ result = createItemFromString(nodeToString(value), type);
2702+ } catch( Exception e ) {
2703+ throw new XQException("Error Creating Item From Node" + e.getLocalizedMessage());
2704+ }
2705+ return result;
2706+ }
2707+
2708+ @Override
2709+ public XQItem createItemFromShort(short value, XQItemType type) throws XQException {
2710+ isClosedXQException();
2711+ if (type == null) {
2712+ type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_SHORT);
2713+ }
2714+ if (type.getBaseType()==XQItemType.XQBASETYPE_BYTE) {
2715+ throw new XQException("Can't create a Byte from a Short number");
2716+ }
2717+ return createDecimal(new BigDecimal(value), type);
2718+ }
2719+
2720+ @Override
2721+ public XQItem createItem(XQItem value) throws XQException {
2722+ isClosedXQException();
2723+ isNullXQException(value);
2724+ if (value.isClosed()) {
2725+ throw new XQException("Item is closed.");
2726+ }
2727+ XQItem result = new org.zorbaxquery.api.xqj.XQItem(value);
2728+ return result;
2729+ }
2730+
2731+ @Override
2732+ public XQSequence createSequence(XQSequence value) throws XQException {
2733+ isClosedXQException();
2734+ isNullXQException(value);
2735+ if (value.isClosed()) {
2736+ throw new XQException("Sequence is closed.");
2737+ }
2738+ XQSequence result = null;
2739+ try {
2740+ result = new org.zorbaxquery.api.xqj.XQSequence(value);
2741+ } catch (Exception ex) {
2742+ throw new XQException("Error creating sequence: " + ex.getLocalizedMessage());
2743+ }
2744+ return result;
2745+ }
2746+
2747+ @Override
2748+ public XQSequence createSequence(Iterator value) throws XQException {
2749+ isClosedXQException();
2750+ isNullXQException(value);
2751+ XQSequence result = null;
2752+ try {
2753+ result = new org.zorbaxquery.api.xqj.XQSequence(value);
2754+ } catch (Exception ex) {
2755+ throw new XQException("Error creating sequence: " + ex.getLocalizedMessage());
2756+ }
2757+ return result;
2758+ }
2759+
2760+ @Override
2761+ public XQItemType createAtomicType(int basetype) throws XQException {
2762+ isClosedXQException();
2763+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED) ||
2764+ (basetype==XQItemType.XQBASETYPE_ANYTYPE) ||
2765+ (basetype==XQItemType.XQBASETYPE_IDREFS) ||
2766+ (basetype==XQItemType.XQBASETYPE_NMTOKENS) ||
2767+ (basetype==XQItemType.XQBASETYPE_ENTITIES) ||
2768+ (basetype==XQItemType.XQBASETYPE_ANYSIMPLETYPE)) {
2769+ throw new XQException("Invalid base type.");
2770+ }
2771+ XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, basetype);
2772+ return type;
2773+ }
2774+
2775+ @Override
2776+ public XQItemType createAtomicType(int basetype, QName qname, URI uri) throws XQException {
2777+ if (closed) {
2778+ throw new XQException("Object closed");
2779+ }
2780+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED) ||
2781+ (basetype==XQItemType.XQBASETYPE_ANYTYPE) ||
2782+ (basetype==XQItemType.XQBASETYPE_IDREFS) ||
2783+ (basetype==XQItemType.XQBASETYPE_NMTOKENS) ||
2784+ (basetype==XQItemType.XQBASETYPE_ENTITIES) ||
2785+ (basetype==XQItemType.XQBASETYPE_ANYSIMPLETYPE)) {
2786+ throw new XQException("Invalid base type.");
2787+ }
2788+ XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, qname, basetype, uri);
2789+ return type;
2790+ }
2791+
2792+ @Override
2793+ public XQItemType createAttributeType(QName nodename, int basetype) throws XQException {
2794+ isClosedXQException();
2795+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED)||(basetype==XQItemType.XQBASETYPE_ANYTYPE)) {
2796+ throw new XQException("Base Type can't be XQItemType.XQBASETYPE_UNTYPED or XQItemType.XQBASETYPE_ANYTYPE");
2797+ }
2798+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATTRIBUTE, nodename, basetype);
2799+ }
2800+
2801+ @Override
2802+ public XQItemType createAttributeType(QName nodename, int basetype, QName typename, URI schemaURI) throws XQException {
2803+ isClosedXQException();
2804+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED)||(basetype==XQItemType.XQBASETYPE_ANYTYPE)) {
2805+ throw new XQException("Base Type can't be XQItemType.XQBASETYPE_UNTYPED or XQItemType.XQBASETYPE_ANYTYPE");
2806+ }
2807+ if ((schemaURI!=null) && (typename==null)) {
2808+ throw new XQException("If Schema URI is specified, Base Type must be also specified");
2809+ }
2810+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATTRIBUTE, nodename, basetype, typename, schemaURI, true);
2811+ }
2812+
2813+ @Override
2814+ public XQItemType createSchemaAttributeType(QName nodename, int basetype, URI uri) throws XQException {
2815+ isClosedXQException();
2816+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE, nodename, basetype, uri);
2817+ }
2818+
2819+ @Override
2820+ public XQItemType createCommentType() throws XQException {
2821+ isClosedXQException();
2822+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_COMMENT);
2823+ }
2824+
2825+ @Override
2826+ public XQItemType createDocumentElementType(XQItemType elementType) throws XQException {
2827+ isClosedXQException();
2828+ isNullXQException(elementType);
2829+ if (elementType.getItemKind()!=XQItemType.XQITEMKIND_ELEMENT) {
2830+ throw new XQException("Item Kind must be XQItemType.XQITEMKIND_ELEMENT");
2831+ }
2832+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), elementType.getBaseType(), elementType.getSchemaURI());
2833+ }
2834+
2835+ @Override
2836+ public XQItemType createDocumentSchemaElementType(XQItemType elementType) throws XQException {
2837+ isClosedXQException();
2838+ if (elementType.getItemKind()!=XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) {
2839+ throw new XQException("Item Kind must be XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT");
2840+ }
2841+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), elementType.getBaseType(), elementType.getSchemaURI());
2842+ }
2843+
2844+ @Override
2845+ public XQItemType createDocumentType() throws XQException {
2846+ isClosedXQException();
2847+ return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT);
2848+ }
2849+
2850+ @Override
2851+ public XQItemType createElementType(QName nodename, int baseType) throws XQException {
2852+ isClosedXQException();
2853+ XQItemType item = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ELEMENT, nodename, baseType);
2854+ return item;
2855+ }
2856+
2857+ @Override
2858+ public XQItemType createElementType(QName nodename, int baseType, QName typename, URI schemaURI, boolean allowNill) throws XQException {
2859+ isClosedXQException();
2860+ XQItemType item = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ELEMENT, nodename, baseType, typename, schemaURI, allowNill);
2861+ return item;
2862+ }
2863+
2864+ @Override
2865+ public XQItemType createSchemaElementType(QName nodename, int baseType, URI schemaURI) throws XQException {
2866+ isClosedXQException();
2867+ XQItemType item = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_SCHEMA_ELEMENT, nodename, baseType, schemaURI);
2868+ return item;
2869+ }
2870+
2871+ @Override
2872+ public XQItemType createItemType() throws XQException {
2873+ isClosedXQException();
2874+ XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ITEM);
2875+ return type;
2876+ }
2877+
2878+ @Override
2879+ public XQItemType createNodeType() throws XQException {
2880+ isClosedXQException();
2881+ XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_NODE);
2882+ return type;
2883+ }
2884+
2885+ @Override
2886+ public XQItemType createProcessingInstructionType(String piTarget) throws XQException {
2887+ isClosedXQException();
2888+ XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_PI, piTarget);
2889+ return type;
2890+ }
2891+
2892+ @Override
2893+ public XQSequenceType createSequenceType(XQItemType item, int occurence) throws XQException {
2894+ isClosedXQException();
2895+ if ( ((item==null) && (occurence != XQSequenceType.OCC_EMPTY)) || ((item!=null) && (occurence == XQSequenceType.OCC_EMPTY))) {
2896+ throw new XQException("Item is null");
2897+ }
2898+ if (!((occurence == XQSequenceType.OCC_ZERO_OR_ONE) ||
2899+ (occurence == XQSequenceType.OCC_EXACTLY_ONE) ||
2900+ (occurence == XQSequenceType.OCC_ZERO_OR_MORE) ||
2901+ (occurence == XQSequenceType.OCC_ONE_OR_MORE) ||
2902+ (occurence == XQSequenceType.OCC_EMPTY))) {
2903+ throw new XQException("Occurence must be from: OCC_ZERO_OR_ONE, OCC_EXACTLY_ONE, OCC_ZERO_OR_MORE, OCC_ONE_OR_MORE, OCC_EMPTY ");
2904+ }
2905+
2906+ XQSequenceType result = new org.zorbaxquery.api.xqj.XQSequenceType(item, occurence);
2907+ return result;
2908+ }
2909+
2910+ @Override
2911+ public XQItemType createTextType() throws XQException {
2912+ isClosedXQException();
2913+ XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_TEXT);
2914+ return type;
2915+ }
2916+
2917+ private void isClosedXQException() throws XQException {
2918+ if (closed) {
2919+ throw new XQException("This connection is closed");
2920+ }
2921+ }
2922+ private void isNullXQException(Object value) throws XQException {
2923+ if (value==null) {
2924+ throw new XQException("Parameter shouldn't be null");
2925+ }
2926+ }
2927+
2928+}
2929
2930=== added file 'swig/xqj/XQDataSource.java'
2931--- swig/xqj/XQDataSource.java 1970-01-01 00:00:00 +0000
2932+++ swig/xqj/XQDataSource.java 2012-04-19 22:34:19 +0000
2933@@ -0,0 +1,171 @@
2934+/*
2935+ * Copyright 2006-2012 The FLWOR Foundation.
2936+ *
2937+ * Licensed under the Apache License, Version 2.0 (the "License");
2938+ * you may not use this file except in compliance with the License.
2939+ * You may obtain a copy of the License at
2940+ *
2941+ * http://www.apache.org/licenses/LICENSE-2.0
2942+ *
2943+ * Unless required by applicable law or agreed to in writing, software
2944+ * distributed under the License is distributed on an "AS IS" BASIS,
2945+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2946+ * See the License for the specific language governing permissions and
2947+ * limitations under the License.
2948+ */
2949+package org.zorbaxquery.api.xqj;
2950+
2951+import java.io.PrintWriter;
2952+import java.sql.Connection;
2953+import java.util.Enumeration;
2954+import java.util.Properties;
2955+import javax.xml.xquery.*;
2956+
2957+public class XQDataSource implements javax.xml.xquery.XQDataSource {
2958+
2959+ static {
2960+ System.loadLibrary ( "zorba_api" );
2961+ }
2962+ public static final String ZORBA_PROPERTIES_URI_PATHS = "URI-PATHS";
2963+ public static final String ZORBA_PROPERTIES_LIB_PATHS = "LIB-PATHS";
2964+ public static final String ZORBA_PROPERTIES_MODULE_PATHS = "MODULE-PATHS";
2965+
2966+ private int loginTimeout;
2967+ protected PrintWriter logWriter;
2968+ private Properties properties = new Properties();
2969+ private String[] propertiesAllowed = {ZORBA_PROPERTIES_URI_PATHS, ZORBA_PROPERTIES_LIB_PATHS, ZORBA_PROPERTIES_MODULE_PATHS};
2970+ public XQDataSource() {
2971+ }
2972+
2973+
2974+ @Override
2975+ public XQConnection getConnection() throws XQException {
2976+ XQConnection conn;
2977+ try {
2978+ if (!properties.isEmpty()) {
2979+ conn = new XQConnection(properties);
2980+ } else {
2981+ conn = new XQConnection();
2982+ }
2983+ } catch ( Exception e ) {
2984+ throw new XQException("Error creating new Zorba Connection Instance");
2985+ }
2986+ return conn;
2987+ }
2988+
2989+ @Override
2990+ public XQConnection getConnection(Connection cnctn) throws XQException {
2991+ /* Attempts to create a connection to an XML datasource using an
2992+ * existing JDBC connection. An XQJ implementation is not required
2993+ * to support this method. If it is not supported, then an
2994+ * exception (XQException) is thrown. The XQJ and JDBC connections
2995+ * will operate under the same transaction context.
2996+ * */
2997+ throw new XQException("Connection to an XML datasource using an existing JDBC connection is not supported.");
2998+ }
2999+
3000+ @Override
3001+ public XQConnection getConnection(String username, String passwd) throws XQException {
3002+ XQConnection conn;
3003+ try {
3004+ if (!properties.isEmpty()) {
3005+ conn = new XQConnection(properties);
3006+ } else {
3007+ conn = new XQConnection();
3008+ }
3009+ } catch ( Exception e ) {
3010+ throw new XQException("Error creating new Zorba Connection Instance");
3011+ }
3012+ return conn;
3013+ }
3014+
3015+ @Override
3016+ public int getLoginTimeout() throws XQException {
3017+ return loginTimeout;
3018+ }
3019+
3020+ @Override
3021+ public PrintWriter getLogWriter() throws XQException {
3022+ return logWriter;
3023+ }
3024+
3025+ @Override
3026+ public String[] getSupportedPropertyNames() {
3027+ return propertiesAllowed;
3028+ }
3029+
3030+ @Override
3031+ public void setProperty(String name, String value) throws XQException {
3032+ if (name==null) {
3033+ throw new XQException("Property name is null.");
3034+ }
3035+ boolean allowed = false;
3036+ for(int i=0; i<propertiesAllowed.length; i++) {
3037+ if (propertiesAllowed[i].equals(name)) {
3038+ allowed = true;
3039+ }
3040+ }
3041+ if (allowed) {
3042+ properties.setProperty(name, value);
3043+ } else {
3044+ throw new XQException("Property not allowed.");
3045+ }
3046+ }
3047+
3048+ @Override
3049+ public String getProperty(String name) throws XQException {
3050+ if (name==null) {
3051+ throw new XQException("Property name is null.");
3052+ }
3053+ boolean allowed = false;
3054+ for(int i=0; i<propertiesAllowed.length; i++) {
3055+ if (propertiesAllowed[i].equals(name)) {
3056+ allowed = true;
3057+ }
3058+ }
3059+ if (!allowed) {
3060+ throw new XQException("Property name not supported.");
3061+ }
3062+ return properties.getProperty(name);
3063+ }
3064+
3065+ @Override
3066+ public void setProperties(Properties prprts) throws XQException {
3067+ if (prprts==null) {
3068+ throw new XQException("Properties are null.");
3069+ }
3070+ boolean allowed = false;
3071+ String tmpstr = null;
3072+ Enumeration em = prprts.keys();
3073+ while (em.hasMoreElements()) {
3074+ allowed = false;
3075+ tmpstr = (String)em.nextElement();
3076+ for (int i=0; i<propertiesAllowed.length; i++) {
3077+ if (propertiesAllowed[i].equals(tmpstr)) {
3078+ allowed = true;
3079+ }
3080+ }
3081+ if (!allowed) {
3082+ throw new XQException("Property [" + tmpstr + "] not allowed");
3083+ }
3084+ }
3085+
3086+ em = prprts.keys();
3087+ while (em.hasMoreElements()) {
3088+ tmpstr = (String)em.nextElement();
3089+ properties.setProperty(tmpstr, prprts.getProperty(tmpstr));
3090+ }
3091+
3092+ }
3093+
3094+ @Override
3095+ public void setLoginTimeout(int i) throws XQException {
3096+ loginTimeout = i;
3097+ }
3098+
3099+ @Override
3100+ public void setLogWriter(PrintWriter writer) throws XQException {
3101+ logWriter = writer;
3102+ }
3103+
3104+}
3105
3106=== added file 'swig/xqj/XQExpression.java'
3107--- swig/xqj/XQExpression.java 1970-01-01 00:00:00 +0000
3108+++ swig/xqj/XQExpression.java 2012-04-19 22:34:19 +0000
3109@@ -0,0 +1,454 @@
3110+/*
3111+ * Copyright 2006-2012 The FLWOR Foundation.
3112+ *
3113+ * Licensed under the Apache License, Version 2.0 (the "License");
3114+ * you may not use this file except in compliance with the License.
3115+ * You may obtain a copy of the License at
3116+ *
3117+ * http://www.apache.org/licenses/LICENSE-2.0
3118+ *
3119+ * Unless required by applicable law or agreed to in writing, software
3120+ * distributed under the License is distributed on an "AS IS" BASIS,
3121+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3122+ * See the License for the specific language governing permissions and
3123+ * limitations under the License.
3124+ */
3125+package org.zorbaxquery.api.xqj;
3126+
3127+import java.io.InputStream;
3128+import java.io.Reader;
3129+import java.io.StringWriter;
3130+import java.io.Writer;
3131+import java.nio.CharBuffer;
3132+import java.util.ArrayList;
3133+import java.util.Collection;
3134+import java.util.HashMap;
3135+import java.util.Map;
3136+import java.util.TimeZone;
3137+import javax.xml.namespace.QName;
3138+import javax.xml.stream.XMLStreamReader;
3139+import javax.xml.transform.Source;
3140+import javax.xml.xquery.XQException;
3141+import javax.xml.xquery.XQItem;
3142+import javax.xml.xquery.XQItemType;
3143+import javax.xml.xquery.XQResultSequence;
3144+import javax.xml.xquery.XQSequence;
3145+import javax.xml.xquery.XQStaticContext;
3146+import javax.xml.xquery.XQConnection;
3147+import javax.xml.xquery.XQConstants;
3148+import org.w3c.dom.Node;
3149+import org.zorbaxquery.api.DynamicContext;
3150+import org.zorbaxquery.api.Item;
3151+import org.zorbaxquery.api.XQuery;
3152+
3153+public class XQExpression implements javax.xml.xquery.XQExpression {
3154+
3155+ //private XQuery query;
3156+ private XQConnection connection;
3157+ private boolean closed = false;
3158+ private boolean cancel = false;
3159+ private Collection<XQResultSequence> resultSequences = new ArrayList<XQResultSequence>();
3160+ private XQStaticContext staticContext;
3161+ private Map<String, Item> itemsToBind = new HashMap<String, Item>();
3162+ private TimeZone implicitTimeZone;
3163+
3164+ public XQExpression (XQConnection conn) throws XQException {
3165+ if (conn.isClosed()) {
3166+ throw new XQException ("Connection is closed");
3167+ }
3168+ connection = conn;
3169+ }
3170+
3171+ public XQExpression (XQConnection conn, XQStaticContext sc) throws XQException {
3172+ if (conn.isClosed()) {
3173+ throw new XQException ("Connection is closed");
3174+ }
3175+ connection = conn;
3176+ staticContext = sc;
3177+ }
3178+
3179+ @Override
3180+ public void cancel() throws XQException {
3181+ isClosedXQException();
3182+ cancel = true;
3183+ }
3184+
3185+ @Override
3186+ public boolean isClosed() {
3187+ return closed;
3188+ }
3189+
3190+ @Override
3191+ public void close() throws XQException {
3192+ closed=true;
3193+// if (query!=null) {
3194+// query.destroy();
3195+// }
3196+ for (XQResultSequence rs: resultSequences) {
3197+ rs.close();
3198+ }
3199+ }
3200+
3201+ @Override
3202+ public void executeCommand(String string) throws XQException {
3203+ throw new UnsupportedOperationException("Not supported yet.");
3204+ }
3205+
3206+ @Override
3207+ public void executeCommand(Reader reader) throws XQException {
3208+ throw new UnsupportedOperationException("Not supported yet.");
3209+ }
3210+
3211+ @Override
3212+ public XQResultSequence executeQuery(String value) throws XQException {
3213+ isClosedXQException();
3214+ isNullXQException(value);
3215+ org.zorbaxquery.api.xqj.XQConnection lConnection = (org.zorbaxquery.api.xqj.XQConnection)connection;
3216+ XQuery query = lConnection.getZorbaInstance().createQuery();
3217+ XQResultSequence result = null;
3218+ try {
3219+ int scrollable = XQConstants.SCROLLTYPE_FORWARD_ONLY;
3220+ if (staticContext!=null) {
3221+ query.compile(value, ((org.zorbaxquery.api.xqj.XQStaticContext)staticContext).getZorbaStaticContext());
3222+ scrollable = staticContext.getScrollability();
3223+ } else {
3224+ query.compile(value);
3225+ }
3226+ DynamicContext dynamicContext = query.getDynamicContext();
3227+ if (implicitTimeZone!=null) {
3228+ dynamicContext.setImplicitTimezone((implicitTimeZone.getRawOffset()/60000));
3229+ implicitTimeZone=null;
3230+ }
3231+ for (String key: itemsToBind.keySet()){
3232+ dynamicContext.setVariable(key, itemsToBind.get(key) );
3233+ //itemsToBind.remove(key);
3234+ }
3235+ if (scrollable == XQConstants.SCROLLTYPE_FORWARD_ONLY) {
3236+ result = new org.zorbaxquery.api.xqj.XQResultSequence(connection, query, false);
3237+ } else {
3238+ result = new org.zorbaxquery.api.xqj.XQResultSequenceScrollable(connection, query, false);
3239+ }
3240+ resultSequences.add(result);
3241+ } catch (Exception e) {
3242+ throw new XQException ("Error executing query: " + e.getLocalizedMessage());
3243+ }
3244+ return result;
3245+ }
3246+
3247+ @Override
3248+ public XQResultSequence executeQuery(Reader value) throws XQException {
3249+ isClosedXQException();
3250+ isNullXQException(value);
3251+
3252+ StringBuffer string = new StringBuffer();
3253+ CharBuffer buffer = CharBuffer.allocate(1024);
3254+ Writer writer = new StringWriter();
3255+
3256+ try {
3257+ while( value.read(buffer) >= 0 ) {
3258+ buffer.flip();
3259+ writer.append(buffer);
3260+ buffer.clear();
3261+ }
3262+ value.close();
3263+ } catch (Exception ex) {
3264+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
3265+ }
3266+
3267+ return executeQuery(writer.toString());
3268+ }
3269+
3270+ @Override
3271+ public XQResultSequence executeQuery(InputStream value) throws XQException {
3272+ isClosedXQException();
3273+ isNullXQException(value);
3274+ StringBuffer out = new StringBuffer ();
3275+ try {
3276+ byte[] b = new byte[4096];
3277+ for (int n; (n = value.read(b)) != -1;) {
3278+ out.append(new String(b, 0, n));
3279+ }
3280+ } catch (Exception ex) {
3281+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
3282+ }
3283+ return executeQuery(out.toString());
3284+ }
3285+
3286+ @Override
3287+ public XQStaticContext getStaticContext() throws XQException {
3288+ isClosedXQException();
3289+ if (staticContext==null) {
3290+ return connection.getStaticContext();
3291+ } else {
3292+ return staticContext;
3293+ }
3294+ }
3295+
3296+ @Override
3297+ public TimeZone getImplicitTimeZone() throws XQException {
3298+ isClosedXQException();
3299+ if (implicitTimeZone!=null) {
3300+ return implicitTimeZone;
3301+ }
3302+ XQuery query = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance().compileQuery("1");
3303+ DynamicContext dc = query.getDynamicContext();
3304+ Integer timeZone = (dc.getImplicitTimezone()/60); // in minutes
3305+ TimeZone result = TimeZone.getTimeZone("GMT"+timeZone.toString());
3306+ return result;
3307+ }
3308+
3309+ @Override
3310+ public void bindAtomicValue(QName varName, String value, XQItemType type) throws XQException {
3311+ isClosedXQException();
3312+ isNullXQException(varName);
3313+ isNullXQException(value);
3314+ try {
3315+ XQItem item = connection.createItemFromAtomicValue(value, type);
3316+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3317+ } catch (Exception e) {
3318+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3319+ }
3320+ }
3321+
3322+ @Override
3323+ public void bindString(QName varName, String value, XQItemType type) throws XQException {
3324+ isClosedXQException();
3325+ isNullXQException(varName);
3326+ isNullXQException(value);
3327+ try {
3328+ XQItem item = connection.createItemFromString(value, type);
3329+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3330+ } catch (Exception e) {
3331+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3332+ }
3333+ }
3334+
3335+ @Override
3336+ public void bindDocument(QName varName, String value, String baseURI, XQItemType type) throws XQException {
3337+ isClosedXQException();
3338+ isNullXQException(varName);
3339+ isNullXQException(value);
3340+ try {
3341+ XQItem item = connection.createItemFromDocument(value, baseURI, type);
3342+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3343+ } catch (Exception e) {
3344+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3345+ }
3346+ }
3347+
3348+ @Override
3349+ public void bindDocument(QName varName, Reader value, String baseURI, XQItemType type) throws XQException {
3350+ isClosedXQException();
3351+ isNullXQException(varName);
3352+ isNullXQException(value);
3353+ try {
3354+ XQItem item = connection.createItemFromDocument(value, baseURI, type);
3355+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3356+ } catch (Exception e) {
3357+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3358+ }
3359+ }
3360+
3361+ @Override
3362+ public void bindDocument(QName varName, InputStream value, String baseURI, XQItemType type) throws XQException {
3363+ isClosedXQException();
3364+ isNullXQException(varName);
3365+ isNullXQException(value);
3366+ try {
3367+ XQItem item = connection.createItemFromDocument(value, baseURI, type);
3368+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3369+ } catch (Exception e) {
3370+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3371+ }
3372+ }
3373+
3374+ @Override
3375+ public void bindDocument(QName varName, XMLStreamReader value, XQItemType type) throws XQException {
3376+ isClosedXQException();
3377+ isNullXQException(varName);
3378+ isNullXQException(value);
3379+ try {
3380+ XQItem item = connection.createItemFromDocument(value, type);
3381+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3382+ } catch (Exception e) {
3383+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3384+ }
3385+ }
3386+
3387+ @Override
3388+ public void bindDocument(QName varName, Source value, XQItemType type) throws XQException {
3389+ isClosedXQException();
3390+ isNullXQException(varName);
3391+ isNullXQException(value);
3392+ try {
3393+ XQItem item = connection.createItemFromDocument(value, type);
3394+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3395+ } catch (Exception e) {
3396+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3397+ }
3398+ }
3399+
3400+ @Override
3401+ public void setImplicitTimeZone(TimeZone value) throws XQException {
3402+ isClosedXQException();
3403+ isNullXQException(value);
3404+ try {
3405+ implicitTimeZone = value;
3406+ } catch (Exception e) {
3407+ throw new XQException("Error setting implicit TimeZone: " + e.getLocalizedMessage());
3408+ }
3409+ }
3410+
3411+ @Override
3412+ public void bindItem(QName varName, XQItem value) throws XQException {
3413+ isClosedXQException();
3414+ isNullXQException(varName);
3415+ isNullXQException(value);
3416+ try {
3417+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)value).getZorbaItem());
3418+ } catch (Exception e) {
3419+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3420+ }
3421+ }
3422+
3423+ @Override
3424+ public void bindSequence(QName varName, XQSequence value) throws XQException {
3425+ isClosedXQException();
3426+ isNullXQException(varName);
3427+ isNullXQException(value);
3428+ try {
3429+ Item item = new Item(((org.zorbaxquery.api.xqj.XQItem)value.getItem()).getZorbaItem());
3430+ itemsToBind.put(varName.getLocalPart(), item);
3431+ } catch (Exception e) {
3432+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3433+ }
3434+ }
3435+
3436+ @Override
3437+ public void bindObject(QName varName, Object value, XQItemType type) throws XQException {
3438+ isClosedXQException();
3439+ isNullXQException(varName);
3440+ isNullXQException(value);
3441+ try {
3442+ XQItem item = null;
3443+ if (value instanceof XQItem) {
3444+ item = (XQItem)value;
3445+ } else {
3446+ item = connection.createItemFromObject(value, type);
3447+ }
3448+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3449+ } catch (Exception e) {
3450+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3451+ }
3452+ }
3453+
3454+ @Override
3455+ public void bindBoolean(QName varName, boolean value, XQItemType type) throws XQException {
3456+ isClosedXQException();
3457+ isNullXQException(varName);
3458+ try {
3459+ XQItem item = connection.createItemFromBoolean(value, type);
3460+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3461+ } catch (Exception e) {
3462+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3463+ }
3464+ }
3465+
3466+ @Override
3467+ public void bindByte(QName varName, byte value, XQItemType type) throws XQException {
3468+ isClosedXQException();
3469+ isNullXQException(varName);
3470+ try {
3471+ XQItem item = connection.createItemFromByte(value, type);
3472+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3473+ } catch (Exception e) {
3474+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3475+ }
3476+ }
3477+
3478+ @Override
3479+ public void bindDouble(QName varName, double value, XQItemType type) throws XQException {
3480+ isClosedXQException();
3481+ isNullXQException(varName);
3482+ try {
3483+ XQItem item = connection.createItemFromDouble(value, type);
3484+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3485+ } catch (Exception e) {
3486+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3487+ }
3488+ }
3489+
3490+ @Override
3491+ public void bindFloat(QName varName, float value, XQItemType type) throws XQException {
3492+ isClosedXQException();
3493+ isNullXQException(varName);
3494+ try {
3495+ XQItem item = connection.createItemFromFloat(value, type);
3496+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3497+ } catch (Exception e) {
3498+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3499+ }
3500+ }
3501+
3502+ @Override
3503+ public void bindInt(QName varName, int value, XQItemType type) throws XQException {
3504+ isClosedXQException();
3505+ isNullXQException(varName);
3506+ try {
3507+ XQItem item = connection.createItemFromInt(value, type);
3508+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3509+ } catch (Exception e) {
3510+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3511+ }
3512+ }
3513+
3514+ @Override
3515+ public void bindLong(QName varName, long value, XQItemType type) throws XQException {
3516+ isClosedXQException();
3517+ isNullXQException(varName);
3518+ try {
3519+ XQItem item = connection.createItemFromLong(value, type);
3520+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3521+ } catch (Exception e) {
3522+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3523+ }
3524+ }
3525+
3526+ @Override
3527+ public void bindNode(QName varName, Node value, XQItemType type) throws XQException {
3528+ isClosedXQException();
3529+ isNullXQException(varName);
3530+ isNullXQException(value);
3531+ try {
3532+ XQItem item = connection.createItemFromNode(value, type);
3533+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3534+ } catch (Exception e) {
3535+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3536+ }
3537+ }
3538+
3539+ @Override
3540+ public void bindShort(QName varName, short value, XQItemType type) throws XQException {
3541+ isClosedXQException();
3542+ isNullXQException(varName);
3543+ try {
3544+ XQItem item = connection.createItemFromShort(value, type);
3545+ itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
3546+ } catch (Exception e) {
3547+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
3548+ }
3549+ }
3550+
3551+ private void isClosedXQException() throws XQException {
3552+ if (closed) {
3553+ throw new XQException("This expression is closed");
3554+ }
3555+ }
3556+ private void isNullXQException(Object value) throws XQException {
3557+ if (value==null) {
3558+ throw new XQException("Parameter shouldn't be null");
3559+ }
3560+ }
3561+
3562+
3563+}
3564
3565=== added file 'swig/xqj/XQItem.java'
3566--- swig/xqj/XQItem.java 1970-01-01 00:00:00 +0000
3567+++ swig/xqj/XQItem.java 2012-04-19 22:34:19 +0000
3568@@ -0,0 +1,642 @@
3569+/*
3570+ * Copyright 2006-2012 The FLWOR Foundation.
3571+ *
3572+ * Licensed under the Apache License, Version 2.0 (the "License");
3573+ * you may not use this file except in compliance with the License.
3574+ * You may obtain a copy of the License at
3575+ *
3576+ * http://www.apache.org/licenses/LICENSE-2.0
3577+ *
3578+ * Unless required by applicable law or agreed to in writing, software
3579+ * distributed under the License is distributed on an "AS IS" BASIS,
3580+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3581+ * See the License for the specific language governing permissions and
3582+ * limitations under the License.
3583+ */
3584+package org.zorbaxquery.api.xqj;
3585+
3586+import java.io.ByteArrayInputStream;
3587+import java.io.InputStream;
3588+import java.io.OutputStream;
3589+import java.io.StringReader;
3590+import java.io.Writer;
3591+import java.math.BigDecimal;
3592+import java.math.BigInteger;
3593+import java.net.URI;
3594+import java.util.ArrayList;
3595+import java.util.Collection;
3596+import java.util.Properties;
3597+import javax.xml.datatype.DatatypeFactory;
3598+import javax.xml.namespace.QName;
3599+import javax.xml.parsers.DocumentBuilder;
3600+import javax.xml.parsers.DocumentBuilderFactory;
3601+import javax.xml.stream.XMLInputFactory;
3602+import javax.xml.stream.XMLStreamReader;
3603+import javax.xml.transform.Result;
3604+import javax.xml.transform.Source;
3605+import javax.xml.transform.Transformer;
3606+import javax.xml.transform.TransformerFactory;
3607+import javax.xml.transform.dom.DOMSource;
3608+import javax.xml.xquery.XQException;
3609+import javax.xml.xquery.XQItemType;
3610+import org.w3c.dom.Document;
3611+import org.w3c.dom.Element;
3612+import org.w3c.dom.Node;
3613+import org.xml.sax.ContentHandler;
3614+import org.xml.sax.InputSource;
3615+import org.xml.sax.helpers.AttributesImpl;
3616+import org.zorbaxquery.api.Item;
3617+import org.zorbaxquery.api.Iterator;
3618+import org.zorbaxquery.api.SerializationOptions;
3619+import org.zorbaxquery.api.StringPair;
3620+import org.zorbaxquery.api.StringPairVector;
3621+
3622+class XQItem implements javax.xml.xquery.XQItem {
3623+
3624+ private Item item;
3625+ private boolean closed=false;
3626+ private XQItemType itemType;
3627+
3628+ protected Item getZorbaItem() {
3629+ return item;
3630+ }
3631+
3632+ public XQItem(XQItemType itemType) {
3633+ this.itemType = itemType;
3634+ }
3635+
3636+ public XQItem(Item item) {
3637+ this.item = new Item(item);
3638+ this.itemType = new org.zorbaxquery.api.xqj.XQItemType(this.item);
3639+ }
3640+
3641+ public XQItem(Item item, XQItemType itemType) {
3642+ this.item = new Item(item);
3643+ this.itemType = itemType;
3644+ }
3645+
3646+ public XQItem(javax.xml.xquery.XQItem item) throws XQException {
3647+ this.item = new Item(((XQItem)item).getZorbaItem());
3648+ this.itemType = item.getItemType();
3649+ }
3650+
3651+ @Override
3652+ public void close() throws XQException {
3653+ if (!closed) {
3654+ item.close();
3655+ item.delete();
3656+ closed = true;
3657+ }
3658+ }
3659+
3660+ @Override
3661+ public boolean isClosed() {
3662+ return closed;
3663+ }
3664+
3665+ @Override
3666+ public boolean getBoolean() throws XQException {
3667+ isClosedXQException();
3668+ if (itemType.getBaseType()!=XQItemType.XQBASETYPE_BOOLEAN) {
3669+ throw new XQException("Object is not boolean");
3670+ }
3671+ Boolean result;
3672+ try {
3673+ result = item.getBooleanValue();
3674+ } catch (Exception e) {
3675+ throw new XQException("Error getting boolean value" + e.getLocalizedMessage());
3676+ }
3677+ return result;
3678+ }
3679+
3680+ @Override
3681+ public byte getByte() throws XQException {
3682+ isClosedXQException();
3683+ isDecimalXQException();
3684+ byte result = 0;
3685+ try {
3686+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_BYTE) {
3687+ result = (byte) item.getIntValue();
3688+ } else {
3689+ result = Byte.parseByte(item.getStringValue());
3690+ }
3691+ } catch (Exception e) {
3692+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
3693+ }
3694+ return result;
3695+ }
3696+
3697+ @Override
3698+ public double getDouble() throws XQException {
3699+ isClosedXQException();
3700+ isFloatXQException();
3701+ double result = 0;
3702+ try {
3703+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_DOUBLE) {
3704+ result = item.getDoubleValue();
3705+ } else {
3706+ result = Double.parseDouble(item.getStringValue());
3707+ }
3708+ } catch (Exception e) {
3709+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
3710+ }
3711+ return result;
3712+ }
3713+
3714+ @Override
3715+ public float getFloat() throws XQException {
3716+ isClosedXQException();
3717+ isFloatXQException();
3718+ float result = 0;
3719+ try {
3720+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_FLOAT) {
3721+ result = (float)item.getDoubleValue();
3722+ } else {
3723+ result = Float.parseFloat(item.getStringValue());
3724+ }
3725+ } catch (Exception e) {
3726+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
3727+ }
3728+ return result;
3729+ }
3730+
3731+ @Override
3732+ public int getInt() throws XQException {
3733+ isClosedXQException();
3734+ isDecimalXQException();
3735+ int result = 0;
3736+ try {
3737+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_INT) {
3738+ result = item.getIntValue();
3739+ } else {
3740+ result = Integer.parseInt(item.getStringValue());
3741+ }
3742+ } catch (Exception e) {
3743+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
3744+ }
3745+ return result;
3746+ }
3747+
3748+ @Override
3749+ public XQItemType getItemType() throws XQException {
3750+ isClosedXQException();
3751+ return itemType;
3752+ }
3753+
3754+ @Override
3755+ public String getAtomicValue() throws XQException {
3756+ isClosedXQException();
3757+ if (!item.isAtomic()) {
3758+ throw new XQException("Object is not atomic");
3759+ }
3760+ org.zorbaxquery.api.Item lItem = null;
3761+ try {
3762+ org.zorbaxquery.api.Iterator iterator = item.getAtomizationValue();
3763+ lItem = new Item(); // creating a new item to be filled by iterator
3764+ iterator.open();
3765+ iterator.next(lItem); // item CAN'T BE NULL
3766+ iterator.close();
3767+ } catch (Exception e) {
3768+ throw new XQException("Error getting atomic value: " + e.getLocalizedMessage());
3769+ }
3770+ return lItem.getStringValue();
3771+ }
3772+
3773+ @Override
3774+ public long getLong() throws XQException {
3775+ isClosedXQException();
3776+ isDecimalXQException();
3777+ long result = 0;
3778+ try {
3779+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_LONG) {
3780+ result = item.getLongValue();
3781+ } else {
3782+ result = Long.parseLong(item.getStringValue());
3783+ }
3784+ } catch (Exception e) {
3785+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
3786+ }
3787+ return result;
3788+ }
3789+
3790+ @Override
3791+ public Node getNode() throws XQException {
3792+ isClosedXQException();
3793+ if (!item.isNode()) {
3794+ throw new XQException("Object is not a node");
3795+ }
3796+ Node result = null;
3797+ InputStream inputStream = new ByteArrayInputStream(item.toString().getBytes());
3798+ try {
3799+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
3800+ DocumentBuilder db = dbf.newDocumentBuilder();
3801+ Document doc = db.newDocument();
3802+ Item nodeName = new Item();
3803+ item.getNodeName(nodeName);
3804+ switch (itemType.getItemKind()) {
3805+ case XQItemType.XQITEMKIND_ATTRIBUTE:
3806+ result = doc.createAttributeNS("", nodeName.getStringValue());
3807+ break;
3808+ case XQItemType.XQITEMKIND_COMMENT:
3809+ result = doc.createComment(item.getStringValue());
3810+ break;
3811+ case XQItemType.XQITEMKIND_DOCUMENT:
3812+ String tmpDoc = item.serialize();
3813+ if (tmpDoc.length()>0) {
3814+ result = db.parse(new InputSource(new StringReader(tmpDoc)));
3815+ } else {
3816+ result = doc; // empty doc
3817+ }
3818+ break;
3819+ case XQItemType.XQITEMKIND_ELEMENT:
3820+ Element e = doc.createElementNS("", nodeName.getStringValue());
3821+ Node text = doc.createTextNode(item.getStringValue());
3822+ e.appendChild(text);
3823+ result = e;
3824+ break;
3825+ case XQItemType.XQITEMKIND_PI:
3826+ String tmpPI = item.serialize().substring(2).split(" ")[0];
3827+ result = doc.createProcessingInstruction(tmpPI, item.getStringValue());
3828+ break;
3829+ case XQItemType.XQITEMKIND_TEXT:
3830+ result = doc.createTextNode(item.getStringValue());
3831+ break;
3832+ }
3833+ } catch (Exception ex) {
3834+ throw new XQException("Error converting Item to Node" + ex.getLocalizedMessage());
3835+ }
3836+
3837+ return result;
3838+ }
3839+
3840+ @Override
3841+ public URI getNodeUri() throws XQException {
3842+ isClosedXQException();
3843+ if (!item.isNode()) {
3844+ throw new XQException("Object is not a node");
3845+ }
3846+ URI result;
3847+ String namespace = "";
3848+ try {
3849+ Item type = new Item();
3850+ type = item.getType();
3851+ if (type.getStringValue().equalsIgnoreCase("xs:qname")) {
3852+ namespace = item.getNamespace();
3853+ } else {
3854+ StringPairVector bindings = item.getNamespaceBindings();
3855+ // Not using the full set, only the first binding
3856+ if (bindings.size()>0) {
3857+ StringPair pair = bindings.get(0);
3858+ namespace = pair.getFirst();
3859+ }
3860+ }
3861+ } catch (Exception ex) {
3862+ throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
3863+ }
3864+ try {
3865+ result = new URI(namespace);
3866+ } catch (Exception ex) {
3867+ throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
3868+ }
3869+ return result;
3870+ }
3871+
3872+ @Override
3873+ public Object getObject() throws XQException {
3874+ isClosedXQException();
3875+ Object result = null;
3876+ try {
3877+ if ((itemType.getItemKind()==XQItemType.XQITEMKIND_ATTRIBUTE) ||
3878+ (itemType.getItemKind()==XQItemType.XQITEMKIND_COMMENT) ||
3879+ (itemType.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT) ||
3880+ (itemType.getItemKind()==XQItemType.XQITEMKIND_ELEMENT) ||
3881+ (itemType.getItemKind()==XQItemType.XQITEMKIND_PI) ||
3882+ (itemType.getItemKind()==XQItemType.XQITEMKIND_TEXT) ) {
3883+ result = this.getNode();
3884+ } else if (itemType.getItemKind()==XQItemType.XQITEMKIND_ATOMIC) {
3885+ //result = this.getNode();
3886+ DatatypeFactory factory = DatatypeFactory.newInstance();
3887+ switch (itemType.getBaseType()) {
3888+ /*
3889+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
3890+ break;
3891+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
3892+ break;
3893+ case XQItemType.XQBASETYPE_ANYTYPE:
3894+ break;
3895+ *
3896+ */
3897+ case XQItemType.XQBASETYPE_ANYURI:
3898+ result = item.getStringValue();
3899+ break;
3900+ case XQItemType.XQBASETYPE_BASE64BINARY:
3901+ result = item.serialize().getBytes();
3902+ break;
3903+ case XQItemType.XQBASETYPE_BOOLEAN:
3904+ result = item.getBooleanValue();
3905+ break;
3906+ case XQItemType.XQBASETYPE_BYTE:
3907+ result = new Byte(item.getStringValue());
3908+ break;
3909+ case XQItemType.XQBASETYPE_DATE:
3910+ case XQItemType.XQBASETYPE_DATETIME:
3911+ case XQItemType.XQBASETYPE_GDAY:
3912+ case XQItemType.XQBASETYPE_GMONTH:
3913+ case XQItemType.XQBASETYPE_GMONTHDAY:
3914+ case XQItemType.XQBASETYPE_GYEAR:
3915+ case XQItemType.XQBASETYPE_GYEARMONTH:
3916+ case XQItemType.XQBASETYPE_TIME:
3917+ result = factory.newXMLGregorianCalendar(item.getStringValue());
3918+ break;
3919+ case XQItemType.XQBASETYPE_DURATION:
3920+ result = factory.newDuration(item.getStringValue());
3921+ break;
3922+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
3923+ String tmpString = item.getStringValue();
3924+ result = factory.newDurationDayTime(tmpString);
3925+ break;
3926+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
3927+ result = factory.newDurationYearMonth(item.getStringValue());
3928+ break;
3929+ case XQItemType.XQBASETYPE_DECIMAL:
3930+ result = new BigDecimal(item.getStringValue());
3931+ break;
3932+ case XQItemType.XQBASETYPE_DOUBLE:
3933+ result = item.getDoubleValue();
3934+ break;
3935+ case XQItemType.XQBASETYPE_ENTITIES:
3936+ result = item.getStringValue();
3937+ break;
3938+ case XQItemType.XQBASETYPE_ENTITY:
3939+ result = item.getStringValue();
3940+ break;
3941+ case XQItemType.XQBASETYPE_FLOAT:
3942+ result = (float)(item.getDoubleValue());
3943+ break;
3944+ case XQItemType.XQBASETYPE_HEXBINARY:
3945+ result = item.getStringValue().getBytes();
3946+ break;
3947+ case XQItemType.XQBASETYPE_ID:
3948+ result = item.getStringValue();
3949+ break;
3950+ case XQItemType.XQBASETYPE_IDREF:
3951+ result = item.getStringValue();
3952+ break;
3953+ case XQItemType.XQBASETYPE_IDREFS:
3954+ result = item.getStringValue();
3955+ break;
3956+ case XQItemType.XQBASETYPE_INT:
3957+ result = item.getIntValue();
3958+ break;
3959+ case XQItemType.XQBASETYPE_LANGUAGE:
3960+ result = item.getStringValue();
3961+ break;
3962+ case XQItemType.XQBASETYPE_LONG:
3963+ result = item.getLongValue();
3964+ break;
3965+ case XQItemType.XQBASETYPE_NAME:
3966+ result = item.getStringValue();
3967+ break;
3968+ case XQItemType.XQBASETYPE_NCNAME:
3969+ result = item.serialize();
3970+ break;
3971+ case XQItemType.XQBASETYPE_NMTOKEN:
3972+ result = item.getStringValue();
3973+ break;
3974+ case XQItemType.XQBASETYPE_NMTOKENS:
3975+ result = item.getStringValue();
3976+ break;
3977+ case XQItemType.XQBASETYPE_INTEGER:
3978+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
3979+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
3980+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
3981+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
3982+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
3983+ result = new BigInteger(item.getStringValue());
3984+ break;
3985+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
3986+ result = item.getStringValue();
3987+ break;
3988+ case XQItemType.XQBASETYPE_NOTATION:
3989+ result = item.getStringValue();
3990+ break;
3991+ case XQItemType.XQBASETYPE_QNAME:
3992+ result = new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()) ;
3993+ break;
3994+ case XQItemType.XQBASETYPE_STRING:
3995+ result = item.getStringValue();
3996+ break;
3997+ case XQItemType.XQBASETYPE_TOKEN:
3998+ result = item.getStringValue();
3999+ break;
4000+ case XQItemType.XQBASETYPE_SHORT:
4001+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
4002+ result = new Short(item.getStringValue());
4003+ break;
4004+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
4005+ result = new Long(item.getStringValue());
4006+ break;
4007+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
4008+ result = new Integer(item.getStringValue());
4009+ break;
4010+ case XQItemType.XQBASETYPE_UNTYPED:
4011+ result = item.getStringValue();
4012+ break;
4013+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
4014+ result = item.getStringValue();
4015+ break;
4016+ }
4017+
4018+ }
4019+ } catch (Exception e) {
4020+ throw new XQException("Error getting byte value: " + e.getLocalizedMessage());
4021+ }
4022+ return result;
4023+ }
4024+
4025+ @Override
4026+ public XMLStreamReader getItemAsStream() throws XQException {
4027+ isClosedXQException();
4028+ XMLInputFactory factory = XMLInputFactory.newInstance();
4029+ XMLStreamReader result = null;
4030+ try {
4031+ result = factory.createXMLStreamReader(new StringReader(item.serialize()));
4032+ } catch (Exception ex) {
4033+ throw new XQException("Error creating XMLStreamReader: " + ex.getLocalizedMessage());
4034+ }
4035+ return result;
4036+ }
4037+
4038+ @Override
4039+ public String getItemAsString(Properties prprts) throws XQException {
4040+ isClosedXQException();
4041+ String result = null;
4042+ try {
4043+ SerializationOptions opts = new SerializationOptions();
4044+ if ((prprts!=null) && prprts.size()>0) {
4045+ for(String key : prprts.stringPropertyNames()) {
4046+ String value = prprts.getProperty(key);
4047+ opts.setSerializerOption(key, value);
4048+ }
4049+ }
4050+ result = item.serialize(opts).replace("&gt;", ">").replace("&lt;", "<");
4051+ } catch (Exception ex) {
4052+ throw new XQException("Error serializing item" + ex.getLocalizedMessage());
4053+ }
4054+ return result;
4055+ }
4056+
4057+ @Override
4058+ public short getShort() throws XQException {
4059+ isClosedXQException();
4060+ isDecimalXQException();
4061+ short result;
4062+ try {
4063+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_SHORT) {
4064+ result = (short) item.getIntValue();
4065+ } else {
4066+ result = Short.parseShort(item.getStringValue());
4067+ }
4068+ } catch (Exception ex) {
4069+ throw new XQException("Error getting short value: " + ex.getLocalizedMessage());
4070+ }
4071+ return result;
4072+ }
4073+
4074+ @Override
4075+ public boolean instanceOf(XQItemType xqit) throws XQException {
4076+ isClosedXQException();
4077+ return itemType.equals(xqit);
4078+ }
4079+
4080+ @Override
4081+ public void writeItem(OutputStream out, Properties prprts) throws XQException {
4082+ isClosedXQException();
4083+ isNullXQException(out);
4084+ isNullXQException(prprts);
4085+ try {
4086+ SerializationOptions opts = new SerializationOptions();
4087+ if ((prprts!=null) && prprts.size()>0) {
4088+ for(String key : prprts.stringPropertyNames()) {
4089+ String value = prprts.getProperty(key);
4090+ opts.setSerializerOption(key, value);
4091+ }
4092+ }
4093+ out.write(item.serialize(opts).getBytes());
4094+ } catch (Exception ex) {
4095+ throw new XQException("Error writing on stream: " + ex.getLocalizedMessage());
4096+ }
4097+ }
4098+
4099+ @Override
4100+ public void writeItem(Writer writer, Properties prprts) throws XQException {
4101+ isClosedXQException();
4102+ isNullXQException(writer);
4103+ isNullXQException(prprts);
4104+ try {
4105+ SerializationOptions opts = new SerializationOptions();
4106+ if ((prprts!=null) && prprts.size()>0) {
4107+ for(String key : prprts.stringPropertyNames()) {
4108+ String value = prprts.getProperty(key);
4109+ opts.setSerializerOption(key, value);
4110+ }
4111+ }
4112+ writer.write(item.serialize(opts));
4113+ } catch (Exception ex) {
4114+ throw new XQException("Error sending to writer: " + ex.getLocalizedMessage());
4115+ }
4116+ }
4117+
4118+ @Override
4119+ public void writeItemToSAX(ContentHandler ch) throws XQException {
4120+ isClosedXQException();
4121+ isNullXQException(ch);
4122+ try {
4123+ AttributesImpl attributes = new AttributesImpl();
4124+ Iterator attr = item.getAttributes();
4125+ attr.open();
4126+ Item attribute = new Item();
4127+ while (attr.next(attribute)) {
4128+ attributes.addAttribute(attribute.getNamespace(), attribute.getLocalName(), "", attribute.getType().getStringValue(), attribute.getStringValue());
4129+ }
4130+ attribute.close();
4131+ attr.close();
4132+ attr.delete();
4133+ //attribute.delete();
4134+ String namespace = "";
4135+ if (itemType.getBaseType() != XQItemType.XQBASETYPE_ANYTYPE){
4136+ namespace = item.getNamespace();
4137+ }
4138+ Item name = new Item();
4139+ item.getNodeName(name);
4140+ String nodeName = name.getStringValue();
4141+ name.close();
4142+ //name.delete();
4143+ char [] content = item.getStringValue().toCharArray();
4144+
4145+ ch.startElement(namespace, nodeName , "", attributes);
4146+ ch.characters(content, 0, content.length);
4147+ ch.endElement(namespace, nodeName, "");
4148+ } catch (Exception ex) {
4149+ throw new XQException("Error writing item to SAX: " + ex.getLocalizedMessage());
4150+ }
4151+ }
4152+
4153+ @Override
4154+ public void writeItemToResult(Result result) throws XQException {
4155+ isClosedXQException();
4156+ isNullXQException(result);
4157+ try {
4158+ Source xmlSource = new DOMSource(getNode());
4159+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
4160+ Transformer transformer;
4161+ transformer = transformerFactory.newTransformer();
4162+ transformer.setOutputProperty("indent", "yes");
4163+ transformer.transform(xmlSource, result);
4164+ } catch (Exception ex) {
4165+ throw new XQException ("Error serializing to javax.xml.transform.Result");
4166+ }
4167+ }
4168+
4169+ private void isClosedXQException() throws XQException {
4170+ if (closed) {
4171+ throw new XQException("This connection is closed");
4172+ }
4173+ }
4174+
4175+ private void isNullXQException(Object value) throws XQException {
4176+ if (value==null) {
4177+ throw new XQException("Parameter shouldn't be null");
4178+ }
4179+ }
4180+
4181+ private void isDecimalXQException() throws XQException {
4182+ switch (itemType.getBaseType()) {
4183+ case XQItemType.XQBASETYPE_DECIMAL:
4184+ case XQItemType.XQBASETYPE_BYTE:
4185+ case XQItemType.XQBASETYPE_INT:
4186+ case XQItemType.XQBASETYPE_INTEGER:
4187+ case XQItemType.XQBASETYPE_LONG:
4188+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
4189+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
4190+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
4191+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
4192+ case XQItemType.XQBASETYPE_SHORT:
4193+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
4194+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
4195+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
4196+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
4197+ break;
4198+ default:
4199+ throw new XQException("Object is not xs:decimal or a derivate");
4200+ }
4201+ }
4202+
4203+ private void isFloatXQException() throws XQException {
4204+ if (! ((itemType.getBaseType()==XQItemType.XQBASETYPE_FLOAT) ||
4205+ (itemType.getBaseType()==XQItemType.XQBASETYPE_DOUBLE)) )
4206+ {
4207+ throw new XQException("Object is not xs:decimal or a derivate");
4208+ }
4209+ }
4210+}
4211
4212=== added file 'swig/xqj/XQItemType.java'
4213--- swig/xqj/XQItemType.java 1970-01-01 00:00:00 +0000
4214+++ swig/xqj/XQItemType.java 2012-04-19 22:34:19 +0000
4215@@ -0,0 +1,743 @@
4216+/*
4217+ * Copyright 2006-2012 The FLWOR Foundation.
4218+ *
4219+ * Licensed under the Apache License, Version 2.0 (the "License");
4220+ * you may not use this file except in compliance with the License.
4221+ * You may obtain a copy of the License at
4222+ *
4223+ * http://www.apache.org/licenses/LICENSE-2.0
4224+ *
4225+ * Unless required by applicable law or agreed to in writing, software
4226+ * distributed under the License is distributed on an "AS IS" BASIS,
4227+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4228+ * See the License for the specific language governing permissions and
4229+ * limitations under the License.
4230+ */
4231+package org.zorbaxquery.api.xqj;
4232+
4233+import java.net.URI;
4234+import javax.xml.namespace.QName;
4235+import javax.xml.xquery.XQException;
4236+import javax.xml.xquery.XQSequenceType;
4237+import org.zorbaxquery.api.IdentTypes.Kind;
4238+import org.zorbaxquery.api.Item;
4239+import org.zorbaxquery.api.TypeIdentifier;
4240+
4241+public class XQItemType implements javax.xml.xquery.XQItemType {
4242+ public static final int ZORBA_XQITEMKIND_ANY = 0;
4243+ public static final int ZORBA_XQITEMKIND_DOCUMENT = 1;
4244+ public static final int ZORBA_XQITEMKIND_ELEMENT = 2;
4245+ public static final int ZORBA_XQITEMKIND_ATTRIBUTE = 3;
4246+ public static final int ZORBA_XQITEMKIND_TEXT = 4;
4247+ public static final int ZORBA_XQITEMKIND_PI = 5;
4248+ public static final int ZORBA_XQITEMKIND_COMMENT = 6;
4249+
4250+ private int itemKind = 0;
4251+ private int baseType = 0;
4252+ private QName nodeName = null;
4253+ private QName typeName = null;
4254+ private URI schemaURI = null;
4255+ private boolean allowNill = false;
4256+ private String piTarget = null;
4257+
4258+ protected TypeIdentifier getTypeIdentifier() throws XQException {
4259+ TypeIdentifier result = null;
4260+ switch (itemKind) {
4261+ case XQITEMKIND_ATOMIC:
4262+ result = TypeIdentifier.createEmptyType();
4263+ break;
4264+ case XQITEMKIND_ATTRIBUTE:
4265+ result = TypeIdentifier.createAttributeType(schemaURI.toString(), true, nodeName.getLocalPart(), true, TypeIdentifier.createAnyNodeType());
4266+ break;
4267+ case XQITEMKIND_COMMENT:
4268+ result = TypeIdentifier.createCommentType();
4269+ break;
4270+ case XQITEMKIND_DOCUMENT:
4271+ case XQITEMKIND_DOCUMENT_ELEMENT:
4272+ case XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
4273+ result = TypeIdentifier.createDocumentType(TypeIdentifier.createAnyNodeType());
4274+ break;
4275+ case XQITEMKIND_ELEMENT:
4276+ result = TypeIdentifier.createElementType(schemaURI.toString(), true, nodeName.getLocalPart(), true, TypeIdentifier.createAnyNodeType());
4277+ break;
4278+ case XQITEMKIND_ITEM:
4279+ result = TypeIdentifier.createItemType();
4280+ break;
4281+ case XQITEMKIND_NODE:
4282+ result = TypeIdentifier.createAnyNodeType();
4283+ break;
4284+ case XQITEMKIND_PI:
4285+ result = TypeIdentifier.createPIType();
4286+ break;
4287+ case XQITEMKIND_TEXT:
4288+ result = TypeIdentifier.createTextType();
4289+ break;
4290+ case XQITEMKIND_SCHEMA_ATTRIBUTE:
4291+ case XQITEMKIND_SCHEMA_ELEMENT:
4292+ default:
4293+ throw new XQException("Item kind is not valid.");
4294+
4295+ }
4296+ return result;
4297+ }
4298+
4299+ public XQItemType(TypeIdentifier typeIdentifier) {
4300+ switch (typeIdentifier.getKind()) {
4301+ case Kind.ANY_NODE_TYPE:
4302+ itemKind = XQITEMKIND_NODE;
4303+ break;
4304+ case Kind.ATTRIBUTE_TYPE:
4305+ itemKind = XQITEMKIND_ATTRIBUTE;
4306+ break;
4307+ case Kind.COMMENT_TYPE:
4308+ itemKind = XQITEMKIND_COMMENT;
4309+ break;
4310+ case Kind.DOCUMENT_TYPE:
4311+ itemKind = XQITEMKIND_DOCUMENT;
4312+ break;
4313+ case Kind.ELEMENT_TYPE:
4314+ itemKind = XQITEMKIND_ELEMENT;
4315+ break;
4316+ case Kind.EMPTY_TYPE:
4317+ case Kind.INVALID_TYPE:
4318+ case Kind.ITEM_TYPE:
4319+ case Kind.NAMED_TYPE:
4320+ itemKind = XQITEMKIND_ITEM;
4321+ break;
4322+ case Kind.PI_TYPE:
4323+ itemKind = XQITEMKIND_PI;
4324+ break;
4325+ case Kind.TEXT_TYPE:
4326+ itemKind = XQITEMKIND_TEXT;
4327+ break;
4328+ default:
4329+ itemKind = XQITEMKIND_NODE;
4330+ break;
4331+ }
4332+
4333+ String type = typeIdentifier.getLocalName();
4334+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
4335+ if (type.indexOf("anyAtomicType")>=0){
4336+ baseType = XQItemType.XQBASETYPE_ANYATOMICTYPE;
4337+ } else if (type.indexOf("anySimpleType")>=0){
4338+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
4339+ } else if (type.indexOf("anyType")>=0){
4340+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
4341+ } else if (type.indexOf("anyURI")>=0){
4342+ baseType = XQItemType.XQBASETYPE_ANYURI;
4343+ } else if (type.indexOf("base64Binary")>=0){
4344+ baseType = XQItemType.XQBASETYPE_BASE64BINARY;
4345+ } else if (type.indexOf("boolean")>=0){
4346+ baseType = XQItemType.XQBASETYPE_BOOLEAN;
4347+ } else if (type.indexOf("byte")>=0){
4348+ baseType = XQItemType.XQBASETYPE_BYTE;
4349+ } else if (type.indexOf("dateTime")>=0){
4350+ baseType = XQItemType.XQBASETYPE_DATETIME;
4351+ } else if (type.indexOf("date")>=0){
4352+ baseType = XQItemType.XQBASETYPE_DATE;
4353+ } else if (type.indexOf("dayTimeDuration")>=0){
4354+ baseType = XQItemType.XQBASETYPE_DAYTIMEDURATION;
4355+ } else if (type.indexOf("decimal")>=0){
4356+ baseType = XQItemType.XQBASETYPE_DECIMAL;
4357+ } else if (type.indexOf("double")>=0){
4358+ baseType = XQItemType.XQBASETYPE_DOUBLE;
4359+ } else if (type.indexOf("duration")>=0){
4360+ baseType = XQItemType.XQBASETYPE_DURATION;
4361+ } else if (type.indexOf("ENTITIES")>=0){
4362+ baseType = XQItemType.XQBASETYPE_ENTITIES;
4363+ } else if (type.indexOf("ENTITY")>=0){
4364+ baseType = XQItemType.XQBASETYPE_ENTITY;
4365+ } else if (type.indexOf("float")>=0){
4366+ baseType = XQItemType.XQBASETYPE_FLOAT;
4367+ } else if (type.indexOf("gDay")>=0){
4368+ baseType = XQItemType.XQBASETYPE_GDAY;
4369+ } else if (type.indexOf("gMonthDay")>=0){
4370+ baseType = XQItemType.XQBASETYPE_GMONTHDAY;
4371+ } else if (type.indexOf("gMonth")>=0){
4372+ baseType = XQItemType.XQBASETYPE_GMONTH;
4373+ } else if (type.indexOf("gYear")>=0){
4374+ baseType = XQItemType.XQBASETYPE_GYEAR;
4375+ } else if (type.indexOf("hexBinary")>=0){
4376+ baseType = XQItemType.XQBASETYPE_HEXBINARY;
4377+ } else if (type.indexOf("IDREFS")>=0){
4378+ baseType = XQItemType.XQBASETYPE_IDREFS;
4379+ } else if (type.indexOf("IDREF")>=0){
4380+ baseType = XQItemType.XQBASETYPE_IDREF;
4381+ } else if (type.indexOf("ID")>=0){
4382+ baseType = XQItemType.XQBASETYPE_ID;
4383+ } else if (type.indexOf("integer")>=0){
4384+ baseType = XQItemType.XQBASETYPE_INTEGER;
4385+ } else if (type.indexOf("int")>=0){
4386+ baseType = XQItemType.XQBASETYPE_INT;
4387+ } else if (type.indexOf("language")>=0){
4388+ baseType = XQItemType.XQBASETYPE_LANGUAGE;
4389+ } else if (type.indexOf("long")>=0){
4390+ baseType = XQItemType.XQBASETYPE_LONG;
4391+ } else if (type.indexOf("QName")>=0){
4392+ baseType = XQItemType.XQBASETYPE_QNAME;
4393+ } else if (type.indexOf("NCName")>=0){
4394+ baseType = XQItemType.XQBASETYPE_NCNAME;
4395+ } else if (type.indexOf("Name")>=0){
4396+ baseType = XQItemType.XQBASETYPE_NAME;
4397+ } else if (type.indexOf("negativeInteger")>=0){
4398+ baseType = XQItemType.XQBASETYPE_NEGATIVE_INTEGER;
4399+ } else if (type.indexOf("NMTOKENS")>=0){
4400+ baseType = XQItemType.XQBASETYPE_NMTOKENS;
4401+ } else if (type.indexOf("NMTOKEN")>=0){
4402+ baseType = XQItemType.XQBASETYPE_NMTOKEN;
4403+ } else if (type.indexOf("nonNegativeInteger")>=0){
4404+ baseType = XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER;
4405+ } else if (type.indexOf("nonPositiveInteger")>=0){
4406+ baseType = XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER;
4407+ } else if (type.indexOf("normalizedString")>=0){
4408+ baseType = XQItemType.XQBASETYPE_NORMALIZED_STRING;
4409+ } else if (type.indexOf("NOTATION")>=0){
4410+ baseType = XQItemType.XQBASETYPE_NOTATION;
4411+ } else if (type.indexOf("positiveInteger")>=0){
4412+ baseType = XQItemType.XQBASETYPE_POSITIVE_INTEGER;
4413+ } else if (type.indexOf("short")>=0){
4414+ baseType = XQItemType.XQBASETYPE_SHORT;
4415+ } else if (type.indexOf("string")>=0){
4416+ baseType = XQItemType.XQBASETYPE_STRING;
4417+ } else if (type.indexOf("time")>=0){
4418+ baseType = XQItemType.XQBASETYPE_TIME;
4419+ } else if (type.indexOf("token")>=0){
4420+ baseType = XQItemType.XQBASETYPE_TOKEN;
4421+ } else if (type.indexOf("unsignedByte")>=0){
4422+ baseType = XQItemType.XQBASETYPE_UNSIGNED_BYTE;
4423+ } else if (type.indexOf("unsignedInt")>=0){
4424+ baseType = XQItemType.XQBASETYPE_UNSIGNED_INT;
4425+ } else if (type.indexOf("unsignedLong")>=0){
4426+ baseType = XQItemType.XQBASETYPE_UNSIGNED_LONG;
4427+ } else if (type.indexOf("unsignedShort")>=0){
4428+ baseType = XQItemType.XQBASETYPE_UNSIGNED_SHORT;
4429+ } else if (type.indexOf("untypedAtomic")>=0){
4430+ baseType = XQItemType.XQBASETYPE_UNTYPEDATOMIC;
4431+ } else if (type.indexOf("untyped")>=0){
4432+ baseType = XQItemType.XQBASETYPE_UNTYPED;
4433+ } else if (type.indexOf("yearMonthDuration")>=0){
4434+ baseType = XQItemType.XQBASETYPE_YEARMONTHDURATION;
4435+ }
4436+ generateTypeName();
4437+ }
4438+ public XQItemType(Item zorbaItem) {
4439+
4440+ String type = "";
4441+ if (zorbaItem.isNode()) {
4442+ switch (zorbaItem.getNodeKind()) {
4443+ case ZORBA_XQITEMKIND_ANY:
4444+ itemKind = XQITEMKIND_ELEMENT;
4445+ break;
4446+ case ZORBA_XQITEMKIND_ATTRIBUTE:
4447+ itemKind = XQITEMKIND_ATTRIBUTE;
4448+ break;
4449+ case ZORBA_XQITEMKIND_COMMENT:
4450+ itemKind = XQITEMKIND_COMMENT;
4451+ break;
4452+ case ZORBA_XQITEMKIND_DOCUMENT:
4453+ itemKind = XQITEMKIND_DOCUMENT;
4454+ break;
4455+ case ZORBA_XQITEMKIND_ELEMENT:
4456+ itemKind = XQITEMKIND_ELEMENT;
4457+ break;
4458+ case ZORBA_XQITEMKIND_PI:
4459+ itemKind = XQITEMKIND_PI;
4460+ break;
4461+ case ZORBA_XQITEMKIND_TEXT:
4462+ itemKind = XQITEMKIND_TEXT;
4463+ break;
4464+ default:
4465+ itemKind = XQITEMKIND_ELEMENT;
4466+ break;
4467+
4468+ }
4469+ } else if (zorbaItem.isAtomic()) {
4470+ itemKind = XQITEMKIND_ATOMIC;
4471+ type = zorbaItem.getType().getStringValue();
4472+ }
4473+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
4474+ if (type.indexOf("anyAtomicType")>=0){
4475+ baseType = XQItemType.XQBASETYPE_ANYATOMICTYPE;
4476+ } else if (type.indexOf("anySimpleType")>=0){
4477+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
4478+ } else if (type.indexOf("anyType")>=0){
4479+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
4480+ } else if (type.indexOf("anyURI")>=0){
4481+ baseType = XQItemType.XQBASETYPE_ANYURI;
4482+ } else if (type.indexOf("base64Binary")>=0){
4483+ baseType = XQItemType.XQBASETYPE_BASE64BINARY;
4484+ } else if (type.indexOf("boolean")>=0){
4485+ baseType = XQItemType.XQBASETYPE_BOOLEAN;
4486+ } else if (type.indexOf("byte")>=0){
4487+ baseType = XQItemType.XQBASETYPE_BYTE;
4488+ } else if (type.indexOf("dateTime")>=0){
4489+ baseType = XQItemType.XQBASETYPE_DATETIME;
4490+ } else if (type.indexOf("date")>=0){
4491+ baseType = XQItemType.XQBASETYPE_DATE;
4492+ } else if (type.indexOf("dayTimeDuration")>=0){
4493+ baseType = XQItemType.XQBASETYPE_DAYTIMEDURATION;
4494+ } else if (type.indexOf("decimal")>=0){
4495+ baseType = XQItemType.XQBASETYPE_DECIMAL;
4496+ } else if (type.indexOf("double")>=0){
4497+ baseType = XQItemType.XQBASETYPE_DOUBLE;
4498+ } else if (type.indexOf("duration")>=0){
4499+ baseType = XQItemType.XQBASETYPE_DURATION;
4500+ } else if (type.indexOf("ENTITIES")>=0){
4501+ baseType = XQItemType.XQBASETYPE_ENTITIES;
4502+ } else if (type.indexOf("ENTITY")>=0){
4503+ baseType = XQItemType.XQBASETYPE_ENTITY;
4504+ } else if (type.indexOf("float")>=0){
4505+ baseType = XQItemType.XQBASETYPE_FLOAT;
4506+ } else if (type.indexOf("gDay")>=0){
4507+ baseType = XQItemType.XQBASETYPE_GDAY;
4508+ } else if (type.indexOf("gMonthDay")>=0){
4509+ baseType = XQItemType.XQBASETYPE_GMONTHDAY;
4510+ } else if (type.indexOf("gMonth")>=0){
4511+ baseType = XQItemType.XQBASETYPE_GMONTH;
4512+ } else if (type.indexOf("gYear")>=0){
4513+ baseType = XQItemType.XQBASETYPE_GYEAR;
4514+ } else if (type.indexOf("hexBinary")>=0){
4515+ baseType = XQItemType.XQBASETYPE_HEXBINARY;
4516+ } else if (type.indexOf("IDREFS")>=0){
4517+ baseType = XQItemType.XQBASETYPE_IDREFS;
4518+ } else if (type.indexOf("IDREF")>=0){
4519+ baseType = XQItemType.XQBASETYPE_IDREF;
4520+ } else if (type.indexOf("ID")>=0){
4521+ baseType = XQItemType.XQBASETYPE_ID;
4522+ } else if (type.indexOf("integer")>=0){
4523+ baseType = XQItemType.XQBASETYPE_INTEGER;
4524+ } else if (type.indexOf("int")>=0){
4525+ baseType = XQItemType.XQBASETYPE_INT;
4526+ } else if (type.indexOf("language")>=0){
4527+ baseType = XQItemType.XQBASETYPE_LANGUAGE;
4528+ } else if (type.indexOf("long")>=0){
4529+ baseType = XQItemType.XQBASETYPE_LONG;
4530+ } else if (type.indexOf("QName")>=0){
4531+ baseType = XQItemType.XQBASETYPE_QNAME;
4532+ } else if (type.indexOf("NCName")>=0){
4533+ baseType = XQItemType.XQBASETYPE_NCNAME;
4534+ } else if (type.indexOf("Name")>=0){
4535+ baseType = XQItemType.XQBASETYPE_NAME;
4536+ } else if (type.indexOf("negativeInteger")>=0){
4537+ baseType = XQItemType.XQBASETYPE_NEGATIVE_INTEGER;
4538+ } else if (type.indexOf("NMTOKENS")>=0){
4539+ baseType = XQItemType.XQBASETYPE_NMTOKENS;
4540+ } else if (type.indexOf("NMTOKEN")>=0){
4541+ baseType = XQItemType.XQBASETYPE_NMTOKEN;
4542+ } else if (type.indexOf("nonNegativeInteger")>=0){
4543+ baseType = XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER;
4544+ } else if (type.indexOf("nonPositiveInteger")>=0){
4545+ baseType = XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER;
4546+ } else if (type.indexOf("normalizedString")>=0){
4547+ baseType = XQItemType.XQBASETYPE_NORMALIZED_STRING;
4548+ } else if (type.indexOf("NOTATION")>=0){
4549+ baseType = XQItemType.XQBASETYPE_NOTATION;
4550+ } else if (type.indexOf("positiveInteger")>=0){
4551+ baseType = XQItemType.XQBASETYPE_POSITIVE_INTEGER;
4552+ } else if (type.indexOf("short")>=0){
4553+ baseType = XQItemType.XQBASETYPE_SHORT;
4554+ } else if (type.indexOf("string")>=0){
4555+ baseType = XQItemType.XQBASETYPE_STRING;
4556+ } else if (type.indexOf("time")>=0){
4557+ baseType = XQItemType.XQBASETYPE_TIME;
4558+ } else if (type.indexOf("token")>=0){
4559+ baseType = XQItemType.XQBASETYPE_TOKEN;
4560+ } else if (type.indexOf("unsignedByte")>=0){
4561+ baseType = XQItemType.XQBASETYPE_UNSIGNED_BYTE;
4562+ } else if (type.indexOf("unsignedInt")>=0){
4563+ baseType = XQItemType.XQBASETYPE_UNSIGNED_INT;
4564+ } else if (type.indexOf("unsignedLong")>=0){
4565+ baseType = XQItemType.XQBASETYPE_UNSIGNED_LONG;
4566+ } else if (type.indexOf("unsignedShort")>=0){
4567+ baseType = XQItemType.XQBASETYPE_UNSIGNED_SHORT;
4568+ } else if (type.indexOf("untypedAtomic")>=0){
4569+ baseType = XQItemType.XQBASETYPE_UNTYPEDATOMIC;
4570+ } else if (type.indexOf("untyped")>=0){
4571+ baseType = XQItemType.XQBASETYPE_UNTYPED;
4572+ } else if (type.indexOf("yearMonthDuration")>=0){
4573+ baseType = XQItemType.XQBASETYPE_YEARMONTHDURATION;
4574+ }
4575+ generateTypeName();
4576+ }
4577+
4578+ public XQItemType(int itemkind, String piTarget) {
4579+ this.itemKind = itemkind;
4580+ this.piTarget = piTarget;
4581+ generateTypeName();
4582+ }
4583+ public XQItemType(int itemkind) {
4584+ this.itemKind = itemkind;
4585+ generateTypeName();
4586+ }
4587+ public XQItemType(int itemkind, int basetype) {
4588+ this.itemKind = itemkind;
4589+ this.baseType = basetype;
4590+ generateTypeName();
4591+ }
4592+ public XQItemType(int itemkind, QName nodename, int basetype) {
4593+ this.itemKind = itemkind;
4594+ this.nodeName = nodename;
4595+ this.baseType = basetype;
4596+ generateTypeName();
4597+ }
4598+ public XQItemType(int itemkind, QName nodename, int basetype, QName typename, URI schemaURI, boolean allowNill) throws XQException {
4599+ this.itemKind = itemkind;
4600+ this.nodeName = nodename;
4601+ this.baseType = basetype;
4602+ this.typeName = typename;
4603+ this.schemaURI = schemaURI;
4604+ this.allowNill = allowNill;
4605+ }
4606+ public XQItemType(int itemkind, QName nodename, int basetype, URI schemaURI) throws XQException {
4607+ this.itemKind = itemkind;
4608+ this.nodeName = nodename;
4609+ this.baseType = basetype;
4610+ this.schemaURI = schemaURI;
4611+ generateTypeName();
4612+ }
4613+
4614+
4615+ private void generateTypeName() {
4616+ String namespaceURI = "http://www.w3.org/2001/XMLSchema";
4617+ String localPart = "untyped";
4618+ String prefix = "";
4619+
4620+ switch (baseType) {
4621+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
4622+ localPart = "anyAtomicType";
4623+ break;
4624+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
4625+ localPart = "anySimpleType";
4626+ break;
4627+ case XQItemType.XQBASETYPE_ANYTYPE:
4628+ localPart = "anyType";
4629+ break;
4630+ case XQItemType.XQBASETYPE_ANYURI:
4631+ localPart = "anyURI";
4632+ break;
4633+ case XQItemType.XQBASETYPE_BASE64BINARY:
4634+ localPart = "base64Binary";
4635+ break;
4636+ case XQItemType.XQBASETYPE_BOOLEAN:
4637+ localPart = "boolean";
4638+ break;
4639+ case XQItemType.XQBASETYPE_BYTE:
4640+ localPart = "byte";
4641+ break;
4642+ case XQItemType.XQBASETYPE_DATE:
4643+ localPart = "date";
4644+ break;
4645+ case XQItemType.XQBASETYPE_DATETIME:
4646+ localPart = "dateTime";
4647+ break;
4648+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
4649+ localPart = "dayTimeDuration";
4650+ break;
4651+ case XQItemType.XQBASETYPE_DECIMAL:
4652+ localPart = "decimal";
4653+ break;
4654+ case XQItemType.XQBASETYPE_DOUBLE:
4655+ localPart = "double";
4656+ break;
4657+ case XQItemType.XQBASETYPE_DURATION:
4658+ localPart = "duration";
4659+ break;
4660+ case XQItemType.XQBASETYPE_ENTITIES:
4661+ localPart = "ENTITIES";
4662+ break;
4663+ case XQItemType.XQBASETYPE_ENTITY:
4664+ localPart = "ENTITY";
4665+ break;
4666+ case XQItemType.XQBASETYPE_FLOAT:
4667+ localPart = "float";
4668+ break;
4669+ case XQItemType.XQBASETYPE_GDAY:
4670+ localPart = "gDay";
4671+ break;
4672+ case XQItemType.XQBASETYPE_GMONTH:
4673+ localPart = "gMonth";
4674+ break;
4675+ case XQItemType.XQBASETYPE_GMONTHDAY:
4676+ localPart = "gMonthDay";
4677+ break;
4678+ case XQItemType.XQBASETYPE_GYEAR:
4679+ localPart = "gYear";
4680+ break;
4681+ case XQItemType.XQBASETYPE_GYEARMONTH:
4682+ localPart = "gYearMonth";
4683+ break;
4684+ case XQItemType.XQBASETYPE_HEXBINARY:
4685+ localPart = "hexBinary";
4686+ break;
4687+ case XQItemType.XQBASETYPE_ID:
4688+ localPart = "ID";
4689+ break;
4690+ case XQItemType.XQBASETYPE_IDREF:
4691+ localPart = "IDREF";
4692+ break;
4693+ case XQItemType.XQBASETYPE_IDREFS:
4694+ localPart = "IDREFS";
4695+ break;
4696+ case XQItemType.XQBASETYPE_INT:
4697+ localPart = "int";
4698+ break;
4699+ case XQItemType.XQBASETYPE_INTEGER:
4700+ localPart = "integer";
4701+ break;
4702+ case XQItemType.XQBASETYPE_LANGUAGE:
4703+ localPart = "language";
4704+ break;
4705+ case XQItemType.XQBASETYPE_LONG:
4706+ localPart = "long";
4707+ break;
4708+ case XQItemType.XQBASETYPE_NAME:
4709+ localPart = "Name";
4710+ break;
4711+ case XQItemType.XQBASETYPE_NCNAME:
4712+ localPart = "NCName";
4713+ break;
4714+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
4715+ localPart = "negativeInteger";
4716+ break;
4717+ case XQItemType.XQBASETYPE_NMTOKEN:
4718+ localPart = "NMTOKEN";
4719+ break;
4720+ case XQItemType.XQBASETYPE_NMTOKENS:
4721+ localPart = "NMTOKENS";
4722+ break;
4723+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
4724+ localPart = "nonNegativeInteger";
4725+ break;
4726+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
4727+ localPart = "nonPositiveInteger";
4728+ break;
4729+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
4730+ localPart = "normalizedString";
4731+ break;
4732+ case XQItemType.XQBASETYPE_NOTATION:
4733+ localPart = "NOTATION";
4734+ break;
4735+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
4736+ localPart = "positiveInteger";
4737+ break;
4738+ case XQItemType.XQBASETYPE_QNAME:
4739+ localPart = "QName";
4740+ break;
4741+ case XQItemType.XQBASETYPE_SHORT:
4742+ localPart = "short";
4743+ break;
4744+ case XQItemType.XQBASETYPE_STRING:
4745+ localPart = "string";
4746+ break;
4747+ case XQItemType.XQBASETYPE_TIME:
4748+ localPart = "time";
4749+ break;
4750+ case XQItemType.XQBASETYPE_TOKEN:
4751+ localPart = "token";
4752+ break;
4753+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
4754+ localPart = "unsignedByte";
4755+ break;
4756+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
4757+ localPart = "unsignedInt";
4758+ break;
4759+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
4760+ localPart = "unsignedLong";
4761+ break;
4762+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
4763+ localPart = "unsignedShort";
4764+ break;
4765+ case XQItemType.XQBASETYPE_UNTYPED:
4766+ localPart = "untyped";
4767+ break;
4768+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
4769+ localPart = "untypedAtomic";
4770+ break;
4771+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
4772+ localPart = "yearMonthDuration";
4773+ break;
4774+ default:
4775+ localPart = "untyped";
4776+ break;
4777+ }
4778+ typeName = new QName(namespaceURI, localPart, prefix);
4779+ }
4780+
4781+
4782+
4783+
4784+ @Override
4785+ public int getBaseType() throws XQException {
4786+ if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
4787+ (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
4788+ (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
4789+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
4790+ (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
4791+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE) ||
4792+ (itemKind==XQItemType.XQITEMKIND_ATOMIC))) {
4793+ throw new XQException("Item kind is not valid for a Base Type.");
4794+ }
4795+ return baseType;
4796+ }
4797+
4798+ @Override
4799+ public int getItemKind() {
4800+ return itemKind;
4801+ }
4802+
4803+ @Override
4804+ public int getItemOccurrence() {
4805+ return XQSequenceType.OCC_EXACTLY_ONE;
4806+ }
4807+
4808+ @Override
4809+ public QName getNodeName() throws XQException {
4810+ if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
4811+ (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
4812+ (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
4813+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
4814+ (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
4815+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE))) {
4816+ throw new XQException("Item kind is not valid for a Type Name.");
4817+ }
4818+ return nodeName;
4819+ }
4820+
4821+ @Override
4822+ public URI getSchemaURI() {
4823+ return schemaURI;
4824+ }
4825+
4826+ @Override
4827+ public QName getTypeName() throws XQException {
4828+ if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
4829+ (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
4830+ (itemKind==XQItemType.XQITEMKIND_ATOMIC) ||
4831+ (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
4832+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
4833+ (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
4834+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE))) {
4835+ throw new XQException("Item kind is not valid for a Type Name.");
4836+ }
4837+ return typeName;
4838+ }
4839+
4840+ @Override
4841+ public boolean isAnonymousType() {
4842+ return (itemKind==0);
4843+ }
4844+
4845+ @Override
4846+ public boolean isElementNillable() {
4847+ return allowNill;
4848+ }
4849+
4850+ @Override
4851+ public String getPIName() throws XQException {
4852+ if (itemKind!=XQItemType.XQITEMKIND_PI) {
4853+ throw new XQException("Item kind is not a PI.");
4854+ }
4855+ return piTarget;
4856+ }
4857+
4858+ @Override
4859+ public XQItemType getItemType() {
4860+ return this;
4861+ }
4862+
4863+ @Override
4864+ public boolean equals(Object o) {
4865+ boolean result = false;
4866+ boolean supportBaseType = false;
4867+ boolean supportNodeName = false;
4868+ boolean supportTypeName = false;
4869+ boolean supportPIName = false;
4870+ if (o instanceof XQItemType) {
4871+ if ( (getItemKind()==((XQItemType)o).getItemKind()) &&
4872+ (getSchemaURI()==((XQItemType)o).getSchemaURI()) &&
4873+ (isAnonymousType()==((XQItemType)o).isAnonymousType()) &&
4874+ (isElementNillable()==((XQItemType)o).isElementNillable()) ) {
4875+ try {
4876+ supportBaseType = getBaseType() == ((XQItemType)o).getBaseType();
4877+ } catch (Exception e) {
4878+ supportBaseType = true; // Not supported
4879+ }
4880+ try {
4881+ supportNodeName = getNodeName() == ((XQItemType)o).getNodeName();
4882+ } catch (Exception e) {
4883+ supportNodeName = true; // Not supported
4884+ }
4885+ try {
4886+ supportTypeName = getTypeName().equals(((XQItemType)o).getTypeName());
4887+ } catch (Exception e) {
4888+ supportTypeName = true; // Not supported
4889+ }
4890+ try {
4891+ supportPIName = getPIName().equals(((XQItemType)o).getPIName());
4892+ } catch (Exception e) {
4893+ supportPIName = true; // Not supported
4894+ }
4895+
4896+
4897+ result = supportBaseType && supportNodeName && supportTypeName && supportPIName;
4898+ }
4899+ }
4900+ return result;
4901+ }
4902+
4903+ @Override
4904+ public int hashCode() {
4905+ int hashCode = 0;
4906+ hashCode = this.getItemKind();
4907+ if (this.getSchemaURI() != null) {
4908+ hashCode = 31*hashCode + this.getSchemaURI().hashCode();
4909+ }
4910+ try {
4911+ int basetype = this.getBaseType();
4912+ hashCode = 31*hashCode + basetype;
4913+ } catch (Exception e) {}
4914+ try {
4915+ QName nodename = this.getNodeName();
4916+ if (nodename!=null) {
4917+ hashCode = 31*hashCode + nodename.hashCode();
4918+ }
4919+ } catch (Exception e) {}
4920+ try {
4921+ QName typename = this.getTypeName();
4922+ hashCode = 31*hashCode + typename.hashCode();
4923+ } catch(Exception e) {}
4924+ try {
4925+ String piname = this.getPIName();
4926+ if (piname != null) {
4927+ hashCode = 31*hashCode + piname.hashCode();
4928+ }
4929+ } catch (Exception e) {}
4930+ return hashCode;
4931+ }
4932+
4933+ @Override
4934+ public String toString() {
4935+ StringBuffer result = new StringBuffer();
4936+
4937+ try {
4938+ for (java.lang.reflect.Field field: XQItemType.class.getFields()) {
4939+ if (field.getName().startsWith("XQITEMKIND_")) {
4940+ if (field.getInt(this)==itemKind) {
4941+ result.append("Item Kind: ").append(field.getName().substring(11));
4942+ }
4943+ }
4944+ if (field.getName().startsWith("XQBASETYPE_")) {
4945+ if (field.getInt(this)==baseType) {
4946+ result.append(" Base Type: ").append(field.getName().substring(11));
4947+ }
4948+ }
4949+ }
4950+ } catch (Exception e){
4951+ result.append("Item Kind or Base Type error: ").append(e.getLocalizedMessage());
4952+ }
4953+
4954+ return result.toString();
4955+ }
4956+
4957+
4958+}
4959
4960=== added file 'swig/xqj/XQMetaData.java'
4961--- swig/xqj/XQMetaData.java 1970-01-01 00:00:00 +0000
4962+++ swig/xqj/XQMetaData.java 2012-04-19 22:34:19 +0000
4963@@ -0,0 +1,204 @@
4964+/*
4965+ * Copyright 2006-2012 The FLWOR Foundation.
4966+ *
4967+ * Licensed under the Apache License, Version 2.0 (the "License");
4968+ * you may not use this file except in compliance with the License.
4969+ * You may obtain a copy of the License at
4970+ *
4971+ * http://www.apache.org/licenses/LICENSE-2.0
4972+ *
4973+ * Unless required by applicable law or agreed to in writing, software
4974+ * distributed under the License is distributed on an "AS IS" BASIS,
4975+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4976+ * See the License for the specific language governing permissions and
4977+ * limitations under the License.
4978+ */
4979+package org.zorbaxquery.api.xqj;
4980+
4981+import java.util.HashSet;
4982+import java.util.Set;
4983+import javax.xml.xquery.XQConnection;
4984+import javax.xml.xquery.XQException;
4985+import org.zorbaxquery.api.Zorba;
4986+
4987+public class XQMetaData implements javax.xml.xquery.XQMetaData {
4988+
4989+ private int XQJ_MAJOR = 1;
4990+ private int XQJ_MINOR = 1;
4991+
4992+ private XQConnection connection;
4993+ private Zorba zorba;
4994+ public XQMetaData(XQConnection conn) throws XQException {
4995+ if (conn.isClosed()) {
4996+ throw new XQException("This connection is closed");
4997+ }
4998+ connection = conn;
4999+ zorba = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance();
5000+ }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches