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

Proposed by Rodolfo Ochoa
Status: Merged
Approved by: Rodolfo Ochoa
Approved revision: 10899
Merged at revision: 11031
Proposed branch: lp:~zorba-coders/zorba/bug938320b
Merge into: lp:zorba
Diff against target: 2644 lines (+1444/-518)
47 files modified
include/zorba/dynamic_context.h (+1/-0)
swig/CMakeLists.txt (+3/-0)
swig/Config.h (+22/-0)
swig/DiagnosticHandler.h (+1/-0)
swig/Item.h (+21/-1)
swig/Item.i (+25/-0)
swig/SerializationOptions.h (+1/-0)
swig/XQuery.h (+28/-2)
swig/XQuery.i (+31/-6)
swig/XmlDataManager.h (+7/-2)
swig/XmlDataManager.i (+7/-0)
swig/Zorba.h (+22/-0)
swig/Zorba.i (+14/-15)
swig/ZorbaIOStream.h (+54/-0)
swig/ZorbaIOStream.i (+74/-0)
swig/ZorbaStreamBuffer.h (+75/-0)
swig/ZorbaStreamBuffer.i (+98/-0)
swig/java/CMakeLists.txt (+8/-2)
swig/java/ZorbaInputWrapper.java (+43/-0)
swig/java/ZorbaOutputWrapper.java (+72/-0)
swig/java/ZorbaReaderWrapper.java (+64/-0)
swig/java/ZorbaWriterWrapper.java (+65/-0)
swig/java/zorba_api.i (+30/-1)
swig/php/CMakeLists.txt (+1/-1)
swig/php/tests/test11.php (+27/-31)
swig/php/zorba_api.i (+1/-0)
swig/python/CMakeLists.txt (+1/-1)
swig/python/tests/CMakeLists.txt (+3/-3)
swig/python/tests/test11.py.in (+15/-22)
swig/python/zorba_api.i (+1/-0)
swig/ruby/CMakeLists.txt (+1/-1)
swig/ruby/tests/CMakeLists.txt (+6/-6)
swig/ruby/tests/test03.rb (+6/-6)
swig/ruby/tests/test11.rb (+22/-32)
swig/ruby/zorba_api.i (+1/-0)
swig/xqj/CMakeLists.txt (+7/-1)
swig/xqj/ZorbaXQConnection.java (+46/-88)
swig/xqj/ZorbaXQItem.java (+4/-1)
swig/xqj/ZorbaXQPreparedExpression.java (+75/-6)
swig/xqj/ZorbaXQResultSequence.java (+9/-9)
swig/xqj/ZorbaXQSequence.java (+1/-1)
swig/xqj/managers/Api_test.java (+53/-275)
swig/xqj/managers/Tests.java (+383/-0)
swig/xqj/managers/utf.txt (+1/-0)
swig/xqj/tck/xqj_test.bat.in (+2/-1)
swig/xqj/tck/xqj_test.sh.in (+2/-1)
swig/zorba_api.i (+10/-3)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug938320b
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Cezar Andrei Approve
Review via email: mp+123356@code.launchpad.net

Commit message

Streaming between Zorba and Java/XQJ

Description of the change

Streaming between Zorba and Java/XQJ

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug938320b 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 bug938320b-2012-09-07T22-01-36.305Z is finished. The
  final status was:

  10 tests did not succeed - changes not commited.

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

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug938320b-2012-09-09T05-51-03.467Z is finished. The final status was:

All tests succeeded!

Revision history for this message
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.

Revision history for this message
Cezar Andrei (cezar-andrei) :
review: Approve
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug938320b 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 bug938320b-2012-09-10T20-35-12.686Z 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

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug938320b-2012-09-10T23-51-09.903Z 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 'include/zorba/dynamic_context.h'
2--- include/zorba/dynamic_context.h 2012-08-30 13:45:43 +0000
3+++ include/zorba/dynamic_context.h 2012-09-08 14:02:23 +0000
4@@ -280,6 +280,7 @@
5 /** \brief Destructor
6 */
7 virtual ~DynamicContext( ) {}
8+
9 };
10
11 } /* namespace zorba */
12
13=== modified file 'swig/CMakeLists.txt'
14--- swig/CMakeLists.txt 2012-08-30 13:45:43 +0000
15+++ swig/CMakeLists.txt 2012-09-08 14:02:23 +0000
16@@ -13,6 +13,9 @@
17 # limitations under the License.
18
19 IF (SWIG_FOUND)
20+
21+ SET (ZORBA_STREAM_BUFFER_SIZE 10240) # 10k default buffer size
22+
23 IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
24 SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
25 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
26
27=== added file 'swig/Config.h'
28--- swig/Config.h 1970-01-01 00:00:00 +0000
29+++ swig/Config.h 2012-09-08 14:02:23 +0000
30@@ -0,0 +1,22 @@
31+/*
32+ * Copyright 2006-2008 The FLWOR Foundation.
33+ *
34+ * Licensed under the Apache License, Version 2.0 (the "License");
35+ * you may not use this file except in compliance with the License.
36+ * You may obtain a copy of the License at
37+ *
38+ * http://www.apache.org/licenses/LICENSE-2.0
39+ *
40+ * Unless required by applicable law or agreed to in writing, software
41+ * distributed under the License is distributed on an "AS IS" BASIS,
42+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43+ * See the License for the specific language governing permissions and
44+ * limitations under the License.
45+ */
46+#ifndef API_CONFIG_H
47+#define API_CONFIG_H
48+
49+#define ZORBA_STREAM_BUFFER_SIZE @ZORBA_STREAM_BUFFER_SIZE@
50+
51+
52+#endif
53\ No newline at end of file
54
55=== modified file 'swig/DiagnosticHandler.h'
56--- swig/DiagnosticHandler.h 2012-08-30 13:45:43 +0000
57+++ swig/DiagnosticHandler.h 2012-09-08 14:02:23 +0000
58@@ -27,6 +27,7 @@
59 void error (const zorba::ZorbaException &ze);
60 void warning (const zorba::XQueryException &xw);
61 public:
62+ DiagnosticHandler() {};
63 virtual ~DiagnosticHandler();
64
65 /**
66
67=== modified file 'swig/Item.h'
68--- swig/Item.h 2012-08-30 13:45:43 +0000
69+++ swig/Item.h 2012-09-08 14:02:23 +0000
70@@ -199,7 +199,7 @@
71 * Note that this function is only available for node Items.
72 *
73 * @return bool if the name of the node was retrieved successfully
74- * @return aNodeName the name of the node
75+ * @param aNodeName the name of the node
76 * @throw ZorbaException if an error occured (e.g. the Item is not of type node).
77 */
78 bool getNodeName (Item &aNodeName) const;
79@@ -298,6 +298,26 @@
80 * Also note that this function is available for all types of Items.
81 */
82 void close();
83+
84+ /** \brief Serializes the object
85+ *
86+ * Put the serialized object into the specified stream.
87+ *
88+ * @param aStream The stream to write the value of the Item.
89+ * @throw ZorbaException if an error occured.
90+ */
91+ void serializeToStream(ZorbaIOStream & aStream) const;
92+
93+ /** \brief Serializes the object
94+ *
95+ * Put the serialized object into the specified stream.
96+ *
97+ * @param aStream The stream to write the value of the Item.
98+ * @param serOptions The serialization options for this Item
99+ * @throw ZorbaException if an error occured.
100+ */
101+ void serializeToStream(ZorbaIOStream & aStream, SerializationOptions serOptions) const;
102+
103 }; // class Item
104
105 #endif
106
107=== modified file 'swig/Item.i'
108--- swig/Item.i 2012-08-30 13:45:43 +0000
109+++ swig/Item.i 2012-09-08 14:02:23 +0000
110@@ -122,6 +122,31 @@
111 void Item::close()
112 { theItem.close(); }
113
114+ void Item::serializeToStream(ZorbaIOStream & aStream) const
115+ {
116+ ZorbaStreamBuffer buffer(aStream);
117+ std::ostream lStream(&buffer);
118+
119+ Zorba_SerializerOptions_t lOptions;
120+ lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
121+ zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
122+ zorba::SingletonItemSequence lSequence(theItem);
123+ lSerializer->serialize(&lSequence, lStream);
124+ return;
125+ }
126+ void Item::serializeToStream(ZorbaIOStream & aStream, SerializationOptions serOptions) const
127+ {
128+ ZorbaStreamBuffer buffer(aStream);
129+ std::ostream lStream(&buffer);
130+
131+ Zorba_SerializerOptions_t lOptions;
132+ serOptions.lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
133+ zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(serOptions.lOptions);
134+ zorba::SingletonItemSequence lSequence(theItem);
135+ lSerializer->serialize(&lSequence, lStream);
136+ return;
137+ }
138+
139 %} // end Implementation
140
141
142
143=== modified file 'swig/SerializationOptions.h'
144--- swig/SerializationOptions.h 2012-08-30 13:45:43 +0000
145+++ swig/SerializationOptions.h 2012-09-08 14:02:23 +0000
146@@ -34,6 +34,7 @@
147 class SerializationOptions
148 {
149 friend class Item;
150+friend class XQuery;
151
152 public:
153 typedef enum
154
155=== modified file 'swig/XQuery.h'
156--- swig/XQuery.h 2012-08-30 13:45:43 +0000
157+++ swig/XQuery.h 2012-09-08 14:02:23 +0000
158@@ -36,8 +36,8 @@
159 XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery), closed(false) {}
160
161 /**
162- * \brief Execute the (updating) query. The query can be executed with this
163- * function only if it is an updating query.
164+ * \brief Execute the query. The query can be executed with this function.
165+ * The query only has a result if it's a non-updating query.
166 *
167 * @throw ZorbaException if an error occurs (e.g. the query is closed or has
168 * not been compiled or is not updating)
169@@ -156,6 +156,32 @@
170 * @throw ZorbaException if an error occured.
171 */
172 void getExternalVariables(Iterator& vars) const;
173+
174+ /** \brief Execute the query and write the result to the given output stream.
175+ * The query only has a result if it's a non-updating query.
176+ *
177+ * @param stream The output stream on which the result is written.
178+ */
179+ void execute( ZorbaIOStream & stream );
180+
181+ /** \brief Execute the query and write the result to the given output stream.
182+ * The query only has a result if it's a non-updating query.
183+ *
184+ * @param stream The output stream on which the result is written.
185+ * @param serOptions The serialization options for this Query result
186+ */
187+ void execute( ZorbaIOStream & stream, SerializationOptions & serOptions );
188+
189+ /**
190+ * \brief Execute the query. The query can be executed with this function.
191+ * The query only has a result if it's a non-updating query.
192+ *
193+ * @param serOptions The serialization options for this Query result
194+ * @throw ZorbaException if an error occurs (e.g. the query is closed or has
195+ * not been compiled or is not updating)
196+ */
197+ std::string execute( SerializationOptions & serOptions );
198+
199 }; // class XQuery
200
201 #endif
202\ No newline at end of file
203
204=== modified file 'swig/XQuery.i'
205--- swig/XQuery.i 2012-08-30 13:45:43 +0000
206+++ swig/XQuery.i 2012-09-08 14:02:23 +0000
207@@ -15,16 +15,15 @@
208 */
209
210 %{ // start Implementation
211-
212+
213 std::string XQuery::execute()
214 {
215 Zorba_SerializerOptions_t lSerOptions;
216- lSerOptions.indent = ZORBA_INDENT_YES;
217- lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
218+ lSerOptions.indent = ZORBA_INDENT_NO;
219+ lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_NO;
220 std::stringstream lStream;
221- lStream << theQuery;
222- std::string str = lStream.str();
223- return str;
224+ theQuery->execute(lStream, &lSerOptions);
225+ return lStream.str();
226 }
227
228 void XQuery::compile (const std::string &aQuery)
229@@ -78,6 +77,32 @@
230 void XQuery::destroy() { theQuery = 0; }
231 Iterator XQuery::iterator() { return Iterator(theQuery->iterator()); }
232
233+ void XQuery::execute( ZorbaIOStream & stream )
234+ {
235+ Zorba_SerializerOptions_t lSerOptions;
236+ lSerOptions.indent = ZORBA_INDENT_NO;
237+ lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
238+ ZorbaStreamBuffer buffer(stream);
239+ std::ostream lStream(&buffer);
240+ theQuery->execute(lStream, &lSerOptions);
241+ return;
242+ }
243+
244+ void XQuery::execute( ZorbaIOStream & stream, SerializationOptions & serOptions )
245+ {
246+ ZorbaStreamBuffer buffer(stream);
247+ std::ostream lStream(&buffer);
248+ theQuery->execute(lStream, &serOptions.lOptions);
249+ }
250+
251+ std::string XQuery::execute( SerializationOptions & serOptions )
252+ {
253+ std::stringstream lStream;
254+ theQuery->execute(lStream, &serOptions.lOptions);
255+ return lStream.str();
256+ }
257+
258+
259 %} // end Implementation
260
261 %include "XQuery.h"
262
263=== modified file 'swig/XmlDataManager.h'
264--- swig/XmlDataManager.h 2012-08-30 13:45:43 +0000
265+++ swig/XmlDataManager.h 2012-09-08 14:02:23 +0000
266@@ -66,8 +66,7 @@
267 * dynamic collections identified by a URI, i.e. those that are
268 * not declared in the prolog of a module or identified by a QName.
269 *
270- * @return The collection manager responsible for managing
271- * collections.
272+ * @return The collection manager responsible for managing collections.
273 *
274 */
275 CollectionManager getW3CCollectionManager();
276@@ -84,5 +83,11 @@
277 */
278 Item parseXMLtoItem(const std::string& aDoc);
279
280+ /** \brief Parse an XML stream and return an Item.
281+ *
282+ * @param aStream the input string whose content should be parsed
283+ */
284+ Item parseXMLtoItem(ZorbaIOStream & aStream);
285+
286 };
287 #endif
288\ No newline at end of file
289
290=== modified file 'swig/XmlDataManager.i'
291--- swig/XmlDataManager.i 2012-08-30 13:45:43 +0000
292+++ swig/XmlDataManager.i 2012-09-08 14:02:23 +0000
293@@ -45,6 +45,13 @@
294 return Item(lItem);
295 }
296
297+ Item XmlDataManager::parseXMLtoItem(ZorbaIOStream & aStream)
298+ {
299+ ZorbaStreamBuffer streamBuffer(aStream);
300+ std::istream stream(&streamBuffer);
301+ zorba::Item lItem = theManager->parseXML(stream);
302+ return Item(lItem);
303+ }
304
305 %} // end Implementation
306
307
308=== modified file 'swig/Zorba.h'
309--- swig/Zorba.h 2012-08-30 13:45:43 +0000
310+++ swig/Zorba.h 2012-09-08 14:02:23 +0000
311@@ -202,6 +202,28 @@
312 */
313 bool isXQueryXSupported();
314
315+ /** \brief Creates and compiles an XQuery object.
316+ *
317+ * This methods creates an XQuery object and compiles the query string
318+ * passed to this method.
319+ *
320+ * @param stream the query stream, this object is an extension to stream data accross the API.
321+ * @return XQuery the newly created and compiled XQuery object.
322+ */
323+ XQuery compileQuery(ZorbaIOStream & stream);
324+
325+ /** \brief Creates and compiles an XQuery object using a StaticContext.
326+ *
327+ * This methods creates an XQuery object and compiles the query string
328+ * passed to this method. Compilation is done using the information
329+ * contained in the StaticContext that is passed as parameter.
330+ *
331+ * @param stream the query stream, this object is an extension to stream data accross the API.
332+ * @param aStaticContext the StaticContext that contains information used for compiling the query.
333+ * @return XQuery the newly created and compiled XQuery object.
334+ */
335+ XQuery compileQuery(ZorbaIOStream & stream, StaticContext &aStaticContext );
336+
337 }; // class Zorba
338
339 #endif
340
341=== modified file 'swig/Zorba.i'
342--- swig/Zorba.i 2012-08-30 13:45:43 +0000
343+++ swig/Zorba.i 2012-09-08 14:02:23 +0000
344@@ -53,21 +53,6 @@
345 );
346 }
347
348- // XQuery Zorba::compileQuery(const ZIStreamHelper& aZorbaStream)
349- // {
350- // zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
351- // std::istream stream = std::istream(buffer);
352- // zistream stream = zistream(buffer);
353- // return XQuery(theZorba->compileQuery(stream));
354- // }
355-
356- // XQuery Zorba::compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext )
357- // {
358- // zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
359- // std::istream stream = std::istream(buffer);
360- // return XQuery(theZorba->compileQuery(stream, aStaticContext.theStaticContext));
361- // }
362-
363 XQuery Zorba::compileQuery(
364 const std::string& aStr,
365 DiagnosticHandler* aDiagnosticHandler
366@@ -132,6 +117,20 @@
367 #endif //ZORBA_XQUERYX
368 }
369
370+ XQuery Zorba::compileQuery(ZorbaIOStream & aStream)
371+ {
372+ ZorbaStreamBuffer streamBuffer(aStream);
373+ std::istream stream(&streamBuffer);
374+ return XQuery(theZorba->compileQuery(stream));
375+ }
376+
377+ XQuery Zorba::compileQuery(ZorbaIOStream & aStream, StaticContext &aStaticContext )
378+ {
379+ ZorbaStreamBuffer streamBuffer(aStream);
380+ std::istream stream(&streamBuffer);
381+ return XQuery(theZorba->compileQuery(stream, aStaticContext.theStaticContext));
382+ }
383+
384 %} // end Implementation
385
386 %include "Zorba.h"
387
388=== added file 'swig/ZorbaIOStream.h'
389--- swig/ZorbaIOStream.h 1970-01-01 00:00:00 +0000
390+++ swig/ZorbaIOStream.h 2012-09-08 14:02:23 +0000
391@@ -0,0 +1,54 @@
392+/*
393+ * Copyright 2006-2012 The FLWOR Foundation.
394+ *
395+ * Licensed under the Apache License, Version 2.0 (the "License");
396+ * you may not use this file except in compliance with the License.
397+ * You may obtain a copy of the License at
398+ *
399+ * http://www.apache.org/licenses/LICENSE-2.0
400+ *
401+ * Unless required by applicable law or agreed to in writing, software
402+ * distributed under the License is distributed on an "AS IS" BASIS,
403+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404+ * See the License for the specific language governing permissions and
405+ * limitations under the License.
406+ */
407+
408+#pragma once
409+
410+#ifndef API_ZORBA_IO_STREAM_H
411+#define API_ZORBA_IO_STREAM_H
412+
413+#include <streambuf>
414+#include <cstdio>
415+#include <cstdlib>
416+#include <vector>
417+
418+class ZorbaIOStream
419+{
420+public:
421+ ZorbaIOStream() {};
422+ virtual ~ZorbaIOStream() {};
423+
424+ //STREAM TO ZORBA
425+ virtual void fillStreamCallback();
426+ void setStream(const char *BYTE, size_t aLen);
427+ void setStream(const char *aStream, size_t aLen, int aBufferLength);
428+ char * getStream();
429+ int getLen();
430+
431+ //STREAM FROM ZORBA
432+ virtual void write(const char *BYTE, size_t aLen);
433+
434+private:
435+ //FOR STREAM TO ZORBA
436+ char buffer[ZORBA_STREAM_BUFFER_SIZE];
437+ int len;
438+
439+ // Copy contructor and assignment not allowed
440+ ZorbaIOStream (const ZorbaIOStream &);
441+ ZorbaIOStream &operator= (const ZorbaIOStream &);
442+
443+};
444+
445+#endif
446
447=== added file 'swig/ZorbaIOStream.i'
448--- swig/ZorbaIOStream.i 1970-01-01 00:00:00 +0000
449+++ swig/ZorbaIOStream.i 2012-09-08 14:02:23 +0000
450@@ -0,0 +1,74 @@
451+/*
452+ * Copyright 2006-2012 The FLWOR Foundation.
453+ *
454+ * Licensed under the Apache License, Version 2.0 (the "License");
455+ * you may not use this file except in compliance with the License.
456+ * You may obtain a copy of the License at
457+ *
458+ * http://www.apache.org/licenses/LICENSE-2.0
459+ *
460+ * Unless required by applicable law or agreed to in writing, software
461+ * distributed under the License is distributed on an "AS IS" BASIS,
462+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
463+ * See the License for the specific language governing permissions and
464+ * limitations under the License.
465+ */
466+
467+%feature("director") ZorbaIOStream;
468+
469+%{ // start Implementation
470+
471+#include "ZorbaIOStream.h"
472+#include <cassert>
473+#include <iostream>
474+#include <ios>
475+
476+void ZorbaIOStream::fillStreamCallback()
477+{
478+ // Local fill buffer EXAMPLE
479+ int len = ZORBA_STREAM_BUFFER_SIZE;
480+ char *buffer = (char*) malloc(sizeof(char)*(len));
481+ char* p=buffer;
482+ for (int i=0; i<(len); i++, *p++ = 'Z')
483+ ;
484+ setStream(buffer, len);
485+ return;
486+}
487+
488+void ZorbaIOStream::setStream(const char *aStream, size_t aLen, int aBufferLength)
489+{
490+ if (aBufferLength<0) aBufferLength=0;
491+ if (aBufferLength > 0)
492+ memcpy(buffer, aStream, aBufferLength*sizeof(char));
493+ len = aBufferLength;
494+ return;
495+}
496+
497+void ZorbaIOStream::setStream(const char *BYTE, size_t aLen)
498+{
499+ if (aLen<0) aLen=0;
500+ if (aLen > 0)
501+ memcpy(buffer, BYTE, aLen*sizeof(char));
502+ len = aLen;
503+ return;
504+}
505+
506+char * ZorbaIOStream::getStream()
507+{
508+ return buffer;
509+}
510+
511+int ZorbaIOStream::getLen()
512+{
513+ return len;
514+}
515+
516+void ZorbaIOStream::write(const char *BYTE, size_t aLen)
517+{
518+ return;
519+}
520+
521+%} // end Implementation
522+
523+
524+%include "ZorbaIOStream.h"
525\ No newline at end of file
526
527=== added file 'swig/ZorbaStreamBuffer.h'
528--- swig/ZorbaStreamBuffer.h 1970-01-01 00:00:00 +0000
529+++ swig/ZorbaStreamBuffer.h 2012-09-08 14:02:23 +0000
530@@ -0,0 +1,75 @@
531+/*
532+ * Copyright 2006-2012 The FLWOR Foundation.
533+ *
534+ * Licensed under the Apache License, Version 2.0 (the "License");
535+ * you may not use this file except in compliance with the License.
536+ * You may obtain a copy of the License at
537+ *
538+ * http://www.apache.org/licenses/LICENSE-2.0
539+ *
540+ * Unless required by applicable law or agreed to in writing, software
541+ * distributed under the License is distributed on an "AS IS" BASIS,
542+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
543+ * See the License for the specific language governing permissions and
544+ * limitations under the License.
545+ */
546+
547+#pragma once
548+
549+#ifndef API_ZORBA_STREAM_BUFFER_H
550+#define API_ZORBA_STREAM_BUFFER_H
551+
552+#include <streambuf>
553+#include <cstdio>
554+#include <cstdlib>
555+#include <vector>
556+#include "ZorbaStreamBuffer.h"
557+
558+
559+class ZorbaStreamBuffer :
560+ public std::streambuf
561+{
562+public:
563+ ZorbaStreamBuffer(ZorbaIOStream &aStreamWrapper): bBegin(0), bEnd(0), bCurrent(0), buffer(0), streamWrapper(&aStreamWrapper) {};
564+ virtual ~ZorbaStreamBuffer() {};
565+
566+ // HELPER
567+ // Function to return EOF character from other languages
568+ static int getEOF();
569+
570+ // INPUT
571+ // Get character in the case of underflow
572+ int underflow();
573+ // Get character in the case of underflow and advance get pointer
574+ int uflow();
575+ // Put character back in the case of backup underflow
576+ int pbackfail(int ch);
577+ // Get number of characters available in the sequence
578+ std::streamsize showmanyc();
579+
580+ // OUTPUT
581+ // Write sequence of characters <Inherited>
582+ virtual std::streamsize xsputn ( const char * BYTE, std::streamsize len );
583+ // Write character in the case of overflow
584+ virtual int overflow ( int c = EOF );
585+
586+
587+
588+
589+private:
590+ void checkBuffer();
591+ // Copy contructor and assignment not allowed
592+ ZorbaStreamBuffer(const ZorbaStreamBuffer &);
593+ ZorbaStreamBuffer &operator= (const ZorbaStreamBuffer &);
594+
595+ //BUFFER
596+ char * buffer;
597+ char * bBegin;
598+ char * bEnd;
599+ char * bCurrent;
600+ ZorbaIOStream *streamWrapper;
601+
602+ char * cBuffer;
603+};
604+
605+#endif
606
607=== added file 'swig/ZorbaStreamBuffer.i'
608--- swig/ZorbaStreamBuffer.i 1970-01-01 00:00:00 +0000
609+++ swig/ZorbaStreamBuffer.i 2012-09-08 14:02:23 +0000
610@@ -0,0 +1,98 @@
611+/*
612+ * Copyright 2006-2012 The FLWOR Foundation.
613+ *
614+ * Licensed under the Apache License, Version 2.0 (the "License");
615+ * you may not use this file except in compliance with the License.
616+ * You may obtain a copy of the License at
617+ *
618+ * http://www.apache.org/licenses/LICENSE-2.0
619+ *
620+ * Unless required by applicable law or agreed to in writing, software
621+ * distributed under the License is distributed on an "AS IS" BASIS,
622+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
623+ * See the License for the specific language governing permissions and
624+ * limitations under the License.
625+ */
626+
627+%feature("director") ZorbaStreamBuffer;
628+
629+%{ // start Implementation
630+
631+#include "ZorbaStreamBuffer.h"
632+#include <cassert>
633+#include <iostream>
634+
635+void ZorbaStreamBuffer::checkBuffer()
636+{
637+ if (buffer==0)
638+ {
639+ streamWrapper->fillStreamCallback();
640+ if (streamWrapper->getLen() > 0) {
641+ bBegin = bCurrent = buffer = streamWrapper->getStream();
642+ bEnd = bBegin + streamWrapper->getLen();
643+ }
644+ } else if (bCurrent == bEnd)
645+ {
646+ if (streamWrapper->getLen()==ZORBA_STREAM_BUFFER_SIZE)
647+ {
648+ streamWrapper->fillStreamCallback();
649+ if (streamWrapper->getLen() > 0) {
650+ bBegin = bCurrent = buffer = streamWrapper->getStream();
651+ bEnd = bBegin + streamWrapper->getLen();
652+ }
653+ }
654+ }
655+
656+}
657+int ZorbaStreamBuffer::getEOF()
658+{
659+ return traits_type::eof();
660+}
661+
662+int ZorbaStreamBuffer::underflow()
663+{
664+ checkBuffer();
665+ if ((bCurrent == bEnd) || (buffer==0))
666+ return traits_type::eof();
667+ return traits_type::to_int_type(*bCurrent);
668+}
669+
670+int ZorbaStreamBuffer::uflow()
671+{
672+ checkBuffer();
673+ if ((bCurrent == bEnd) || (buffer==0))
674+ return traits_type::eof();
675+ return traits_type::to_int_type(*bCurrent++);
676+}
677+
678+int ZorbaStreamBuffer::pbackfail(int ch)
679+{
680+ checkBuffer();
681+ if (bCurrent == bBegin || (ch != traits_type::eof() && ch != bCurrent[-1]) || (buffer==0))
682+ return traits_type::eof();
683+
684+ return traits_type::to_int_type(*--bCurrent);
685+}
686+
687+std::streamsize ZorbaStreamBuffer::showmanyc()
688+{
689+ checkBuffer();
690+ return bEnd - bCurrent;
691+}
692+
693+std::streamsize ZorbaStreamBuffer::xsputn ( const char * BYTE, std::streamsize len ) {
694+ // Wrapping to virtual function
695+ streamWrapper->write(BYTE, len);
696+ return len;
697+}
698+
699+int ZorbaStreamBuffer::overflow ( int c )
700+{
701+ streamWrapper->write((const char*)&c, 1);
702+ return c;
703+}
704+
705+
706+%} // end Implementation
707+
708+%include "ZorbaStreamBuffer.h"
709\ No newline at end of file
710
711=== modified file 'swig/java/CMakeLists.txt'
712--- swig/java/CMakeLists.txt 2012-08-30 13:45:43 +0000
713+++ swig/java/CMakeLists.txt 2012-09-08 14:02:23 +0000
714@@ -51,15 +51,21 @@
715
716 FILE(GLOB ZORBA_API_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/../" "${CMAKE_CURRENT_SOURCE_DIR}/../*.h")
717 FOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
718- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}" COPYONLY)
719+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}")
720 ENDFOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
721+
722+ #STREAM WRAPPER
723+ FILE(GLOB ZORBA_JAVA_EXTRAS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/" "${CMAKE_CURRENT_SOURCE_DIR}/*.java")
724+ FOREACH(ZORBA_JAVA_EXTRA ${ZORBA_JAVA_EXTRAS})
725+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/${ZORBA_JAVA_EXTRA}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_JAVA_EXTRA}")
726+ ENDFOREACH(ZORBA_JAVA_EXTRA ${ZORBA_JAVA_EXTRAS})
727
728 ADD_CUSTOM_COMMAND(TARGET lib_zorba_java_api
729 POST_BUILD
730 COMMAND cmake -E echo "Compiling Java files..."
731 COMMAND ${Java_JAVAC_EXECUTABLE} *.java -d ${CMAKE_CURRENT_BINARY_DIR}
732 COMMAND cmake -E echo "Creating jar file..."
733- COMMAND ${Java_JAR_EXECUTABLE} cvf zorba_api.jar org
734+ COMMAND ${Java_JAR_EXECUTABLE} cf zorba_api.jar org
735 )
736
737 # --- Install
738
739=== added file 'swig/java/ZorbaInputWrapper.java'
740--- swig/java/ZorbaInputWrapper.java 1970-01-01 00:00:00 +0000
741+++ swig/java/ZorbaInputWrapper.java 2012-09-08 14:02:23 +0000
742@@ -0,0 +1,43 @@
743+/*
744+ * Copyright 2006-2012 The FLWOR Foundation.
745+ *
746+ * Licensed under the Apache License, Version 2.0 (the "License");
747+ * you may not use this file except in compliance with the License.
748+ * You may obtain a copy of the License at
749+ *
750+ * http://www.apache.org/licenses/LICENSE-2.0
751+ *
752+ * Unless required by applicable law or agreed to in writing, software
753+ * distributed under the License is distributed on an "AS IS" BASIS,
754+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
755+ * See the License for the specific language governing permissions and
756+ * limitations under the License.
757+ */
758+
759+package org.zorbaxquery.api;
760+
761+import java.io.IOException;
762+import java.io.InputStream;
763+
764+public class ZorbaInputWrapper extends org.zorbaxquery.api.ZorbaIOStream {
765+
766+ private static final int BUFFER_SIZE = @ZORBA_STREAM_BUFFER_SIZE@;
767+ private InputStream input;
768+ private byte[] b = new byte[BUFFER_SIZE];;
769+
770+ public ZorbaInputWrapper(InputStream aInput) {
771+ input= aInput;
772+ }
773+
774+ @Override
775+ public void fillStreamCallback() {
776+ int total = 0;
777+ try {
778+ total = input.read(b, 0, BUFFER_SIZE);
779+ setStream(b, total);
780+ } catch (IOException ex) {
781+ System.err.println("Unexpected exception trying to get bytes from ZorbaInputWrapper: " + ex.getLocalizedMessage());
782+ ex.printStackTrace();
783+ }
784+ }
785+}
786
787=== added file 'swig/java/ZorbaOutputWrapper.java'
788--- swig/java/ZorbaOutputWrapper.java 1970-01-01 00:00:00 +0000
789+++ swig/java/ZorbaOutputWrapper.java 2012-09-08 14:02:23 +0000
790@@ -0,0 +1,72 @@
791+/*
792+ * Copyright 2006-2012 The FLWOR Foundation.
793+ *
794+ * Licensed under the Apache License, Version 2.0 (the "License");
795+ * you may not use this file except in compliance with the License.
796+ * You may obtain a copy of the License at
797+ *
798+ * http://www.apache.org/licenses/LICENSE-2.0
799+ *
800+ * Unless required by applicable law or agreed to in writing, software
801+ * distributed under the License is distributed on an "AS IS" BASIS,
802+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
803+ * See the License for the specific language governing permissions and
804+ * limitations under the License.
805+ */
806+package org.zorbaxquery.api;
807+
808+import java.io.IOException;
809+import java.io.OutputStream;
810+import java.io.OutputStreamWriter;
811+import java.nio.ByteBuffer;
812+import java.nio.CharBuffer;
813+import java.nio.charset.Charset;
814+import java.nio.charset.CharsetDecoder;
815+import java.nio.charset.CharsetEncoder;
816+
817+public class ZorbaOutputWrapper extends ZorbaIOStream {
818+ private OutputStream output;
819+ private static final int BUFFER_SIZE = @ZORBA_STREAM_BUFFER_SIZE@;
820+ private static CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
821+ CharBuffer charBuffer;
822+ ByteBuffer byteBuffer;
823+ ByteBuffer byteBufferFinal;
824+
825+ public ZorbaOutputWrapper(OutputStream aOutput) {
826+ try {
827+ output = aOutput;
828+ } catch (Exception e) {
829+ System.out.println("Error creating OutputStreamWriter" + e.getLocalizedMessage());
830+ }
831+ charBuffer = CharBuffer.allocate(BUFFER_SIZE);
832+ byteBuffer = ByteBuffer.allocate(BUFFER_SIZE*2);
833+ byteBufferFinal = ByteBuffer.allocate(BUFFER_SIZE*2);
834+ }
835+
836+ @Override
837+ public void write(byte[] stream, long aLen){
838+ try {
839+ int offset = 0;
840+ int bufferLength = 0;
841+ while (aLen>offset) {
842+ byteBuffer.clear();
843+ bufferLength = BUFFER_SIZE;
844+ if ((offset+BUFFER_SIZE)>aLen) {
845+ bufferLength = (int)aLen-offset;
846+ }
847+ offset += BUFFER_SIZE;
848+ byteBuffer.put(stream, 0, bufferLength);
849+ byteBuffer.flip();
850+ charBuffer.clear();
851+ decoder.decode(byteBuffer, charBuffer, false);
852+ charBuffer.flip();
853+ }
854+ ByteBuffer result = Charset.forName("UTF-8").encode(charBuffer);
855+ output.write(result.array());
856+ } catch (IOException ex) {
857+ System.err.println("Error writing on output stream" + ex.getLocalizedMessage());
858+ }
859+
860+ }
861+
862+}
863\ No newline at end of file
864
865=== added file 'swig/java/ZorbaReaderWrapper.java'
866--- swig/java/ZorbaReaderWrapper.java 1970-01-01 00:00:00 +0000
867+++ swig/java/ZorbaReaderWrapper.java 2012-09-08 14:02:23 +0000
868@@ -0,0 +1,64 @@
869+/*
870+ * Copyright 2006-2012 The FLWOR Foundation.
871+ *
872+ * Licensed under the Apache License, Version 2.0 (the "License");
873+ * you may not use this file except in compliance with the License.
874+ * You may obtain a copy of the License at
875+ *
876+ * http://www.apache.org/licenses/LICENSE-2.0
877+ *
878+ * Unless required by applicable law or agreed to in writing, software
879+ * distributed under the License is distributed on an "AS IS" BASIS,
880+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
881+ * See the License for the specific language governing permissions and
882+ * limitations under the License.
883+ */
884+
885+package org.zorbaxquery.api;
886+
887+import java.io.Reader;
888+import java.nio.ByteBuffer;
889+import java.nio.CharBuffer;
890+import java.nio.charset.Charset;
891+import java.nio.charset.CharsetEncoder;
892+
893+public class ZorbaReaderWrapper extends org.zorbaxquery.api.ZorbaIOStream {
894+
895+ private static final int BUFFER_SIZE = @ZORBA_STREAM_BUFFER_SIZE@;
896+ private static CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
897+ private Reader reader;
898+ private char[] charsReaded = new char[BUFFER_SIZE];
899+ private byte[] bytesEncoded = new byte[BUFFER_SIZE];
900+ CharBuffer charBuffer;
901+ ByteBuffer byteBuffer;
902+
903+ public ZorbaReaderWrapper(Reader aReader) {
904+ charBuffer = CharBuffer.allocate(BUFFER_SIZE);
905+ byteBuffer = ByteBuffer.allocate(BUFFER_SIZE*2);
906+ reader= aReader;
907+ }
908+
909+ private int encode(char[] initialBuffer, int initialIndex, int initialLength,
910+ byte[] result, int resultIndex, int resultLength) {
911+ charBuffer = CharBuffer.wrap(initialBuffer, initialIndex, initialLength);
912+ byteBuffer.clear();
913+ encoder.encode(charBuffer, byteBuffer, false);
914+ byteBuffer.flip();
915+ resultLength = byteBuffer.limit()-byteBuffer.position();
916+ byteBuffer.get(result, resultIndex, resultLength);
917+ return resultLength;
918+ }
919+
920+ @Override
921+ public void fillStreamCallback() {
922+ int total;
923+ try {
924+ total = reader.read(charsReaded, 0, BUFFER_SIZE);
925+ total = encode(charsReaded, 0, total, bytesEncoded, 0, total);
926+ setStream(bytesEncoded, total);
927+ } catch (Exception ex) {
928+ System.err.println("Unexpected exception trying to get bytes from ZorbaReaderWrapper: " + ex.getLocalizedMessage());
929+ ex.printStackTrace();
930+ }
931+ }
932+}
933
934=== added file 'swig/java/ZorbaWriterWrapper.java'
935--- swig/java/ZorbaWriterWrapper.java 1970-01-01 00:00:00 +0000
936+++ swig/java/ZorbaWriterWrapper.java 2012-09-08 14:02:23 +0000
937@@ -0,0 +1,65 @@
938+/*
939+ * Copyright 2006-2012 The FLWOR Foundation.
940+ *
941+ * Licensed under the Apache License, Version 2.0 (the "License");
942+ * you may not use this file except in compliance with the License.
943+ * You may obtain a copy of the License at
944+ *
945+ * http://www.apache.org/licenses/LICENSE-2.0
946+ *
947+ * Unless required by applicable law or agreed to in writing, software
948+ * distributed under the License is distributed on an "AS IS" BASIS,
949+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
950+ * See the License for the specific language governing permissions and
951+ * limitations under the License.
952+ */
953+package org.zorbaxquery.api;
954+
955+import java.io.IOException;
956+import java.io.Writer;
957+import java.nio.ByteBuffer;
958+import java.nio.CharBuffer;
959+import java.nio.charset.Charset;
960+import java.nio.charset.CharsetDecoder;
961+
962+public class ZorbaWriterWrapper extends org.zorbaxquery.api.ZorbaIOStream {
963+
964+ private static final int BUFFER_SIZE = @ZORBA_STREAM_BUFFER_SIZE@;
965+ private static CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
966+ private Writer writer;
967+ CharBuffer charBuffer;
968+ ByteBuffer byteBuffer;
969+
970+
971+ public ZorbaWriterWrapper(Writer aWriter) {
972+ writer = aWriter;
973+ charBuffer = CharBuffer.allocate(BUFFER_SIZE);
974+ byteBuffer = ByteBuffer.allocate(BUFFER_SIZE*2);
975+ }
976+
977+ @Override
978+ public void write(byte[] stream, long aLen){
979+ try {
980+ int offset = 0;
981+ int bufferLength = 0;
982+ while (stream.length>offset) {
983+ byteBuffer.clear();
984+ bufferLength = BUFFER_SIZE;
985+ if ((offset+BUFFER_SIZE)>stream.length) {
986+ bufferLength = stream.length-offset;
987+ }
988+ offset += BUFFER_SIZE;
989+ byteBuffer.put(stream, 0, bufferLength);
990+ byteBuffer.flip();
991+ charBuffer.clear();
992+ decoder.decode(byteBuffer, charBuffer, false);
993+ charBuffer.flip();
994+ writer.append(charBuffer);
995+ }
996+ } catch (IOException ex) {
997+ System.err.println("Error writing on output stream" + ex.getLocalizedMessage());
998+ }
999+
1000+ }
1001+
1002+}
1003
1004=== modified file 'swig/java/zorba_api.i'
1005--- swig/java/zorba_api.i 2012-08-30 13:45:43 +0000
1006+++ swig/java/zorba_api.i 2012-09-08 14:02:23 +0000
1007@@ -16,10 +16,39 @@
1008 // Generate Java 1.5 proper enums
1009 //include "enums.swg"
1010 %include "enumtypeunsafe.swg"
1011+%include "std_string.i"
1012
1013 // don't do a JNI call for constants and enums.
1014 %javaconst(1);
1015
1016-
1017+%typemap(jni) char *BYTE "jbyteArray"
1018+%typemap(jtype) char *BYTE "byte[]"
1019+%typemap(jstype) char *BYTE "byte[]"
1020+%typemap(javain) char *BYTE "$javainput"
1021+%typemap(freearg) char *BYTE ""
1022+%typemap(in) char *BYTE {
1023+ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
1024+}
1025+%typemap(argout) char *BYTE {
1026+ JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
1027+}
1028+
1029+%typemap(directorin, descriptor="[B") char *BYTE {
1030+ jbyteArray jb = (jenv)->NewByteArray(strlen($1));
1031+ (jenv)->SetByteArrayRegion(jb, 0, strlen($1), (jbyte*)$1);
1032+ $input = jb;
1033+}
1034+%typemap(directorout) char *BYTE {
1035+ $1 = 0;
1036+ if($input){
1037+ $result = (char *) jenv->GetByteArrayElements($input, 0);
1038+ if(!$1)
1039+ return $null;
1040+ jenv->ReleaseByteArrayElements($input, $result, 0);
1041+ }
1042+}
1043+
1044+%typemap(javadirectorin) char *BYTE "$jniinput"
1045+%typemap(javadirectorout) char *BYTE "$javacall"
1046
1047 %include ../zorba_api.i
1048
1049=== modified file 'swig/php/CMakeLists.txt'
1050--- swig/php/CMakeLists.txt 2012-08-30 13:45:43 +0000
1051+++ swig/php/CMakeLists.txt 2012-09-08 14:02:23 +0000
1052@@ -46,7 +46,7 @@
1053
1054 FILE(GLOB ZORBA_API_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/../" "${CMAKE_CURRENT_SOURCE_DIR}/../*.h")
1055 FOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
1056- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}" COPYONLY)
1057+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}")
1058 ENDFOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
1059
1060 # The following fix was added because of the changes in CMake 2.8, which have the
1061
1062=== modified file 'swig/php/tests/test11.php'
1063--- swig/php/tests/test11.php 2012-03-27 00:56:11 +0000
1064+++ swig/php/tests/test11.php 2012-09-08 14:02:23 +0000
1065@@ -15,38 +15,34 @@
1066 * limitations under the License.
1067 */
1068
1069-//require '@phpPath@/Zorba/zorba_api_wrapper.php';
1070-require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
1071-
1072-class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
1073- def error(self, *args):
1074- print "Error args: ", args
1075-
1076-def test(zorba):
1077- #Read and write result
1078- print 'Executing: compilerHints.xq'
1079- f = open('compilerHints.xq', 'r')
1080- lines = f.read()
1081- f.close()
1082+require '@phpPath@/Zorba/zorba_api_wrapper.php';
1083+
1084+class MyDiagnosticHandler(DiagnosticHandler handler) {
1085+ funtion error(self, *args) {
1086+ print "Error args: ", args;
1087+ }
1088+}
1089+
1090+function test(Zorba $aZorba)
1091+{
1092 diagnosticHandler = MyDiagnosticHandler()
1093- compilerHints = zorba_api.CompilerHints()
1094- compilerHints.setOptimizationLevel(0)
1095- xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
1096-
1097- result = xquery.execute()
1098- print result
1099+ try {
1100+ xquery = zorba.compileQuery("1 div 0", diagnosticHandler);
1101+ print xquery.execute()
1102+ } catch (Exception e) {
1103+ print "Caught error: ";
1104+ }
1105 return
1106-
1107-
1108-store = zorba_api.InMemoryStore_getInstance()
1109-zorba = zorba_api.Zorba_getInstance(store)
1110-
1111-print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0"
1112-test(zorba)
1113-print "Success"
1114-
1115-
1116-zorba.shutdown()
1117-zorba_api.InMemoryStore_shutdown(store)
1118+}
1119+
1120+$store = InMemoryStore::getInstance();
1121+$zorba = Zorba::getInstance($store);
1122+
1123+print "Running: Compile query string using Diagnostic Handler"
1124+test($zorba);
1125+print "Success";
1126+
1127+$zorba->shutdown();
1128+InMemoryStore::shutdown($store);
1129
1130 ?>
1131\ No newline at end of file
1132
1133=== modified file 'swig/php/zorba_api.i'
1134--- swig/php/zorba_api.i 2012-08-30 13:45:43 +0000
1135+++ swig/php/zorba_api.i 2012-09-08 14:02:23 +0000
1136@@ -31,6 +31,7 @@
1137
1138 %}
1139
1140+%include "std_string.i"
1141
1142 %{
1143 #include "zend_exceptions.h"
1144
1145=== modified file 'swig/python/CMakeLists.txt'
1146--- swig/python/CMakeLists.txt 2012-08-30 13:45:43 +0000
1147+++ swig/python/CMakeLists.txt 2012-09-08 14:02:23 +0000
1148@@ -36,7 +36,7 @@
1149
1150 FILE(GLOB ZORBA_API_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/../" "${CMAKE_CURRENT_SOURCE_DIR}/../*.h")
1151 FOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
1152- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}" COPYONLY)
1153+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}")
1154 ENDFOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
1155
1156 SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python")
1157
1158=== modified file 'swig/python/tests/CMakeLists.txt'
1159--- swig/python/tests/CMakeLists.txt 2012-08-30 13:45:43 +0000
1160+++ swig/python/tests/CMakeLists.txt 2012-09-08 14:02:23 +0000
1161@@ -60,9 +60,9 @@
1162 ADD_TEST("python_test10" ${PYTHON_EXECUTABLE} test10.py)
1163 SET_TESTS_PROPERTIES("python_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1164
1165-#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.py.in ${CMAKE_CURRENT_BINARY_DIR}/test11.py)
1166-#ADD_TEST("python_test11" ${PYTHON_EXECUTABLE} test11.py)
1167-#SET_TESTS_PROPERTIES("python_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1168+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.py.in ${CMAKE_CURRENT_BINARY_DIR}/test11.py)
1169+ADD_TEST("python_test11" ${PYTHON_EXECUTABLE} test11.py)
1170+SET_TESTS_PROPERTIES("python_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1171
1172 #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.py.in ${CMAKE_CURRENT_BINARY_DIR}/test12.py)
1173 #ADD_TEST("python_test12" ${PYTHON_EXECUTABLE} test12.py)
1174
1175=== modified file 'swig/python/tests/test11.py.in'
1176--- swig/python/tests/test11.py.in 2012-08-30 13:45:43 +0000
1177+++ swig/python/tests/test11.py.in 2012-09-08 14:02:23 +0000
1178@@ -16,31 +16,24 @@
1179 sys.path.insert(0, '@pythonPath@')
1180 import zorba_api
1181
1182-class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
1183- def error(self, *args):
1184- print "Error args: ", args
1185-
1186-def test(zorba):
1187- #Read and write result
1188- print 'Executing: compilerHints.xq'
1189- f = open('compilerHints.xq', 'r')
1190- lines = f.read()
1191- f.close()
1192- diagnosticHandler = MyDiagnosticHandler()
1193- compilerHints = zorba_api.CompilerHints()
1194- compilerHints.setOptimizationLevel(0)
1195- xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
1196-
1197- result = xquery.execute()
1198- print result
1199- return
1200-
1201-
1202 store = zorba_api.InMemoryStore_getInstance()
1203 zorba = zorba_api.Zorba_getInstance(store)
1204
1205-print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0"
1206-test(zorba)
1207+print "Running: CompileQuery CollectionManager"
1208+
1209+xmlManager = zorba.getXmlDataManager()
1210+collectionManager = xmlManager.getCollectionManager()
1211+itemFactory = zorba.getItemFactory()
1212+name = itemFactory.createQName("http://www.zorba-xquery.com/", "aaa")
1213+collectionManager.createCollection(name)
1214+isAdded = collectionManager.isAvailableCollection(name)
1215+
1216+if isAdded :
1217+ collection = collectionManager.getCollection(name);
1218+ data = xmlManager.parseXMLtoItem("<books><book>Book 1</book><book>Book 2</book></books>");
1219+ itemSequence = zorba_api.ItemSequence(data)
1220+ collection.insertNodesLast(itemSequence)
1221+
1222 print "Success"
1223
1224
1225
1226=== modified file 'swig/python/zorba_api.i'
1227--- swig/python/zorba_api.i 2012-08-30 13:45:43 +0000
1228+++ swig/python/zorba_api.i 2012-09-08 14:02:23 +0000
1229@@ -23,6 +23,7 @@
1230 #include <zorba/singleton_item_sequence.h>
1231 #include <zorba/serializer.h>
1232 %}
1233+%include "std_string.i"
1234
1235 %{
1236
1237
1238=== modified file 'swig/ruby/CMakeLists.txt'
1239--- swig/ruby/CMakeLists.txt 2012-08-30 13:45:43 +0000
1240+++ swig/ruby/CMakeLists.txt 2012-09-08 14:02:23 +0000
1241@@ -53,7 +53,7 @@
1242
1243 FILE(GLOB ZORBA_API_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/../" "${CMAKE_CURRENT_SOURCE_DIR}/../*.h")
1244 FOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
1245- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}" COPYONLY)
1246+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../${ZORBA_API_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_API_HEADER}")
1247 ENDFOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
1248
1249 SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby")
1250
1251=== modified file 'swig/ruby/tests/CMakeLists.txt'
1252--- swig/ruby/tests/CMakeLists.txt 2012-08-30 13:45:43 +0000
1253+++ swig/ruby/tests/CMakeLists.txt 2012-09-08 14:02:23 +0000
1254@@ -29,9 +29,9 @@
1255 ADD_TEST("ruby_test02" ${RUBY_EXECUTABLE} test02.rb)
1256 SET_TESTS_PROPERTIES("ruby_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1257
1258-#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.rb ${CMAKE_CURRENT_BINARY_DIR}/test03.rb)
1259-#ADD_TEST("ruby_test03" ${RUBY_EXECUTABLE} test03.rb)
1260-#SET_TESTS_PROPERTIES("ruby_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1261+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.rb ${CMAKE_CURRENT_BINARY_DIR}/test03.rb)
1262+ADD_TEST("ruby_test03" ${RUBY_EXECUTABLE} test03.rb)
1263+SET_TESTS_PROPERTIES("ruby_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1264
1265 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.rb ${CMAKE_CURRENT_BINARY_DIR}/test04.rb)
1266 ADD_TEST("ruby_test04" ${RUBY_EXECUTABLE} test04.rb)
1267@@ -64,9 +64,9 @@
1268 ADD_TEST("ruby_test10" ${RUBY_EXECUTABLE} test10.rb)
1269 SET_TESTS_PROPERTIES("ruby_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1270
1271-#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.rb ${CMAKE_CURRENT_BINARY_DIR}/test11.rb)
1272-#ADD_TEST("ruby_test11" ${RUBY_EXECUTABLE} test11.rb)
1273-#SET_TESTS_PROPERTIES("ruby_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1274+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.rb ${CMAKE_CURRENT_BINARY_DIR}/test11.rb)
1275+ADD_TEST("ruby_test11" ${RUBY_EXECUTABLE} test11.rb)
1276+SET_TESTS_PROPERTIES("ruby_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
1277
1278 #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.rb ${CMAKE_CURRENT_BINARY_DIR}/test12.rb)
1279 #ADD_TEST("ruby_test12" ${RUBY_EXECUTABLE} test12.rb)
1280
1281=== modified file 'swig/ruby/tests/test03.rb'
1282--- swig/ruby/tests/test03.rb 2012-03-27 00:56:11 +0000
1283+++ swig/ruby/tests/test03.rb 2012-09-08 14:02:23 +0000
1284@@ -14,13 +14,13 @@
1285
1286 require '@rubyPath@/zorba_api'
1287
1288-class MyDiagnosticHandler < Zorba_api.DiagnosticHandler
1289- def error(self, *args)
1290- print "Error args: " + args
1291+class MyDiagnosticHandler < Zorba_api::DiagnosticHandler
1292+ def error(args)
1293+ print "Error args: " + args.getDescription() + "\n"
1294 end
1295 end
1296
1297-def test(zorba):
1298+def test(zorba)
1299 diagnosticHandler = MyDiagnosticHandler.new
1300 begin
1301 xquery = zorba.compileQuery("1 div 0", diagnosticHandler)
1302@@ -35,9 +35,9 @@
1303 store = Zorba_api::InMemoryStore.getInstance()
1304 zorba = Zorba_api::Zorba.getInstance(store)
1305
1306-print "Running: Capturing error with DiagnosticHandler"
1307+print "Running: Capturing error with DiagnosticHandler\n"
1308 test(zorba)
1309 print "Success"
1310
1311 zorba.shutdown()
1312-Zorba_api::InMemoryStore.shutdown(store)
1313+Zorba_api::InMemoryStore.shutdown(store)
1314\ No newline at end of file
1315
1316=== modified file 'swig/ruby/tests/test11.rb'
1317--- swig/ruby/tests/test11.rb 2012-03-27 00:56:11 +0000
1318+++ swig/ruby/tests/test11.rb 2012-09-08 14:02:23 +0000
1319@@ -12,38 +12,28 @@
1320 # See the License for the specific language governing permissions and
1321 # limitations under the License.
1322
1323-import sys
1324-sys.path.insert(0, '@pythonPath@')
1325-import zorba_api
1326-
1327-class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
1328- def error(self, *args):
1329- print "Error args: ", args
1330-
1331-def test(zorba):
1332- #Read and write result
1333- print 'Executing: compilerHints.xq'
1334- f = open('compilerHints.xq', 'r')
1335- lines = f.read()
1336- f.close()
1337- diagnosticHandler = MyDiagnosticHandler()
1338- compilerHints = zorba_api.CompilerHints()
1339- compilerHints.setOptimizationLevel(0)
1340- xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
1341-
1342- result = xquery.execute()
1343- print result
1344- return
1345-
1346-
1347-store = zorba_api.InMemoryStore_getInstance()
1348-zorba = zorba_api.Zorba_getInstance(store)
1349-
1350-print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0"
1351-test(zorba)
1352+require '@rubyPath@/zorba_api'
1353+
1354+store = Zorba_api::InMemoryStore.getInstance()
1355+zorba = Zorba_api::Zorba.getInstance(store)
1356+
1357+print "Running: CompileQuery CollectionManager\n"
1358+
1359+xmlManager = zorba.getXmlDataManager()
1360+collectionManager = xmlManager.getCollectionManager()
1361+itemFactory = zorba.getItemFactory()
1362+name = itemFactory.createQName("http://www.zorba-xquery.com/", "aaa")
1363+collectionManager.createCollection(name)
1364+isAdded = collectionManager.isAvailableCollection(name)
1365+
1366+if isAdded :
1367+ collection = collectionManager.getCollection(name)
1368+ data = xmlManager.parseXMLtoItem("<books><book>Book 1</book><book>Book 2</book></books>")
1369+ itemSequence = Zorba_api::ItemSequence.new(data)
1370+ collection.insertNodesLast(itemSequence)
1371+end
1372+
1373 print "Success"
1374
1375-
1376 zorba.shutdown()
1377-zorba_api.InMemoryStore_shutdown(store)
1378-
1379+Zorba_api::InMemoryStore.shutdown(store)
1380
1381=== modified file 'swig/ruby/zorba_api.i'
1382--- swig/ruby/zorba_api.i 2012-08-30 13:45:43 +0000
1383+++ swig/ruby/zorba_api.i 2012-09-08 14:02:23 +0000
1384@@ -13,6 +13,7 @@
1385 * See the License for the specific language governing permissions and
1386 * limitations under the License.
1387 */
1388+%include "std_string.i"
1389 %include ../zorba_api.i
1390
1391 %runtime %{
1392
1393=== modified file 'swig/xqj/CMakeLists.txt'
1394--- swig/xqj/CMakeLists.txt 2012-08-30 13:45:43 +0000
1395+++ swig/xqj/CMakeLists.txt 2012-09-08 14:02:23 +0000
1396@@ -29,6 +29,12 @@
1397 #SWIG Java: Generating XQJ Tests
1398 FILE(GLOB ZORBA_XQJ_TESTS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/managers/" "${CMAKE_CURRENT_SOURCE_DIR}/managers/*.*")
1399 FOREACH(ZORBA_XQJ_TEST ${ZORBA_XQJ_TESTS})
1400+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/managers/${ZORBA_XQJ_TEST}" "${CMAKE_CURRENT_BINARY_DIR}/managers/${ZORBA_XQJ_TEST}" COPYONLY)
1401+ ENDFOREACH(ZORBA_XQJ_TEST ${ZORBA_API_HEADERS})
1402+
1403+ #SWIG Java: Processing XQ
1404+ FILE(GLOB ZORBA_XQJ_TESTS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/managers/" "${CMAKE_CURRENT_SOURCE_DIR}/managers/*.xq")
1405+ FOREACH(ZORBA_XQJ_TEST ${ZORBA_XQJ_TESTS})
1406 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/managers/${ZORBA_XQJ_TEST}" "${CMAKE_CURRENT_BINARY_DIR}/managers/${ZORBA_XQJ_TEST}")
1407 ENDFOREACH(ZORBA_XQJ_TEST ${ZORBA_API_HEADERS})
1408
1409@@ -100,7 +106,7 @@
1410 COMMAND cmake -E echo "Compiling XQJ files..."
1411 COMMAND ${Java_JAVAC_EXECUTABLE} -cp ${XQJ_CLASSPATH} *.java -d ${CMAKE_CURRENT_BINARY_DIR}
1412 COMMAND cmake -E echo "Creating jar file..."
1413- COMMAND ${Java_JAR_EXECUTABLE} cvf zorba_xqj.jar org
1414+ COMMAND ${Java_JAR_EXECUTABLE} cf zorba_xqj.jar org
1415 )
1416 ENDIF (${RESULT} GREATER -1)
1417
1418
1419=== modified file 'swig/xqj/ZorbaXQConnection.java'
1420--- swig/xqj/ZorbaXQConnection.java 2012-08-30 13:45:43 +0000
1421+++ swig/xqj/ZorbaXQConnection.java 2012-09-08 14:02:23 +0000
1422@@ -333,26 +333,11 @@
1423 isClosedXQException();
1424 isNullXQException(reader);
1425
1426- StringBuffer string = new StringBuffer();
1427- CharBuffer buffer = CharBuffer.allocate(1024);
1428- Writer writer = new StringWriter();
1429-
1430- try {
1431- while( reader.read(buffer) >= 0 ) {
1432- buffer.flip();
1433- writer.append(buffer);
1434- buffer.clear();
1435- }
1436- reader.close();
1437- } catch (Exception ex) {
1438- throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1439- }
1440-
1441 XQPreparedExpression expression;
1442 if (lStaticContext == null) {
1443- expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, writer.toString());
1444+ expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, reader);
1445 } else {
1446- expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, writer.toString(), lStaticContext);
1447+ expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, reader, lStaticContext);
1448 }
1449 cPreparedExpression.add(expression);
1450 return expression;
1451@@ -372,21 +357,8 @@
1452 isClosedXQException();
1453 isNullXQException(reader);
1454 isNullXQException(xqsc);
1455- StringBuffer string = new StringBuffer();
1456- CharBuffer buffer = CharBuffer.allocate(1024);
1457- Writer writer = new StringWriter();
1458- try {
1459- while( reader.read(buffer) >= 0 ) {
1460- buffer.flip();
1461- writer.append(buffer);
1462- buffer.clear();
1463- }
1464- reader.close();
1465- } catch (Exception ex) {
1466- throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1467- }
1468-
1469- XQPreparedExpression expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, writer.toString(), xqsc);
1470+
1471+ XQPreparedExpression expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, reader, xqsc);
1472
1473 cPreparedExpression.add(expression);
1474 return expression;
1475@@ -404,21 +376,12 @@
1476 public XQPreparedExpression prepareExpression(InputStream in) throws XQException {
1477 isClosedXQException();
1478 isNullXQException(in);
1479- StringBuffer out = new StringBuffer ();
1480- try {
1481- byte[] b = new byte[4096];
1482- for (int n; (n = in.read(b)) != -1;) {
1483- out.append(new String(b, 0, n));
1484- }
1485- } catch (Exception ex) {
1486- throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1487- }
1488-
1489+
1490 XQPreparedExpression expression;
1491 if (lStaticContext == null) {
1492- expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, out.toString());
1493+ expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, in);
1494 } else {
1495- expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, out.toString(), lStaticContext);
1496+ expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, in, lStaticContext);
1497 }
1498 try {
1499 cPreparedExpression.add(expression);
1500@@ -443,19 +406,10 @@
1501 isClosedXQException();
1502 isNullXQException(in);
1503 isNullXQException(xqsc);
1504- StringBuffer out = new StringBuffer ();
1505- try {
1506- byte[] b = new byte[4096];
1507- for (int n; (n = in.read(b)) != -1;) {
1508- out.append(new String(b, 0, n));
1509- }
1510- } catch (IOException ex) {
1511- throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1512- }
1513
1514 XQPreparedExpression expression = null;
1515 try {
1516- expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, out.toString(), xqsc);
1517+ expression = new org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression(this, in, xqsc);
1518 cPreparedExpression.add(expression);
1519 } catch (Exception ex) {
1520 throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1521@@ -726,11 +680,7 @@
1522 try {
1523 dm = zorba.getXmlDataManager();
1524 doc = new Item();
1525- org.zorbaxquery.api.Iterator iterator = dm.parseXML(value);
1526- iterator.open();
1527- iterator.next(doc);
1528- iterator.close();
1529- iterator.delete();
1530+ doc = dm.parseXMLtoItem(value);
1531 item = new org.zorbaxquery.api.xqj.ZorbaXQItem(doc);
1532 } catch (Exception e) {
1533 throw new XQException("Error creating Item" + e.getLocalizedMessage());
1534@@ -756,23 +706,26 @@
1535 public XQItem createItemFromDocument(Reader value, String baseURI, XQItemType type) throws XQException {
1536 isClosedXQException();
1537 isNullXQException(value);
1538-
1539- StringBuffer string = new StringBuffer();
1540- CharBuffer buffer = CharBuffer.allocate(1024);
1541- Writer writer = new StringWriter();
1542-
1543+ if (type!=null) {
1544+ if ( ! ((type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_ELEMENT)||(type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT)) ) {
1545+ throw new XQException("Invalid type");
1546+ }
1547+ } else {
1548+ type = this.createElementType(null, XQItemType.XQBASETYPE_UNTYPED);
1549+ }
1550+
1551+ XmlDataManager dm = null;
1552+ Item doc = null;
1553+ XQItem item = null;
1554 try {
1555- while( value.read(buffer) >= 0 ) {
1556- buffer.flip();
1557- writer.append(buffer);
1558- buffer.clear();
1559- }
1560- value.close();
1561- } catch (Exception ex) {
1562- throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1563+ dm = zorba.getXmlDataManager();
1564+ doc = new Item();
1565+ ZorbaReaderWrapper stream = new ZorbaReaderWrapper(value);
1566+ doc = dm.parseXMLtoItem(stream);
1567+ item = new org.zorbaxquery.api.xqj.ZorbaXQItem(doc);
1568+ } catch (Exception e) {
1569+ throw new XQException("Error creating Item" + e.getLocalizedMessage());
1570 }
1571-
1572- XQItem item = createItemFromDocument(writer.toString(), baseURI, type);
1573 return item;
1574 }
1575
1576@@ -794,17 +747,26 @@
1577 public XQItem createItemFromDocument(InputStream value, String baseURI, XQItemType type) throws XQException {
1578 isClosedXQException();
1579 isNullXQException(value);
1580- // TODO: Rodolfo: optimize this, not good to have a string
1581- StringBuffer out = new StringBuffer ();
1582+ if (type!=null) {
1583+ if ( ! ((type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_ELEMENT)||(type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT)) ) {
1584+ throw new XQException("Invalid type");
1585+ }
1586+ } else {
1587+ type = this.createElementType(null, XQItemType.XQBASETYPE_UNTYPED);
1588+ }
1589+
1590+ XmlDataManager dm = null;
1591+ Item doc = null;
1592+ XQItem item = null;
1593 try {
1594- byte[] b = new byte[4096];
1595- for (int n; (n = value.read(b)) != -1;) {
1596- out.append(new String(b, 0, n));
1597- }
1598- } catch (Exception ex) {
1599- throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
1600+ dm = zorba.getXmlDataManager();
1601+ doc = new Item();
1602+ ZorbaInputWrapper stream = new ZorbaInputWrapper(value);
1603+ doc = dm.parseXMLtoItem(stream);
1604+ item = new org.zorbaxquery.api.xqj.ZorbaXQItem(doc);
1605+ } catch (Exception e) {
1606+ throw new XQException("Error creating Item" + e.getLocalizedMessage());
1607 }
1608- XQItem item = createItemFromDocument(out.toString(), baseURI, type);
1609 return item;
1610 }
1611
1612@@ -1203,11 +1165,7 @@
1613 Item tmpItem = new Item();
1614 if (xmlString.length()>0) {
1615 XmlDataManager dataManager = zorba.getXmlDataManager();
1616- org.zorbaxquery.api.Iterator iter = dataManager.parseXML(xmlString);
1617- iter.open();
1618- iter.next(tmpItem);
1619- iter.close();
1620- iter.delete();
1621+ tmpItem = dataManager.parseXMLtoItem(xmlString);
1622 } else {
1623 tmpItem = itemFactory.createDocumentNode("", "");
1624 }
1625
1626=== modified file 'swig/xqj/ZorbaXQItem.java'
1627--- swig/xqj/ZorbaXQItem.java 2012-08-30 13:45:43 +0000
1628+++ swig/xqj/ZorbaXQItem.java 2012-09-08 14:02:23 +0000
1629@@ -699,7 +699,8 @@
1630 opts.setSerializerOption(key, value);
1631 }
1632 }
1633- out.write(item.serialize(opts).getBytes());
1634+ ZorbaOutputWrapper OStream = new ZorbaOutputWrapper(out);
1635+ item.serializeToStream(OStream);
1636 } catch (Exception ex) {
1637 throw new XQException("Error writing on stream: " + ex.getLocalizedMessage());
1638 }
1639@@ -727,6 +728,8 @@
1640 opts.setSerializerOption(key, value);
1641 }
1642 }
1643+ ZorbaWriterWrapper OStream = new ZorbaWriterWrapper(writer);
1644+ item.serializeToStream(OStream);
1645 writer.write(item.serialize(opts));
1646 } catch (Exception ex) {
1647 throw new XQException("Error sending to writer: " + ex.getLocalizedMessage());
1648
1649=== modified file 'swig/xqj/ZorbaXQPreparedExpression.java'
1650--- swig/xqj/ZorbaXQPreparedExpression.java 2012-08-30 13:45:43 +0000
1651+++ swig/xqj/ZorbaXQPreparedExpression.java 2012-09-08 14:02:23 +0000
1652@@ -15,10 +15,7 @@
1653 */
1654 package org.zorbaxquery.api.xqj;
1655
1656-import java.io.InputStream;
1657-import java.io.Reader;
1658-import java.io.StringWriter;
1659-import java.io.Writer;
1660+import java.io.*;
1661 import java.nio.CharBuffer;
1662 import java.util.ArrayList;
1663 import java.util.Collection;
1664@@ -112,6 +109,43 @@
1665
1666 }
1667 }
1668+
1669+ public ZorbaXQPreparedExpression (XQConnection conn, Reader reader) throws XQException {
1670+ if (conn.isClosed()) {
1671+ throw new XQException ("Connection is closed");
1672+ }
1673+ closed = false;
1674+ connection = conn;
1675+ Zorba zorba = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance();
1676+ try {
1677+ ZorbaReaderWrapper stream = new ZorbaReaderWrapper(reader);
1678+ query = zorba.compileQuery(stream);
1679+ dynamicContext = query.getDynamicContext();
1680+ xmlDataManager = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance().getXmlDataManager();
1681+ } catch (Exception e) {
1682+ throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
1683+
1684+ }
1685+ }
1686+
1687+ public ZorbaXQPreparedExpression (XQConnection conn, InputStream input) throws XQException {
1688+ if (conn.isClosed()) {
1689+ throw new XQException ("Connection is closed");
1690+ }
1691+ closed = false;
1692+ connection = conn;
1693+ Zorba zorba = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance();
1694+ try {
1695+ ZorbaInputWrapper stream = new ZorbaInputWrapper(input);
1696+ query = zorba.compileQuery(stream);
1697+ dynamicContext = query.getDynamicContext();
1698+ xmlDataManager = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance().getXmlDataManager();
1699+ } catch (Exception e) {
1700+ throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
1701+
1702+ }
1703+ }
1704+
1705 public ZorbaXQPreparedExpression (XQConnection conn, String string, XQStaticContext sc) throws XQException {
1706 if (conn.isClosed()) {
1707 throw new XQException ("Connection is closed");
1708@@ -129,6 +163,42 @@
1709 }
1710 }
1711
1712+ public ZorbaXQPreparedExpression (XQConnection conn, Reader reader, XQStaticContext sc) throws XQException {
1713+ if (conn.isClosed()) {
1714+ throw new XQException ("Connection is closed");
1715+ }
1716+ closed = false;
1717+ connection = conn;
1718+ Zorba zorba = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance();
1719+ try {
1720+ ZorbaReaderWrapper stream = new ZorbaReaderWrapper(reader);
1721+ query = zorba.compileQuery(stream, ((org.zorbaxquery.api.xqj.ZorbaXQStaticContext)sc).getZorbaStaticContext());
1722+ dynamicContext = query.getDynamicContext();
1723+ xmlDataManager = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance().getXmlDataManager();
1724+ } catch (Exception e) {
1725+ throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
1726+
1727+ }
1728+ }
1729+
1730+ public ZorbaXQPreparedExpression (XQConnection conn, InputStream input, XQStaticContext sc) throws XQException {
1731+ if (conn.isClosed()) {
1732+ throw new XQException ("Connection is closed");
1733+ }
1734+ closed = false;
1735+ connection = conn;
1736+ Zorba zorba = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance();
1737+ try {
1738+ ZorbaInputWrapper stream = new ZorbaInputWrapper(input);
1739+ query = zorba.compileQuery(stream, ((org.zorbaxquery.api.xqj.ZorbaXQStaticContext)sc).getZorbaStaticContext());
1740+ dynamicContext = query.getDynamicContext();
1741+ xmlDataManager = ((org.zorbaxquery.api.xqj.ZorbaXQConnection)connection).getZorbaInstance().getXmlDataManager();
1742+ } catch (Exception e) {
1743+ throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
1744+
1745+ }
1746+ }
1747+
1748 /** \brief Attempts to cancel the execution if both the XQuery engine and XQJ driver support aborting the execution of an ZorbaXQPreparedExpression.
1749 *
1750 * This method can be used by one thread to cancel an ZorbaXQPreparedExpression, that is being executed in another thread. If cancellation is not supported or the attempt to cancel the execution was not successful, the method returns without any error. If the cancellation is successful, an XQException is thrown, to indicate that it has been aborted, by executeQuery, executeCommand or any method accessing the ZorbaXQResultSequence returned by executeQuery. If applicable, any open ZorbaXQResultSequence and XQResultItem objects will also be implicitly closed in this case.
1751@@ -445,9 +515,8 @@
1752 throw new XQException ("Variable not found in context.");
1753 }
1754 try {
1755- Iterator iter = xmlDataManager.parseXML(value);
1756 Item item = new Item();
1757- iter.next(item);
1758+ item = xmlDataManager.parseXMLtoItem(value);
1759 dynamicContext.setVariable(varName.getLocalPart(), item);
1760 itemsBounded.add(varName.getLocalPart());
1761 } catch (Exception e) {
1762
1763=== modified file 'swig/xqj/ZorbaXQResultSequence.java'
1764--- swig/xqj/ZorbaXQResultSequence.java 2012-08-30 13:45:43 +0000
1765+++ swig/xqj/ZorbaXQResultSequence.java 2012-09-08 14:02:23 +0000
1766@@ -35,6 +35,7 @@
1767 import org.xml.sax.ContentHandler;
1768 import org.zorbaxquery.api.Item;
1769 import org.zorbaxquery.api.Iterator;
1770+import org.zorbaxquery.api.SerializationOptions;
1771
1772 /**
1773 * This class represents a sequence of items obtained as a result of evaluation XQuery expressions. The result sequence is tied to the XQconnection object on which the expression was evaluated.
1774@@ -309,21 +310,20 @@
1775 isConsumedXQException();
1776 String result = null;
1777 try {
1778- /*
1779- if (item.isNode() && item.getNodeKind()==3) { //attribute node
1780- resultString = resultString.concat(item.getStringValue()).concat(" ");
1781- } else {
1782- resultString = resultString.concat(item.serialize().replace("&gt;", ">").replace("&lt;", "<")).concat(" ");
1783- }
1784- *
1785- */
1786+ SerializationOptions opts = new SerializationOptions();
1787+ if ((prprts!=null) && prprts.size()>0) {
1788+ for(String key : prprts.stringPropertyNames()) {
1789+ String value = prprts.getProperty(key);
1790+ opts.setSerializerOption(key, value);
1791+ }
1792+ }
1793 if (iter.isOpen()) {
1794 iter.close();
1795 iter.delete();
1796 }
1797 iterDeleted = true;
1798 consumedItem = true;
1799- result = lQuery.execute().replace("&gt;", ">").replace("&lt;", "<");
1800+ result = lQuery.execute(opts).replace("&gt;", ">").replace("&lt;", "<");
1801 } catch (Exception e) {
1802 throw new XQException("Error getting stream: " + e.getLocalizedMessage());
1803 } finally {
1804
1805=== modified file 'swig/xqj/ZorbaXQSequence.java'
1806--- swig/xqj/ZorbaXQSequence.java 2012-08-30 13:45:43 +0000
1807+++ swig/xqj/ZorbaXQSequence.java 2012-09-08 14:02:23 +0000
1808@@ -359,7 +359,7 @@
1809 isItemGetXQException();
1810 StringBuffer sb = new StringBuffer();
1811 for (XQItem item: content) {
1812- sb.append(item.getItemAsString(null));
1813+ sb.append(item.getItemAsString(prprts));
1814 }
1815 return sb.toString();
1816 }
1817
1818=== modified file 'swig/xqj/managers/Api_test.java'
1819--- swig/xqj/managers/Api_test.java 2012-08-30 13:45:43 +0000
1820+++ swig/xqj/managers/Api_test.java 2012-09-08 14:02:23 +0000
1821@@ -16,285 +16,63 @@
1822 package api_test;
1823
1824
1825-import java.io.BufferedReader;
1826-import java.io.FileReader;
1827-import java.net.URI;
1828-import java.net.URISyntaxException;
1829-import javax.xml.namespace.QName;
1830-import javax.xml.xquery.*;
1831-import org.zorbaxquery.api.*;
1832-import org.zorbaxquery.api.xqj.*;
1833+import java.lang.reflect.InvocationTargetException;
1834+import java.lang.reflect.Method;
1835+import java.lang.reflect.Type;
1836+import java.util.Locale;
1837
1838 public class Api_test {
1839-
1840- static
1841- {
1842- System.loadLibrary ( "zorba_api" );
1843- }
1844-
1845- static boolean example_1() throws XQException
1846- {
1847- ZorbaXQDataSource xqds = new ZorbaXQDataSource();
1848- XQConnection xqc = xqds.getConnection();
1849- XQExpression xqe = xqc.createExpression();
1850- org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery("1,2,3");
1851- ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
1852- xqc.close();
1853- xqc.close();
1854- return true;
1855- }
1856-
1857- static boolean example_2 () throws XQException
1858- {
1859- StringBuilder strBuilder = new StringBuilder();
1860- try {
1861- BufferedReader in = new BufferedReader(new FileReader("managers/module1.xq"));
1862- String str;
1863- while ((str = in.readLine()) != null) {
1864- strBuilder.append(str);
1865- }
1866- in.close();
1867- } catch (Exception e) {
1868- throw new XQException("Error reading file for test: " + e.getLocalizedMessage());
1869- }
1870- ZorbaXQDataSource xqds = new ZorbaXQDataSource();
1871- XQConnection xqc = xqds.getConnection();
1872- XQExpression xqe = xqc.createExpression();
1873- org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery(strBuilder.toString());
1874- ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
1875- boolean resultAdding = false;
1876- boolean resultDeleting = true;
1877- URI uri;
1878- QName qname;
1879- XQItemType type = null;
1880- try {
1881- uri = new URI("http://www.mod2.com/");
1882- qname = new QName("http://www.mod2.com/", "coll");
1883- type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
1884- } catch (URISyntaxException e) {
1885- throw new XQException("Error creating QName: " + e.getLocalizedMessage());
1886- }
1887- XQItem colName = xqc.createItemFromString("coll", type);
1888- colManager.createCollection(colName);
1889- resultAdding = colManager.isAvailableCollection(colName);
1890- colManager.deleteCollection(colName);
1891- resultDeleting = !colManager.isAvailableCollection(colName);
1892- xqc.close();
1893- return resultAdding && resultDeleting;
1894- }
1895-
1896- static boolean example_3a() throws XQException
1897- {
1898- StringBuilder strBuilder = new StringBuilder();
1899- try {
1900- BufferedReader in = new BufferedReader(new FileReader("managers/module1.xq"));
1901- String str;
1902- while ((str = in.readLine()) != null) {
1903- strBuilder.append(str);
1904- }
1905- in.close();
1906- } catch (Exception e) {
1907- throw new XQException("Error reading file for test: " + e.getLocalizedMessage());
1908- }
1909- ZorbaXQDataSource xqds = new ZorbaXQDataSource();
1910- org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
1911- XQExpression xqe = xqc.createExpression();
1912- org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery(strBuilder.toString());
1913- ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
1914- URI uri;
1915- QName qname;
1916- XQItemType type = null;
1917- try {
1918- uri = new URI("http://www.mod2.com/");
1919- qname = new QName("http://www.mod2.com/", "coll");
1920- type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
1921- } catch (URISyntaxException e) {
1922- throw new XQException("Error creating QName: " + e.getLocalizedMessage());
1923- }
1924- XQItem colName = xqc.createItemFromString("coll", type);
1925- colManager.createCollection(colName);
1926- ZorbaXQCollection collection = colManager.getCollection(colName);
1927-
1928- ZorbaXQXmlDataManager manager = xqc.getXmlDataManager();
1929- XQSequence data = manager.parseXML("<books><book>Book 1</book><book>Book 2</book></books>");
1930- collection.insertNodesFirst(data);
1931-
1932- colManager.deleteCollection(colName);
1933- boolean resultDeleting = !colManager.isAvailableCollection(colName);
1934- xqc.close();
1935- return resultDeleting;
1936- }
1937-
1938- static boolean example_3b() throws XQException
1939- {
1940- StringBuilder strBuilder = new StringBuilder();
1941- try {
1942- BufferedReader in = new BufferedReader(new FileReader("managers/module1.xq"));
1943- String str;
1944- while ((str = in.readLine()) != null) {
1945- strBuilder.append(str);
1946- }
1947- in.close();
1948- } catch (Exception e) {
1949- throw new XQException("Error reading file for test: " + e.getLocalizedMessage());
1950- }
1951- InMemoryStore store = InMemoryStore.getInstance();
1952- Zorba zorba = Zorba.getInstance ( store );
1953- XQuery query = zorba.compileQuery(strBuilder.toString());
1954- StaticCollectionManager manager = query.getStaticCollectionManager();
1955-
1956-
1957- ItemFactory factory = zorba.getItemFactory();
1958- Item name = factory.createQName("http://www.mod2.com/", "coll");
1959-
1960- manager.createCollection(name);
1961- Collection collection = manager.getCollection(name);
1962-
1963- XmlDataManager xmlManager = zorba.getXmlDataManager();
1964- Item data = xmlManager.parseXMLtoItem("<books><book>Book 1</book><book>Book 2</book></books>");
1965- ItemSequence sequence = new ItemSequence(data);
1966- collection.insertNodesLast(sequence);
1967-
1968- zorba.shutdown();
1969- InMemoryStore.shutdown ( store );
1970-
1971- return true;
1972- }
1973-
1974- static boolean example_4() throws XQException
1975- {
1976- ZorbaXQDataSource xqds = new ZorbaXQDataSource();
1977- org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
1978- XQExpression xqe = xqc.createExpression();
1979- ZorbaXQXmlDataManager xmlManager = xqc.getXmlDataManager();
1980- ZorbaXQCollectionManager colManager = xmlManager.getCollectionManager();
1981- xqc.close();
1982- xqc.close();
1983- return true;
1984- }
1985-
1986- static boolean example_5() throws XQException
1987- {
1988- ZorbaXQDataSource xqds = new ZorbaXQDataSource();
1989- org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
1990- ZorbaXQXmlDataManager xmlManager = xqc.getXmlDataManager();
1991- ZorbaXQCollectionManager colManager = xmlManager.getCollectionManager();
1992- boolean resultAdding = false;
1993- boolean resultDeleting = true;
1994- URI uri;
1995- QName qname;
1996- XQItemType type = null;
1997- try {
1998- uri = new URI("http://www.mod2.com/");
1999- qname = new QName("http://www.mod2.com/", "col2");
2000- type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
2001- } catch (URISyntaxException e) {
2002- throw new XQException("Error creating QName: " + e.getLocalizedMessage());
2003- }
2004- XQItem colName = xqc.createItemFromString("col2", type);
2005- colManager.createCollection(colName);
2006- resultAdding = colManager.isAvailableCollection(colName);
2007- colManager.deleteCollection(colName);
2008- resultDeleting = !colManager.isAvailableCollection(colName);
2009- xqc.close();
2010- return resultAdding && resultDeleting;
2011- }
2012- static boolean example_6a() throws XQException
2013- {
2014- InMemoryStore store = InMemoryStore.getInstance();
2015- Zorba zorba = Zorba.getInstance ( store );
2016- XmlDataManager xmlManager = new XmlDataManager(zorba.getXmlDataManager());
2017- CollectionManager manager = new CollectionManager(xmlManager.getCollectionManager());
2018-
2019- ItemFactory factory = zorba.getItemFactory();
2020- Item name = factory.createQName("http://www.zorba-xquery.com/", "aaa");
2021- manager.createCollection(name);
2022- boolean resultAdding = manager.isAvailableCollection(name);
2023- Collection collection = null;
2024- //Item data = new Item();
2025- if (resultAdding) {
2026- collection = manager.getCollection(name);
2027- Item data = xmlManager.parseXMLtoItem("<books><book>Book 1</book><book>Book 2</book></books>");
2028- collection.insertNodesLast(new ItemSequence(data));
2029+ static
2030+ {
2031+ System.loadLibrary ( "zorba_api" );
2032 }
2033- collection.delete();
2034-
2035- zorba.shutdown();
2036- InMemoryStore.shutdown ( store );
2037- return true;
2038- }
2039-
2040- static boolean example_6b() throws XQException
2041- {
2042- ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2043- org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
2044- ZorbaXQXmlDataManager xmlManager = xqc.getXmlDataManager();
2045- ZorbaXQCollectionManager colManager = xmlManager.getCollectionManager();
2046- URI uri;
2047- QName qname;
2048- XQItemType type = null;
2049+
2050+
2051+ public static void main ( String... args )
2052+ {
2053 try {
2054- uri = new URI("http://www.mod2.com/");
2055- qname = new QName("http://www.mod2.com/", "col2");
2056- type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
2057- } catch (URISyntaxException e) {
2058- throw new XQException("Error creating QName: " + e.getLocalizedMessage());
2059+ Class<?> c = Class.forName("api_test.Tests");
2060+ Object t = c.newInstance();
2061+
2062+ Method[] allMethods = c.getDeclaredMethods();
2063+ for (Method m : allMethods) {
2064+ String mname = m.getName();
2065+ if (!mname.startsWith("test")
2066+ || (m.getGenericReturnType() != boolean.class)) {
2067+ continue;
2068+ }
2069+ Type[] pType = m.getGenericParameterTypes();
2070+ if ((pType.length != 1)
2071+ || Locale.class.isAssignableFrom(pType[0].getClass())) {
2072+ //continue;
2073+ }
2074+
2075+ System.out.format("invoking %s()%n", mname);
2076+ try {
2077+ m.setAccessible(true);
2078+ Object o = m.invoke(t);
2079+ System.out.format("%s() returned %b%n", mname, (Boolean) o);
2080+ if ((Boolean) o) {
2081+ System.out.println("Success");
2082+ } else {
2083+ System.out.println("Failed");
2084+ System.exit (1);
2085+ }
2086+
2087+ // Handle any exceptions thrown by method to be invoked.
2088+ } catch (InvocationTargetException x) {
2089+ Throwable cause = x.getCause();
2090+ System.err.format("invocation of %s failed: %s%n",
2091+ mname, cause.getMessage());
2092+ }
2093+ }
2094+
2095+ // production code should handle these exceptions more gracefully
2096+ } catch (Exception e) {
2097+ System.out.println("Failed");
2098+ System.out.println("Exception caught. " + e.getLocalizedMessage());
2099+ e.printStackTrace();
2100 }
2101- XQItem colName = xqc.createItemFromString("col2", type);
2102- colManager.createCollection(colName);
2103- ZorbaXQCollection collection = colManager.getCollection(colName);
2104- colName.close();
2105- XQSequence data = xmlManager.parseXML("<books><book>Book 1</book><book>Book 2</book></books>");
2106- collection.insertNodesLast(data);
2107- xqc.close();
2108- return true;
2109- }
2110-
2111- public static void main ( String argv[] ) throws XQException
2112- {
2113- boolean res = false;
2114-
2115- System.out.println ("executing test 1" );
2116- res = example_1( );
2117- if ( !res )
2118- System.exit ( 1 );
2119-
2120- System.out.println ( "executing test 2" );
2121- res = example_2 ( );
2122- if (!res)
2123- System.exit ( 1 );
2124-
2125- System.out.println ( "executing test 3a" );
2126- res = example_3a ( );
2127- if (!res)
2128- System.exit ( 1 );
2129-
2130- System.out.println ( "executing test 3b" );
2131- res = example_3b ( );
2132- if (!res)
2133- System.exit ( 1 );
2134-
2135- System.out.println ( "executing test 4" );
2136- res = example_4 ( );
2137- if (!res)
2138- System.exit ( 1 );
2139-
2140- System.out.println ( "executing test 5" );
2141- res = example_5 ( );
2142- if (!res)
2143- System.exit ( 1 );
2144- System.out.println ( "executing test 6a" );
2145- res = example_6a ( );
2146- if (!res)
2147- System.exit ( 1 );
2148-
2149- System.out.println ( "executing test 6b" );
2150- res = example_6b ( );
2151- if (!res)
2152- System.exit ( 1 );
2153- System.out.println ( "done." );
2154-
2155- } // main
2156+ } // main
2157
2158 } // class Test_Zorba
2159-
2160
2161=== added file 'swig/xqj/managers/Tests.java'
2162--- swig/xqj/managers/Tests.java 1970-01-01 00:00:00 +0000
2163+++ swig/xqj/managers/Tests.java 2012-09-08 14:02:23 +0000
2164@@ -0,0 +1,383 @@
2165+/*
2166+ * Copyright 2006-2012 The FLWOR Foundation.
2167+ *
2168+ * Licensed under the Apache License, Version 2.0 (the "License");
2169+ * you may not use this file except in compliance with the License.
2170+ * You may obtain a copy of the License at
2171+ *
2172+ * http://www.apache.org/licenses/LICENSE-2.0
2173+ *
2174+ * Unless required by applicable law or agreed to in writing, software
2175+ * distributed under the License is distributed on an "AS IS" BASIS,
2176+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2177+ * See the License for the specific language governing permissions and
2178+ * limitations under the License.
2179+ */
2180+package api_test;
2181+
2182+
2183+import java.io.*;
2184+import java.net.URI;
2185+import java.net.URISyntaxException;
2186+import java.util.Properties;
2187+import javax.xml.namespace.QName;
2188+import javax.xml.xquery.*;
2189+import org.zorbaxquery.api.*;
2190+import org.zorbaxquery.api.xqj.*;
2191+
2192+public class Tests {
2193+
2194+ static
2195+ {
2196+ System.loadLibrary ( "zorba_api" );
2197+ }
2198+
2199+ static String getFile(String filename) throws FileNotFoundException, IOException {
2200+ File file = new File(filename);
2201+ FileInputStream fileStream = new FileInputStream(file);
2202+ InputStreamReader reader = new InputStreamReader( fileStream, "UTF8" );
2203+ BufferedReader buffer = new BufferedReader( reader );
2204+ String line;
2205+ StringBuilder builder = new StringBuilder();
2206+ while ( (line = buffer.readLine()) != null )
2207+ {
2208+ builder.append(line);
2209+ }
2210+ return builder.toString();
2211+ }
2212+
2213+ static boolean checkResult(String expected, String result) {
2214+ System.out.println("Result:");
2215+ System.out.println(result);
2216+ System.out.println("Expected:");
2217+ System.out.println(expected);
2218+ return expected.equals(result);
2219+ }
2220+
2221+ static boolean test_1() throws XQException
2222+ {
2223+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2224+ XQConnection xqc = xqds.getConnection();
2225+ XQExpression xqe = xqc.createExpression();
2226+ org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery("1,2,3");
2227+ ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
2228+ xqc.close();
2229+ xqc.close();
2230+ return true;
2231+ }
2232+
2233+
2234+ static boolean test_2 () throws XQException
2235+ {
2236+ StringBuilder strBuilder = new StringBuilder();
2237+ try {
2238+ BufferedReader in = new BufferedReader(new FileReader("managers/module1.xq"));
2239+ String str;
2240+ while ((str = in.readLine()) != null) {
2241+ strBuilder.append(str);
2242+ }
2243+ in.close();
2244+ } catch (Exception e) {
2245+ throw new XQException("Error reading file for test: " + e.getLocalizedMessage());
2246+ }
2247+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2248+ XQConnection xqc = xqds.getConnection();
2249+ XQExpression xqe = xqc.createExpression();
2250+ org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery(strBuilder.toString());
2251+ ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
2252+ boolean resultAdding = false;
2253+ boolean resultDeleting = true;
2254+ URI uri;
2255+ QName qname;
2256+ XQItemType type = null;
2257+ try {
2258+ uri = new URI("http://www.mod2.com/");
2259+ qname = new QName("http://www.mod2.com/", "coll");
2260+ type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
2261+ } catch (URISyntaxException e) {
2262+ throw new XQException("Error creating QName: " + e.getLocalizedMessage());
2263+ }
2264+ XQItem colName = xqc.createItemFromString("coll", type);
2265+ colManager.createCollection(colName);
2266+ resultAdding = colManager.isAvailableCollection(colName);
2267+ colManager.deleteCollection(colName);
2268+ resultDeleting = !colManager.isAvailableCollection(colName);
2269+ xqc.close();
2270+ return resultAdding && resultDeleting;
2271+ }
2272+
2273+ static boolean test_3a() throws XQException
2274+ {
2275+ StringBuilder strBuilder = new StringBuilder();
2276+ try {
2277+ BufferedReader in = new BufferedReader(new FileReader("managers/module1.xq"));
2278+ String str;
2279+ while ((str = in.readLine()) != null) {
2280+ strBuilder.append(str);
2281+ }
2282+ in.close();
2283+ } catch (Exception e) {
2284+ throw new XQException("Error reading file for test: " + e.getLocalizedMessage());
2285+ }
2286+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2287+ org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
2288+ XQExpression xqe = xqc.createExpression();
2289+ org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery(strBuilder.toString());
2290+ ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
2291+ URI uri;
2292+ QName qname;
2293+ XQItemType type = null;
2294+ try {
2295+ uri = new URI("http://www.mod2.com/");
2296+ qname = new QName("http://www.mod2.com/", "coll");
2297+ type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
2298+ } catch (URISyntaxException e) {
2299+ throw new XQException("Error creating QName: " + e.getLocalizedMessage());
2300+ }
2301+ XQItem colName = xqc.createItemFromString("coll", type);
2302+ colManager.createCollection(colName);
2303+ ZorbaXQCollection collection = colManager.getCollection(colName);
2304+
2305+ ZorbaXQXmlDataManager manager = xqc.getXmlDataManager();
2306+ XQSequence data = manager.parseXML("<books><book>Book 1</book><book>Book 2</book></books>");
2307+ collection.insertNodesFirst(data);
2308+
2309+ colManager.deleteCollection(colName);
2310+ boolean resultDeleting = !colManager.isAvailableCollection(colName);
2311+ xqc.close();
2312+ return resultDeleting;
2313+ }
2314+
2315+ static boolean test_3b() throws XQException
2316+ {
2317+ StringBuilder strBuilder = new StringBuilder();
2318+ try {
2319+ BufferedReader in = new BufferedReader(new FileReader("managers/module1.xq"));
2320+ String str;
2321+ while ((str = in.readLine()) != null) {
2322+ strBuilder.append(str);
2323+ }
2324+ in.close();
2325+ } catch (Exception e) {
2326+ throw new XQException("Error reading file for test: " + e.getLocalizedMessage());
2327+ }
2328+ InMemoryStore store = InMemoryStore.getInstance();
2329+ Zorba zorba = Zorba.getInstance ( store );
2330+ XQuery query = zorba.compileQuery(strBuilder.toString());
2331+ StaticCollectionManager manager = query.getStaticCollectionManager();
2332+
2333+
2334+ ItemFactory factory = zorba.getItemFactory();
2335+ Item name = factory.createQName("http://www.mod2.com/", "coll");
2336+
2337+ manager.createCollection(name);
2338+ Collection collection = manager.getCollection(name);
2339+
2340+ XmlDataManager xmlManager = zorba.getXmlDataManager();
2341+ Item data = xmlManager.parseXMLtoItem("<books><book>Book 1</book><book>Book 2</book></books>");
2342+ ItemSequence sequence = new ItemSequence(data);
2343+ collection.insertNodesLast(sequence);
2344+
2345+ zorba.shutdown();
2346+ InMemoryStore.shutdown ( store );
2347+
2348+ return true;
2349+ }
2350+
2351+ static boolean test_4() throws XQException
2352+ {
2353+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2354+ org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
2355+ XQExpression xqe = xqc.createExpression();
2356+ ZorbaXQXmlDataManager xmlManager = xqc.getXmlDataManager();
2357+ ZorbaXQCollectionManager colManager = xmlManager.getCollectionManager();
2358+ xqc.close();
2359+ xqc.close();
2360+ return true;
2361+ }
2362+
2363+ static boolean test_5() throws XQException
2364+ {
2365+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2366+ org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
2367+ ZorbaXQXmlDataManager xmlManager = xqc.getXmlDataManager();
2368+ ZorbaXQCollectionManager colManager = xmlManager.getCollectionManager();
2369+ boolean resultAdding = false;
2370+ boolean resultDeleting = true;
2371+ URI uri;
2372+ QName qname;
2373+ XQItemType type = null;
2374+ try {
2375+ uri = new URI("http://www.mod2.com/");
2376+ qname = new QName("http://www.mod2.com/", "col2");
2377+ type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
2378+ } catch (URISyntaxException e) {
2379+ throw new XQException("Error creating QName: " + e.getLocalizedMessage());
2380+ }
2381+ XQItem colName = xqc.createItemFromString("col2", type);
2382+ colManager.createCollection(colName);
2383+ resultAdding = colManager.isAvailableCollection(colName);
2384+ colManager.deleteCollection(colName);
2385+ resultDeleting = !colManager.isAvailableCollection(colName);
2386+ xqc.close();
2387+ return resultAdding && resultDeleting;
2388+ }
2389+ static boolean test_6a() throws XQException
2390+ {
2391+ InMemoryStore store = InMemoryStore.getInstance();
2392+ Zorba zorba = Zorba.getInstance ( store );
2393+ XmlDataManager xmlManager = new XmlDataManager(zorba.getXmlDataManager());
2394+ CollectionManager manager = new CollectionManager(xmlManager.getCollectionManager());
2395+ ItemFactory factory = zorba.getItemFactory();
2396+ Item name = factory.createQName("http://www.zorba-xquery.com/", "aaa");
2397+ manager.createCollection(name);
2398+ boolean resultAdding = manager.isAvailableCollection(name);
2399+ Collection collection = null;
2400+ //Item data = new Item();
2401+ if (resultAdding) {
2402+ collection = manager.getCollection(name);
2403+ Item data = xmlManager.parseXMLtoItem("<books><book>Book 1</book><book>Book 2</book></books>");
2404+ collection.insertNodesLast(new ItemSequence(data));
2405+ }
2406+ collection.delete();
2407+
2408+ zorba.shutdown();
2409+ InMemoryStore.shutdown ( store );
2410+ return true;
2411+ }
2412+
2413+ static boolean test_6b() throws XQException
2414+ {
2415+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2416+ org.zorbaxquery.api.xqj.ZorbaXQConnection xqc = (org.zorbaxquery.api.xqj.ZorbaXQConnection) xqds.getConnection();
2417+ ZorbaXQXmlDataManager xmlManager = xqc.getXmlDataManager();
2418+ ZorbaXQCollectionManager colManager = xmlManager.getCollectionManager();
2419+ URI uri;
2420+ QName qname;
2421+ XQItemType type = null;
2422+ try {
2423+ uri = new URI("http://www.mod2.com/");
2424+ qname = new QName("http://www.mod2.com/", "col2");
2425+ type = xqc.createAtomicType( XQItemType.XQBASETYPE_QNAME, qname, uri);
2426+ } catch (URISyntaxException e) {
2427+ throw new XQException("Error creating QName: " + e.getLocalizedMessage());
2428+ }
2429+ XQItem colName = xqc.createItemFromString("col2", type);
2430+ colManager.createCollection(colName);
2431+ ZorbaXQCollection collection = colManager.getCollection(colName);
2432+ colName.close();
2433+ XQSequence data = xmlManager.parseXML("<books><book>Book 1</book><book>Book 2</book></books>");
2434+ collection.insertNodesLast(data);
2435+ xqc.close();
2436+ return true;
2437+ }
2438+
2439+ static boolean test_7() throws XQException
2440+ {
2441+ InMemoryStore store = InMemoryStore.getInstance();
2442+ Zorba zorba = Zorba.getInstance ( store );
2443+ String test = "Hello world!";
2444+ ZorbaReaderWrapper stream = new ZorbaReaderWrapper(new StringReader("'"+test+"'"));
2445+ XQuery query = zorba.compileQuery(stream);
2446+ SerializationOptions opts = new SerializationOptions();
2447+ opts.setOmitXMLDeclaration(SerializationOptions.OmitXMLDeclaration.ZORBA_API_OMIT_XML_DECLARATION_YES);
2448+ String queryResult = query.execute(opts);
2449+ boolean result = checkResult(test, queryResult);
2450+ zorba.shutdown();
2451+ InMemoryStore.shutdown ( store );
2452+ return result;
2453+ }
2454+
2455+ static boolean test_8() throws XQException, UnsupportedEncodingException
2456+ {
2457+ InMemoryStore store = InMemoryStore.getInstance();
2458+ Zorba zorba = Zorba.getInstance ( store );
2459+ StringBuilder test = new StringBuilder();
2460+ for (int i=0; i<20; i++) {
2461+ test.append("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); // 100 chars
2462+ }
2463+ String queryString = "'" + test.toString() + "'";
2464+ ZorbaInputWrapper stream = new ZorbaInputWrapper(new ByteArrayInputStream(queryString.getBytes("UTF-8")));
2465+ XQuery query = zorba.compileQuery(stream);
2466+ SerializationOptions opts = new SerializationOptions();
2467+ opts.setOmitXMLDeclaration(SerializationOptions.OmitXMLDeclaration.ZORBA_API_OMIT_XML_DECLARATION_YES);
2468+ String queryResult = query.execute(opts);
2469+ boolean result = checkResult(test.toString(), queryResult);
2470+ zorba.shutdown();
2471+ InMemoryStore.shutdown ( store );
2472+ return result;
2473+ }
2474+
2475+ static boolean test_9() throws XQException, UnsupportedEncodingException
2476+ {
2477+ InMemoryStore store = InMemoryStore.getInstance();
2478+ Zorba zorba = Zorba.getInstance ( store );
2479+ String test = "<Hello><ab/><ax/>World</Hello>";
2480+ ZorbaInputWrapper stream = new ZorbaInputWrapper(new ByteArrayInputStream(test.getBytes("UTF-8")));
2481+ SerializationOptions opts = new SerializationOptions();
2482+ opts.setIndent(SerializationOptions.Indent.ZORBA_API_INDENT_NO);
2483+ opts.setOmitXMLDeclaration(SerializationOptions.OmitXMLDeclaration.ZORBA_API_OMIT_XML_DECLARATION_YES);
2484+ XQuery query = zorba.compileQuery(stream);
2485+ String queryResult = query.execute(opts);
2486+ boolean result = checkResult(test, queryResult);
2487+ query.destroy();
2488+ zorba.shutdown();
2489+ InMemoryStore.shutdown ( store );
2490+ return result;
2491+ }
2492+
2493+ static boolean test_10() throws XQException, UnsupportedEncodingException
2494+ {
2495+ InMemoryStore store = InMemoryStore.getInstance();
2496+ Zorba zorba = Zorba.getInstance ( store );
2497+ String test = "<Hello><ab/><ax/>World</Hello>";
2498+ ZorbaInputWrapper stream = new ZorbaInputWrapper(new ByteArrayInputStream(test.getBytes("UTF-8")));
2499+ XQuery query = zorba.compileQuery(stream);
2500+ ByteArrayOutputStream out = new ByteArrayOutputStream();
2501+ ZorbaOutputWrapper OStream = new ZorbaOutputWrapper(out);
2502+ SerializationOptions opts = new SerializationOptions();
2503+ opts.setIndent(SerializationOptions.Indent.ZORBA_API_INDENT_NO);
2504+ opts.setOmitXMLDeclaration(SerializationOptions.OmitXMLDeclaration.ZORBA_API_OMIT_XML_DECLARATION_YES);
2505+ query.execute(OStream, opts);
2506+ boolean result = checkResult(test, out.toString());
2507+ query.destroy();
2508+ zorba.shutdown();
2509+ InMemoryStore.shutdown ( store );
2510+ return result;
2511+ }
2512+
2513+ static boolean test_11a() throws XQException, FileNotFoundException, IOException
2514+ {
2515+ InMemoryStore store = InMemoryStore.getInstance();
2516+ Zorba zorba = Zorba.getInstance ( store );
2517+ String test = getFile("managers/utf.txt");
2518+ org.zorbaxquery.api.ZorbaReaderWrapper stream = new org.zorbaxquery.api.ZorbaReaderWrapper(new StringReader("'"+test+"'"));
2519+ XQuery query = zorba.compileQuery(stream);
2520+ SerializationOptions opts = new SerializationOptions();
2521+ opts.setOmitXMLDeclaration(SerializationOptions.OmitXMLDeclaration.ZORBA_API_OMIT_XML_DECLARATION_YES);
2522+ String queryResult = query.execute(opts);
2523+ boolean result = checkResult(test, queryResult);
2524+ zorba.shutdown();
2525+ InMemoryStore.shutdown ( store );
2526+ return result;
2527+ }
2528+
2529+ static boolean test_11b() throws XQException, FileNotFoundException, IOException
2530+ {
2531+ String test = getFile("managers/utf.txt");
2532+ ZorbaXQDataSource xqds = new ZorbaXQDataSource();
2533+ XQConnection xqc = xqds.getConnection();
2534+ XQExpression xqe = xqc.createExpression();
2535+ org.zorbaxquery.api.xqj.ZorbaXQResultSequence xqs = (org.zorbaxquery.api.xqj.ZorbaXQResultSequence) xqe.executeQuery("'"+test+"'");
2536+ ZorbaXQStaticCollectionManager colManager = xqs.getStaticCollectionManager();
2537+ Properties prpts = new Properties();
2538+ prpts.setProperty("omit-xml-declaration", "yes");
2539+ String queryResult =xqs.getSequenceAsString(prpts);
2540+ boolean result = checkResult(test, queryResult);
2541+ xqc.close();
2542+ xqc.close();
2543+ return result;
2544+ }
2545+
2546+} // class Test_Zorba
2547+
2548
2549=== added file 'swig/xqj/managers/utf.txt'
2550--- swig/xqj/managers/utf.txt 1970-01-01 00:00:00 +0000
2551+++ swig/xqj/managers/utf.txt 2012-09-08 14:02:23 +0000
2552@@ -0,0 +1,1 @@
2553+abcdefghijklmnopqrstuvwxyz ñÑuD407áéíó´súiïöठ学퐇ﺔﺖﺚﻀﺺﮚ
2554\ No newline at end of file
2555
2556=== modified file 'swig/xqj/tck/xqj_test.bat.in'
2557--- swig/xqj/tck/xqj_test.bat.in 2012-08-30 13:45:43 +0000
2558+++ swig/xqj/tck/xqj_test.bat.in 2012-09-08 14:02:23 +0000
2559@@ -18,6 +18,7 @@
2560 SET JAVA_LOAD_PATH=@JAVA_LOAD_PATH@
2561 SET XQJ_LOAD_PATH=@XQJ_LOAD_PATH@
2562 SET PATH=%PATH%;@XQJ_LOAD_PATH@;@JAVA_DLL_PATH@;@ZORBA_SIMPLE_STORE@;
2563+SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
2564
2565 ECHO "xqj_test.bat: Deleting old Java API if found..."
2566 RD /S /Q "%XQJ_LOAD_PATH%\tck\org"
2567@@ -42,7 +43,7 @@
2568 RD /S /Q "%XQJ_LOAD_PATH%\tck\org"
2569
2570 ECHO "xqj_test.bat: Compiling Managers Tests..."
2571-"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -cp tck\xqjapi.jar;tck\zorba_api.jar;tck\zorba_xqj.jar -d managers "managers\Api_test.java"
2572+"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -cp tck\xqjapi.jar;tck\zorba_api.jar;tck\zorba_xqj.jar -d managers "managers\*.java"
2573
2574 ECHO "xqj_test.bat: Executing XQJ TCK ..."
2575 "@Java_JAVA_EXECUTABLE@" -cp tck\xqjapi.jar;tck\xqjtck.jar;tck\junit-4.9.jar;tck\zorba_api.jar;tck\zorba_xqj.jar -Dcom.oracle.xqj.tck.datasource=tck\zorba.properties com.oracle.xqj.tck.AllTests
2576
2577=== modified file 'swig/xqj/tck/xqj_test.sh.in'
2578--- swig/xqj/tck/xqj_test.sh.in 2012-08-30 13:45:43 +0000
2579+++ swig/xqj/tck/xqj_test.sh.in 2012-09-08 14:02:23 +0000
2580@@ -24,6 +24,7 @@
2581 export CLASSPATH="tck:$XQJ_LOAD_PATH"
2582 CURRENT_D=$PWD
2583 cd $XQJ_LOAD_PATH
2584+export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
2585
2586 echo "xqj_test.sh: Deleting old Java API if found..."
2587 if [ -d "$XQJ_LOAD_PATH/tck/org" ]
2588@@ -55,7 +56,7 @@
2589 rm -r "$XQJ_LOAD_PATH/tck/org"
2590
2591 echo "xqj_test.sh: Compiling Managers Tests..."
2592-"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -cp tck/xqjapi.jar:tck/zorba_api.jar:tck/zorba_xqj.jar -d managers "managers/Api_test.java"
2593+"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -cp tck/xqjapi.jar:tck/zorba_api.jar:tck/zorba_xqj.jar -d managers $XQJ_LOAD_PATH/managers/*.java
2594
2595 echo "java_test.sh: Executing XQJ TCK ..."
2596 "@Java_JAVA_EXECUTABLE@" -cp tck/xqjapi.jar:tck/xqjtck.jar:tck/junit-4.9.jar:tck/zorba_api.jar:tck/zorba_xqj.jar -Dcom.oracle.xqj.tck.datasource=tck/zorba.properties com.oracle.xqj.tck.AllTests
2597
2598=== modified file 'swig/zorba_api.i'
2599--- swig/zorba_api.i 2012-08-30 13:45:43 +0000
2600+++ swig/zorba_api.i 2012-09-08 14:02:23 +0000
2601@@ -18,11 +18,14 @@
2602 %module(directors="1") zorba_api
2603
2604
2605-TSRMLS_FETCH();
2606+TSRMLS_FETCH();
2607
2608-%include "std_string.i"
2609+//%include "std_string.i"
2610 %include "std_pair.i"
2611 %include "exception.i"
2612+%include "carrays.i"
2613+%apply (char *STRING, size_t LENGTH) { (const char aStream[], size_t aLen) }
2614+%rename(opEquals) operator=;
2615
2616 #ifndef SWIGRUBY
2617 %include "std_vector.i"
2618@@ -54,6 +57,7 @@
2619
2620 %{ // Implementations
2621
2622+#include "Config.h"
2623
2624 #include <string>
2625 #include <sstream>
2626@@ -86,6 +90,8 @@
2627 class Store;
2628 class InMemoryStore;
2629
2630+ #include "ZorbaIOStream.h"
2631+ #include "ZorbaStreamBuffer.h"
2632 #include "SerializationOptions.h"
2633 #include "TypeIdentifier.h"
2634 #include "Item.h"
2635@@ -114,7 +120,8 @@
2636
2637 /* %include "various.i" required for mapping to Java byte[]*/
2638
2639-//%include "ZorbaStreamProxy.i"
2640+%include "ZorbaIOStream.i"
2641+%include "ZorbaStreamBuffer.i"
2642 %include "SerializationOptions.i"
2643 %include "TypeIdentifier.i"
2644 %include "Item.i"

Subscribers

People subscribed via source and target branches