zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #03409
[Merge] lp:~rodolfo-ochoa/zorba/xqj into lp:zorba
Rodolfo Ochoa has proposed merging lp:~rodolfo-ochoa/zorba/xqj into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Cezar Andrei (cezar-andrei)
For more details, see:
https://code.launchpad.net/~rodolfo-ochoa/zorba/xqj/+merge/87841
XQJ implementation
3 tests are failing because of the bug: https://bugs.launchpad.net/zorba/+bug/905035
The rest of the tests are passing, but Zorba need a more robust implementation on Type definition.
This XQJ implementation needs more work on the DataFactory implementation, it is not implemented any Stream usage, instead, the Streams are converted to Strings and then used by Zorba engine.
--
https://code.launchpad.net/~rodolfo-ochoa/zorba/xqj/+merge/87841
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-01-05 13:20:30 +0000
+++ ChangeLog 2012-01-07 02:13:25 +0000
@@ -19,6 +19,7 @@
* Added split function to the string module that allows for streamable tokenization but doesn't have regular expression
support.
* zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
+ * Added XQJ support.
version 2.1
=== removed file 'NOTICE.txt'
--- NOTICE.txt 2011-10-21 08:09:17 +0000
+++ NOTICE.txt 1970-01-01 00:00:00 +0000
@@ -1,740 +0,0 @@
------------
-Zorba 2.1.0
------------
-
-(Note: This file is generated automatically from NOTICE.xml.
-Please do not modify this file directly.)
-
-
-
-
-Apache 2
-
- Copyright 2006-2011 The FLWOR Foundation
-
- See LICENSE.txt for license information.
-
- ------------------------
- This product includes software developed at
- The FLWOR Foundation (http://www.flworfound.org/).
-
- ------------------------
- Portions of this software were developed at the Systems
- Group of the ETH Zurich, Switzerland.
-
-
-Other files used by this project:
-----------------------------------------------------
-
-src/zorbatypes/m_apm.h
-src/zorbatypes/mapm/
-
-Copyright: 1999-2007 Michael C. Ring
-Website: http://www.tc.umn.edu/~ringx004/mapm-main.html
-
- This software is Freeware.
-
- Permission to use, copy, and distribute this software and its
- documentation for any purpose with or without fee is hereby granted,
- provided that the above copyright notice appear in all copies and
- that both that copyright notice and this permission notice appear
- in supporting documentation.
-
- Permission to modify the software is granted. Permission to distribute
- the modified code is granted. Modifications are to be distributed by
- using the file 'license.txt' as a template to modify the file header.
- 'license.txt' is available in the official MAPM distribution.
-
- To distribute modified source code, insert the file 'license.txt'
- at the top of all modified source code files and edit accordingly.
-
- This software is provided "as is" without express or implied warranty.
-
-----------------------------------------------------
-
-src/zorbamisc/config/stdint.h
-
-Copyright: 2006 Alexander Chemeris
-
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. The name of the author may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-src/zorbautils/stemmer/
-
-Copyright: 2001 Dr. Martin Porter
-
-
- All the software given out on this Snowball site is covered by the BSD
- License (see http://www.opensource.org/licenses/bsd-license.html), with
- Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
- Copyright (c) 2002, Richard Boulton.
-
- Essentially, all this means is that you can do what you like with the code,
- except claim another Copyright for it, or claim that it is issued under a
- different license. The software is also issued without warranties, which
- means that if anyone suffers through its use, they cannot come back and sue
- you. You also have to alert anyone to whom you give the Snowball software to
- the fact that it is covered by the BSD license.
-
- We have not bothered to insert the licensing arrangement into the text of
- the Snowball software.
-
-----------------------------------------------------
-
-src/util/less.h
-
-Copyright: 1998 Paul J. Lucas
-
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- o Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- o Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- o The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-src/util/auto_vector.h (has been modified)
-
-Copyright: 2003 Reliable Software
-
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- o Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- o Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- o The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-cmake_modules/FindBoost.cmake
-
-Copyright:
- 2006-2008 Andreas Schneider <mail@xxxxxxxxxxxx>
- 2007 Wengo
- 2007 Mike Jackson
- 2008 Andreas Pakulat <apaku@xxxxxx>
-
-
-
- Redistribution AND use is allowed according to the terms of the New BSD license.
- For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-----------------------------------------------------
-
-cmake_modules/FindJNI.cmake
-cmake_modules/FindPythonLibs.cmake
-cmake_modules/FindSWIG.cmake
-
-Copyright: 2001-2009 Kitware, Inc.
-
-
- Distributed under the OSI-approved BSD License (the "License");
- see accompanying file Copyright.txt for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License for more information.
-
- CMake - Cross Platform Makefile Generator
- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the names of Kitware, Inc., the Insight Software Consortium,
- nor the names of their contributors may be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- ------------------------------------------------------------------------------
-
- The above copyright and license notice applies to distributions of
- CMake in source and binary form. Some source files contain additional
- notices of original copyright by their contributors; see each source
- for details. Third-party software packages supplied with CMake under
- compatible licenses provide their own copyright notices documented in
- corresponding subdirectories.
-
- ------------------------------------------------------------------------------
-
- CMake was initially developed by Kitware with the following sponsorship:
-
- * National Library of Medicine at the National Institutes of Health
- as part of the Insight Segmentation and Registration Toolkit (ITK).
-
- * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
- Visualization Initiative.
-
- * National Alliance for Medical Image Computing (NAMIC) is funded by the
- National Institutes of Health through the NIH Roadmap for Medical Research,
- Grant U54 EB005149.
-
- * Kitware, Inc.
-
-----------------------------------------------------
-
-/xml.xsd
-
-Copyright: 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
-
-
- All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- W3C Software Notice and License
-
- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
-
- License
-
- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
-
- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
-
- Disclaimers
-
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
-
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
-
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
-
-----------------------------------------------------
-
-schemas/xslt-xquery-serialization.xsd
-
-Copyright: 2010 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
-
-
- All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- W3C Software Notice and License
-
- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
-
- License
-
- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
-
- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
-
- Disclaimers
-
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
-
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
-
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
-
-----------------------------------------------------
-
-modules/w3c/xpath-functions.xsd
-
-Copyright: 2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
-
-
- All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- W3C Software Notice and License
-
- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
-
- License
-
- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
-
- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
-
- Disclaimers
-
- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
-
- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
-
- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
-
-----------------------------------------------------
-
-include/xqc.h
-
-Copyright: 2008, Matthias Brantner, John Snelson
-
-
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the developers nor the names of contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-modules/functx/functx.xq
-
-Copyright: 2007 Datypic
-
-
- : This library is free software; you can redistribute it and/or
- : modify it under the terms of the GNU Lesser General Public
- : License as published by the Free Software Foundation; either
- : version 2.1 of the License.
-
- : This library is distributed in the hope that it will be useful,
- : but WITHOUT ANY WARRANTY; without even the implied warranty of
- : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- : Lesser General Public License for more details.
-
- : You should have received a copy of the GNU Lesser General Public
- : License along with this library; if not, write to the Free Software
- : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-----------------------------------------------------
-
-src/compiler/parser/FlexLexer.h
-
-Copyright: 1993 The Regents of the University of California
-
-
- // All rights reserved.
- //
- // This code is derived from software contributed to Berkeley by
- // Kent Williams and Tom Epperly.
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions
- // are met:
-
- // 1. Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- // 2. Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the distribution.
-
- // Neither the name of the University nor the names of its contributors
- // may be used to endorse or promote products derived from this software
- // without specific prior written permission.
-
- // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- // PURPOSE.
-
-----------------------------------------------------
-
-src/diagnostics/StackWalker.cpp
-src/diagnostics/StackWalker.h
-
-Copyright: 2005 Jochen Kalmbach
-
-
- Under BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-----------------------------------------------------
-
-src/util/singleton.h
-src/util/threads.h
-
-Copyright: 2001 Andrei Alexandrescu
-
-
- This code accompanies the book:
- Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
- Patterns Applied". Copyright (c) 2001. Addison-Wesley.
- Permission to use, copy, modify, distribute and sell this software for any
- purpose is hereby granted without fee, provided that the above copyright
- notice appear in all copies and that both that copyright notice and this
- permission notice appear in supporting documentation.
- The author or Addison-Wesley Longman make no representations about the
- suitability of this software for any purpose. It is provided "as is"
- without express or implied warranty.
-
-
-External libraries used by this project:
-----------------------------------------------------
-
-Name: LIBXML2
-Preferred version: 2.2.16 or higher
-Is mandatory: true
-Website: http://xmlsoft.org/
-License: MIT
-Copyright: 1998-2002 Daniel Veillard. All Rights Reserved.
-External notice:
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name of Daniel Veillard shall not
- be used in advertising or otherwise to promote the sale, use or other deal-
- ings in this Software without prior written authorization from him.
-
-----------------------------------------------------
-
-Name: LIBXSLT
-Preferred version: 1.1.26
-Is mandatory: false
-Website: http://xmlsoft.org/XSLT/
-License: MIT
-Copyright: 2001-2002 Daniel Veillard. All Rights Reserved.
-External notice:
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
- Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from him.
-
-
-----------------------------------------------------
-
-Name: ICU4C
-Preferred version: 3.6 or higher
-Is mandatory: true
-Website: http://www.icu-project.org/
-License: ICU License
-Copyright: 1995-2011 International Business Machines Corporation and others
-External notice:
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
-
-----------------------------------------------------
-
-Name: CURL
-Preferred version: above 7.12
-Is mandatory: false
-Website: http://curl.haxx.se/
-License: MIT/X derivate license
-Copyright: 1996 - 2011, Daniel Stenberg, <daniel@xxxxxxx>.
-External notice:
-
- All rights reserved.
-
- Permission to use, copy, modify, and distribute this software for any purpose
- with or without fee is hereby granted, provided that the above copyright
- notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
- NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
- OR OTHER DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name of a copyright holder shall not
- be used in advertising or otherwise to promote the sale, use or other dealings
- in this Software without prior written authorization of the copyright holder.
-
-----------------------------------------------------
-
-Name: ICONV
-Preferred version: above 1.12
-Is mandatory: true
-Website: http://www.gnu.org/software/libiconv/
-License: LGPL
-Copyright: 1998, 2010 Free Software Foundation, Inc.
-External notice:
-
-----------------------------------------------------
-
-Name: ZLIB
-Preferred version: 1.2.5
-Is mandatory: true
-Website: http://www.zlib.net/
-Copyright: 1995-2004 Jean-loup Gailly and Mark Adler
-External notice:
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly jloup@xxxxxxxx
- Mark Adler madler@xxxxxxxxxxxxxxxxxx
-
-----------------------------------------------------
-
-Name: XERCES
-Preferred version: 2.8.0 or higher
-Is mandatory: true
-Website: http://xerces.apache.org/xerces-c/
-License: Apache 2
-Copyright: Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.
-External notice:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-----------------------------------------------------
-
-Name: BOOST (boost_filesystem)
-Preferred version: 1.32 or higher
-Is mandatory: false
-Website: http://www.boost.org/
-License: Boost Software License v1.0
-Copyright:
- Beman Dawes, David Abrahams, 1998-2005.
- Rene Rivera 2004-2007
-
-External notice:
-
- Permission is hereby granted, free of charge, to any person or organization
- obtaining a copy of the software and accompanying documentation covered by
- this license (the "Software") to use, reproduce, display, distribute,
- execute, and transmit the Software, and to prepare derivative works of the
- Software, and to permit third-parties to whom the Software is furnished to
- do so, all subject to the following:
-
- The copyright notices in the Software and this entire statement, including
- the above license grant, this restriction and the following disclaimer,
- must be included in all copies of the Software, in whole or in part, and
- all derivative works of the Software, unless such copies or derivative
- works are solely in the form of machine-executable object code generated by
- a source language processor.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
-
-External applications used by this project:
-----------------------------------------------------
-
-Name: FLEX
-Preferred version: 2.5.33
-Is mandatory: false
-Website: http://flex.sourceforge.net/
-Copyright:
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The Flex Project.
- 1990, 1997 The Regents of the University of California. All rights reserved.
-
-External notice:
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
- Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-----------------------------------------------------
-
-Name: BISON
-Preferred version: 2.4 or higher
-Is mandatory: false
-Website: http://www.gnu.org/software/bison/
-License: GPL
-Copyright: 1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-External notice:
-
-----------------------------------------------------
-
-Name: DOXYGEN
-Preferred version: v1.7.4
-Is mandatory: false
-Website: www.doxygen.org
-License: GPL
-Copyright: 1997-2011 by Dimitri van Heesch
-External notice:
-
- Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
- No representations are made about the suitability of this software for any purpose.
- It is provided "as is" without express or implied warranty.
- See the GNU General Public License for more details.
-
- Documents produced by doxygen are derivative works derived from the input used in their production; they are not affected by this license.
-
-----------------------------------------------------
-
-Name: CMAKE
-Preferred version: 2.8.4
-Is mandatory: true
-Website: http://www.cmake.org/
-License: Creative Commons Attribution-NoDerivs 3.0 Unported License
-Copyright: 2000-2009 Kitware, Inc., Insight Software Consortium. All rights reserved.
-External notice:
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
- Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------
-
-Name: SWIG
-Preferred version: 2.0.4 or above
-Is mandatory: false
-Website: http://www.swig.org/
-License: GPL
-Copyright:
- 1995-2011 The SWIG Developers
- 2005-2006 Arizona Board of Regents (University of Arizona).
- 1998-2005 University of Chicago.
- 1995-1998 The University of Utah and the Regents of the University of California
-
-External notice:
-
- SWIG is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. See the LICENSE-GPL file for
- the full terms of the GNU General Public license version 3.
-
- Portions of SWIG are also licensed under the terms of the licenses
- in the file LICENSE-UNIVERSITIES. You must observe the terms of
- these licenses, as well as the terms of the GNU General Public License,
- when you distribute SWIG.
-
- The SWIG library and examples, under the Lib and Examples top level
- directories, are distributed under the following terms:
-
- You may copy, modify, distribute, and make derivative works based on
- this software, in source code or object code form, without
- restriction. If you distribute the software to others, you may do
- so according to the terms of your choice. This software is offered as
- is, without warranty of any kind.
-
- See the COPYRIGHT file for a list of contributors to SWIG and their
- copyright notices.
-
\ No newline at end of file
=== modified file 'doc/CMakeLists.txt'
--- doc/CMakeLists.txt 2011-08-26 22:46:24 +0000
+++ doc/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -40,6 +40,7 @@
IF (SWIG_FOUND)
ADD_SUBDIRECTORY(java)
+ ADD_SUBDIRECTORY(xqj)
ADD_SUBDIRECTORY(python)
ADD_SUBDIRECTORY(ruby)
ADD_SUBDIRECTORY(php)
=== modified file 'doc/java/examples/java_test.bat.in'
--- doc/java/examples/java_test.bat.in 2011-08-05 02:21:55 +0000
+++ doc/java/examples/java_test.bat.in 2012-01-07 02:13:25 +0000
@@ -15,7 +15,7 @@
:: limitations under the License.
::
-SET JAVA_LOAD_PATH=@Java_Load_Path@/@CMAKE_BUILD_TYPE@
+SET JAVA_LOAD_PATH=@Java_Load_Path@
SET PATH=%PATH%;%JAVA_LOAD_PATH%
MKDIR build
=== added directory 'doc/xqj'
=== added file 'doc/xqj/CMakeLists.txt'
--- doc/xqj/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ doc/xqj/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -0,0 +1,35 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ZORBA_DOXYGEN ("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "xqjdocs")
+
+IF (DOXYGEN_FOUND)
+ ADD_DEPENDENCIES (doc "xqjdocs")
+
+ CONFIGURE_FILE (
+ ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_b.gif
+ ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_b.gif
+ COPYONLY
+ )
+ CONFIGURE_FILE (
+ ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_r.gif
+ ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_r.gif
+ COPYONLY
+ )
+ CONFIGURE_FILE (
+ ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_l.gif
+ ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_l.gif
+ COPYONLY
+ )
+ENDIF (DOXYGEN_FOUND)
=== added file 'doc/xqj/doxy.config.in'
--- doc/xqj/doxy.config.in 1970-01-01 00:00:00 +0000
+++ doc/xqj/doxy.config.in 2012-01-07 02:13:25 +0000
@@ -0,0 +1,1207 @@
+# Doxyfile 1.4.5
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = Zorba XQJ-API
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = @ZORBA_MAJOR_NUMBER@.@ZORBA_MINOR_NUMBER@.@ZORBA_PATCH_NUMBER@
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish,
+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese,
+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish,
+# Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/src
+
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@/include @CMAKE_BINARY_DIR@/include
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like the Qt-style comments (thus requiring an
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF = YES
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 2
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for Java.
+# For instance, namespaces will be presented as packages, qualified scopes
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
+# include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+# BUILTIN_STL_SUPPORT = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = YES
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = YES
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is YES.
+
+SHOW_DIRECTORIES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from the
+# version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = @DOXY_WARN_FORMAT@
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE = Doc/doxy.log
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = @CMAKE_CURRENT_SOURCE_DIR@/manual
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+
+FILE_PATTERNS = *.java *.dox
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS = */.svn \
+ */.svn/*
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH = @CMAKE_CURRENT_BINARY_DIR@/examples
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS = *.java
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = YES
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@
+
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 2
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+HTML_HEADER = @CMAKE_CURRENT_SOURCE_DIR@/../style/header.html
+
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/../style/footer.html
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/../style/stylesheet.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+#LATEX_CMD_NAME = latex
+LATEX_CMD_NAME = @LATEX_COMPILER@
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+#MAKEINDEX_CMD_NAME = makeindex
+MAKEINDEX_CMD_NAME = @MAKEINDEX_COMPILER@
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = YES
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = YES
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE = html/@PROJECT_NAME@.TAGFILE
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = YES
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = @DOXYGEN_DOT_FOUND@
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+# UML_LOOK = YES
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a call dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH = @DOXYGEN_DOT_EXECUTABLE_PATH@
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, which results in a white background.
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+# JW
+# DOT_MULTI_TARGETS = NO
+DOT_MULTI_TARGETS = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+# JW SEARCHENGINE = NO
+SEARCHENGINE = YES
=== added directory 'doc/xqj/manual'
=== added file 'doc/xqj/manual/indexpage.dox'
--- doc/xqj/manual/indexpage.dox 1970-01-01 00:00:00 +0000
+++ doc/xqj/manual/indexpage.dox 2012-01-07 02:13:25 +0000
@@ -0,0 +1,18 @@
+/*! \mainpage XQJ API Documentation
+
+ Zorba ships with a XQJ binding that provides basic features in order to prepare and execute queries
+ with Zorba.
+
+ For the moment, we provide a <a class="en" href="examples.html">TCK set</a> that show how this language binding can be used.
+
+ \section note Note for garbage collected languages
+ Zorba requires that objects must be deleted in a certain order, which Garbage Collectors are not aware of. For that reason,
+ the Iterators created with XQuery.iterator() must be explicitly deleted with iterator.delete() before the XQuery
+ object is deleted.
+
+
+ \example Test_Zorba.java
+ This is a simple example that demonstrate how to use the Zorba XQuery Engine to
+ create, compile, and execute queries.
+ */
+
=== modified file 'src/functions/func_serialize_impl.cpp'
--- src/functions/func_serialize_impl.cpp 2012-01-03 12:10:06 +0000
+++ src/functions/func_serialize_impl.cpp 2012-01-07 02:13:25 +0000
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "stdafx.h"
#include "functions/function.h"
#include "functions/func_parsing_and_serializing.h"
=== modified file 'swig/CMakeLists.txt'
--- swig/CMakeLists.txt 2011-12-21 14:40:33 +0000
+++ swig/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -36,6 +36,7 @@
ADD_SUBDIRECTORY (python)
ADD_SUBDIRECTORY (php)
ADD_SUBDIRECTORY (java)
+ ADD_SUBDIRECTORY (xqj)
IF (APPLE AND UNIVERSAL)
MESSAGE (STATUS "Ruby module can't be built Universal")
=== added file 'swig/DynamicContext.h'
--- swig/DynamicContext.h 1970-01-01 00:00:00 +0000
+++ swig/DynamicContext.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef API_DYNAMIC_CONTEXT_H
+#define API_DYNAMIC_CONTEXT_H
+
+class DynamicContext
+{
+private:
+ zorba::DynamicContext* theContext;
+public:
+
+ DynamicContext():theContext(0) {}
+ DynamicContext(const DynamicContext& aCtx):theContext(aCtx.theContext) {}
+ DynamicContext(zorba::DynamicContext* aCtx):theContext(aCtx) {}
+
+ bool getContextItem (Item& aItem);
+ Item getCurrentDateTime ();
+ Item getDefaultCollection ();
+ int getImplicitTimezone ();
+ bool getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator);
+
+ bool setContextItem (Item& aItem);
+ bool setCurrentDateTime (Item& aDateTimeItem);
+ bool setDefaultCollection (Item& aCollectionUri);
+ bool setImplicitTimezone (int aTimezone);
+ bool setVariable (const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter);
+ bool setVariable (const std::string& aQName, Item& aItem);
+ bool setVariable (const std::string& aQName, Iterator& aIterator);
+
+};
+
+#endif
\ No newline at end of file
=== added file 'swig/DynamicContext.i'
--- swig/DynamicContext.i 1970-01-01 00:00:00 +0000
+++ swig/DynamicContext.i 2012-01-07 02:13:25 +0000
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+%{ // start Implementation
+
+ bool DynamicContext::getContextItem (Item& aItem) {
+ return theContext->getContextItem(aItem.theItem);
+ }
+ Item DynamicContext::getCurrentDateTime (){
+ return Item(theContext->getCurrentDateTime());
+ }
+ Item DynamicContext::getDefaultCollection () {
+ return Item(theContext->getDefaultCollection());
+ }
+ int DynamicContext::getImplicitTimezone (){
+ return theContext->getImplicitTimezone();
+ }
+ bool DynamicContext::getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator) {
+ return theContext->getVariable(aNamespace, aLocalname, aItem.theItem, aIterator.theIterator);
+ }
+
+ bool DynamicContext::setContextItem (Item& aItem) {
+ return theContext->setContextItem(aItem.theItem);
+ }
+ bool DynamicContext::setCurrentDateTime (Item& aDateTimeItem) {
+ return theContext->setCurrentDateTime(aDateTimeItem.theItem);
+ }
+ bool DynamicContext::setDefaultCollection (Item& aCollectionUri) {
+ return theContext->setDefaultCollection(aCollectionUri.theItem);
+ }
+ bool DynamicContext::setImplicitTimezone (int aTimezone) {
+ return theContext->setImplicitTimezone(aTimezone);
+ }
+ bool DynamicContext::setVariable(const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter) {
+ return theContext->setVariable(aNamespace, aLocalname, aIter.theIterator);
+ }
+ bool DynamicContext::setVariable (const std::string& aQName, Item& aItem) {
+ return theContext->setVariable (aQName, aItem.theItem);
+ }
+ bool DynamicContext::setVariable (const std::string& aQName, Iterator& aIterator) {
+ return theContext->setVariable (aQName, aIterator.theIterator);
+ }
+
+%} // end Implementation
+
+%include "DynamicContext.h"
=== added file 'swig/Item.h'
--- swig/Item.h 1970-01-01 00:00:00 +0000
+++ swig/Item.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef API_ITEM_H
+#define API_ITEM_H
+
+class Item
+{
+ friend class Iterator;
+ friend class StaticContext;
+ friend class DocumentManager;
+ friend class SingletonIterator;
+ friend class DynamicContext;
+ friend class ItemFactory;
+private:
+ zorba::Item theItem;
+
+public:
+ Item() {}
+ Item(const Item& aItem) : theItem(aItem.theItem) {}
+ Item(const zorba::Item& aZItem) : theItem(aZItem) {}
+
+ static Item createEmptyItem();
+ std::string getStringValue() const;
+ std::string serialize() const;
+ Iterator getAtomizationValue () const;
+ Iterator getAttributes () const;
+ bool getBooleanValue () const;
+ Iterator getChildren () const;
+ Item getEBV () const;
+ int getIntValue () const;
+ double getDoubleValue () const;
+ long long getLongValue () const;
+ std::string getLocalName () const;
+ std::string getNamespace () const;
+ bool getNodeName (Item &aNodeName) const;
+ Item getParent () const;
+ std::string getPrefix () const;
+ Item getType () const;
+ unsigned int getUnsignedIntValue () const;
+
+ int getNodeKind() const;
+ bool isAtomic () const;
+ bool isNaN () const;
+ bool isNode () const;
+ bool isNull () const;
+ bool isPosOrNegInf () const;
+
+ void close();
+}; // class Item
+
+#endif
=== added file 'swig/Item.i'
--- swig/Item.i 1970-01-01 00:00:00 +0000
+++ swig/Item.i 2012-01-07 02:13:25 +0000
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+%{ // start Implementation
+
+ Item Item::createEmptyItem()
+ { return Item(); }
+
+ std::string Item::getStringValue() const
+ { return std::string(theItem.getStringValue().c_str()); }
+
+ std::string Item::serialize() const
+ {
+ std::stringstream lStream;
+ Zorba_SerializerOptions_t lOptions;
+ lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
+ lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XML;
+ lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_NO;
+ //lOptions.standalone = ZORBA_STANDALONE_YES;
+ lOptions.encoding = ZORBA_ENCODING_UTF8;
+ zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
+ zorba::SingletonItemSequence lSequence(theItem);
+ lSerializer->serialize(&lSequence, lStream);
+ return lStream.str();
+ }
+
+ Iterator Item::getAtomizationValue () const
+ { return Iterator(theItem.getAtomizationValue()); }
+
+ Iterator Item::getAttributes () const
+ { return Iterator(theItem.getAttributes()); }
+
+ bool Item::getBooleanValue () const
+ { return theItem.getBooleanValue(); }
+
+ Iterator Item::getChildren () const
+ { return Iterator(theItem.getChildren()); }
+
+ Item Item::getEBV () const
+ { return Item(theItem.getEBV()); }
+
+ int Item::getIntValue () const
+ { return theItem.getIntValue(); }
+
+ double Item::getDoubleValue () const
+ { return theItem.getDoubleValue(); }
+
+ long long Item::getLongValue () const
+ { return theItem.getLongValue(); }
+
+ std::string Item::getLocalName () const
+ { return std::string(theItem.getLocalName().c_str()); }
+
+ std::string Item::getNamespace () const
+ { return std::string(theItem.getNamespace().c_str()); }
+
+ bool Item::getNodeName (Item &aNodeName) const
+ { return theItem.getNodeName( aNodeName.theItem ); }
+
+ Item Item::getParent () const
+ { return theItem.getParent(); }
+
+ std::string Item::getPrefix () const
+ { return std::string(theItem.getPrefix().c_str()); }
+
+ Item Item::getType () const
+ { return Item( theItem.getType() ); }
+
+ unsigned int Item::getUnsignedIntValue () const
+ { return theItem.getUnsignedIntValue(); }
+
+ bool Item::isAtomic () const
+ { return theItem.isAtomic(); }
+
+ bool Item::isNaN () const
+ { return theItem.isNaN(); }
+
+ bool Item::isNode () const
+ { return theItem.isNode(); }
+
+ bool Item::isNull () const
+ { return theItem.isNull(); }
+
+ bool Item::isPosOrNegInf () const
+ { return theItem.isPosOrNegInf(); }
+
+ int Item::getNodeKind () const
+ { return theItem.getNodeKind(); }
+
+ void Item::close()
+ { theItem.close(); }
+
+%} // end Implementation
+
+
+%include "Item.h"
=== added file 'swig/ItemFactory.h'
--- swig/ItemFactory.h 1970-01-01 00:00:00 +0000
+++ swig/ItemFactory.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef API_ITEM_FACTORY_H
+#define API_ITEM_FACTORY_H
+
+class ItemFactory
+{
+
+ private:
+ zorba::ItemFactory* theItemFactory;
+ public:
+ ItemFactory(): theItemFactory(0) {}
+ ItemFactory(zorba::ItemFactory* aItemFactory) : theItemFactory(aItemFactory) {}
+ ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {}
+
+ Item createAnyURI (const std::string &aURI);
+ Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue);
+#ifndef SWIGRUBY
+ Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue);
+#endif
+ Item createBase64Binary (const char *aBinData, size_t aLength);
+ Item createBase64Binary (std::istream &aStream);
+ Item createBase64Binary (const unsigned char *aBinData, size_t aLength);
+ Item createBoolean (bool aValue);
+ Item createByte (char aByte);
+ Item createCommentNode (Item &aParent, const std::string &aContent);
+ Item createDate (const std::string &aDate);
+ Item createDate (short aYear, short aMonth, short aDay);
+ Item createDateTime (const std::string &aDateTimeValue);
+ Item createDateTime (short aYear, short aMonth, short aDay, short aHour, short aMinute, double aSecond, short aTimeZone_hours);
+ Item createDecimal (const std::string &aValue);
+ Item createDecimalFromDouble (double aValue);
+ Item createDecimalFromLong (unsigned long aValue);
+ Item createDouble (const std::string &aValue);
+ Item createDouble (double aValue);
+ Item createDuration (const std::string &aValue);
+ Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds);
+ Item createDayTimeDuration (const std::string &aValue);
+ Item createYearMonthDuration (const std::string &aValue);
+ Item createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri);
+#ifndef SWIGRUBY
+ Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings);
+#endif
+ Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue);
+ Item createFloat (const std::string &aValue);
+ Item createFloat (float aValue);
+ Item createGDay (const std::string &aValue);
+ Item createGDay (short aDay);
+ Item createGMonth (const std::string &aValue);
+ Item createGMonth (short aMonth);
+ Item createGMonthDay (const std::string &aValue);
+ Item createGMonthDay (short aMonth, short aDay);
+ Item createGYear (short aYear);
+ Item createGYear (const std::string &aValue);
+ Item createGYearMonth (const std::string &aValue);
+ Item createGYearMonth (short aYear, short aMonth);
+ Item createHexBinary (const char *aHexData, size_t aSize);
+ Item createInt (int aInt);
+ Item createInteger (const std::string &aInteger);
+ Item createInteger (long long aInteger);
+ Item createLong (long long aLong);
+ Item createNCName (const std::string &aValue);
+ Item createNegativeInteger (long long aValue);
+ Item createNonNegativeInteger (unsigned long long aValue);
+ Item createNonPositiveInteger (long long aValue);
+ Item createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri);
+ Item createPositiveInteger (unsigned long long aValue);
+ Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname);
+ Item createQName (const std::string &aNamespace, const std::string &aLocalname);
+ Item createQName (const std::string &aQNameString);
+ Item createShort (short aShort);
+ //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false);
+ Item createString (const std::string &aString);
+ Item createTextNode (Item &aParent, const std::string &aContent);
+ Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours);
+ Item createTime (short aHour, short aMinute, double aSecond);
+ Item createTime (const std::string &aValue);
+ Item createUnsignedByte (const unsigned char aValue);
+ Item createUnsignedInt (unsigned int aValue);
+ Item createUnsignedLong (unsigned long long aValue);
+ Item createUnsignedShort (unsigned short aValue);
+}; // class ItemFactory
+
+#endif
\ No newline at end of file
=== removed file 'swig/ItemFactory.h'
--- swig/ItemFactory.h 2011-10-27 18:01:22 +0000
+++ swig/ItemFactory.h 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-// Interface
-
-class ItemFactory
-{
-
- private:
- zorba::ItemFactory* theItemFactory;
- public:
- ItemFactory(): theItemFactory(0) {}
- ItemFactory(zorba::ItemFactory* aItemFactory) : theItemFactory(aItemFactory) {}
- ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {}
-
- Item createAnyURI (const std::string &aURI);
- Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue);
- Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue);
- Item createBase64Binary (const char *aBinData, size_t aLength);
- Item createBase64Binary (std::istream &aStream);
- Item createBase64Binary (const unsigned char *aBinData, size_t aLength);
- Item createBoolean (bool aValue);
- Item createByte (char aByte);
- Item createDate (const std::string &aDate);
- Item createDate (short aYear, short aMonth, short aDay);
- Item createDateTime (const std::string &aDateTimeValue);
- Item createDateTime (short aYear, short aMonth, short aDay, short aHour, short aMinute, double aSecond, short aTimeZone_hours);
- Item createDecimal (const std::string &aValue);
- Item createDecimalFromDouble (double aValue);
- Item createDecimalFromLong (unsigned long aValue);
- Item createDouble (const std::string &aValue);
- Item createDouble (double aValue);
- Item createDuration (const std::string &aValue);
- Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds);
- //Item createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings);
- Item createFloat (const std::string &aValue);
- Item createFloat (float aValue);
- Item createGDay (const std::string &aValue);
- Item createGDay (short aDay);
- Item createGMonth (const std::string &aValue);
- Item createGMonth (short aMonth);
- Item createGMonthDay (const std::string &aValue);
- Item createGMonthDay (short aMonth, short aDay);
- Item createGYear (short aYear);
- Item createGYear (const std::string &aValue);
- Item createGYearMonth (const std::string &aValue);
- Item createGYearMonth (short aYear, short aMonth);
- Item createHexBinary (const char *aHexData, size_t aSize);
- Item createInt (int aInt);
- Item createInteger (const std::string &aInteger);
- Item createInteger (long long aInteger);
- Item createLong (long long aLong);
- Item createNCName (const std::string &aValue);
- Item createNegativeInteger (long long aValue);
- Item createNonNegativeInteger (unsigned long long aValue);
- Item createNonPositiveInteger (long long aValue);
- Item createPositiveInteger (unsigned long long aValue);
- Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname);
- Item createQName (const std::string &aNamespace, const std::string &aLocalname);
- Item createQName (const std::string &aQNameString);
- Item createShort (short aShort);
- //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false);
- Item createString (const std::string &aString);
- Item createTextNode (Item parent, std::string content);
- Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours);
- Item createTime (short aHour, short aMinute, double aSecond);
- Item createTime (const std::string &aValue);
- Item createUnsignedByte (const unsigned char aValue);
- Item createUnsignedInt (unsigned int aValue);
- Item createUnsignedLong (unsigned long long aValue);
- Item createUnsignedShort (unsigned short aValue);
-}; // class ItemFactory
=== added file 'swig/ItemFactory.i'
--- swig/ItemFactory.i 1970-01-01 00:00:00 +0000
+++ swig/ItemFactory.i 2012-01-07 02:13:25 +0000
@@ -0,0 +1,226 @@
+
+%{ // start Implementation3
+
+
+
+ Item ItemFactory::createAnyURI (const std::string &aURI){
+ return Item(theItemFactory->createAnyURI(aURI));
+ }
+
+ Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue){
+ return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem ));
+ }
+
+#ifndef SWIGRUBY
+ Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue){
+
+ std::vector< zorba::Item > typedValue;
+ typedValue.reserve(aTypedValue.size());
+ std::vector< Item >::iterator iter;
+ for(iter = aTypedValue.begin(); iter != aTypedValue.end(); iter++) {
+ typedValue.push_back((*iter).theItem);
+ }
+ return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue ));
+ }
+#endif
+
+ Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){
+ return Item( theItemFactory->createBase64Binary(aBinData, aLength));
+ }
+ Item ItemFactory::createBase64Binary (std::istream &aStream){
+ return Item( theItemFactory->createBase64Binary(aStream));
+ }
+ Item ItemFactory::createBase64Binary (const unsigned char *aBinData, size_t aLength){
+ return Item( theItemFactory->createBase64Binary(aBinData, aLength));
+ }
+ Item ItemFactory::createBoolean (bool aValue){
+ return Item( theItemFactory->createBoolean(aValue));
+ }
+ Item ItemFactory::createByte (char aByte){
+ return Item( theItemFactory->createByte(aByte));
+ }
+ Item ItemFactory::createCommentNode (Item &aParent, const std::string &aContent){
+ zorba::String lContent = zorba::String(aContent);
+ return Item( theItemFactory->createCommentNode (aParent.theItem, lContent));
+ }
+ Item ItemFactory::createDate (const std::string &aDate){
+ return Item( theItemFactory->createDate(aDate));
+ }
+ Item ItemFactory::createDate (short aYear, short aMonth, short aDay){
+ return Item( theItemFactory->createDate (aYear, aMonth, aDay));
+ }
+ Item ItemFactory::createDateTime (const std::string &aDateTimeValue){
+ return Item( theItemFactory->createDateTime (aDateTimeValue));
+ }
+ Item ItemFactory::createDateTime (short aYear, short aMonth, short aDay, short aHour, short aMinute, double aSecond, short aTimeZone_hours){
+ return Item( theItemFactory->createDateTime (aYear, aMonth, aDay, aHour, aMinute, aSecond, aTimeZone_hours));
+ }
+ Item ItemFactory::createDecimal (const std::string &aValue){
+ return Item( theItemFactory->createDecimal (aValue));
+ }
+ Item ItemFactory::createDecimalFromDouble (double aValue){
+ return Item( theItemFactory->createDecimalFromDouble (aValue));
+ }
+ Item ItemFactory::createDecimalFromLong (unsigned long aValue){
+ return Item( theItemFactory->createDecimalFromLong (aValue));
+ }
+ Item ItemFactory::createDouble (const std::string &aValue){
+ return Item( theItemFactory->createDouble (aValue));
+ }
+ Item ItemFactory::createDouble (double aValue){
+ return Item( theItemFactory->createDouble (aValue));
+ }
+ Item ItemFactory::createDuration (const std::string &aValue){
+ return Item( theItemFactory->createDuration (aValue));
+ }
+ Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){
+ return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds));
+ }
+ Item ItemFactory::createDayTimeDuration (const std::string &aValue){
+ return Item( theItemFactory->createDayTimeDuration (aValue));
+ }
+ Item ItemFactory::createYearMonthDuration (const std::string &aValue){
+ return Item( theItemFactory->createYearMonthDuration (aValue));
+ }
+ Item ItemFactory::createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri){
+ return Item( theItemFactory->createDocumentNode (aBaseUri, aDocUri));
+ }
+#ifndef SWIGRUBY
+ Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){
+ std::vector< std::pair< zorba::String, zorba::String > > items;
+ items.reserve(aNsBindings.size());
+ std::vector< std::pair< std::string, std::string > >::iterator iter;
+ for(iter = aNsBindings.begin(); iter != aNsBindings.end(); iter++) {
+ std::pair< zorba::String, zorba::String > pair;
+ pair.first = (*iter).first;
+ pair.second = (*iter).second;
+ items.push_back(pair);
+ }
+ return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, items));
+ }
+#endif
+ Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue){
+ return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, std::vector<std::pair<zorba::String, zorba::String> >()));
+ }
+ Item ItemFactory::createFloat (const std::string &aValue){
+ return Item( theItemFactory->createFloat (aValue));
+ }
+ Item ItemFactory::createFloat (float aValue){
+ return Item( theItemFactory->createFloat (aValue));
+ }
+ Item ItemFactory::createGDay (const std::string &aValue){
+ return Item( theItemFactory->createGDay (aValue));
+ }
+ Item ItemFactory::createGDay (short aDay){
+ return Item( theItemFactory->createGDay (aDay));
+ }
+ Item ItemFactory::createGMonth (const std::string &aValue){
+ return Item( theItemFactory->createGMonth (aValue));
+ }
+ Item ItemFactory::createGMonth (short aMonth){
+ return Item( theItemFactory->createGMonth (aMonth));
+ }
+ Item ItemFactory::createGMonthDay (const std::string &aValue){
+ return Item( theItemFactory->createGMonthDay (aValue));
+ }
+ Item ItemFactory::createGMonthDay (short aMonth, short aDay){
+ return Item( theItemFactory->createGMonthDay (aMonth, aDay));
+ }
+ Item ItemFactory::createGYear (short aYear){
+ return Item( theItemFactory->createGYear (aYear));
+ }
+ Item ItemFactory::createGYear (const std::string &aValue){
+ return Item( theItemFactory->createGYear (aValue));
+ }
+ Item ItemFactory::createGYearMonth (const std::string &aValue){
+ return Item( theItemFactory->createGYearMonth (aValue));
+ }
+ Item ItemFactory::createGYearMonth (short aYear, short aMonth){
+ return Item( theItemFactory->createGYearMonth (aYear, aMonth));
+ }
+ Item ItemFactory::createHexBinary (const char *aHexData, size_t aSize){
+ return Item( theItemFactory->createHexBinary (aHexData, aSize));
+ }
+ Item ItemFactory::createInt (int aInt){
+ return Item( theItemFactory->createInt (aInt));
+ }
+ Item ItemFactory::createInteger (const std::string &aInteger){
+ return Item( theItemFactory->createInteger (aInteger));
+ }
+ Item ItemFactory::createInteger (long long aInteger){
+ return Item( theItemFactory->createInteger (aInteger));
+ }
+ Item ItemFactory::createLong (long long aLong){
+ return Item( theItemFactory->createLong (aLong));
+ }
+ Item ItemFactory::createNCName (const std::string &aValue){
+ return Item( theItemFactory->createNCName (aValue));
+ }
+ Item ItemFactory::createNegativeInteger (long long aValue){
+ return Item( theItemFactory->createNegativeInteger (aValue));
+ }
+ Item ItemFactory::createNonNegativeInteger (unsigned long long aValue){
+ return Item( theItemFactory->createNonNegativeInteger (aValue));
+ }
+ Item ItemFactory::createNonPositiveInteger (long long aValue){
+ return Item( theItemFactory->createNonPositiveInteger (aValue));
+ }
+ Item ItemFactory::createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri){
+ zorba::String lTarget = zorba::String(aTarget);
+ zorba::String lContent = zorba::String(aContent);
+ zorba::String lBaseUri = zorba::String(aBaseUri);
+ return Item( theItemFactory->createPiNode (aParent.theItem, lTarget, lContent, lBaseUri));
+ }
+ Item ItemFactory::createPositiveInteger (unsigned long long aValue){
+ return Item( theItemFactory->createPositiveInteger (aValue));
+ }
+ Item ItemFactory::createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname){
+ return Item( theItemFactory->createQName (aNamespace, aPrefix, aLocalname));
+ }
+ Item ItemFactory::createQName (const std::string &aNamespace, const std::string &aLocalname){
+ return Item( theItemFactory->createQName (aNamespace, aLocalname));
+ }
+ Item ItemFactory::createQName (const std::string &aQNameString){
+ return Item( theItemFactory->createQName (aQNameString));
+ }
+ Item ItemFactory::createShort (short aShort){
+ return Item( theItemFactory->createShort (aShort));
+ }
+ /*
+ Item ItemFactory::createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false){
+ return Item( theItemFactory->createStreamableString (std::istream &stream, StreamReleaser streamReleaser, seekable));
+ }
+ */
+ Item ItemFactory::createString (const std::string &aString){
+ return Item( theItemFactory->createString (aString));
+ }
+ Item ItemFactory::createTextNode (Item &aParent, const std::string &aContent){
+ zorba::String lContent = zorba::String(aContent);
+ return Item( theItemFactory->createTextNode (aParent.theItem, lContent));
+ }
+ Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){
+ return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours));
+ }
+ Item ItemFactory::createTime (short aHour, short aMinute, double aSecond){
+ return Item( theItemFactory->createTime (aHour, aMinute, aSecond));
+ }
+ Item ItemFactory::createTime (const std::string &aValue){
+ return Item( theItemFactory->createTime (aValue));
+ }
+ Item ItemFactory::createUnsignedByte (const unsigned char aValue){
+ return Item( theItemFactory->createUnsignedByte (aValue));
+ }
+ Item ItemFactory::createUnsignedInt (unsigned int aValue){
+ return Item( theItemFactory->createUnsignedInt (aValue));
+ }
+ Item ItemFactory::createUnsignedLong (unsigned long long aValue){
+ return Item( theItemFactory->createUnsignedLong (aValue));
+ }
+ Item ItemFactory::createUnsignedShort (unsigned short aValue){
+ return Item( theItemFactory->createUnsignedShort (aValue));
+ }
+
+
+%} // end Implementation
+
+%include "ItemFactory.h"
=== removed file 'swig/ItemFactory.i'
--- swig/ItemFactory.i 2011-10-27 18:01:22 +0000
+++ swig/ItemFactory.i 1970-01-01 00:00:00 +0000
@@ -1,192 +0,0 @@
-
-%{ // start Implementation
-
-
-
- Item ItemFactory::createAnyURI (const std::string &aURI){
- return Item(theItemFactory->createAnyURI(aURI));
- }
-
- Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue){
- return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem ));
- }
-
- Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue){
-
- std::vector< zorba::Item > typedValue;
- typedValue.reserve(aTypedValue.size());
- std::vector< Item >::iterator iter;
- for(iter = aTypedValue.begin(); iter != aTypedValue.end(); iter++) {
- typedValue.push_back((*iter).theItem);
- }
- return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue ));
- }
-
- Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){
- return Item( theItemFactory->createBase64Binary(aBinData, aLength));
- }
- Item ItemFactory::createBase64Binary (std::istream &aStream){
- return Item( theItemFactory->createBase64Binary(aStream));
- }
- Item ItemFactory::createBase64Binary (const unsigned char *aBinData, size_t aLength){
- return Item( theItemFactory->createBase64Binary(aBinData, aLength));
- }
- Item ItemFactory::createBoolean (bool aValue){
- return Item( theItemFactory->createBoolean(aValue));
- }
- Item ItemFactory::createByte (char aByte){
- return Item( theItemFactory->createByte(aByte));
- }
- Item ItemFactory::createDate (const std::string &aDate){
- return Item( theItemFactory->createDate(aDate));
- }
- Item ItemFactory::createDate (short aYear, short aMonth, short aDay){
- return Item( theItemFactory->createDate (aYear, aMonth, aDay));
- }
- Item ItemFactory::createDateTime (const std::string &aDateTimeValue){
- return Item( theItemFactory->createDateTime (aDateTimeValue));
- }
- Item ItemFactory::createDateTime (short aYear, short aMonth, short aDay, short aHour, short aMinute, double aSecond, short aTimeZone_hours){
- return Item( theItemFactory->createDateTime (aYear, aMonth, aDay, aHour, aMinute, aSecond, aTimeZone_hours));
- }
- Item ItemFactory::createDecimal (const std::string &aValue){
- return Item( theItemFactory->createDecimal (aValue));
- }
- Item ItemFactory::createDecimalFromDouble (double aValue){
- return Item( theItemFactory->createDecimalFromDouble (aValue));
- }
- Item ItemFactory::createDecimalFromLong (unsigned long aValue){
- return Item( theItemFactory->createDecimalFromLong (aValue));
- }
- Item ItemFactory::createDouble (const std::string &aValue){
- return Item( theItemFactory->createDouble (aValue));
- }
- Item ItemFactory::createDouble (double aValue){
- return Item( theItemFactory->createDouble (aValue));
- }
- Item ItemFactory::createDuration (const std::string &aValue){
- return Item( theItemFactory->createDuration (aValue));
- }
- Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){
- return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds));
- }
- /*
- Item ItemFactory::createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){
- return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, aNsBindings));
- }
- */
- Item ItemFactory::createFloat (const std::string &aValue){
- return Item( theItemFactory->createFloat (aValue));
- }
- Item ItemFactory::createFloat (float aValue){
- return Item( theItemFactory->createFloat (aValue));
- }
- Item ItemFactory::createGDay (const std::string &aValue){
- return Item( theItemFactory->createGDay (aValue));
- }
- Item ItemFactory::createGDay (short aDay){
- return Item( theItemFactory->createGDay (aDay));
- }
- Item ItemFactory::createGMonth (const std::string &aValue){
- return Item( theItemFactory->createGMonth (aValue));
- }
- Item ItemFactory::createGMonth (short aMonth){
- return Item( theItemFactory->createGMonth (aMonth));
- }
- Item ItemFactory::createGMonthDay (const std::string &aValue){
- return Item( theItemFactory->createGMonthDay (aValue));
- }
- Item ItemFactory::createGMonthDay (short aMonth, short aDay){
- return Item( theItemFactory->createGMonthDay (aMonth, aDay));
- }
- Item ItemFactory::createGYear (short aYear){
- return Item( theItemFactory->createGYear (aYear));
- }
- Item ItemFactory::createGYear (const std::string &aValue){
- return Item( theItemFactory->createGYear (aValue));
- }
- Item ItemFactory::createGYearMonth (const std::string &aValue){
- return Item( theItemFactory->createGYearMonth (aValue));
- }
- Item ItemFactory::createGYearMonth (short aYear, short aMonth){
- return Item( theItemFactory->createGYearMonth (aYear, aMonth));
- }
- Item ItemFactory::createHexBinary (const char *aHexData, size_t aSize){
- return Item( theItemFactory->createHexBinary (aHexData, aSize));
- }
- Item ItemFactory::createInt (int aInt){
- return Item( theItemFactory->createInt (aInt));
- }
- Item ItemFactory::createInteger (const std::string &aInteger){
- return Item( theItemFactory->createInteger (aInteger));
- }
- Item ItemFactory::createInteger (long long aInteger){
- return Item( theItemFactory->createInteger (aInteger));
- }
- Item ItemFactory::createLong (long long aLong){
- return Item( theItemFactory->createLong (aLong));
- }
- Item ItemFactory::createNCName (const std::string &aValue){
- return Item( theItemFactory->createNCName (aValue));
- }
- Item ItemFactory::createNegativeInteger (long long aValue){
- return Item( theItemFactory->createNegativeInteger (aValue));
- }
- Item ItemFactory::createNonNegativeInteger (unsigned long long aValue){
- return Item( theItemFactory->createNonNegativeInteger (aValue));
- }
- Item ItemFactory::createNonPositiveInteger (long long aValue){
- return Item( theItemFactory->createNonPositiveInteger (aValue));
- }
- Item ItemFactory::createPositiveInteger (unsigned long long aValue){
- return Item( theItemFactory->createPositiveInteger (aValue));
- }
- Item ItemFactory::createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname){
- return Item( theItemFactory->createQName (aNamespace, aPrefix, aLocalname));
- }
- Item ItemFactory::createQName (const std::string &aNamespace, const std::string &aLocalname){
- return Item( theItemFactory->createQName (aNamespace, aLocalname));
- }
- Item ItemFactory::createQName (const std::string &aQNameString){
- return Item( theItemFactory->createQName (aQNameString));
- }
- Item ItemFactory::createShort (short aShort){
- return Item( theItemFactory->createShort (aShort));
- }
- /*
- Item ItemFactory::createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false){
- return Item( theItemFactory->createStreamableString (std::istream &stream, StreamReleaser streamReleaser, seekable));
- }
- */
- Item ItemFactory::createString (const std::string &aString){
- return Item( theItemFactory->createString (aString));
- }
- Item ItemFactory::createTextNode (Item parent, std::string content){
- return Item( theItemFactory->createTextNode (parent.theItem, content));
- }
- Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){
- return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours));
- }
- Item ItemFactory::createTime (short aHour, short aMinute, double aSecond){
- return Item( theItemFactory->createTime (aHour, aMinute, aSecond));
- }
- Item ItemFactory::createTime (const std::string &aValue){
- return Item( theItemFactory->createTime (aValue));
- }
- Item ItemFactory::createUnsignedByte (const unsigned char aValue){
- return Item( theItemFactory->createUnsignedByte (aValue));
- }
- Item ItemFactory::createUnsignedInt (unsigned int aValue){
- return Item( theItemFactory->createUnsignedInt (aValue));
- }
- Item ItemFactory::createUnsignedLong (unsigned long long aValue){
- return Item( theItemFactory->createUnsignedLong (aValue));
- }
- Item ItemFactory::createUnsignedShort (unsigned short aValue){
- return Item( theItemFactory->createUnsignedShort (aValue));
- }
-
-
-%} // end Implementation
-
-%include "ItemFactory.h"
\ No newline at end of file
=== added file 'swig/Iterator.h'
--- swig/Iterator.h 1970-01-01 00:00:00 +0000
+++ swig/Iterator.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef API_ITERATOR_H
+#define API_ITERATOR_H
+
+class Iterator
+{
+protected:
+ friend class DynamicContext;
+ friend class StaticContext;
+ friend class XQuery;
+ zorba::Iterator_t theIterator;
+ zorba::Item theItem;
+ bool theConsumed;
+public:
+ // constructors
+ Iterator() {}
+ Iterator(const Iterator& anIterator)
+ : theIterator(anIterator.theIterator),
+ theItem(anIterator.theItem),
+ theConsumed(false)
+ {}
+ Iterator(zorba::Iterator_t anIterator)
+ : theIterator(anIterator),
+ theConsumed(false)
+ {}
+ Iterator(zorba::Item& aItem)
+ : theIterator(0),
+ theItem(aItem),
+ theConsumed(false)
+ {}
+
+ void open();
+ bool isOpen();
+ bool next(Item&);
+ void close();
+ void destroy();
+}; // class Iterator
+
+#endif
\ No newline at end of file
=== added file 'swig/Iterator.i'
--- swig/Iterator.i 1970-01-01 00:00:00 +0000
+++ swig/Iterator.i 2012-01-07 02:13:25 +0000
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+%{ // start Implementation
+
+ void Iterator::open()
+ {
+ if (theIterator)
+ theIterator->open();
+ theConsumed = false;
+ }
+
+ bool Iterator::isOpen()
+ {
+ if (theIterator)
+ return theIterator->isOpen();
+ else
+ return !theConsumed;
+ }
+
+ void Iterator::close()
+ {
+ if (theIterator)
+ theIterator->close();
+ theConsumed = true;
+ }
+
+ void Iterator::destroy()
+ {
+ theIterator = 0;
+ }
+
+ bool Iterator::next(Item& aItem)
+ {
+ if (theIterator)
+ {
+ return theIterator->next(aItem.theItem);
+ }
+ else
+ {
+ if (!theConsumed)
+ {
+ aItem = theItem;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+
+%} // end Implementation
+
+%include "Iterator.h"
=== added file 'swig/StaticContext.h'
--- swig/StaticContext.h 1970-01-01 00:00:00 +0000
+++ swig/StaticContext.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef API_STATIC_CONTEXT_H
+#define API_STATIC_CONTEXT_H
+
+#include <zorba/static_context_consts.h>
+
+class ZorbaConstants
+{
+public:
+ typedef enum {
+ PRESERVE,
+ NO_PRESERVE
+ } PreserveMode;
+
+ typedef enum {
+ INHERIT,
+ NO_INHERIT
+ } InheritMode;
+
+ typedef enum {
+ PRESERVE_SPACE,
+ STRIP_SPACE
+ } BoundarySpaceMode;
+
+ typedef enum {
+ PRESERVE_CONSTRUCTION,
+ STRIP_CONSTRUCTION
+ } ConstructionMode;
+
+ typedef enum {
+ EMPTY_GREATEST,
+ EMPTY_LEAST
+ } OrderEmptyMode;
+
+ typedef enum {
+ ORDERED,
+ UNORDERED
+ } OrderingMode;
+
+ typedef enum {
+ VALIDATE_SKIP,
+ VALIDATE_LAX,
+ VALIDATE_STRICT
+ } RevalidationMode;
+
+ typedef enum {
+ XPATH2_0,
+ XPATH1_0
+ } XPath1_0CompatibleMode;
+
+}; // ZorbaConstants
+
+class StaticContext
+{
+friend class Zorba;
+friend class XQuery;
+
+private:
+ zorba::StaticContext_t theStaticContext;
+public:
+
+ StaticContext();
+ StaticContext(const StaticContext& aStaticContext);
+ StaticContext(zorba::StaticContext_t aStaticContext);
+
+ void addColation(const std::string& aURI);
+ bool addNamespace(const std::string& aPrefix,
+ const std::string& aURI);
+
+ bool containsFunction(const std::string &aFnNameUri,
+ const std::string &aFnNameLocal,
+ int arity) const;
+
+ StaticContext createChildContext() const;
+ void declareOption(const Item &aQName,
+ const std::string &aOptionVal);
+ void disableFunction(const Item &aQName, int arity);
+
+ std::string getBaseURI () const;
+
+ ZorbaConstants::BoundarySpaceMode getBoundarySpacePolicy ();
+ ZorbaConstants::ConstructionMode getConstructionMode();
+ ZorbaConstants::PreserveMode getCopyNamespacesModePreserve();
+ ZorbaConstants::InheritMode getCopyNamespacesModeInherit();
+ ZorbaConstants::OrderEmptyMode getDefaultOrderForEmptySequences();
+ ZorbaConstants::OrderingMode getOrderingMode();
+ ZorbaConstants::RevalidationMode getRevalidationMode();
+ ZorbaConstants::XPath1_0CompatibleMode getXPath1_0CompatibMode();
+
+ std::string getDefaultCollation () const;
+ std::string getDefaultElementAndTypeNamespace () const;
+ std::string getDefaultFunctionNamespace () const;
+
+ std::string getNamespaceURIByPrefix(const std::string &aPrefix) const;
+ bool getOption(const Item &aQName, std::string &aOptionValue) const;
+ void loadProlog (const std::string & aProlog, const CompilerHints &hints);
+
+ void getExternalVariables(Iterator& vars) const;
+
+ TypeIdentifier getCollectionType(const std::string &aCollectionUri);
+ TypeIdentifier getDocumentType(const std::string &aDocUri);
+ TypeIdentifier getContextItemStaticType();
+
+ void setContextItemStaticType(const TypeIdentifier &aType);
+
+ void resetTraceStream ();
+ bool setBaseURI (const std::string &aBaseURI);
+
+ bool setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode);
+ bool setConstructionMode (ZorbaConstants::ConstructionMode aMode);
+ bool setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit);
+ bool setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode);
+ bool setOrderingMode (ZorbaConstants::OrderingMode aMode);
+ void setRevalidationMode (ZorbaConstants::RevalidationMode aMode);
+ bool setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode);
+
+ void setDefaultCollation (const std::string &aURI);
+ bool setDefaultElementAndTypeNamespace (const std::string &aURI);
+ bool setDefaultFunctionNamespace (const std::string &aURI);
+
+ void destroy();
+}; // class StaticContext
+
+#endif
\ No newline at end of file
=== removed file 'swig/StaticContext.h'
--- swig/StaticContext.h 2011-10-27 18:01:22 +0000
+++ swig/StaticContext.h 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-#include <zorba/static_context_consts.h>
-
-class StaticContext
-{
-friend class Zorba;
-friend class XQuery;
-
-private:
- zorba::StaticContext_t theStaticContext;
-public:
- StaticContext();
- StaticContext(const StaticContext& aStaticContext);
- StaticContext(zorba::StaticContext_t aStaticContext);
-
- virtual void addColation(const std::string& aURI);
- virtual bool addNamespace(const std::string& aPrefix,
- const std::string& aURI);
- void addReference() const;
- virtual bool containsFunction(const std::string &aFnNameUri,
- const std::string &aFnNameLocal,
- int arity) const;
-
- virtual StaticContext createChildContext() const;
- virtual void declareOption(const Item &aQName,
- const std::string &aOptionVal);
- virtual void disableFunction(const Item &aQName, int arity);
-
- virtual void free ();
- virtual std::string getBaseURI () const;
- virtual zorba::boundary_space_mode_t getBoundarySpacePolicy () const;
-
- virtual zorba::construction_mode_t getConstructionMode () const;
- virtual void getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const;
- virtual std::string getDefaultCollation () const;
- virtual std::string getDefaultElementAndTypeNamespace () const;
- virtual std::string getDefaultFunctionNamespace () const;
- virtual zorba::order_empty_mode_t getDefaultOrderForEmptySequences () const;
-
- virtual std::string getNamespaceURIByPrefix(const std::string &aPrefix) const;
- virtual bool getOption(const Item &aQName, std::string &aOptionValue) const;
- virtual zorba::ordering_mode_t getOrderingMode() const;
- long getRefCount() const;
- virtual zorba::validation_mode_t getRevalidationMode();
- virtual zorba::xpath1_0compatib_mode_t getXPath1_0CompatibMode () const;
- virtual void loadProlog (const std::string & aProlog,
- const CompilerHints &hints);
-
- void removeReference ();
- virtual void resetTraceStream ();
- virtual bool setBaseURI (const std::string &aBaseURI);
- virtual bool setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode);
-
- virtual bool setConstructionMode (zorba::construction_mode_t aMode);
-
- virtual bool setCopyNamespacesMode (zorba::preserve_mode_t aPreserve,
- zorba::inherit_mode_t aInherit);
- virtual void setDefaultCollation (const std::string &aURI);
- virtual bool setDefaultElementAndTypeNamespace (const std::string &aURI);
- virtual bool setDefaultFunctionNamespace (const std::string &aURI);
- virtual bool setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode);
-
- virtual bool setOrderingMode (zorba::ordering_mode_t aMode);
- virtual void setRevalidationMode (zorba::validation_mode_t aMode);
-
- virtual bool setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode);
-
- void destroy();
-}; // class StaticContext
-
=== modified file 'swig/StaticContext.i'
--- swig/StaticContext.i 2011-10-12 20:56:27 +0000
+++ swig/StaticContext.i 2012-01-07 02:13:25 +0000
@@ -31,65 +31,94 @@
void StaticContext::addColation(const std::string& aURI)
{ theStaticContext->addCollation(aURI); }
-bool StaticContext::addNamespace(const std::string& aPrefix,
- const std::string& aURI)
+bool StaticContext::addNamespace(const std::string& aPrefix, const std::string& aURI)
{ return theStaticContext->addNamespace(aPrefix, aURI); }
-void StaticContext::addReference() const
- { theStaticContext->addReference(); }
-
-bool StaticContext::containsFunction(const std::string &aFnNameUri,
- const std::string &aFnNameLocal,
- int arity) const
- { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal,
- arity); }
+bool StaticContext::containsFunction(const std::string &aFnNameUri, const std::string &aFnNameLocal, int arity) const
+ { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal, arity); }
StaticContext StaticContext::createChildContext() const
{ return StaticContext(theStaticContext->createChildContext()); }
-void StaticContext::declareOption (const Item &aQName,
- const std::string &aOptionVal)
+void StaticContext::declareOption (const Item &aQName, const std::string &aOptionVal)
{ return theStaticContext->declareOption(aQName.theItem, aOptionVal); }
void StaticContext::disableFunction (const Item &aQName, int arity)
{ theStaticContext->disableFunction( aQName.theItem, arity); }
-void StaticContext::free ()
- { theStaticContext->free(); }
-
std::string StaticContext::getBaseURI () const
{ return std::string(theStaticContext->getBaseURI().c_str()); }
-zorba::boundary_space_mode_t StaticContext::getBoundarySpacePolicy() const
- { return theStaticContext->getBoundarySpacePolicy(); }
-
-zorba::construction_mode_t StaticContext::getConstructionMode () const
- { return theStaticContext->getConstructionMode(); }
-
-void StaticContext::getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const
- { return theStaticContext->getCopyNamespacesMode(aPreserve, aInherit); }
+ZorbaConstants::BoundarySpaceMode StaticContext::getBoundarySpacePolicy()
+ {
+ ZorbaConstants::BoundarySpaceMode result = ZorbaConstants::PRESERVE_SPACE;
+ zorba::boundary_space_mode_t boundary = theStaticContext->getBoundarySpacePolicy();
+ if (boundary == zorba::strip_space) {
+ result = ZorbaConstants::STRIP_SPACE;
+ }
+ return result;
+ }
+
+ZorbaConstants::ConstructionMode StaticContext::getConstructionMode()
+ {
+ ZorbaConstants::ConstructionMode result = ZorbaConstants::STRIP_CONSTRUCTION;
+ zorba::construction_mode_t construction = theStaticContext->getConstructionMode();
+ if (construction == zorba::preserve_cons) {
+ result = ZorbaConstants::PRESERVE_CONSTRUCTION;
+ }
+ return result;
+ }
+
+ZorbaConstants::PreserveMode StaticContext::getCopyNamespacesModePreserve()
+ {
+ zorba::preserve_mode_t lPreserve;
+ zorba::inherit_mode_t lInherit;
+ ZorbaConstants::PreserveMode aPreserve = ZorbaConstants::NO_PRESERVE;
+ theStaticContext->getCopyNamespacesMode(lPreserve, lInherit);
+ if (lPreserve==zorba::preserve_ns) {
+ aPreserve = ZorbaConstants::PRESERVE;
+ }
+ return aPreserve;
+ }
+
+ZorbaConstants::InheritMode StaticContext::getCopyNamespacesModeInherit()
+ {
+ zorba::preserve_mode_t lPreserve;
+ zorba::inherit_mode_t lInherit;
+ ZorbaConstants::InheritMode aInherit = ZorbaConstants::NO_INHERIT;
+ theStaticContext->getCopyNamespacesMode(lPreserve, lInherit);
+ if (lInherit==zorba::inherit_ns) {
+ aInherit = ZorbaConstants::INHERIT;
+ }
+ return aInherit;
+ }
std::string StaticContext::getDefaultCollation () const
{ return std::string(theStaticContext->getDefaultCollation().c_str()); }
std::string StaticContext::getDefaultElementAndTypeNamespace () const
{
- return std::string(theStaticContext->getDefaultElementAndTypeNamespace().
- c_str());
+ return std::string( theStaticContext->getDefaultElementAndTypeNamespace().c_str() );
}
std::string StaticContext::getDefaultFunctionNamespace () const
{
- return std::string(theStaticContext->getDefaultFunctionNamespace().c_str());
+ return std::string( theStaticContext->getDefaultFunctionNamespace().c_str() );
}
-zorba::order_empty_mode_t StaticContext::getDefaultOrderForEmptySequences() const
- { return theStaticContext->getDefaultOrderForEmptySequences(); }
+ZorbaConstants::OrderEmptyMode StaticContext::getDefaultOrderForEmptySequences()
+ {
+ ZorbaConstants::OrderEmptyMode result = ZorbaConstants::EMPTY_GREATEST;
+ zorba::order_empty_mode_t order = theStaticContext->getDefaultOrderForEmptySequences();
+ if (order == zorba::empty_least) {
+ result = ZorbaConstants::EMPTY_LEAST;
+ }
+ return result;
+ }
std::string StaticContext::getNamespaceURIByPrefix(const std::string &aPrefix) const
{
- return std::string(theStaticContext->getNamespaceURIByPrefix(aPrefix).
- c_str());
+ return std::string( theStaticContext->getNamespaceURIByPrefix(aPrefix).c_str() );
}
bool StaticContext::getOption(const Item &aQName, std::string &aOptionValue) const
@@ -98,40 +127,92 @@
return theStaticContext->getOption(aQName.theItem, optVal);
}
-zorba::ordering_mode_t StaticContext::getOrderingMode () const
- { return theStaticContext->getOrderingMode(); }
-
-long StaticContext::getRefCount () const
- { return theStaticContext->getRefCount(); }
-
-zorba::validation_mode_t StaticContext::getRevalidationMode ()
- { return theStaticContext->getRevalidationMode(); }
-
-zorba::xpath1_0compatib_mode_t StaticContext::getXPath1_0CompatibMode () const
- { return theStaticContext->getXPath1_0CompatibMode(); }
-
-void StaticContext::loadProlog (const std::string & aProlog,
- const CompilerHints &hints)
+ZorbaConstants::OrderingMode StaticContext::getOrderingMode ()
+ {
+ ZorbaConstants::OrderingMode result = ZorbaConstants::ORDERED;
+ zorba::ordering_mode_t order = theStaticContext->getOrderingMode();
+ if (order == zorba::unordered) {
+ result = ZorbaConstants::UNORDERED;
+ }
+ return result;
+ }
+
+ZorbaConstants::RevalidationMode StaticContext::getRevalidationMode ()
+ {
+ ZorbaConstants::RevalidationMode result = ZorbaConstants::VALIDATE_SKIP;
+ zorba::validation_mode_t revalidation = theStaticContext->getRevalidationMode();
+ if (revalidation == zorba::validate_lax) {
+ result = ZorbaConstants::VALIDATE_LAX;
+ } else if (revalidation == zorba::validate_strict) {
+ result = ZorbaConstants::VALIDATE_STRICT;
+ }
+ return result;
+ }
+
+ZorbaConstants::XPath1_0CompatibleMode StaticContext::getXPath1_0CompatibMode ()
+ {
+ ZorbaConstants::XPath1_0CompatibleMode result = ZorbaConstants::XPATH2_0;
+ zorba::xpath1_0compatib_mode_t comp = theStaticContext->getXPath1_0CompatibMode();
+ if (comp == zorba::xpath1_0) {
+ result = ZorbaConstants::XPATH1_0;
+ }
+ return result;
+ }
+
+void StaticContext::loadProlog (const std::string & aProlog, const CompilerHints &hints)
{ theStaticContext->loadProlog( aProlog, hints.theCompilerHints); }
-void StaticContext::removeReference ()
- { theStaticContext->removeReference(); }
-
+void StaticContext::getExternalVariables(Iterator& vars) const
+ { theStaticContext->getExternalVariables( vars.theIterator ); }
+
+TypeIdentifier StaticContext::getCollectionType(const std::string & aCollectionUri)
+ { return TypeIdentifier(theStaticContext->getCollectionType(aCollectionUri)); }
+
+TypeIdentifier StaticContext::getDocumentType(const std::string &aDocUri)
+ { return TypeIdentifier(theStaticContext->getDocumentType(aDocUri)); }
+
+TypeIdentifier StaticContext::getContextItemStaticType()
+ { return TypeIdentifier(theStaticContext->getContextItemStaticType()); }
+
+void StaticContext::setContextItemStaticType(const TypeIdentifier &aType)
+ { theStaticContext->setContextItemStaticType(aType.theTypeIdentifier); }
+
void StaticContext::resetTraceStream ()
{ theStaticContext->resetTraceStream(); }
bool StaticContext::setBaseURI (const std::string &aBaseURI)
{ return theStaticContext->setBaseURI(aBaseURI); }
-bool StaticContext::setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode)
- { return theStaticContext->setBoundarySpacePolicy(aMode); }
-
-bool StaticContext::setConstructionMode (zorba::construction_mode_t aMode)
- { return theStaticContext->setConstructionMode(aMode); }
-
-bool StaticContext::setCopyNamespacesMode (zorba::preserve_mode_t aPreserve,
- zorba::inherit_mode_t aInherit)
- { return theStaticContext->setCopyNamespacesMode(aPreserve, aInherit); }
+bool StaticContext::setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode)
+ {
+ zorba::boundary_space_mode_t lMode = zorba::strip_space;
+ if (aMode == ZorbaConstants::PRESERVE_SPACE) {
+ lMode = zorba::preserve_space;
+ }
+ return theStaticContext->setBoundarySpacePolicy(lMode);
+ }
+
+bool StaticContext::setConstructionMode (ZorbaConstants::ConstructionMode aMode)
+ {
+ zorba::construction_mode_t lMode = zorba::preserve_cons;
+ if (aMode == ZorbaConstants::STRIP_CONSTRUCTION) {
+ lMode = zorba::strip_cons;
+ }
+ return theStaticContext->setConstructionMode(lMode);
+ }
+
+bool StaticContext::setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit)
+ {
+ zorba::preserve_mode_t lPreserve = zorba::no_preserve_ns;
+ zorba::inherit_mode_t lInherit = zorba::no_inherit_ns;
+ if (aPreserve == ZorbaConstants::PRESERVE) {
+ lPreserve = zorba::preserve_ns;
+ }
+ if (aInherit == ZorbaConstants::INHERIT) {
+ lInherit = zorba::inherit_ns;
+ }
+ return theStaticContext->setCopyNamespacesMode(lPreserve, lInherit);
+ }
void StaticContext::setDefaultCollation (const std::string &aURI)
{ theStaticContext->setDefaultCollation(aURI); }
@@ -142,17 +223,43 @@
bool StaticContext::setDefaultFunctionNamespace (const std::string &aURI)
{ return theStaticContext->setDefaultFunctionNamespace(aURI); }
-bool StaticContext::setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode)
- { return theStaticContext->setDefaultOrderForEmptySequences(aMode); }
-
-bool StaticContext::setOrderingMode (zorba::ordering_mode_t aMode)
- { return theStaticContext->setOrderingMode(aMode); }
-
-void StaticContext::setRevalidationMode (zorba::validation_mode_t aMode)
- { return theStaticContext->setRevalidationMode(aMode); }
-
-bool StaticContext::setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode)
- { return theStaticContext->setXPath1_0CompatibMode(aMode); }
+bool StaticContext::setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode)
+ {
+ zorba::order_empty_mode_t lMode = zorba::empty_greatest;
+ if (aMode == ZorbaConstants::EMPTY_LEAST) {
+ lMode = zorba::empty_least;
+ }
+ return theStaticContext->setDefaultOrderForEmptySequences(lMode);
+ }
+
+bool StaticContext::setOrderingMode (ZorbaConstants::OrderingMode aMode)
+ {
+ zorba::ordering_mode_t lMode = zorba::ordered;
+ if (aMode == ZorbaConstants::UNORDERED) {
+ lMode = zorba::unordered;
+ }
+ return theStaticContext->setOrderingMode(lMode);
+ }
+
+void StaticContext::setRevalidationMode (ZorbaConstants::RevalidationMode aMode)
+ {
+ zorba::validation_mode_t lMode = zorba::validate_skip;
+ if (aMode == ZorbaConstants::VALIDATE_LAX) {
+ lMode = zorba::validate_lax;
+ } else if (aMode == ZorbaConstants::VALIDATE_STRICT) {
+ lMode = zorba::validate_strict;
+ }
+ return theStaticContext->setRevalidationMode(lMode);
+ }
+
+bool StaticContext::setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode)
+ {
+ zorba::xpath1_0compatib_mode_t lMode = zorba::xpath2_0;
+ if (aMode == ZorbaConstants::XPATH1_0) {
+ lMode = zorba::xpath1_0;
+ }
+ return theStaticContext->setXPath1_0CompatibMode(lMode);
+ }
void StaticContext::destroy()
{ theStaticContext = 0; }
@@ -165,7 +272,7 @@
%} // end Implementation
- // Interface
+// Interface
%rename(XPath1_0CompatibModeEnum) zorba::xpath1_0compatib_mode_t;
%rename(XPATH2_0) xpath2_0;
=== modified file 'swig/Store.i'
--- swig/Store.i 2010-03-23 05:30:50 +0000
+++ swig/Store.i 2012-01-07 02:13:25 +0000
@@ -15,6 +15,8 @@
*/
%{ // start Implementation
+
+#include <zorba/store_consts.h>
class Store
{
=== added file 'swig/TypeIdentifier.h'
--- swig/TypeIdentifier.h 1970-01-01 00:00:00 +0000
+++ swig/TypeIdentifier.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef API_TYPE_IDENTIFIER_H
+#define API_TYPE_IDENTIFIER_H
+
+class IdentTypes {
+public:
+ typedef enum {
+ NAMED_TYPE,
+ ELEMENT_TYPE,
+ ATTRIBUTE_TYPE,
+ DOCUMENT_TYPE,
+ PI_TYPE,
+ TEXT_TYPE,
+ COMMENT_TYPE,
+ ANY_NODE_TYPE,
+ ITEM_TYPE,
+ EMPTY_TYPE,
+ INVALID_TYPE,
+ } Kind;
+
+ typedef enum {
+ QUANT_ONE,
+ QUANT_QUESTION,
+ QUANT_PLUS,
+ QUANT_STAR,
+ } Quantifier;
+};
+
+class TypeIdentifier
+{
+ friend class StaticContext;
+private:
+ zorba::TypeIdentifier_t theTypeIdentifier;
+ static zorba::IdentTypes::quantifier_t convertQuantifier(IdentTypes::Quantifier quantifier);
+
+public:
+ TypeIdentifier() {}
+ TypeIdentifier (const TypeIdentifier& aTypeIdentifier) : theTypeIdentifier(aTypeIdentifier.theTypeIdentifier) {}
+ TypeIdentifier (const zorba::TypeIdentifier_t& aZTypeIdentifier) : theTypeIdentifier(aZTypeIdentifier) {}
+
+ TypeIdentifier getContentType();
+ IdentTypes::Kind getKind();
+ const std::string getLocalName();
+ IdentTypes::Quantifier getQuantifier();
+ long getRefCount();
+ const std::string getUri();
+ bool isLocalNameWildcard();
+ bool isUriWildcard();
+
+ static TypeIdentifier
+ createAnyNodeType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createCommentType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createEmptyType();
+
+ static TypeIdentifier
+ createItemType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createPIType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+ static TypeIdentifier
+ createTextType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
+
+}; // class TypeIdentifier
+
+
+#endif
\ No newline at end of file
=== added file 'swig/TypeIdentifier.i'
--- swig/TypeIdentifier.i 1970-01-01 00:00:00 +0000
+++ swig/TypeIdentifier.i 2012-01-07 02:13:25 +0000
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+%{ // start Implementation
+
+ zorba::IdentTypes::quantifier_t
+ TypeIdentifier::convertQuantifier(IdentTypes::Quantifier quantifier)
+ {
+ zorba::IdentTypes::quantifier_t result;
+ switch (quantifier) {
+ case IdentTypes::QUANT_ONE:
+ result = zorba::IdentTypes::QUANT_ONE;
+ break;
+ case IdentTypes::QUANT_QUESTION:
+ result = zorba::IdentTypes::QUANT_QUESTION;
+ break;
+ case IdentTypes::QUANT_PLUS:
+ result = zorba::IdentTypes::QUANT_PLUS;
+ break;
+ case IdentTypes::QUANT_STAR:
+ result = zorba::IdentTypes::QUANT_STAR;
+ break;
+ }
+ return result;
+ }
+
+ TypeIdentifier TypeIdentifier::getContentType()
+ {
+ return TypeIdentifier(theTypeIdentifier->getContentType());
+ }
+ IdentTypes::Kind TypeIdentifier::getKind()
+ {
+ zorba::IdentTypes::kind_t lKind = theTypeIdentifier->getKind();
+ IdentTypes::Kind result;
+ switch (lKind) {
+ case zorba::IdentTypes::NAMED_TYPE:
+ result = IdentTypes::NAMED_TYPE;
+ break;
+ case zorba::IdentTypes::ELEMENT_TYPE:
+ result = IdentTypes::ELEMENT_TYPE;
+ break;
+ case zorba::IdentTypes::ATTRIBUTE_TYPE:
+ result = IdentTypes::ATTRIBUTE_TYPE;
+ break;
+ case zorba::IdentTypes::DOCUMENT_TYPE:
+ result = IdentTypes::DOCUMENT_TYPE;
+ break;
+ case zorba::IdentTypes::PI_TYPE:
+ result = IdentTypes::PI_TYPE;
+ break;
+ case zorba::IdentTypes::TEXT_TYPE:
+ result = IdentTypes::TEXT_TYPE;
+ break;
+ case zorba::IdentTypes::COMMENT_TYPE:
+ result = IdentTypes::COMMENT_TYPE;
+ break;
+ case zorba::IdentTypes::ANY_NODE_TYPE:
+ result = IdentTypes::ANY_NODE_TYPE;
+ break;
+ case zorba::IdentTypes::ITEM_TYPE:
+ result = IdentTypes::ITEM_TYPE;
+ break;
+ case zorba::IdentTypes::EMPTY_TYPE:
+ result = IdentTypes::EMPTY_TYPE;
+ break;
+ case zorba::IdentTypes::INVALID_TYPE:
+ result = IdentTypes::INVALID_TYPE;
+ break;
+ default:
+ result = IdentTypes::ANY_NODE_TYPE;
+ break;
+ }
+ return result;
+ }
+ const std::string TypeIdentifier::getLocalName()
+ {
+ return std::string(theTypeIdentifier->getLocalName().c_str());
+ }
+ IdentTypes::Quantifier TypeIdentifier::getQuantifier()
+ {
+ zorba::IdentTypes::quantifier_t lQuantifier = theTypeIdentifier->getQuantifier();
+ IdentTypes::Quantifier result;
+ switch (lQuantifier) {
+ case zorba::IdentTypes::QUANT_ONE:
+ result = IdentTypes::QUANT_ONE;
+ break;
+ case zorba::IdentTypes::QUANT_QUESTION:
+ result = IdentTypes::QUANT_QUESTION;
+ break;
+ case zorba::IdentTypes::QUANT_PLUS:
+ result = IdentTypes::QUANT_PLUS;
+ break;
+ case zorba::IdentTypes::QUANT_STAR:
+ result = IdentTypes::QUANT_STAR;
+ break;
+ }
+ return result;
+ }
+ long TypeIdentifier::getRefCount()
+ {
+ return theTypeIdentifier->getRefCount();
+ }
+ const std::string TypeIdentifier::getUri()
+ {
+ return std::string(theTypeIdentifier->getUri().c_str());
+ }
+ bool TypeIdentifier::isLocalNameWildcard()
+ {
+ return theTypeIdentifier->isLocalNameWildcard();
+ }
+ bool TypeIdentifier::isUriWildcard()
+ {
+ return theTypeIdentifier->isUriWildcard();
+ }
+
+
+ // STATIC METHODS
+ TypeIdentifier
+ TypeIdentifier::createAnyNodeType (IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createAnyNodeType ( convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createAttributeType( uri, uriWildcard, localNameName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createCommentType (IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createCommentType ( convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createDocumentType(contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createElementType(uri, uriWildcard, localName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createEmptyType()
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createEmptyType() );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createItemType (IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createItemType( convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createNamedType( uri, localName, convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createPIType (IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createPIType( convertQuantifier(quantifier) ) );
+ }
+
+ TypeIdentifier
+ TypeIdentifier::createTextType (IdentTypes::Quantifier quantifier)
+ {
+ return TypeIdentifier( zorba::TypeIdentifier::createTextType( convertQuantifier(quantifier) ) );
+ }
+
+ // END OF STATIC METHODS
+
+
+%} // end Implementation
+
+
+%include "TypeIdentifier.h"
=== added file 'swig/XQuery.h'
--- swig/XQuery.h 1970-01-01 00:00:00 +0000
+++ swig/XQuery.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef API_XQUERY_H
+#define API_XQUERY_H
+
+class XQuery
+{
+private:
+ zorba::XQuery_t theQuery;
+ bool closed;
+
+public:
+ XQuery():closed(false) {}
+ XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery), closed(aXQuery.closed) {}
+ XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery), closed(false) {}
+
+ std::string execute();
+ std::string printPlanAsXML();
+ std::string printPlanAsDOT();
+ void compile (const std::string &aQuery);
+ void compile (const std::string &aQuery, StaticContext &aStaticContext);
+
+#ifdef SWIGPYTHON
+ void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy);
+#endif
+
+ void destroy();
+ Iterator iterator();
+ DynamicContext getDynamicContext();
+ StaticContext getStaticContext();
+ void getExternalVariables(Iterator& vars) const;
+}; // class XQuery
+
+#endif
\ No newline at end of file
=== modified file 'swig/XQuery.i'
--- swig/XQuery.i 2011-10-17 22:42:10 +0000
+++ swig/XQuery.i 2012-01-07 02:13:25 +0000
@@ -16,332 +16,60 @@
%{ // start Implementation
-class Iterator
-{
-protected:
- friend class DynamicContext;
- zorba::Iterator_t theIterator;
- zorba::Item theItem;
- bool theConsumed;
-
-public:
- Iterator() {}
- Iterator(const Iterator& anIterator)
- : theIterator(anIterator.theIterator),
- theItem(anIterator.theItem),
- theConsumed(false)
- {}
-
- Iterator(zorba::Iterator_t anIterator)
- : theIterator(anIterator),
- theConsumed(false)
- {}
-
- Iterator(zorba::Item& aItem)
- : theIterator(0),
- theItem(aItem),
- theConsumed(false)
- {}
-
- void open()
- {
- if (theIterator)
- theIterator->open();
- theConsumed = false;
- }
-
- bool next(Item& aItem);
-
- void close()
- {
- if (theIterator)
- theIterator->close();
- theConsumed = true;
- }
-
- void destroy()
- {
- theIterator = 0;
- }
-
-}; // class Iterator
-
-
-class Item
-{
- friend class Iterator;
- friend class StaticContext;
- friend class DocumentManager;
- friend class SingletonIterator;
- friend class DynamicContext;
- friend class ItemFactory;
-
-private:
- zorba::Item theItem;
-
-public:
- Item() {}
- Item(const Item& aItem) : theItem(aItem.theItem) {}
- Item(const zorba::Item& aZItem) : theItem(aZItem) {}
-
- static Item createEmptyItem()
- { return Item(); }
-
- std::string getStringValue() const
- { return std::string(theItem.getStringValue().c_str()); }
-
- std::string serialize() const
- {
- std::stringstream lStream;
- Zorba_SerializerOptions_t lOptions;
- zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
- zorba::SingletonItemSequence lSequence(theItem);
- lSerializer->serialize(&lSequence, lStream);
- return lStream.str();
- }
-
- Iterator getAtomizationValue () const
- { return Iterator(theItem.getAtomizationValue()); }
-
- Iterator getAttributes () const
- { return Iterator(theItem.getAttributes()); }
-
- bool getBooleanValue () const
- { return theItem.getBooleanValue(); }
-
- Iterator getChildren () const
- { return Iterator(theItem.getChildren()); }
-
- Item getEBV () const
- { return Item(theItem.getEBV()); }
-
- int getIntValue () const
- { return theItem.getIntValue(); }
-
- std::string getLocalName () const
- { return std::string(theItem.getLocalName().c_str()); }
-
- std::string getNamespace () const
- { return std::string(theItem.getNamespace().c_str()); }
-
- bool getNodeName (Item &aNodeName) const
- { return theItem.getNodeName( aNodeName.theItem ); }
-
- std::string getPrefix () const
- { return std::string(theItem.getPrefix().c_str()); }
-
- Item getType () const
- { return Item( theItem.getType() ); }
-
- unsigned int getUnsignedIntValue () const
- { return theItem.getUnsignedIntValue(); }
-
- bool isAtomic () const
- { return theItem.isAtomic(); }
-
- bool isNaN () const
- { return theItem.isNaN(); }
-
- bool isNode () const
- { return theItem.isNode(); }
-
- bool isNull () const
- { return theItem.isNull(); }
-
- bool isPosOrNegInf () const
- { return theItem.isPosOrNegInf(); }
-
- int getNodeKind () const
- { return theItem.getNodeKind(); }
-
-}; // class Item
-
-class DynamicContext
-{
-private:
- zorba::DynamicContext* theContext;
-
-public:
- DynamicContext()
- : theContext(0)
- {
- }
-
- DynamicContext(const DynamicContext& aCtx)
- : theContext(aCtx.theContext)
- {
- }
-
- DynamicContext(zorba::DynamicContext* aCtx)
- : theContext(aCtx)
- {
- }
-
- void
- setVariable(
- const std::string& aNamespace,
- const std::string& aLocalname,
- Iterator aIter)
- {
- theContext->setVariable(aNamespace, aLocalname, aIter.theIterator);
- }
-
- void
- setContextItem(Item aItem)
- {
- theContext->setContextItem(aItem.theItem);
- }
-};
-
-class XQuery
-{
-private:
- zorba::XQuery_t theQuery;
-
-public:
- XQuery() {}
- XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery) {}
- XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery) {}
-
- std::string execute()
+ std::string XQuery::execute()
{
std::stringstream lStream;
lStream << theQuery;
- return lStream.str();
+ std::string str = lStream.str();
+ return str;
}
-
- void compile (const std::string &aQuery)
+
+ void XQuery::compile (const std::string &aQuery)
{
theQuery->compile(aQuery);
}
- void compile (const std::string &aQuery, StaticContext &aStaticContext )
+ void XQuery::compile (const std::string &aQuery, StaticContext &aStaticContext )
{
Zorba_CompilerHints_t hints;
theQuery->compile(aQuery, aStaticContext.theStaticContext, hints);
}
-
- std::string printPlanAsXML()
+
+ std::string XQuery::printPlanAsXML()
{
std::ostringstream lStream;
theQuery->printPlan(lStream);
return lStream.str();
}
- std::string printPlanAsDOT()
+ std::string XQuery::printPlanAsDOT()
{
std::ostringstream lStream;
theQuery->printPlan(lStream, true);
return lStream.str();
}
-
- DynamicContext
- getDynamicContext()
+
+ DynamicContext XQuery::getDynamicContext()
{
return DynamicContext(theQuery->getDynamicContext());
}
+ StaticContext XQuery::getStaticContext()
+ {
+ return StaticContext( zorba::StaticContext_t( const_cast<zorba::StaticContext *>(theQuery->getStaticContext()) ) );
+ }
+
+ void XQuery::getExternalVariables(Iterator& vars) const
+ { theQuery->getExternalVariables( vars.theIterator ); }
+
#ifdef SWIGPYTHON
- void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy)
+ void XQuery::executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy)
{ theQuery->executeSAX(contentHandlerProxy); }
#endif
- void destroy() { theQuery = 0; }
- Iterator iterator() { return Iterator(theQuery->iterator()); }
-}; // class XQuery
-
-
-// remaining method definitions from Iterator
-bool
-Iterator::next(Item& aItem)
-{
- if (theIterator)
- {
- return theIterator->next(aItem.theItem);
- }
- else
- {
- if (!theConsumed)
- {
- aItem = theItem;
- return true;
- }
- else
- {
- return false;
- }
- }
-}
-
+ void XQuery::destroy() { theQuery = 0; }
+ Iterator XQuery::iterator() { return Iterator(theQuery->iterator()); }
%} // end Implementation
-
-// Interfaces
-
-class DynamicContext
-{
-public:
- void
- setVariable(
- const std::string& aNamespace,
- const std::string& aLocalname,
- Iterator);
-
- void
- setContextItem(Item);
-};
-
-class Item
-{
-public:
- static Item createEmptyItem();
- std::string getStringValue() const;
- std::string serialize() const;
- Iterator getAtomizationValue () const;
- Iterator getAttributes () const;
- bool getBooleanValue () const;
- Iterator getChildren () const;
- Item getEBV () const;
- int getIntValue () const;
- std::string getLocalName () const;
- std::string getNamespace () const;
- bool getNodeName (Item &aNodeName) const;
- std::string getPrefix () const;
- Item getType () const;
- unsigned int getUnsignedIntValue () const;
-
- int getNodeKind() const;
- bool isAtomic () const;
- bool isNaN () const;
- bool isNode () const;
- bool isNull () const;
- bool isPosOrNegInf () const;
-}; // class Item
-
-class Iterator
-{
-public:
- void open();
- bool next(Item&);
- void close();
- void destroy();
-}; // class Iterator
-
-class XQuery
-{
-public:
- std::string execute();
- std::string printPlanAsXML();
- std::string printPlanAsDOT();
- void compile (const std::string &aQuery);
- void compile (const std::string &aQuery, StaticContext &aStaticContext);
-
-#ifdef SWIGPYTHON
- void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy);
-#endif
-
- void destroy();
- Iterator iterator();
- DynamicContext getDynamicContext();
-}; // class XQuery
+%include "XQuery.h"
\ No newline at end of file
=== added file 'swig/XmlDataManager.h'
--- swig/XmlDataManager.h 1970-01-01 00:00:00 +0000
+++ swig/XmlDataManager.h 2012-01-07 02:13:25 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef API_XML_DATA_MANAGER_H
+#define API_XML_DATA_MANAGER_H
+
+class DocumentManager
+{
+private:
+ zorba::DocumentManager* theManager;
+
+public:
+ DocumentManager() : theManager(0) {}
+ DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {}
+ DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {}
+
+ void put(const std::string& aName, Item aDoc);
+ void remove(const std::string& aName);
+ Item document(const std::string& aName);
+ bool isAvailableDocument(const std::string& aName);
+};
+
+class XmlDataManager
+{
+private:
+ zorba::XmlDataManager* theManager;
+
+public:
+ XmlDataManager() : theManager(0) {}
+ XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {}
+ XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {}
+
+ DocumentManager getDocumentManager();
+ Iterator parseXML(const std::string& aDoc);
+
+};
+#endif
\ No newline at end of file
=== modified file 'swig/XmlDataManager.i'
--- swig/XmlDataManager.i 2011-08-04 02:14:56 +0000
+++ swig/XmlDataManager.i 2012-01-07 02:13:25 +0000
@@ -15,55 +15,33 @@
*/
%{ // start Implementation
-
-
-class DocumentManager
-{
-private:
- zorba::DocumentManager* theManager;
-
-public:
- DocumentManager() : theManager(0) {}
- DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {}
- DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {}
-
- void put(const std::string& aName, Item aDoc)
+ void DocumentManager::put(const std::string& aName, Item aDoc)
{
theManager->put(aName, aDoc.theItem);
}
- void remove(const std::string& aName)
+ void DocumentManager::remove(const std::string& aName)
{
theManager->remove(aName);
}
- Item document(const std::string& aName)
+ Item DocumentManager::document(const std::string& aName)
{
return theManager->document(aName);
}
- bool isAvailableDocument(const std::string& aName)
+ bool DocumentManager::isAvailableDocument(const std::string& aName)
{
return theManager->isAvailableDocument(aName);
}
-};
-
-class XmlDataManager
-{
-private:
- zorba::XmlDataManager* theManager;
-
-public:
- XmlDataManager() : theManager(0) {}
- XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {}
- XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {}
-
- DocumentManager getDocumentManager()
+
+
+ DocumentManager XmlDataManager::getDocumentManager()
{
return DocumentManager(theManager->getDocumentManager());
}
- Iterator parseXML(const std::string& aDoc)
+ Iterator XmlDataManager::parseXML(const std::string& aDoc)
{
std::stringstream lDoc;
lDoc << aDoc;
@@ -71,28 +49,7 @@
return Iterator(lItem);
}
-};
%} // end Implementation
-class DocumentManager
-{
-public:
- void put(const std::string& aName, Item aDoc);
-
- void remove(const std::string& aName);
-
- Item document(const std::string& aName);
-
- bool isAvailableDocument(const std::string& aName);
-};
-
-
-class XmlDataManager
-{
-public:
- DocumentManager getDocumentManager();
-
- Iterator parseXML(const std::string& aDoc);
-
-}; // class XmlDataManager
+%include "XmlDataManager.h"
=== modified file 'swig/Zorba.i'
--- swig/Zorba.i 2011-10-17 22:42:10 +0000
+++ swig/Zorba.i 2012-01-07 02:13:25 +0000
@@ -15,12 +15,11 @@
{
return Zorba(zorba::Zorba::getInstance(aStore.getStore()));
}
-
ItemFactory getItemFactory()
{
return ItemFactory(theZorba->getItemFactory());
}
-
+
StaticContext createStaticContext()
{
return StaticContext(theZorba->createStaticContext());
@@ -95,6 +94,18 @@
{
theZorba->shutdown();
}
+ std::string getVersion() {
+ return zorba::Zorba::version().getVersion();
+ }
+ int getMajorVersion() {
+ return zorba::Zorba::version().getMajorVersion();
+ }
+ int getMinorVersion() {
+ return zorba::Zorba::version().getMinorVersion();
+ }
+ int getPatchVersion() {
+ return zorba::Zorba::version().getPatchVersion();
+ }
}; // class Zorba
@@ -112,7 +123,6 @@
XQuery compileQuery(const std::string& aStr);
XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext );
ItemFactory getItemFactory();
-
/*
XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler);
XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext,
@@ -122,5 +132,9 @@
*/
XmlDataManager getXmlDataManager();
void shutdown();
+ std::string getVersion();
+ int getMajorVersion();
+ int getMinorVersion();
+ int getPatchVersion();
}; // class Zorba
=== modified file 'swig/java/CMakeLists.txt'
--- swig/java/CMakeLists.txt 2011-10-12 20:56:27 +0000
+++ swig/java/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -62,6 +62,12 @@
FILE(GLOB JAVA_SWIG_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.java")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
IF ( APPLE )
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}libzorba_api.jnilib DESTINATION ${JAVA_SITEARCH_DIR})
=== modified file 'swig/php/CMakeLists.txt'
--- swig/php/CMakeLists.txt 2011-12-21 14:40:33 +0000
+++ swig/php/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -40,6 +40,12 @@
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
# The following fix was added because of the changes in CMake 2.8, which have the
# result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so"
=== modified file 'swig/php/zorba_api.i'
--- swig/php/zorba_api.i 2011-10-12 20:56:27 +0000
+++ swig/php/zorba_api.i 2012-01-07 02:13:25 +0000
@@ -15,19 +15,10 @@
*/
%begin %{
#include <iostream>
-#if defined( _MSC_VER )
-#if (_MSC_VER >= 1600)
- #define PHP_COMPILER_ID "VC10"
-#elif (_MSC_VER >= 1500)
- #define PHP_COMPILER_ID "VC9"
-#elif (_MSC_VER >= 1400)
- #define PHP_COMPILER_ID "VC8"
-#elif (_MSC_VER >= 1300)
- #define PHP_COMPILER_ID "VC7"
-#elif (_MSC_VER >= 1200)
- #define PHP_COMPILER_ID "VC6"
-#endif
-#endif
+
+// Important definition for PHP Signature
+// please review it and compare with your current version of PHP
+#define PHP_COMPILER_ID "VC9"
#if defined(_MSC_VER)
#define strtoll _strtoi64
=== modified file 'swig/python/CMakeLists.txt'
--- swig/python/CMakeLists.txt 2011-10-12 20:56:27 +0000
+++ swig/python/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -31,6 +31,13 @@
SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
+
MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH})
IF (NOT WIN32)
=== modified file 'swig/ruby/CMakeLists.txt'
--- swig/ruby/CMakeLists.txt 2011-10-27 18:01:22 +0000
+++ swig/ruby/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -52,7 +52,13 @@
#STRING(REPLACE "/usr/" "" RUBY_SITEARCH_DIR "${RUBY_SITEARCH_DIR}" )
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
-
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
+
SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby")
IF ( APPLE )
@@ -76,7 +82,6 @@
ENDIF ( LINUX )
ENDIF ( APPLE )
-
ELSE (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
MESSAGE(STATUS "SWIG Ruby: binding not generated because library and include files are not installed.")
ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
=== modified file 'swig/ruby/zorba_api.i'
--- swig/ruby/zorba_api.i 2011-09-02 19:58:59 +0000
+++ swig/ruby/zorba_api.i 2012-01-07 02:13:25 +0000
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-%include ../zorba_api.i
%runtime %{
#ifdef WIN32
@@ -23,3 +22,4 @@
#endif
%}
+%include ../zorba_api.i
=== added directory 'swig/xqj'
=== added file 'swig/xqj/CMakeLists.txt'
--- swig/xqj/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ swig/xqj/CMakeLists.txt 2012-01-07 02:13:25 +0000
@@ -0,0 +1,69 @@
+# Copyright 2006-2008 The FLWOR Foundation.n
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FIND_PACKAGE ( Java )
+INCLUDE ( ${CMAKE_SOURCE_DIR}/cmake_modules/FindJNI.cmake )
+
+STRING ( COMPARE NOTEQUAL ${JAVA_INCLUDE_PATH} "JAVA_INCLUDE_PATH-NOTFOUND" JNI_FOUND )
+
+IF (JAVA_INCLUDE_PATH)
+ INCLUDE (CMakeJavaInformation )
+ MESSAGE(STATUS "SWIG Java: Generating XQJ API")
+
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQConnection.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQConnection.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQDataSource.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQDataSource.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQExpression.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQExpression.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQItem.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQItem.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQItemType.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQItemType.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQMetaData.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQMetaData.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQPreparedExpression.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQPreparedExpression.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQResultItem.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQResultItem.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQResultSequence.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQResultSequence.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQResultSequenceScrollable.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQResultSequenceScrollable.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQSequence.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQSequence.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQSequenceType.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQSequenceType.java")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaXQStaticContext.java" "${CMAKE_CURRENT_BINARY_DIR}/ZorbaXQStaticContext.java")
+
+ MESSAGE(STATUS "SWIG Java: Generating XQJ TCK Tests")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/junit-4.9.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/junit-4.9.jar" COPYONLY)
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/xqjapi.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjapi.jar" COPYONLY)
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/xqjtck.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjtck.jar" COPYONLY)
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/zorba.properties" "${CMAKE_CURRENT_BINARY_DIR}/tck/zorba.properties" COPYONLY)
+
+ SET (XQJ_LOAD_PATH "${CMAKE_BINARY_DIR}/swig/xqj")
+ SET (JAVA_LOAD_PATH "${CMAKE_BINARY_DIR}/swig/java")
+
+ MESSAGE (STATUS "Path for XQJ tests ${XQJ_LOAD_PATH}/tck")
+ IF(WIN32)
+ #Convert to backslashes for windows
+ STRING(REGEX REPLACE "/" "\\\\" XQJ_LOAD_PATH ${XQJ_LOAD_PATH})
+ STRING(REGEX REPLACE "/" "\\\\" JAVA_LOAD_PATH ${JAVA_LOAD_PATH})
+ MESSAGE (STATUS "Copying tck batch...")
+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/tck/xqj_test.bat.in ${CMAKE_CURRENT_BINARY_DIR}/xqj_test.bat)
+ ADD_TEST ("swig_xqj" xqj_test.bat)
+ ELSE(WIN32)
+ MESSAGE (STATUS "Copying tck batch...")
+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/tck/xqj_test.sh.in ${CMAKE_CURRENT_BINARY_DIR}/xqj_test.sh)
+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/xqj_test.sh")
+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/junit-4.9.jar")
+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjapi.jar")
+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjtck.jar")
+ EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/zorba.properties")
+ ADD_TEST ("swig_xqj" xqj_test.sh)
+ ENDIF(WIN32)
+
+
+ELSE (JAVA_INCLUDE_PATH)
+ MESSAGE ( STATUS "SWIG Java: Not generating XQJ API because JNI headers not found.")
+ENDIF (JAVA_INCLUDE_PATH)
\ No newline at end of file
=== added file 'swig/xqj/ZorbaXQConnection.java'
--- swig/xqj/ZorbaXQConnection.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQConnection.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,1385 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Iterator;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQExpression;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQMetaData;
+import javax.xml.xquery.XQPreparedExpression;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQSequenceType;
+import javax.xml.xquery.XQStaticContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+import org.zorbaxquery.api.*;
+
+public class ZorbaXQConnection implements javax.xml.xquery.XQConnection {
+ private InMemoryStore store;
+ private Zorba zorba;
+ private boolean autocommit;
+ private boolean closed;
+ private Collection<XQExpression> cExpression;
+ private Collection<XQPreparedExpression> cPreparedExpression;
+ private Collection<XQMetaData> cMetadata;
+ private XQStaticContext lStaticContext;
+
+ //TODO: Rodolfo ALL CASES should return an exception("Not implemented yet")
+ protected Zorba getZorbaInstance() throws XQException {
+ if (zorba!=null) {
+ return zorba;
+ } else {
+ throw new XQException("Error returning Zorba Instance");
+ }
+ }
+
+ public ZorbaXQConnection() {
+ cExpression = new ArrayList<XQExpression>();
+ cPreparedExpression = new ArrayList<XQPreparedExpression>();
+ store = InMemoryStore.getInstance();
+ zorba = Zorba.getInstance ( store );
+ autocommit = true;
+ closed = false;
+ }
+
+
+ @Override
+ public void close() throws XQException {
+ if (closed) return; // already closed
+ try {
+ for (XQExpression exp : cExpression ){
+ exp.close(); // Notify the dependents objects to close
+ }
+ for (XQPreparedExpression exp : cPreparedExpression ){
+ exp.close(); // Notify the dependents objects to close
+ }
+ } catch (XQException e) {
+ throw new XQException("Error closing connection: " + e.getLocalizedMessage());
+ }
+
+ if (lStaticContext != null ) {
+ ((ZorbaXQStaticContext)lStaticContext).getZorbaStaticContext().destroy();
+ }
+ zorba.shutdown();
+ InMemoryStore.shutdown ( store );
+ closed = true;
+ }
+
+ @Override
+ public void setAutoCommit(boolean bln) throws XQException {
+ isClosedXQException();
+ autocommit = bln;
+ }
+
+ @Override
+ public boolean getAutoCommit() throws XQException {
+ isClosedXQException();
+ return autocommit;
+ }
+
+ @Override
+ public void commit() throws XQException {
+ isClosedXQException();
+ throw new UnsupportedOperationException("Zorba does not support transactions... yet...");
+ /*
+ if (!autocommit) {
+ try {
+ query.execute();
+ } catch (Exception e) {
+ throw new XQException("Error executing query");
+ }
+ } else {
+ throw new XQException("Autocommit was specified");
+ }
+
+ */
+ }
+
+ @Override
+ public XQExpression createExpression() throws XQException {
+ isClosedXQException();
+ XQExpression expression;
+ if (lStaticContext == null) {
+ expression = new ZorbaXQExpression(this);
+ } else {
+ expression = new ZorbaXQExpression(this, lStaticContext);
+ }
+ cExpression.add(expression);
+ return expression;
+ }
+
+ @Override
+ public XQExpression createExpression(XQStaticContext value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ XQExpression expression = new ZorbaXQExpression(this, value);
+ cExpression.add(expression);
+ return expression;
+ }
+
+ @Override
+ public XQMetaData getMetaData() throws XQException {
+ isClosedXQException();
+ return new ZorbaXQMetaData(this);
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public XQPreparedExpression prepareExpression(String value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ XQPreparedExpression expression;
+ try {
+ if (lStaticContext == null) {
+ expression = new ZorbaXQPreparedExpression(this, value);
+ } else {
+ expression = new ZorbaXQPreparedExpression(this, value, lStaticContext);
+ }
+ cPreparedExpression.add(expression);
+ } catch (Exception e) {
+ throw new XQException("Error preparing expression: "+e.getLocalizedMessage());
+ }
+ return expression;
+ }
+
+ @Override
+ public XQPreparedExpression prepareExpression(String string, XQStaticContext xqsc) throws XQException {
+ isClosedXQException();
+ isNullXQException(string);
+ isNullXQException(xqsc);
+ XQPreparedExpression expression = null;
+ try {
+ expression = new ZorbaXQPreparedExpression(this, string, xqsc);
+ cPreparedExpression.add(expression);
+ } catch (Exception e) {
+ throw new XQException("Error preparing expression");
+ }
+ return expression;
+ }
+
+ @Override
+ public XQPreparedExpression prepareExpression(Reader reader) throws XQException {
+ isClosedXQException();
+ isNullXQException(reader);
+
+ StringBuffer string = new StringBuffer();
+ CharBuffer buffer = CharBuffer.allocate(1024);
+ Writer writer = new StringWriter();
+
+ try {
+ while( reader.read(buffer) >= 0 ) {
+ buffer.flip();
+ writer.append(buffer);
+ buffer.clear();
+ }
+ reader.close();
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ XQPreparedExpression expression;
+ if (lStaticContext == null) {
+ expression = new ZorbaXQPreparedExpression(this, writer.toString());
+ } else {
+ expression = new ZorbaXQPreparedExpression(this, writer.toString(), lStaticContext);
+ }
+ cPreparedExpression.add(expression);
+ return expression;
+ }
+
+ @Override
+ public XQPreparedExpression prepareExpression(Reader reader, XQStaticContext xqsc) throws XQException {
+ isClosedXQException();
+ isNullXQException(reader);
+ isNullXQException(xqsc);
+ StringBuffer string = new StringBuffer();
+ CharBuffer buffer = CharBuffer.allocate(1024);
+ Writer writer = new StringWriter();
+ try {
+ while( reader.read(buffer) >= 0 ) {
+ buffer.flip();
+ writer.append(buffer);
+ buffer.clear();
+ }
+ reader.close();
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ XQPreparedExpression expression = new ZorbaXQPreparedExpression(this, writer.toString(), xqsc);
+
+ cPreparedExpression.add(expression);
+ return expression;
+ }
+
+ @Override
+ public XQPreparedExpression prepareExpression(InputStream in) throws XQException {
+ isClosedXQException();
+ isNullXQException(in);
+ StringBuffer out = new StringBuffer ();
+ try {
+ byte[] b = new byte[4096];
+ for (int n; (n = in.read(b)) != -1;) {
+ out.append(new String(b, 0, n));
+ }
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ XQPreparedExpression expression;
+ if (lStaticContext == null) {
+ expression = new ZorbaXQPreparedExpression(this, out.toString());
+ } else {
+ expression = new ZorbaXQPreparedExpression(this, out.toString(), lStaticContext);
+ }
+ try {
+ cPreparedExpression.add(expression);
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ return expression;
+ }
+
+ @Override
+ public XQPreparedExpression prepareExpression(InputStream in, XQStaticContext xqsc) throws XQException {
+ isClosedXQException();
+ isNullXQException(in);
+ isNullXQException(xqsc);
+ StringBuffer out = new StringBuffer ();
+ try {
+ byte[] b = new byte[4096];
+ for (int n; (n = in.read(b)) != -1;) {
+ out.append(new String(b, 0, n));
+ }
+ } catch (IOException ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ XQPreparedExpression expression = null;
+ try {
+ expression = new ZorbaXQPreparedExpression(this, out.toString(), xqsc);
+ cPreparedExpression.add(expression);
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+ return expression;
+ }
+
+ @Override
+ public void rollback() throws XQException {
+ throw new UnsupportedOperationException("Zorba does not support transactions... yet...");
+ }
+
+ @Override
+ public XQStaticContext getStaticContext() throws XQException {
+ isClosedXQException();
+ lStaticContext = new ZorbaXQStaticContext(zorba.createStaticContext());
+ return lStaticContext;
+ }
+
+ @Override
+ public void setStaticContext(XQStaticContext xqsc) throws XQException {
+ isClosedXQException();
+ isNullXQException(xqsc);
+ if ((lStaticContext!=null) && (lStaticContext!=xqsc)) { // delete previous static context
+ ((ZorbaXQStaticContext)lStaticContext).getZorbaStaticContext().delete();
+ }
+ lStaticContext = xqsc;
+ }
+
+ @Override
+ public XQItem createItemFromAtomicValue(String value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ isNullXQException(type);
+ if (type.getItemKind()!=XQItemType.XQITEMKIND_ATOMIC) {
+ throw new XQException("ItemType is not Atomic");
+ }
+ XQItem item = null;
+ try {
+ item = this.createItemFromString(value, type);
+ } catch (Exception e) {
+ throw new XQException("Error creating item of this type " + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromString(String value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ if (type==null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_STRING);
+ }
+ ItemFactory itemFactory = zorba.getItemFactory();
+ XQItem item = null;
+ try {
+ switch (type.getBaseType()) {
+ case XQItemType.XQBASETYPE_BOOLEAN:
+ item = new ZorbaXQItem(itemFactory.createBoolean(Boolean.parseBoolean(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_ANYURI:
+ item = new ZorbaXQItem(itemFactory.createAnyURI(value), type);
+ break;
+ case XQItemType.XQBASETYPE_BASE64BINARY:
+ item = new ZorbaXQItem(itemFactory.createBase64Binary(value, value.length()), type);
+ break;
+ case XQItemType.XQBASETYPE_BYTE:
+ item = new ZorbaXQItem(itemFactory.createByte(value.charAt(0)), type);
+ break;
+ case XQItemType.XQBASETYPE_DATE:
+ item = new ZorbaXQItem(itemFactory.createDate(value), type);
+ break;
+ case XQItemType.XQBASETYPE_DATETIME:
+ item = new ZorbaXQItem(itemFactory.createDateTime(value), type);
+ break;
+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+ item = new ZorbaXQItem(itemFactory.createDuration(value), type);
+ break;
+ case XQItemType.XQBASETYPE_DECIMAL:
+ BigDecimal dec = new BigDecimal(value);
+ item = new ZorbaXQItem(itemFactory.createDecimal(value), type);
+ break;
+ case XQItemType.XQBASETYPE_DOUBLE:
+ item = new ZorbaXQItem(itemFactory.createDouble(Double.parseDouble(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_DURATION:
+ item = new ZorbaXQItem(itemFactory.createDuration(value), type);
+ break;
+ case XQItemType.XQBASETYPE_FLOAT:
+ item = new ZorbaXQItem(itemFactory.createFloat(value), type);
+ break;
+ case XQItemType.XQBASETYPE_GDAY:
+ item = new ZorbaXQItem(itemFactory.createGDay(value), type);
+ break;
+ case XQItemType.XQBASETYPE_GMONTH:
+ item = new ZorbaXQItem(itemFactory.createGMonth(value), type);
+ break;
+ case XQItemType.XQBASETYPE_GMONTHDAY:
+ item = new ZorbaXQItem(itemFactory.createGMonthDay(value), type);
+ break;
+ case XQItemType.XQBASETYPE_GYEAR:
+ item = new ZorbaXQItem(itemFactory.createGYear(value), type);
+ break;
+ case XQItemType.XQBASETYPE_GYEARMONTH:
+ item = new ZorbaXQItem(itemFactory.createGYearMonth(value), type);
+ break;
+ case XQItemType.XQBASETYPE_HEXBINARY:
+ item = new ZorbaXQItem(itemFactory.createHexBinary(value, value.length()), type);
+ break;
+ case XQItemType.XQBASETYPE_INT:
+ item = new ZorbaXQItem(itemFactory.createInt(Integer.parseInt(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createInteger(Integer.parseInt(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_LONG:
+ item = new ZorbaXQItem(itemFactory.createLong(Long.parseLong(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_NCNAME:
+ item = new ZorbaXQItem(itemFactory.createNCName(value), type);
+ break;
+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNegativeInteger(Long.parseLong(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNonNegativeInteger(new BigInteger(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNonPositiveInteger(Long.parseLong(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createPositiveInteger(new BigInteger(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_QNAME:
+ item = new ZorbaXQItem(itemFactory.createQName(value), type);
+ break;
+ case XQItemType.XQBASETYPE_SHORT:
+ item = new ZorbaXQItem(itemFactory.createShort(Short.parseShort(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_STRING:
+ item = new ZorbaXQItem(itemFactory.createString(value), type);
+ break;
+ case XQItemType.XQBASETYPE_TIME:
+ item = new ZorbaXQItem(itemFactory.createTime(value), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+ item = new ZorbaXQItem(itemFactory.createUnsignedByte(Short.parseShort(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
+ item = new ZorbaXQItem(itemFactory.createUnsignedInt(Long.parseLong(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+ item = new ZorbaXQItem(itemFactory.createUnsignedLong(new BigInteger(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+ item = new ZorbaXQItem(itemFactory.createUnsignedShort(Integer.parseInt(value)), type);
+ break;
+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+ item = new ZorbaXQItem(itemFactory.createDuration(value), type);
+ break;
+ // TODO: revisit this posibilities
+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+ case XQItemType.XQBASETYPE_ENTITY:
+ case XQItemType.XQBASETYPE_ENTITIES:
+ case XQItemType.XQBASETYPE_ANYTYPE:
+ case XQItemType.XQBASETYPE_LANGUAGE:
+ case XQItemType.XQBASETYPE_ID:
+ case XQItemType.XQBASETYPE_IDREF:
+ case XQItemType.XQBASETYPE_IDREFS:
+ case XQItemType.XQBASETYPE_NAME:
+ case XQItemType.XQBASETYPE_NMTOKEN:
+ case XQItemType.XQBASETYPE_NMTOKENS:
+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+ case XQItemType.XQBASETYPE_NOTATION:
+ case XQItemType.XQBASETYPE_TOKEN:
+ case XQItemType.XQBASETYPE_UNTYPED:
+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+ throw new UnsupportedOperationException("Not supported yet.");
+ default:
+
+ item = new ZorbaXQItem(itemFactory.createString(value), type);
+ break;
+ }
+ } catch (Exception e) {
+ throw new XQException ("Error parsing value" + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromDocument(String value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ if (type!=null) {
+ if ( ! ((type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_ELEMENT)||(type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT)) ) {
+ throw new XQException("Invalid type");
+ }
+ } else {
+ type = this.createElementType(null, XQItemType.XQBASETYPE_UNTYPED);
+ }
+
+ XmlDataManager dm = null;
+ Item doc = null;
+ XQItem item = null;
+ try {
+ dm = zorba.getXmlDataManager();
+ doc = new Item();
+ org.zorbaxquery.api.Iterator iterator = dm.parseXML(value);
+ iterator.open();
+ iterator.next(doc);
+ iterator.close();
+ iterator.delete();
+ item = new ZorbaXQItem(doc);
+ } catch (Exception e) {
+ throw new XQException("Error creating Item" + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromDocument(Reader value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+
+ StringBuffer string = new StringBuffer();
+ CharBuffer buffer = CharBuffer.allocate(1024);
+ Writer writer = new StringWriter();
+
+ try {
+ while( value.read(buffer) >= 0 ) {
+ buffer.flip();
+ writer.append(buffer);
+ buffer.clear();
+ }
+ value.close();
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ XQItem item = createItemFromDocument(writer.toString(), baseURI, type);
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromDocument(InputStream value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ // TODO: Rodolfo: optimize this, not good to have a string
+ StringBuffer out = new StringBuffer ();
+ try {
+ byte[] b = new byte[4096];
+ for (int n; (n = value.read(b)) != -1;) {
+ out.append(new String(b, 0, n));
+ }
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+ XQItem item = createItemFromDocument(out.toString(), baseURI, type);
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromDocument(XMLStreamReader value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t;
+ StAXSource source;
+ StAXResult result;
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ Writer writer = new StringWriter();
+ try {
+ XMLStreamWriter xmlStreamWriter = xof.createXMLStreamWriter(writer);
+ t = tf.newTransformer();
+ source = new StAXSource(value);
+ result = new StAXResult(xmlStreamWriter);
+ t.transform(source, result);
+ } catch (Exception ex) {
+ throw new XQException("Error transforming xml expression" + ex.getLocalizedMessage());
+ }
+ XQItem item = createItemFromDocument(writer.toString(), "", type);
+ return item;
+ }
+
+ private String nodeToString(Node node) {
+ StringWriter sw = new StringWriter();
+ try {
+ Transformer t = TransformerFactory.newInstance().newTransformer();
+ t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ t.transform(new DOMSource(node), new StreamResult(sw));
+ } catch (TransformerException te) {
+ System.out.println("nodeToString Transformer Exception" + te.getLocalizedMessage());
+ }
+ return sw.toString();
+ }
+
+ @Override
+ public XQItem createItemFromDocument(Source value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ XQItem item = null;
+ if (value instanceof StreamSource) {
+ item = createItemFromDocument(((StreamSource)value).getReader(), "", type);
+ } else if (value instanceof SAXSource) {
+ item = createItemFromDocument(((SAXSource)value).getInputSource().getByteStream(), "", type);
+ } else if (value instanceof DOMSource) {
+ item = createItemFromDocument( nodeToString(((DOMSource)value).getNode()), "", type);
+ } else {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ return item;
+
+ }
+
+ @Override
+ public XQItem createItemFromObject(Object value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ if (value instanceof XQItem) {
+ return (XQItem)value;
+ }
+
+ ItemFactory itemFactory = zorba.getItemFactory();
+ XQItem item = null;
+ if (type==null) {
+
+ if (value instanceof Boolean) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BOOLEAN);
+ } else if (value instanceof Byte) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BYTE);
+ } else if (value instanceof Float) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_FLOAT);
+ } else if (value instanceof Double) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DOUBLE);
+ } else if (value instanceof Integer) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INT);
+ } else if (value instanceof Long) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_LONG);
+ } else if (value instanceof Short) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_SHORT);
+ } else if (value instanceof String) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_STRING);
+ } else if (value instanceof BigDecimal) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DECIMAL);
+ } else if (value instanceof BigInteger) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INTEGER);
+ } else if (value instanceof Duration) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DURATION);
+ } else if (value instanceof XMLGregorianCalendar) {
+ QName schType = ((XMLGregorianCalendar)value).getXMLSchemaType();
+ if (schType.equals(DatatypeConstants.GDAY)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GDAY);
+ } else if (schType.equals(DatatypeConstants.GMONTHDAY)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GMONTHDAY);
+ } else if (schType.equals(DatatypeConstants.GMONTH)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GMONTH);
+ } else if (schType.equals(DatatypeConstants.GYEAR)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GYEAR);
+ } else if (schType.equals(DatatypeConstants.GYEARMONTH)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GYEARMONTH);
+ } else if (schType.equals(DatatypeConstants.DATETIME)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DATETIME);
+ } else if (schType.equals(DatatypeConstants.DATE)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DATE);
+ } else if (schType.equals(DatatypeConstants.TIME)) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_TIME);
+ }
+ } else if (value instanceof QName) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_QNAME);
+ } else if (value instanceof Document) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_DOCUMENT);
+ } else if (value instanceof DocumentFragment) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_DOCUMENT);
+ } else if (value instanceof Element){
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ELEMENT);
+ } else if (value instanceof Attr) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATTRIBUTE);
+ } else if (value instanceof Comment) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_COMMENT);
+ } else if (value instanceof ProcessingInstruction) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_PI);
+ } else if (value instanceof Text) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_TEXT);
+ } else {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC);
+ }
+ }
+ try {
+ switch (type.getItemKind()) {
+ case XQItemType.XQITEMKIND_ATOMIC:
+ switch (type.getBaseType()) {
+ case XQItemType.XQBASETYPE_BOOLEAN:
+ item = new ZorbaXQItem(itemFactory.createBoolean((Boolean)value), type);
+ break;
+ case XQItemType.XQBASETYPE_ANYURI:
+ item = new ZorbaXQItem(itemFactory.createAnyURI(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_BASE64BINARY:
+ item = new ZorbaXQItem(itemFactory.createBase64Binary(value.toString(), (value.toString()).length()), type);
+ break;
+ case XQItemType.XQBASETYPE_BYTE:
+ if (value instanceof Byte) {
+ byte tmpByte = ((Byte)value).byteValue();
+ item = new ZorbaXQItem(itemFactory.createByte((char)tmpByte), type);
+ } else {
+ item = new ZorbaXQItem(itemFactory.createByte((value.toString()).charAt(0)), type);
+ }
+ break;
+ case XQItemType.XQBASETYPE_DATE:
+ item = new ZorbaXQItem(itemFactory.createDate(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_DATETIME:
+ if (value.toString().contains(":")) {
+ item = new ZorbaXQItem(itemFactory.createDateTime(value.toString()), type);
+ } else {
+ item = new ZorbaXQItem(itemFactory.createDate(value.toString()), type);
+ }
+ break;
+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+ item = new ZorbaXQItem(itemFactory.createDuration(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_DECIMAL:
+ if (value instanceof BigDecimal) {
+ item = new ZorbaXQItem(itemFactory.createDecimal(((BigDecimal)value).toPlainString()), type);
+ } else {
+ item = new ZorbaXQItem(itemFactory.createDecimal(value.toString()), type);
+ }
+ break;
+ case XQItemType.XQBASETYPE_DOUBLE:
+ item = new ZorbaXQItem(itemFactory.createDouble(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_DURATION:
+ if (value instanceof Duration) {
+ Duration duration = (Duration)value;
+ Boolean daytime = duration.isSet(DatatypeConstants.DAYS) || duration.isSet(DatatypeConstants.HOURS) ||
+ duration.isSet(DatatypeConstants.MINUTES) || duration.isSet(DatatypeConstants.SECONDS);
+ Boolean yearmonth = duration.isSet(DatatypeConstants.YEARS) || duration.isSet(DatatypeConstants.MONTHS);
+ if (daytime && yearmonth){
+ item = new ZorbaXQItem(itemFactory.createDuration(value.toString()), type);
+ } else if (yearmonth) {
+ item = new ZorbaXQItem(itemFactory.createYearMonthDuration(value.toString()), type);
+ } else if (daytime) {
+ item = new ZorbaXQItem(itemFactory.createDayTimeDuration(value.toString()), type);
+ }
+ } else {
+ boolean yearMonth = value.toString().contains("Y") || value.toString().contains("M");
+ boolean dayTime = value.toString().contains("D") || value.toString().contains("T");
+ if (yearMonth && dayTime) {
+ item = new ZorbaXQItem(itemFactory.createDuration(value.toString()), type);
+ } else if (yearMonth) {
+ item = new ZorbaXQItem(itemFactory.createYearMonthDuration(value.toString()), type);
+ } else if (dayTime) {
+ item = new ZorbaXQItem(itemFactory.createDayTimeDuration(value.toString()), type);
+ }
+ }
+ break;
+ case XQItemType.XQBASETYPE_FLOAT:
+ item = new ZorbaXQItem(itemFactory.createFloat((Float)value), type);
+ break;
+ case XQItemType.XQBASETYPE_GDAY:
+ item = new ZorbaXQItem(itemFactory.createGDay(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_GMONTH:
+ item = new ZorbaXQItem(itemFactory.createGMonth(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_GMONTHDAY:
+ item = new ZorbaXQItem(itemFactory.createGMonthDay(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_GYEAR:
+ item = new ZorbaXQItem(itemFactory.createGYear(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_GYEARMONTH:
+ item = new ZorbaXQItem(itemFactory.createGYearMonth(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_HEXBINARY:
+ item = new ZorbaXQItem(itemFactory.createHexBinary(value.toString(), (value.toString()).length()), type);
+ break;
+ case XQItemType.XQBASETYPE_INT:
+ case XQItemType.XQBASETYPE_INTEGER:
+ if (value instanceof BigInteger) {
+ BigInteger val = (BigInteger)value;
+ item = new ZorbaXQItem(itemFactory.createInteger(val.longValue()), type);
+ } else if (value instanceof Integer) {
+ item = new ZorbaXQItem(itemFactory.createInt((Integer)value), type);
+ } else if (value instanceof String) {
+ item = new ZorbaXQItem(itemFactory.createInteger(value.toString()), type);
+ } else {
+ throw new XQException ("Error parsing integer: " + value.toString());
+ }
+ break;
+ case XQItemType.XQBASETYPE_LONG:
+ item = new ZorbaXQItem(itemFactory.createLong((Long)value), type);
+ break;
+ case XQItemType.XQBASETYPE_NCNAME:
+ item = new ZorbaXQItem(itemFactory.createNCName(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNegativeInteger((Long)value), type);
+ break;
+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNonNegativeInteger(new BigInteger(value.toString())), type);
+ break;
+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNonPositiveInteger((Long)value), type);
+ break;
+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createPositiveInteger(new BigInteger(value.toString())), type);
+ break;
+ case XQItemType.XQBASETYPE_QNAME:
+ if (value instanceof QName) {
+ QName qname = (QName) value;
+ item = new ZorbaXQItem(itemFactory.createQName(qname.getNamespaceURI(), qname.getPrefix(), qname.getLocalPart()), type);
+ } else if (value.toString().contains("{")) {
+ item = new ZorbaXQItem(itemFactory.createQName(value.toString()), type);
+ } else {
+ item = new ZorbaXQItem(itemFactory.createQName("", value.toString()), type);
+ }
+ break;
+ case XQItemType.XQBASETYPE_SHORT:
+ item = new ZorbaXQItem(itemFactory.createShort((Short)value), type);
+ break;
+ case XQItemType.XQBASETYPE_STRING:
+ item = new ZorbaXQItem(itemFactory.createString(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_TIME:
+ item = new ZorbaXQItem(itemFactory.createTime(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_TOKEN:
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+ item = new ZorbaXQItem(itemFactory.createUnsignedByte((Short)value), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
+ item = new ZorbaXQItem(itemFactory.createUnsignedInt((Long)value), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+ item = new ZorbaXQItem(itemFactory.createUnsignedLong(new BigInteger(value.toString())), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+ item = new ZorbaXQItem(itemFactory.createUnsignedShort((Integer)value), type);
+ break;
+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+ item = new ZorbaXQItem(itemFactory.createDuration(value.toString()), type);
+ break;
+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+ case XQItemType.XQBASETYPE_ANYTYPE:
+ case XQItemType.XQBASETYPE_ENTITIES:
+ case XQItemType.XQBASETYPE_ENTITY:
+ case XQItemType.XQBASETYPE_ID:
+ case XQItemType.XQBASETYPE_IDREF:
+ case XQItemType.XQBASETYPE_IDREFS:
+ case XQItemType.XQBASETYPE_LANGUAGE:
+ case XQItemType.XQBASETYPE_NAME:
+ case XQItemType.XQBASETYPE_NMTOKEN:
+ case XQItemType.XQBASETYPE_NMTOKENS:
+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+ case XQItemType.XQBASETYPE_NOTATION:
+ case XQItemType.XQBASETYPE_UNTYPED:
+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+ throw new XQException ("Base type not supported yet.");
+ default:
+ throw new XQException ("Unable to determine XQBASETYPE.");
+ }
+ break;
+ case XQItemType.XQITEMKIND_ATTRIBUTE:
+ if (value instanceof Attr){
+ Attr attribute = (Attr) value;
+ Item iEmpty = new Item();
+ Item nodeName = itemFactory.createQName(attribute.getNamespaceURI()==null?"":attribute.getNamespaceURI(),
+ attribute.getPrefix()==null?"":attribute.getPrefix(),
+ attribute.getName()==null?"":attribute.getName());
+ Item nodeValue = null;
+ if (!attribute.getValue().isEmpty()) {
+ nodeValue = itemFactory.createQName(attribute.getNamespaceURI()==null?"":attribute.getNamespaceURI(),
+ attribute.getPrefix()==null?"":attribute.getPrefix(),
+ attribute.getValue()==null?"":attribute.getValue());
+ } else {
+ nodeValue = new Item();
+ }
+ //TODO: Rodolfo: use centralized constants instead of strings
+ Item iUntyped = itemFactory.createQName("http://www.w3.org/2001/XMLSchema", "xs", "untyped");
+ Item attributeNode = itemFactory.createAttributeNode(iEmpty, nodeName, iUntyped, nodeValue);
+ item = new ZorbaXQItem(attributeNode, type);
+ }
+ break;
+ case XQItemType.XQITEMKIND_COMMENT:
+ if (value instanceof Comment){
+ Comment comment = (Comment) value;
+ Item iEmpty = new Item();
+ Item elementNode = itemFactory.createCommentNode(iEmpty, comment.getTextContent());
+ item = new ZorbaXQItem(elementNode, type);
+ } else {
+ Item iEmpty = new Item();
+ Item elementNode = itemFactory.createCommentNode(iEmpty, value.toString());
+ item = new ZorbaXQItem(elementNode, type);
+ }
+ break;
+ case XQItemType.XQITEMKIND_DOCUMENT:
+ if ((value instanceof Document) || (value instanceof DocumentFragment)){
+ DOMSource source = null;
+ if (value instanceof Document) {
+ source = new DOMSource((Document)value);
+ } else {
+ source = new DOMSource((DocumentFragment)value);
+ }
+
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ StreamResult result = new StreamResult(new StringWriter());
+
+ transformer.transform(source, result);
+ String xmlString = result.getWriter().toString();
+ Item tmpItem = new Item();
+ if (xmlString.length()>0) {
+ XmlDataManager dataManager = zorba.getXmlDataManager();
+ org.zorbaxquery.api.Iterator iter = dataManager.parseXML(xmlString);
+ iter.open();
+ iter.next(tmpItem);
+ iter.close();
+ iter.delete();
+ } else {
+ tmpItem = itemFactory.createDocumentNode("", "");
+ }
+
+ item = new ZorbaXQItem(tmpItem, type);
+ }
+
+ break;
+ case XQItemType.XQITEMKIND_ELEMENT:
+ if (value instanceof Element){
+ Element element = (Element) value;
+ Item iEmpty = new Item();
+ Item nodeName = itemFactory.createQName(element.getNamespaceURI()==null?"":element.getNamespaceURI(),
+ element.getPrefix()==null?"":element.getPrefix(),
+ element.getNodeName()==null?"":element.getNodeName());
+ Item iUntyped = itemFactory.createQName("http://www.w3.org/2001/XMLSchema", "xs", "untyped");
+ Item elementNode = itemFactory.createElementNode(iEmpty, nodeName, iUntyped, false, false);
+ item = new ZorbaXQItem(elementNode, type);
+ }
+ break;
+ case XQItemType.XQITEMKIND_PI:
+ if (value instanceof ProcessingInstruction){
+ ProcessingInstruction pi = (ProcessingInstruction) value;
+ Item iEmpty = new Item();
+ Item elementNode = itemFactory.createPiNode(iEmpty,
+ pi.getTarget(),
+ pi.getTextContent(),
+ pi.getBaseURI()==null?"":pi.getBaseURI());
+ item = new ZorbaXQItem(elementNode, type);
+ }
+ break;
+ case XQItemType.XQITEMKIND_TEXT:
+ if (value instanceof Text){
+ Text text = (Text) value;
+ Item iEmpty = new Item();
+ Item elementNode = itemFactory.createTextNode(iEmpty, text.getWholeText());
+ item = new ZorbaXQItem(elementNode, type);
+ }
+ break;
+ case XQItemType.XQITEMKIND_DOCUMENT_ELEMENT:
+ case XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
+ case XQItemType.XQITEMKIND_ITEM:
+ case XQItemType.XQITEMKIND_NODE:
+ case XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE:
+ case XQItemType.XQITEMKIND_SCHEMA_ELEMENT:
+ throw new XQException ("This item kind is currently unsupported.");
+ default:
+ throw new XQException ("Unable to determine XQITEMKIND.");
+ }
+ } catch (Exception e) {
+ throw new XQException ("Error parsing value" + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromBoolean(boolean bln, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BOOLEAN);
+ }
+ if (type.getBaseType() != XQItemType.XQBASETYPE_BOOLEAN) {
+ throw new XQException("Type is not boolean, use proper method");
+ }
+
+ XQItem item = null;
+ try {
+ ItemFactory itemFactory = zorba.getItemFactory();
+ item = new ZorbaXQItem(itemFactory.createBoolean(bln));
+ } catch (Exception e) {
+ throw new XQException("Error creating new item");
+ }
+ return item;
+ }
+
+ // This method works for Decimal and all subtypes,
+ // verifies that the type is correct and create the Item
+ private XQItem createDecimal(BigDecimal value, XQItemType type) throws XQException {
+ XQItem item = null;
+ try {
+ ItemFactory itemFactory = zorba.getItemFactory();
+ switch (type.getBaseType()) {
+ case XQItemType.XQBASETYPE_BYTE:
+ item = new ZorbaXQItem(itemFactory.createByte((char)value.byteValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createInteger(value.longValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_DECIMAL:
+ item = new ZorbaXQItem(itemFactory.createDecimalFromLong(value.longValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_INT:
+ item = new ZorbaXQItem(itemFactory.createInt(value.intValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_LONG:
+ item = new ZorbaXQItem(itemFactory.createLong(value.longValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNegativeInteger(value.longValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNonNegativeInteger(value.toBigInteger()), type);
+ break;
+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createNonPositiveInteger(value.longValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+ item = new ZorbaXQItem(itemFactory.createPositiveInteger(value.toBigInteger()), type);
+ break;
+ case XQItemType.XQBASETYPE_SHORT:
+ item = new ZorbaXQItem(itemFactory.createShort(value.shortValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+ item = new ZorbaXQItem(itemFactory.createUnsignedByte(value.shortValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
+ item = new ZorbaXQItem(itemFactory.createUnsignedInt(value.longValue()), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+ item = new ZorbaXQItem(itemFactory.createUnsignedLong(value.toBigInteger()), type);
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+ item = new ZorbaXQItem(itemFactory.createShort(value.shortValue()), type);
+ break;
+ default:
+ throw new XQException("Type is not xs:decimal or a derivate.");
+ }
+ } catch (Exception e) {
+ throw new XQException("Error creating Item: " + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromByte(byte b, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BYTE);
+ }
+ return createDecimal(new BigDecimal(b), type);
+ }
+
+ @Override
+ public XQItem createItemFromDouble(double value, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DOUBLE);
+ }
+ if (type.getBaseType() != XQItemType.XQBASETYPE_DOUBLE) {
+ throw new XQException("Type is not double, use proper method");
+ }
+ XQItem item = null;
+ try {
+ ItemFactory itemFactory = zorba.getItemFactory();
+ item = new ZorbaXQItem(itemFactory.createDouble(value), type);
+ } catch (Exception e) {
+ throw new XQException("Error Creating Item From Double" + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromFloat(float value, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_FLOAT);
+ }
+ if (type.getBaseType() != XQItemType.XQBASETYPE_FLOAT) {
+ throw new XQException("Type is not float, use proper method");
+ }
+ XQItem item = null;
+ try {
+ ItemFactory itemFactory = zorba.getItemFactory();
+ item = new ZorbaXQItem(itemFactory.createFloat(value), type);
+ } catch (Exception e) {
+ throw new XQException("Error Creating Item From Float" + e.getLocalizedMessage());
+ }
+ return item;
+ }
+
+ @Override
+ public XQItem createItemFromInt(int value, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INT);
+ }
+ switch (type.getBaseType()) {
+ case XQItemType.XQBASETYPE_BYTE:
+ case XQItemType.XQBASETYPE_SHORT:
+ throw new XQException("Can't downgrade the Base Type from an Int number");
+ default:
+ break;
+ }
+ return createDecimal(new BigDecimal(value), type);
+ }
+
+ @Override
+ public XQItem createItemFromLong(long value, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_LONG);
+ }
+ switch (type.getBaseType()) {
+ case XQItemType.XQBASETYPE_BYTE:
+ case XQItemType.XQBASETYPE_SHORT:
+ case XQItemType.XQBASETYPE_INT:
+ throw new XQException("Can't downgrade the Base Type from an Long number");
+ default:
+ break;
+ }
+ return createDecimal(new BigDecimal(value), type);
+ }
+
+ @Override
+ public XQItem createItemFromNode(Node value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+
+ XQItem result = null;
+ try {
+ result = createItemFromString(nodeToString(value), type);
+ } catch( Exception e ) {
+ throw new XQException("Error Creating Item From Node" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public XQItem createItemFromShort(short value, XQItemType type) throws XQException {
+ isClosedXQException();
+ if (type == null) {
+ type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_SHORT);
+ }
+ if (type.getBaseType()==XQItemType.XQBASETYPE_BYTE) {
+ throw new XQException("Can't create a Byte from a Short number");
+ }
+ return createDecimal(new BigDecimal(value), type);
+ }
+
+ @Override
+ public XQItem createItem(XQItem value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ if (value.isClosed()) {
+ throw new XQException("Item is closed.");
+ }
+ XQItem result = new ZorbaXQItem(value);
+ return result;
+ }
+
+ @Override
+ public XQSequence createSequence(XQSequence value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ if (value.isClosed()) {
+ throw new XQException("Sequence is closed.");
+ }
+ XQSequence result = null;
+ try {
+ result = new ZorbaXQSequence(value);
+ } catch (Exception ex) {
+ throw new XQException("Error creating sequence: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public XQSequence createSequence(Iterator value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ XQSequence result = null;
+ try {
+ result = new ZorbaXQSequence(value);
+ } catch (Exception ex) {
+ throw new XQException("Error creating sequence: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public XQItemType createAtomicType(int basetype) throws XQException {
+ isClosedXQException();
+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED) ||
+ (basetype==XQItemType.XQBASETYPE_ANYTYPE) ||
+ (basetype==XQItemType.XQBASETYPE_IDREFS) ||
+ (basetype==XQItemType.XQBASETYPE_NMTOKENS) ||
+ (basetype==XQItemType.XQBASETYPE_ENTITIES) ||
+ (basetype==XQItemType.XQBASETYPE_ANYSIMPLETYPE)) {
+ throw new XQException("Invalid base type.");
+ }
+ XQItemType type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, basetype);
+ return type;
+ }
+
+ @Override
+ public XQItemType createAtomicType(int basetype, QName qname, URI uri) throws XQException {
+ if (closed) {
+ throw new XQException("Object closed");
+ }
+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED) ||
+ (basetype==XQItemType.XQBASETYPE_ANYTYPE) ||
+ (basetype==XQItemType.XQBASETYPE_IDREFS) ||
+ (basetype==XQItemType.XQBASETYPE_NMTOKENS) ||
+ (basetype==XQItemType.XQBASETYPE_ENTITIES) ||
+ (basetype==XQItemType.XQBASETYPE_ANYSIMPLETYPE)) {
+ throw new XQException("Invalid base type.");
+ }
+ XQItemType type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ATOMIC, qname, basetype, uri);
+ return type;
+ }
+
+ @Override
+ public XQItemType createAttributeType(QName nodename, int basetype) throws XQException {
+ isClosedXQException();
+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED)||(basetype==XQItemType.XQBASETYPE_ANYTYPE)) {
+ throw new XQException("Base Type can't be XQItemType.XQBASETYPE_UNTYPED or XQItemType.XQBASETYPE_ANYTYPE");
+ }
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_ATTRIBUTE, nodename, basetype);
+ }
+
+ @Override
+ public XQItemType createAttributeType(QName nodename, int basetype, QName typename, URI schemaURI) throws XQException {
+ isClosedXQException();
+ if ((basetype==XQItemType.XQBASETYPE_UNTYPED)||(basetype==XQItemType.XQBASETYPE_ANYTYPE)) {
+ throw new XQException("Base Type can't be XQItemType.XQBASETYPE_UNTYPED or XQItemType.XQBASETYPE_ANYTYPE");
+ }
+ if ((schemaURI!=null) && (typename==null)) {
+ throw new XQException("If Schema URI is specified, Base Type must be also specified");
+ }
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_ATTRIBUTE, nodename, basetype, typename, schemaURI, true);
+ }
+
+ @Override
+ public XQItemType createSchemaAttributeType(QName nodename, int basetype, URI uri) throws XQException {
+ isClosedXQException();
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE, nodename, basetype, uri);
+ }
+
+ @Override
+ public XQItemType createCommentType() throws XQException {
+ isClosedXQException();
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_COMMENT);
+ }
+
+ @Override
+ public XQItemType createDocumentElementType(XQItemType elementType) throws XQException {
+ isClosedXQException();
+ isNullXQException(elementType);
+ if (elementType.getItemKind()!=XQItemType.XQITEMKIND_ELEMENT) {
+ throw new XQException("Item Kind must be XQItemType.XQITEMKIND_ELEMENT");
+ }
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), elementType.getBaseType(), elementType.getSchemaURI());
+ }
+
+ @Override
+ public XQItemType createDocumentSchemaElementType(XQItemType elementType) throws XQException {
+ isClosedXQException();
+ if (elementType.getItemKind()!=XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) {
+ throw new XQException("Item Kind must be XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT");
+ }
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), elementType.getBaseType(), elementType.getSchemaURI());
+ }
+
+ @Override
+ public XQItemType createDocumentType() throws XQException {
+ isClosedXQException();
+ return new ZorbaXQItemType(XQItemType.XQITEMKIND_DOCUMENT);
+ }
+
+ @Override
+ public XQItemType createElementType(QName nodename, int baseType) throws XQException {
+ isClosedXQException();
+ XQItemType item = new ZorbaXQItemType(XQItemType.XQITEMKIND_ELEMENT, nodename, baseType);
+ return item;
+ }
+
+ @Override
+ public XQItemType createElementType(QName nodename, int baseType, QName typename, URI schemaURI, boolean allowNill) throws XQException {
+ isClosedXQException();
+ XQItemType item = new ZorbaXQItemType(XQItemType.XQITEMKIND_ELEMENT, nodename, baseType, typename, schemaURI, allowNill);
+ return item;
+ }
+
+ @Override
+ public XQItemType createSchemaElementType(QName nodename, int baseType, URI schemaURI) throws XQException {
+ isClosedXQException();
+ XQItemType item = new ZorbaXQItemType(XQItemType.XQITEMKIND_SCHEMA_ELEMENT, nodename, baseType, schemaURI);
+ return item;
+ }
+
+ @Override
+ public XQItemType createItemType() throws XQException {
+ isClosedXQException();
+ XQItemType type = new ZorbaXQItemType(XQItemType.XQITEMKIND_ITEM);
+ return type;
+ }
+
+ @Override
+ public XQItemType createNodeType() throws XQException {
+ isClosedXQException();
+ XQItemType type = new ZorbaXQItemType(XQItemType.XQITEMKIND_NODE);
+ return type;
+ }
+
+ @Override
+ public XQItemType createProcessingInstructionType(String piTarget) throws XQException {
+ isClosedXQException();
+ XQItemType type = new ZorbaXQItemType(XQItemType.XQITEMKIND_PI, piTarget);
+ return type;
+ }
+
+ @Override
+ public XQSequenceType createSequenceType(XQItemType item, int occurence) throws XQException {
+ isClosedXQException();
+ if ( ((item==null) && (occurence != XQSequenceType.OCC_EMPTY)) || ((item!=null) && (occurence == XQSequenceType.OCC_EMPTY))) {
+ throw new XQException("Item is null");
+ }
+ if (!((occurence == XQSequenceType.OCC_ZERO_OR_ONE) ||
+ (occurence == XQSequenceType.OCC_EXACTLY_ONE) ||
+ (occurence == XQSequenceType.OCC_ZERO_OR_MORE) ||
+ (occurence == XQSequenceType.OCC_ONE_OR_MORE) ||
+ (occurence == XQSequenceType.OCC_EMPTY))) {
+ throw new XQException("Occurence must be from: OCC_ZERO_OR_ONE, OCC_EXACTLY_ONE, OCC_ZERO_OR_MORE, OCC_ONE_OR_MORE, OCC_EMPTY ");
+ }
+
+ XQSequenceType result = new ZorbaXQSequenceType(item, occurence);
+ return result;
+ }
+
+ @Override
+ public XQItemType createTextType() throws XQException {
+ isClosedXQException();
+ XQItemType type = new ZorbaXQItemType(XQItemType.XQITEMKIND_TEXT);
+ return type;
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This connection is closed");
+ }
+ }
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+}
=== added file 'swig/xqj/ZorbaXQDataSource.java'
--- swig/xqj/ZorbaXQDataSource.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQDataSource.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.util.Enumeration;
+import java.util.Properties;
+import javax.xml.xquery.*;
+
+public class ZorbaXQDataSource implements XQDataSource {
+
+ static {
+ System.loadLibrary ( "zorba_api" );
+ }
+
+ private int loginTimeout;
+ protected PrintWriter logWriter;
+ private Properties properties = new Properties();
+ private String[] propertiesAllowed = {"username", "password"};
+ public ZorbaXQDataSource() {
+ }
+
+
+ @Override
+ public XQConnection getConnection() throws XQException {
+ XQConnection conn;
+ try {
+ conn = new ZorbaXQConnection();
+ } catch ( Exception e ) {
+ throw new XQException("Error creating new Zorba Connection Instance");
+ }
+ return conn;
+ }
+
+ @Override
+ public XQConnection getConnection(Connection cnctn) throws XQException {
+ /* Attempts to create a connection to an XML datasource using an
+ * existing JDBC connection. An XQJ implementation is not required
+ * to support this method. If it is not supported, then an
+ * exception (XQException) is thrown. The XQJ and JDBC connections
+ * will operate under the same transaction context.
+ * */
+ throw new XQException("Connection to an XML datasource using an existing JDBC connection is not supported.");
+ }
+
+ @Override
+ public XQConnection getConnection(String username, String passwd) throws XQException {
+ XQConnection conn;
+ try {
+ conn = new ZorbaXQConnection();
+ } catch ( Exception e ) {
+ throw new XQException("Error creating new Zorba Connection Instance");
+ }
+ return conn;
+ }
+
+ @Override
+ public int getLoginTimeout() throws XQException {
+ return loginTimeout;
+ }
+
+ @Override
+ public PrintWriter getLogWriter() throws XQException {
+ return logWriter;
+ }
+
+ @Override
+ public String[] getSupportedPropertyNames() {
+ return propertiesAllowed;
+ }
+
+ @Override
+ public void setProperty(String name, String value) throws XQException {
+ if (name==null) {
+ throw new XQException("Property name is null.");
+ }
+ boolean allowed = false;
+ for(int i=0; i<propertiesAllowed.length; i++) {
+ if (propertiesAllowed[i].equals(name)) {
+ allowed = true;
+ }
+ }
+ if (allowed) {
+ properties.setProperty(name, value);
+ } else {
+ throw new XQException("Property not allowed.");
+ }
+ }
+
+ @Override
+ public String getProperty(String name) throws XQException {
+ if (name==null) {
+ throw new XQException("Property name is null.");
+ }
+ boolean allowed = false;
+ for(int i=0; i<propertiesAllowed.length; i++) {
+ if (propertiesAllowed[i].equals(name)) {
+ allowed = true;
+ }
+ }
+ if (!allowed) {
+ throw new XQException("Property name not supported.");
+ }
+ return properties.getProperty(name);
+ }
+
+ @Override
+ public void setProperties(Properties prprts) throws XQException {
+ if (prprts==null) {
+ throw new XQException("Properties are null.");
+ }
+ boolean allowed = false;
+ String tmpstr = null;
+ Enumeration em = prprts.keys();
+ while (em.hasMoreElements()) {
+ allowed = false;
+ tmpstr = (String)em.nextElement();
+ for (int i=0; i<propertiesAllowed.length; i++) {
+ if (propertiesAllowed[i].equals(tmpstr)) {
+ allowed = true;
+ }
+ }
+ if (!allowed) {
+ throw new XQException("Property [" + tmpstr + "] not allowed");
+ }
+ }
+
+ em = prprts.keys();
+ while (em.hasMoreElements()) {
+ tmpstr = (String)em.nextElement();
+ properties.setProperty(tmpstr, prprts.getProperty(tmpstr));
+ }
+
+ }
+
+ @Override
+ public void setLoginTimeout(int i) throws XQException {
+ loginTimeout = i;
+ }
+
+ @Override
+ public void setLogWriter(PrintWriter writer) throws XQException {
+ logWriter = writer;
+ }
+
+}
=== added file 'swig/xqj/ZorbaXQExpression.java'
--- swig/xqj/ZorbaXQExpression.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQExpression.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,460 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQResultSequence;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQStaticContext;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQConstants;
+import org.w3c.dom.Node;
+import org.zorbaxquery.api.DynamicContext;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.XQuery;
+
+public class ZorbaXQExpression implements javax.xml.xquery.XQExpression {
+
+ //private XQuery query;
+ private XQConnection connection;
+ private boolean closed = false;
+ private boolean cancel = false;
+ private Collection<XQResultSequence> resultSequences = new ArrayList<XQResultSequence>();
+ private XQStaticContext staticContext;
+ private Map<String, Item> itemsToBind = new HashMap<String, Item>();
+ private TimeZone implicitTimeZone;
+
+ public ZorbaXQExpression (XQConnection conn) throws XQException {
+ if (conn.isClosed()) {
+ throw new XQException ("Connection is closed");
+ }
+ connection = conn;
+ }
+
+ public ZorbaXQExpression (XQConnection conn, XQStaticContext sc) throws XQException {
+ if (conn.isClosed()) {
+ throw new XQException ("Connection is closed");
+ }
+ connection = conn;
+ staticContext = sc;
+ }
+
+ @Override
+ public void cancel() throws XQException {
+ isClosedXQException();
+ cancel = true;
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public void close() throws XQException {
+ closed=true;
+// if (query!=null) {
+// query.destroy();
+// }
+ for (XQResultSequence rs: resultSequences) {
+ rs.close();
+ }
+ }
+
+ @Override
+ public void executeCommand(String string) throws XQException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void executeCommand(Reader reader) throws XQException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public XQResultSequence executeQuery(String value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ XQuery query = ((ZorbaXQConnection)connection).getZorbaInstance().createQuery();
+ XQResultSequence result = null;
+ try {
+ int scrollable = XQConstants.SCROLLTYPE_FORWARD_ONLY;
+ if (staticContext!=null) {
+ query.compile(value, ((ZorbaXQStaticContext)staticContext).getZorbaStaticContext());
+ scrollable = staticContext.getScrollability();
+ } else {
+ query.compile(value);
+ }
+ DynamicContext dynamicContext = query.getDynamicContext();
+ if (implicitTimeZone!=null) {
+ dynamicContext.setImplicitTimezone((implicitTimeZone.getRawOffset()/60000));
+ implicitTimeZone=null;
+ }
+ for (String key: itemsToBind.keySet()){
+ dynamicContext.setVariable(key, itemsToBind.get(key) );
+ //itemsToBind.remove(key);
+ }
+ if (scrollable == XQConstants.SCROLLTYPE_FORWARD_ONLY) {
+ result = new ZorbaXQResultSequence(connection, query, false);
+ } else {
+ result = new ZorbaXQResultSequenceScrollable(connection, query, false);
+ }
+ resultSequences.add(result);
+ } catch (Exception e) {
+ throw new XQException ("Error executing query: " + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public XQResultSequence executeQuery(Reader value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+
+ StringBuffer string = new StringBuffer();
+ CharBuffer buffer = CharBuffer.allocate(1024);
+ Writer writer = new StringWriter();
+
+ try {
+ while( value.read(buffer) >= 0 ) {
+ buffer.flip();
+ writer.append(buffer);
+ buffer.clear();
+ }
+ value.close();
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ return executeQuery(writer.toString());
+ }
+
+ @Override
+ public XQResultSequence executeQuery(InputStream value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ StringBuffer out = new StringBuffer ();
+ try {
+ byte[] b = new byte[4096];
+ for (int n; (n = value.read(b)) != -1;) {
+ out.append(new String(b, 0, n));
+ }
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+ return executeQuery(out.toString());
+ }
+
+ @Override
+ public XQStaticContext getStaticContext() throws XQException {
+ isClosedXQException();
+ if (staticContext==null) {
+ return connection.getStaticContext();
+ } else {
+ return staticContext;
+ }
+ }
+
+ @Override
+ public TimeZone getImplicitTimeZone() throws XQException {
+ isClosedXQException();
+ if (implicitTimeZone!=null) {
+ return implicitTimeZone;
+ }
+ // dummy query
+// boolean queryIsNull = (query==null);
+// if (queryIsNull) {
+ XQuery query = ((ZorbaXQConnection)connection).getZorbaInstance().compileQuery("1");
+// }
+ DynamicContext dc = query.getDynamicContext();
+ Integer timeZone = (dc.getImplicitTimezone()/60); // in minutes
+ TimeZone result = TimeZone.getTimeZone("GMT"+timeZone.toString());
+// if (queryIsNull) {
+// query = null;
+// }
+ return result;
+ }
+
+ @Override
+ public void bindAtomicValue(QName varName, String value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromAtomicValue(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindString(QName varName, String value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromString(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDocument(QName varName, String value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromDocument(value, baseURI, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDocument(QName varName, Reader value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromDocument(value, baseURI, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDocument(QName varName, InputStream value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromDocument(value, baseURI, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDocument(QName varName, XMLStreamReader value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromDocument(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDocument(QName varName, Source value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromDocument(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void setImplicitTimeZone(TimeZone value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ try {
+ implicitTimeZone = value;
+ } catch (Exception e) {
+ throw new XQException("Error setting implicit TimeZone: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindItem(QName varName, XQItem value) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)value).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindSequence(QName varName, XQSequence value) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ Item item = new Item(((ZorbaXQItem)value.getItem()).getZorbaItem());
+ itemsToBind.put(varName.getLocalPart(), item);
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindObject(QName varName, Object value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = null;
+ if (value instanceof XQItem) {
+ item = (XQItem)value;
+ } else {
+ item = connection.createItemFromObject(value, type);
+ }
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindBoolean(QName varName, boolean value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromBoolean(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindByte(QName varName, byte value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromByte(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDouble(QName varName, double value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromDouble(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindFloat(QName varName, float value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromFloat(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindInt(QName varName, int value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromInt(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindLong(QName varName, long value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromLong(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindNode(QName varName, Node value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ try {
+ XQItem item = connection.createItemFromNode(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindShort(QName varName, short value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ try {
+ XQItem item = connection.createItemFromShort(value, type);
+ itemsToBind.put(varName.getLocalPart(),((ZorbaXQItem)item).getZorbaItem());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This expression is closed");
+ }
+ }
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+
+}
=== added file 'swig/xqj/ZorbaXQItem.java'
--- swig/xqj/ZorbaXQItem.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQItem.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,609 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.AttributesImpl;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+
+class ZorbaXQItem implements XQItem {
+
+ private Item item;
+ private boolean closed=false;
+ private XQItemType itemType;
+
+ protected Item getZorbaItem() {
+ return item;
+ }
+
+ public ZorbaXQItem(XQItemType itemType) {
+ this.itemType = itemType;
+ }
+
+ public ZorbaXQItem(Item item) {
+ this.item = new Item(item);
+ this.itemType = new ZorbaXQItemType(this.item);
+ }
+
+ public ZorbaXQItem(Item item, XQItemType itemType) {
+ this.item = new Item(item);
+ this.itemType = itemType;
+ }
+
+ public ZorbaXQItem(XQItem item) throws XQException {
+ this.item = new Item(((ZorbaXQItem)item).getZorbaItem());
+ this.itemType = item.getItemType();
+ }
+
+ @Override
+ public void close() throws XQException {
+ if (!closed) {
+ item.close();
+ item.delete();
+ closed = true;
+ }
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public boolean getBoolean() throws XQException {
+ isClosedXQException();
+ if (itemType.getBaseType()!=XQItemType.XQBASETYPE_BOOLEAN) {
+ throw new XQException("Object is not boolean");
+ }
+ Boolean result;
+ try {
+ result = item.getBooleanValue();
+ } catch (Exception e) {
+ throw new XQException("Error getting boolean value" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public byte getByte() throws XQException {
+ isClosedXQException();
+ isDecimalXQException();
+ byte result = 0;
+ try {
+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_BYTE) {
+ result = (byte) item.getIntValue();
+ } else {
+ result = Byte.parseByte(item.getStringValue());
+ }
+ } catch (Exception e) {
+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public double getDouble() throws XQException {
+ isClosedXQException();
+ isFloatXQException();
+ double result = 0;
+ try {
+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_DOUBLE) {
+ result = item.getDoubleValue();
+ } else {
+ result = Double.parseDouble(item.getStringValue());
+ }
+ } catch (Exception e) {
+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public float getFloat() throws XQException {
+ isClosedXQException();
+ isFloatXQException();
+ float result = 0;
+ try {
+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_FLOAT) {
+ result = (float)item.getDoubleValue();
+ } else {
+ result = Float.parseFloat(item.getStringValue());
+ }
+ } catch (Exception e) {
+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public int getInt() throws XQException {
+ isClosedXQException();
+ isDecimalXQException();
+ int result = 0;
+ try {
+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_INT) {
+ result = item.getIntValue();
+ } else {
+ result = Integer.parseInt(item.getStringValue());
+ }
+ } catch (Exception e) {
+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public XQItemType getItemType() throws XQException {
+ isClosedXQException();
+ return itemType;
+ }
+
+ @Override
+ public String getAtomicValue() throws XQException {
+ isClosedXQException();
+ if (!item.isAtomic()) {
+ throw new XQException("Object is not atomic");
+ }
+ org.zorbaxquery.api.Item lItem = null;
+ try {
+ org.zorbaxquery.api.Iterator iterator = item.getAtomizationValue();
+ lItem = new Item(); // creating a new item to be filled by iterator
+ iterator.open();
+ iterator.next(lItem); // item CAN'T BE NULL
+ iterator.close();
+ } catch (Exception e) {
+ throw new XQException("Error getting atomic value: " + e.getLocalizedMessage());
+ }
+ return lItem.getStringValue();
+ }
+
+ @Override
+ public long getLong() throws XQException {
+ isClosedXQException();
+ isDecimalXQException();
+ long result = 0;
+ try {
+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_LONG) {
+ result = item.getLongValue();
+ } else {
+ result = Long.parseLong(item.getStringValue());
+ }
+ } catch (Exception e) {
+ throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public Node getNode() throws XQException {
+ isClosedXQException();
+ if (!item.isNode()) {
+ throw new XQException("Object is not a node");
+ }
+ Node result = null;
+ InputStream inputStream = new ByteArrayInputStream(item.toString().getBytes());
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.newDocument();
+ Item nodeName = new Item();
+ item.getNodeName(nodeName);
+ switch (itemType.getItemKind()) {
+ case XQItemType.XQITEMKIND_ATTRIBUTE:
+ result = doc.createAttributeNS("", nodeName.getStringValue());
+ break;
+ case XQItemType.XQITEMKIND_COMMENT:
+ result = doc.createComment(item.getStringValue());
+ break;
+ case XQItemType.XQITEMKIND_DOCUMENT:
+ String tmpDoc = item.serialize();
+ if (tmpDoc.length()>0) {
+ result = db.parse(new InputSource(new StringReader(tmpDoc)));
+ } else {
+ result = doc; // empty doc
+ }
+ break;
+ case XQItemType.XQITEMKIND_ELEMENT:
+ Element e = doc.createElementNS("", nodeName.getStringValue());
+ Node text = doc.createTextNode(item.getStringValue());
+ e.appendChild(text);
+ result = e;
+ break;
+ case XQItemType.XQITEMKIND_PI:
+ String tmpPI = item.serialize().substring(2).split(" ")[0];
+ result = doc.createProcessingInstruction(tmpPI, item.getStringValue());
+ break;
+ case XQItemType.XQITEMKIND_TEXT:
+ result = doc.createTextNode(item.getStringValue());
+ break;
+ }
+ } catch (Exception ex) {
+ throw new XQException("Error converting Item to Node" + ex.getLocalizedMessage());
+ }
+
+ return result;
+ }
+
+ @Override
+ public URI getNodeUri() throws XQException {
+ isClosedXQException();
+ if (!item.isNode()) {
+ throw new XQException("Object is not a node");
+ }
+ URI result;
+ String namespace = "";
+ try {
+ namespace = item.getNamespace();
+ } catch (Exception ex) {
+ //throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
+ }
+ try {
+ result = new URI(namespace);
+ } catch (Exception ex) {
+ throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public Object getObject() throws XQException {
+ isClosedXQException();
+ Object result = null;
+ try {
+ if ((itemType.getItemKind()==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+ (itemType.getItemKind()==XQItemType.XQITEMKIND_COMMENT) ||
+ (itemType.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT) ||
+ (itemType.getItemKind()==XQItemType.XQITEMKIND_ELEMENT) ||
+ (itemType.getItemKind()==XQItemType.XQITEMKIND_PI) ||
+ (itemType.getItemKind()==XQItemType.XQITEMKIND_TEXT) ) {
+ result = this.getNode();
+ } else if (itemType.getItemKind()==XQItemType.XQITEMKIND_ATOMIC) {
+ //result = this.getNode();
+ DatatypeFactory factory = DatatypeFactory.newInstance();
+ switch (itemType.getBaseType()) {
+ /*
+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+ break;
+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+ break;
+ case XQItemType.XQBASETYPE_ANYTYPE:
+ break;
+ *
+ */
+ case XQItemType.XQBASETYPE_ANYURI:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_BASE64BINARY:
+ result = item.serialize().getBytes();
+ break;
+ case XQItemType.XQBASETYPE_BOOLEAN:
+ result = item.getBooleanValue();
+ break;
+ case XQItemType.XQBASETYPE_BYTE:
+ result = new Byte(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_DATE:
+ case XQItemType.XQBASETYPE_DATETIME:
+ case XQItemType.XQBASETYPE_GDAY:
+ case XQItemType.XQBASETYPE_GMONTH:
+ case XQItemType.XQBASETYPE_GMONTHDAY:
+ case XQItemType.XQBASETYPE_GYEAR:
+ case XQItemType.XQBASETYPE_GYEARMONTH:
+ case XQItemType.XQBASETYPE_TIME:
+ result = factory.newXMLGregorianCalendar(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_DURATION:
+ result = factory.newDuration(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+ String tmpString = item.getStringValue();
+ result = factory.newDurationDayTime(tmpString);
+ break;
+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+ result = factory.newDurationYearMonth(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_DECIMAL:
+ result = new BigDecimal(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_DOUBLE:
+ result = item.getDoubleValue();
+ break;
+ case XQItemType.XQBASETYPE_ENTITIES:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_ENTITY:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_FLOAT:
+ result = (float)(item.getDoubleValue());
+ break;
+ case XQItemType.XQBASETYPE_HEXBINARY:
+ result = item.getStringValue().getBytes();
+ break;
+ case XQItemType.XQBASETYPE_ID:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_IDREF:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_IDREFS:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_INT:
+ result = item.getIntValue();
+ break;
+ case XQItemType.XQBASETYPE_LANGUAGE:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_LONG:
+ result = item.getLongValue();
+ break;
+ case XQItemType.XQBASETYPE_NAME:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_NCNAME:
+ result = item.serialize();
+ break;
+ case XQItemType.XQBASETYPE_NMTOKEN:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_NMTOKENS:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_INTEGER:
+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+ result = new BigInteger(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_NOTATION:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_QNAME:
+ result = new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()) ;
+ break;
+ case XQItemType.XQBASETYPE_STRING:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_TOKEN:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_SHORT:
+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+ result = new Short(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
+ result = new Long(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+ result = new Integer(item.getStringValue());
+ break;
+ case XQItemType.XQBASETYPE_UNTYPED:
+ result = item.getStringValue();
+ break;
+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+ result = item.getStringValue();
+ break;
+ }
+
+ }
+ } catch (Exception e) {
+ throw new XQException("Error getting byte value: " + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public XMLStreamReader getItemAsStream() throws XQException {
+ isClosedXQException();
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ XMLStreamReader result = null;
+ try {
+ result = factory.createXMLStreamReader(new StringReader(item.serialize()));
+ } catch (Exception ex) {
+ throw new XQException("Error creating XMLStreamReader: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public String getItemAsString(Properties prprts) throws XQException {
+ isClosedXQException();
+ String result = null;
+ try {
+ result = item.serialize().replace(">", ">").replace("<", "<");
+ } catch (Exception ex) {
+ throw new XQException("Error serializing item" + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public short getShort() throws XQException {
+ isClosedXQException();
+ isDecimalXQException();
+ short result;
+ try {
+ if (itemType.getBaseType() == XQItemType.XQBASETYPE_SHORT) {
+ result = (short) item.getIntValue();
+ } else {
+ result = Short.parseShort(item.getStringValue());
+ }
+ } catch (Exception ex) {
+ throw new XQException("Error getting short value: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public boolean instanceOf(XQItemType xqit) throws XQException {
+ isClosedXQException();
+ return itemType.equals(xqit);
+ }
+
+ @Override
+ public void writeItem(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(out);
+ isNullXQException(prprts);
+ try {
+ out.write(item.serialize().getBytes());
+ } catch (Exception ex) {
+ throw new XQException("Error writing on stream: " + ex.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void writeItem(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(writer);
+ isNullXQException(prprts);
+ try {
+ writer.write(item.serialize());
+ } catch (Exception ex) {
+ throw new XQException("Error sending to writer: " + ex.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void writeItemToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isNullXQException(ch);
+ try {
+ AttributesImpl attributes = new AttributesImpl();
+ Iterator attr = item.getAttributes();
+ attr.open();
+ Item attribute = new Item();
+ while (attr.next(attribute)) {
+ attributes.addAttribute(attribute.getNamespace(), attribute.getLocalName(), "", attribute.getType().getStringValue(), attribute.getStringValue());
+ }
+ attribute.close();
+ attr.close();
+ attr.delete();
+ //attribute.delete();
+ String namespace = "";
+ if (itemType.getBaseType() != XQItemType.XQBASETYPE_ANYTYPE){
+ namespace = item.getNamespace();
+ }
+ Item name = new Item();
+ item.getNodeName(name);
+ String nodeName = name.getStringValue();
+ name.close();
+ //name.delete();
+ char [] content = item.getStringValue().toCharArray();
+
+ ch.startElement(namespace, nodeName , "", attributes);
+ ch.characters(content, 0, content.length);
+ ch.endElement(namespace, nodeName, "");
+ } catch (Exception ex) {
+ throw new XQException("Error writing item to SAX: " + ex.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void writeItemToResult(Result result) throws XQException {
+ isClosedXQException();
+ isNullXQException(result);
+ try {
+ Source xmlSource = new DOMSource(getNode());
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer;
+ transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperty("indent", "yes");
+ transformer.transform(xmlSource, result);
+ } catch (Exception ex) {
+ throw new XQException ("Error serializing to javax.xml.transform.Result");
+ }
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This connection is closed");
+ }
+ }
+
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+ private void isDecimalXQException() throws XQException {
+ switch (itemType.getBaseType()) {
+ case XQItemType.XQBASETYPE_DECIMAL:
+ case XQItemType.XQBASETYPE_BYTE:
+ case XQItemType.XQBASETYPE_INT:
+ case XQItemType.XQBASETYPE_INTEGER:
+ case XQItemType.XQBASETYPE_LONG:
+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+ case XQItemType.XQBASETYPE_SHORT:
+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+ break;
+ default:
+ throw new XQException("Object is not xs:decimal or a derivate");
+ }
+ }
+
+ private void isFloatXQException() throws XQException {
+ if (! ((itemType.getBaseType()==XQItemType.XQBASETYPE_FLOAT) ||
+ (itemType.getBaseType()==XQItemType.XQBASETYPE_DOUBLE)) )
+ {
+ throw new XQException("Object is not xs:decimal or a derivate");
+ }
+ }
+}
=== added file 'swig/xqj/ZorbaXQItemType.java'
--- swig/xqj/ZorbaXQItemType.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQItemType.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,740 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.net.URI;
+import javax.xml.namespace.QName;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQSequenceType;
+import org.zorbaxquery.api.IdentTypes.Kind;
+import org.zorbaxquery.api.IdentTypes.Quantifier;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.TypeIdentifier;
+
+public class ZorbaXQItemType implements XQItemType {
+ public static final int ZORBA_XQITEMKIND_ANY = 0;
+ public static final int ZORBA_XQITEMKIND_DOCUMENT = 1;
+ public static final int ZORBA_XQITEMKIND_ELEMENT = 2;
+ public static final int ZORBA_XQITEMKIND_ATTRIBUTE = 3;
+ public static final int ZORBA_XQITEMKIND_TEXT = 4;
+ public static final int ZORBA_XQITEMKIND_PI = 5;
+ public static final int ZORBA_XQITEMKIND_COMMENT = 6;
+
+ private int itemKind = 0;
+ private int baseType = 0;
+ private QName nodeName = null;
+ private QName typeName = null;
+ private URI schemaURI = null;
+ private boolean allowNill = false;
+ private String piTarget = null;
+
+ protected TypeIdentifier getTypeIdentifier() throws XQException {
+ TypeIdentifier result = null;
+ switch (itemKind) {
+ case XQITEMKIND_ATOMIC:
+ result = TypeIdentifier.createEmptyType();
+ break;
+ case XQITEMKIND_ATTRIBUTE:
+ // TODO: fix uriWildcard, localNameWildcard
+ result = TypeIdentifier.createAttributeType(schemaURI.toString(), true, nodeName.getLocalPart(), true, TypeIdentifier.createAnyNodeType());
+ break;
+ case XQITEMKIND_COMMENT:
+ result = TypeIdentifier.createCommentType();
+ break;
+ case XQITEMKIND_DOCUMENT:
+ case XQITEMKIND_DOCUMENT_ELEMENT:
+ case XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
+ result = TypeIdentifier.createDocumentType(TypeIdentifier.createAnyNodeType());
+ break;
+ case XQITEMKIND_ELEMENT:
+ // TODO: fix uriWildcard, localNameWildcard
+ result = TypeIdentifier.createElementType(schemaURI.toString(), true, nodeName.getLocalPart(), true, TypeIdentifier.createAnyNodeType());
+ break;
+ case XQITEMKIND_ITEM:
+ result = TypeIdentifier.createItemType();
+ break;
+ case XQITEMKIND_NODE:
+ result = TypeIdentifier.createAnyNodeType();
+ break;
+ case XQITEMKIND_PI:
+ result = TypeIdentifier.createPIType();
+ break;
+ case XQITEMKIND_TEXT:
+ result = TypeIdentifier.createTextType();
+ break;
+ case XQITEMKIND_SCHEMA_ATTRIBUTE:
+ case XQITEMKIND_SCHEMA_ELEMENT:
+ default:
+ throw new XQException("Item kind is not valid.");
+
+ }
+ return result;
+ }
+
+ public ZorbaXQItemType(TypeIdentifier typeIdentifier) {
+ switch (typeIdentifier.getKind()) {
+ case Kind.ANY_NODE_TYPE:
+ itemKind = XQITEMKIND_NODE;
+ break;
+ case Kind.ATTRIBUTE_TYPE:
+ itemKind = XQITEMKIND_ATTRIBUTE;
+ break;
+ case Kind.COMMENT_TYPE:
+ itemKind = XQITEMKIND_COMMENT;
+ break;
+ case Kind.DOCUMENT_TYPE:
+ itemKind = XQITEMKIND_DOCUMENT;
+ break;
+ case Kind.ELEMENT_TYPE:
+ itemKind = XQITEMKIND_ELEMENT;
+ break;
+ case Kind.EMPTY_TYPE:
+ case Kind.INVALID_TYPE:
+ case Kind.ITEM_TYPE:
+ case Kind.NAMED_TYPE:
+ itemKind = XQITEMKIND_ITEM;
+ break;
+ case Kind.PI_TYPE:
+ itemKind = XQITEMKIND_PI;
+ break;
+ case Kind.TEXT_TYPE:
+ itemKind = XQITEMKIND_TEXT;
+ break;
+ }
+
+ String type = typeIdentifier.getLocalName();
+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
+ if (type.indexOf("anyAtomicType")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYATOMICTYPE;
+ } else if (type.indexOf("anySimpleType")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
+ } else if (type.indexOf("anyType")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
+ } else if (type.indexOf("anyURI")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYURI;
+ } else if (type.indexOf("base64Binary")>=0){
+ baseType = XQItemType.XQBASETYPE_BASE64BINARY;
+ } else if (type.indexOf("boolean")>=0){
+ baseType = XQItemType.XQBASETYPE_BOOLEAN;
+ } else if (type.indexOf("byte")>=0){
+ baseType = XQItemType.XQBASETYPE_BYTE;
+ } else if (type.indexOf("dateTime")>=0){
+ baseType = XQItemType.XQBASETYPE_DATETIME;
+ } else if (type.indexOf("date")>=0){
+ baseType = XQItemType.XQBASETYPE_DATE;
+ } else if (type.indexOf("dayTimeDuration")>=0){
+ baseType = XQItemType.XQBASETYPE_DAYTIMEDURATION;
+ } else if (type.indexOf("decimal")>=0){
+ baseType = XQItemType.XQBASETYPE_DECIMAL;
+ } else if (type.indexOf("double")>=0){
+ baseType = XQItemType.XQBASETYPE_DOUBLE;
+ } else if (type.indexOf("duration")>=0){
+ baseType = XQItemType.XQBASETYPE_DURATION;
+ } else if (type.indexOf("ENTITIES")>=0){
+ baseType = XQItemType.XQBASETYPE_ENTITIES;
+ } else if (type.indexOf("ENTITY")>=0){
+ baseType = XQItemType.XQBASETYPE_ENTITY;
+ } else if (type.indexOf("float")>=0){
+ baseType = XQItemType.XQBASETYPE_FLOAT;
+ } else if (type.indexOf("gDay")>=0){
+ baseType = XQItemType.XQBASETYPE_GDAY;
+ } else if (type.indexOf("gMonthDay")>=0){
+ baseType = XQItemType.XQBASETYPE_GMONTHDAY;
+ } else if (type.indexOf("gMonth")>=0){
+ baseType = XQItemType.XQBASETYPE_GMONTH;
+ } else if (type.indexOf("gYear")>=0){
+ baseType = XQItemType.XQBASETYPE_GYEAR;
+ } else if (type.indexOf("hexBinary")>=0){
+ baseType = XQItemType.XQBASETYPE_HEXBINARY;
+ } else if (type.indexOf("IDREFS")>=0){
+ baseType = XQItemType.XQBASETYPE_IDREFS;
+ } else if (type.indexOf("IDREF")>=0){
+ baseType = XQItemType.XQBASETYPE_IDREF;
+ } else if (type.indexOf("ID")>=0){
+ baseType = XQItemType.XQBASETYPE_ID;
+ } else if (type.indexOf("integer")>=0){
+ baseType = XQItemType.XQBASETYPE_INTEGER;
+ } else if (type.indexOf("int")>=0){
+ baseType = XQItemType.XQBASETYPE_INT;
+ } else if (type.indexOf("language")>=0){
+ baseType = XQItemType.XQBASETYPE_LANGUAGE;
+ } else if (type.indexOf("long")>=0){
+ baseType = XQItemType.XQBASETYPE_LONG;
+ } else if (type.indexOf("QName")>=0){
+ baseType = XQItemType.XQBASETYPE_QNAME;
+ } else if (type.indexOf("NCName")>=0){
+ baseType = XQItemType.XQBASETYPE_NCNAME;
+ } else if (type.indexOf("Name")>=0){
+ baseType = XQItemType.XQBASETYPE_NAME;
+ } else if (type.indexOf("negativeInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_NEGATIVE_INTEGER;
+ } else if (type.indexOf("NMTOKENS")>=0){
+ baseType = XQItemType.XQBASETYPE_NMTOKENS;
+ } else if (type.indexOf("NMTOKEN")>=0){
+ baseType = XQItemType.XQBASETYPE_NMTOKEN;
+ } else if (type.indexOf("nonNegativeInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER;
+ } else if (type.indexOf("nonPositiveInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER;
+ } else if (type.indexOf("normalizedString")>=0){
+ baseType = XQItemType.XQBASETYPE_NORMALIZED_STRING;
+ } else if (type.indexOf("NOTATION")>=0){
+ baseType = XQItemType.XQBASETYPE_NOTATION;
+ } else if (type.indexOf("positiveInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_POSITIVE_INTEGER;
+ } else if (type.indexOf("short")>=0){
+ baseType = XQItemType.XQBASETYPE_SHORT;
+ } else if (type.indexOf("string")>=0){
+ baseType = XQItemType.XQBASETYPE_STRING;
+ } else if (type.indexOf("time")>=0){
+ baseType = XQItemType.XQBASETYPE_TIME;
+ } else if (type.indexOf("token")>=0){
+ baseType = XQItemType.XQBASETYPE_TOKEN;
+ } else if (type.indexOf("unsignedByte")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_BYTE;
+ } else if (type.indexOf("unsignedInt")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_INT;
+ } else if (type.indexOf("unsignedLong")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_LONG;
+ } else if (type.indexOf("unsignedShort")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_SHORT;
+ } else if (type.indexOf("untypedAtomic")>=0){
+ baseType = XQItemType.XQBASETYPE_UNTYPEDATOMIC;
+ } else if (type.indexOf("untyped")>=0){
+ baseType = XQItemType.XQBASETYPE_UNTYPED;
+ } else if (type.indexOf("yearMonthDuration")>=0){
+ baseType = XQItemType.XQBASETYPE_YEARMONTHDURATION;
+ }
+ generateTypeName();
+ }
+ public ZorbaXQItemType(Item zorbaItem) {
+
+ String type = "";
+ if (zorbaItem.isNode()) {
+ switch (zorbaItem.getNodeKind()) {
+ case ZORBA_XQITEMKIND_ANY:
+ itemKind = XQITEMKIND_ELEMENT;
+ break;
+ case ZORBA_XQITEMKIND_ATTRIBUTE:
+ itemKind = XQITEMKIND_ATTRIBUTE;
+ break;
+ case ZORBA_XQITEMKIND_COMMENT:
+ itemKind = XQITEMKIND_COMMENT;
+ break;
+ case ZORBA_XQITEMKIND_DOCUMENT:
+ itemKind = XQITEMKIND_DOCUMENT;
+ break;
+ case ZORBA_XQITEMKIND_ELEMENT:
+ itemKind = XQITEMKIND_ELEMENT;
+ break;
+ case ZORBA_XQITEMKIND_PI:
+ itemKind = XQITEMKIND_PI;
+ break;
+ case ZORBA_XQITEMKIND_TEXT:
+ itemKind = XQITEMKIND_TEXT;
+ break;
+ }
+ } else if (zorbaItem.isAtomic()) {
+ itemKind = XQITEMKIND_ATOMIC;
+ type = zorbaItem.getType().getStringValue();
+ }
+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
+ if (type.indexOf("anyAtomicType")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYATOMICTYPE;
+ } else if (type.indexOf("anySimpleType")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
+ } else if (type.indexOf("anyType")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYTYPE;
+ } else if (type.indexOf("anyURI")>=0){
+ baseType = XQItemType.XQBASETYPE_ANYURI;
+ } else if (type.indexOf("base64Binary")>=0){
+ baseType = XQItemType.XQBASETYPE_BASE64BINARY;
+ } else if (type.indexOf("boolean")>=0){
+ baseType = XQItemType.XQBASETYPE_BOOLEAN;
+ } else if (type.indexOf("byte")>=0){
+ baseType = XQItemType.XQBASETYPE_BYTE;
+ } else if (type.indexOf("dateTime")>=0){
+ baseType = XQItemType.XQBASETYPE_DATETIME;
+ } else if (type.indexOf("date")>=0){
+ baseType = XQItemType.XQBASETYPE_DATE;
+ } else if (type.indexOf("dayTimeDuration")>=0){
+ baseType = XQItemType.XQBASETYPE_DAYTIMEDURATION;
+ } else if (type.indexOf("decimal")>=0){
+ baseType = XQItemType.XQBASETYPE_DECIMAL;
+ } else if (type.indexOf("double")>=0){
+ baseType = XQItemType.XQBASETYPE_DOUBLE;
+ } else if (type.indexOf("duration")>=0){
+ baseType = XQItemType.XQBASETYPE_DURATION;
+ } else if (type.indexOf("ENTITIES")>=0){
+ baseType = XQItemType.XQBASETYPE_ENTITIES;
+ } else if (type.indexOf("ENTITY")>=0){
+ baseType = XQItemType.XQBASETYPE_ENTITY;
+ } else if (type.indexOf("float")>=0){
+ baseType = XQItemType.XQBASETYPE_FLOAT;
+ } else if (type.indexOf("gDay")>=0){
+ baseType = XQItemType.XQBASETYPE_GDAY;
+ } else if (type.indexOf("gMonthDay")>=0){
+ baseType = XQItemType.XQBASETYPE_GMONTHDAY;
+ } else if (type.indexOf("gMonth")>=0){
+ baseType = XQItemType.XQBASETYPE_GMONTH;
+ } else if (type.indexOf("gYear")>=0){
+ baseType = XQItemType.XQBASETYPE_GYEAR;
+ } else if (type.indexOf("hexBinary")>=0){
+ baseType = XQItemType.XQBASETYPE_HEXBINARY;
+ } else if (type.indexOf("IDREFS")>=0){
+ baseType = XQItemType.XQBASETYPE_IDREFS;
+ } else if (type.indexOf("IDREF")>=0){
+ baseType = XQItemType.XQBASETYPE_IDREF;
+ } else if (type.indexOf("ID")>=0){
+ baseType = XQItemType.XQBASETYPE_ID;
+ } else if (type.indexOf("integer")>=0){
+ baseType = XQItemType.XQBASETYPE_INTEGER;
+ } else if (type.indexOf("int")>=0){
+ baseType = XQItemType.XQBASETYPE_INT;
+ } else if (type.indexOf("language")>=0){
+ baseType = XQItemType.XQBASETYPE_LANGUAGE;
+ } else if (type.indexOf("long")>=0){
+ baseType = XQItemType.XQBASETYPE_LONG;
+ } else if (type.indexOf("QName")>=0){
+ baseType = XQItemType.XQBASETYPE_QNAME;
+ } else if (type.indexOf("NCName")>=0){
+ baseType = XQItemType.XQBASETYPE_NCNAME;
+ } else if (type.indexOf("Name")>=0){
+ baseType = XQItemType.XQBASETYPE_NAME;
+ } else if (type.indexOf("negativeInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_NEGATIVE_INTEGER;
+ } else if (type.indexOf("NMTOKENS")>=0){
+ baseType = XQItemType.XQBASETYPE_NMTOKENS;
+ } else if (type.indexOf("NMTOKEN")>=0){
+ baseType = XQItemType.XQBASETYPE_NMTOKEN;
+ } else if (type.indexOf("nonNegativeInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER;
+ } else if (type.indexOf("nonPositiveInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER;
+ } else if (type.indexOf("normalizedString")>=0){
+ baseType = XQItemType.XQBASETYPE_NORMALIZED_STRING;
+ } else if (type.indexOf("NOTATION")>=0){
+ baseType = XQItemType.XQBASETYPE_NOTATION;
+ } else if (type.indexOf("positiveInteger")>=0){
+ baseType = XQItemType.XQBASETYPE_POSITIVE_INTEGER;
+ } else if (type.indexOf("short")>=0){
+ baseType = XQItemType.XQBASETYPE_SHORT;
+ } else if (type.indexOf("string")>=0){
+ baseType = XQItemType.XQBASETYPE_STRING;
+ } else if (type.indexOf("time")>=0){
+ baseType = XQItemType.XQBASETYPE_TIME;
+ } else if (type.indexOf("token")>=0){
+ baseType = XQItemType.XQBASETYPE_TOKEN;
+ } else if (type.indexOf("unsignedByte")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_BYTE;
+ } else if (type.indexOf("unsignedInt")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_INT;
+ } else if (type.indexOf("unsignedLong")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_LONG;
+ } else if (type.indexOf("unsignedShort")>=0){
+ baseType = XQItemType.XQBASETYPE_UNSIGNED_SHORT;
+ } else if (type.indexOf("untypedAtomic")>=0){
+ baseType = XQItemType.XQBASETYPE_UNTYPEDATOMIC;
+ } else if (type.indexOf("untyped")>=0){
+ baseType = XQItemType.XQBASETYPE_UNTYPED;
+ } else if (type.indexOf("yearMonthDuration")>=0){
+ baseType = XQItemType.XQBASETYPE_YEARMONTHDURATION;
+ }
+ generateTypeName();
+ }
+
+ public ZorbaXQItemType(int itemkind, String piTarget) {
+ this.itemKind = itemkind;
+ this.piTarget = piTarget;
+ generateTypeName();
+ }
+ public ZorbaXQItemType(int itemkind) {
+ this.itemKind = itemkind;
+ generateTypeName();
+ }
+ public ZorbaXQItemType(int itemkind, int basetype) {
+ this.itemKind = itemkind;
+ this.baseType = basetype;
+ generateTypeName();
+ }
+ public ZorbaXQItemType(int itemkind, QName nodename, int basetype) {
+ this.itemKind = itemkind;
+ this.nodeName = nodename;
+ this.baseType = basetype;
+ generateTypeName();
+ }
+ public ZorbaXQItemType(int itemkind, QName nodename, int basetype, QName typename, URI schemaURI, boolean allowNill) throws XQException {
+ this.itemKind = itemkind;
+ this.nodeName = nodename;
+ this.baseType = basetype;
+ this.typeName = typename;
+ this.schemaURI = schemaURI;
+ this.allowNill = allowNill;
+ }
+ public ZorbaXQItemType(int itemkind, QName nodename, int basetype, URI schemaURI) throws XQException {
+ this.itemKind = itemkind;
+ this.nodeName = nodename;
+ this.baseType = basetype;
+ this.schemaURI = schemaURI;
+ generateTypeName();
+ }
+
+
+ private void generateTypeName() {
+ String namespaceURI = "http://www.w3.org/2001/XMLSchema";
+ String localPart = "untyped";
+ String prefix = "";
+
+ switch (baseType) {
+ case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+ localPart = "anyAtomicType";
+ break;
+ case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+ localPart = "anySimpleType";
+ break;
+ case XQItemType.XQBASETYPE_ANYTYPE:
+ localPart = "anyType";
+ break;
+ case XQItemType.XQBASETYPE_ANYURI:
+ localPart = "anyURI";
+ break;
+ case XQItemType.XQBASETYPE_BASE64BINARY:
+ localPart = "base64Binary";
+ break;
+ case XQItemType.XQBASETYPE_BOOLEAN:
+ localPart = "boolean";
+ break;
+ case XQItemType.XQBASETYPE_BYTE:
+ localPart = "byte";
+ break;
+ case XQItemType.XQBASETYPE_DATE:
+ localPart = "date";
+ break;
+ case XQItemType.XQBASETYPE_DATETIME:
+ localPart = "dateTime";
+ break;
+ case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+ localPart = "dayTimeDuration";
+ break;
+ case XQItemType.XQBASETYPE_DECIMAL:
+ localPart = "decimal";
+ break;
+ case XQItemType.XQBASETYPE_DOUBLE:
+ localPart = "double";
+ break;
+ case XQItemType.XQBASETYPE_DURATION:
+ localPart = "duration";
+ break;
+ case XQItemType.XQBASETYPE_ENTITIES:
+ localPart = "ENTITIES";
+ break;
+ case XQItemType.XQBASETYPE_ENTITY:
+ localPart = "ENTITY";
+ break;
+ case XQItemType.XQBASETYPE_FLOAT:
+ localPart = "float";
+ break;
+ case XQItemType.XQBASETYPE_GDAY:
+ localPart = "gDay";
+ break;
+ case XQItemType.XQBASETYPE_GMONTH:
+ localPart = "gMonth";
+ break;
+ case XQItemType.XQBASETYPE_GMONTHDAY:
+ localPart = "gMonthDay";
+ break;
+ case XQItemType.XQBASETYPE_GYEAR:
+ localPart = "gYear";
+ break;
+ case XQItemType.XQBASETYPE_GYEARMONTH:
+ localPart = "gYearMonth";
+ break;
+ case XQItemType.XQBASETYPE_HEXBINARY:
+ localPart = "hexBinary";
+ break;
+ case XQItemType.XQBASETYPE_ID:
+ localPart = "ID";
+ break;
+ case XQItemType.XQBASETYPE_IDREF:
+ localPart = "IDREF";
+ break;
+ case XQItemType.XQBASETYPE_IDREFS:
+ localPart = "IDREFS";
+ break;
+ case XQItemType.XQBASETYPE_INT:
+ localPart = "int";
+ break;
+ case XQItemType.XQBASETYPE_INTEGER:
+ localPart = "integer";
+ break;
+ case XQItemType.XQBASETYPE_LANGUAGE:
+ localPart = "language";
+ break;
+ case XQItemType.XQBASETYPE_LONG:
+ localPart = "long";
+ break;
+ case XQItemType.XQBASETYPE_NAME:
+ localPart = "Name";
+ break;
+ case XQItemType.XQBASETYPE_NCNAME:
+ localPart = "NCName";
+ break;
+ case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+ localPart = "negativeInteger";
+ break;
+ case XQItemType.XQBASETYPE_NMTOKEN:
+ localPart = "NMTOKEN";
+ break;
+ case XQItemType.XQBASETYPE_NMTOKENS:
+ localPart = "NMTOKENS";
+ break;
+ case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+ localPart = "nonNegativeInteger";
+ break;
+ case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+ localPart = "nonPositiveInteger";
+ break;
+ case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+ localPart = "normalizedString";
+ break;
+ case XQItemType.XQBASETYPE_NOTATION:
+ localPart = "NOTATION";
+ break;
+ case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+ localPart = "positiveInteger";
+ break;
+ case XQItemType.XQBASETYPE_QNAME:
+ localPart = "QName";
+ break;
+ case XQItemType.XQBASETYPE_SHORT:
+ localPart = "short";
+ break;
+ case XQItemType.XQBASETYPE_STRING:
+ localPart = "string";
+ break;
+ case XQItemType.XQBASETYPE_TIME:
+ localPart = "time";
+ break;
+ case XQItemType.XQBASETYPE_TOKEN:
+ localPart = "token";
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+ localPart = "unsignedByte";
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_INT:
+ localPart = "unsignedInt";
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+ localPart = "unsignedLong";
+ break;
+ case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+ localPart = "unsignedShort";
+ break;
+ case XQItemType.XQBASETYPE_UNTYPED:
+ localPart = "untyped";
+ break;
+ case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+ localPart = "untypedAtomic";
+ break;
+ case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+ localPart = "yearMonthDuration";
+ break;
+ default:
+ localPart = "untyped";
+ break;
+ }
+ typeName = new QName(namespaceURI, localPart, prefix);
+ }
+
+
+
+
+ @Override
+ public int getBaseType() throws XQException {
+ if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE) ||
+ (itemKind==XQItemType.XQITEMKIND_ATOMIC))) {
+ throw new XQException("Item kind is not valid for a Base Type.");
+ }
+ return baseType;
+ }
+
+ @Override
+ public int getItemKind() {
+ return itemKind;
+ }
+
+ @Override
+ public int getItemOccurrence() {
+ return XQSequenceType.OCC_EXACTLY_ONE;
+ }
+
+ @Override
+ public QName getNodeName() throws XQException {
+ if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE))) {
+ throw new XQException("Item kind is not valid for a Type Name.");
+ }
+ return nodeName;
+ }
+
+ @Override
+ public URI getSchemaURI() {
+ return schemaURI;
+ }
+
+ @Override
+ public QName getTypeName() throws XQException {
+ if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_ATOMIC) ||
+ (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
+ (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+ (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE))) {
+ throw new XQException("Item kind is not valid for a Type Name.");
+ }
+ return typeName;
+ }
+
+ @Override
+ public boolean isAnonymousType() {
+ return (itemKind==0);
+ }
+
+ @Override
+ public boolean isElementNillable() {
+ return allowNill;
+ }
+
+ @Override
+ public String getPIName() throws XQException {
+ if (itemKind!=XQItemType.XQITEMKIND_PI) {
+ throw new XQException("Item kind is not a PI.");
+ }
+ return piTarget;
+ }
+
+ @Override
+ public XQItemType getItemType() {
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ boolean result = false;
+ boolean supportBaseType = false;
+ boolean supportNodeName = false;
+ boolean supportTypeName = false;
+ boolean supportPIName = false;
+ if (o instanceof XQItemType) {
+ if ( (getItemKind()==((XQItemType)o).getItemKind()) &&
+ (getSchemaURI()==((XQItemType)o).getSchemaURI()) &&
+ (isAnonymousType()==((XQItemType)o).isAnonymousType()) &&
+ (isElementNillable()==((XQItemType)o).isElementNillable()) ) {
+ try {
+ supportBaseType = getBaseType() == ((XQItemType)o).getBaseType();
+ } catch (Exception e) {
+ supportBaseType = true; // Not supported
+ }
+ try {
+ supportNodeName = getNodeName() == ((XQItemType)o).getNodeName();
+ } catch (Exception e) {
+ supportNodeName = true; // Not supported
+ }
+ try {
+ supportTypeName = getTypeName().equals(((XQItemType)o).getTypeName());
+ } catch (Exception e) {
+ supportTypeName = true; // Not supported
+ }
+ try {
+ supportPIName = getPIName().equals(((XQItemType)o).getPIName());
+ } catch (Exception e) {
+ supportPIName = true; // Not supported
+ }
+
+
+ result = supportBaseType && supportNodeName && supportTypeName && supportPIName;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 0;
+ hashCode = this.getItemKind();
+ if (this.getSchemaURI() != null) {
+ hashCode = 31*hashCode + this.getSchemaURI().hashCode();
+ }
+ try {
+ int basetype = this.getBaseType();
+ hashCode = 31*hashCode + basetype;
+ } catch (Exception e) {}
+ try {
+ QName nodename = this.getNodeName();
+ if (nodename!=null) {
+ hashCode = 31*hashCode + nodename.hashCode();
+ }
+ } catch (Exception e) {}
+ try {
+ QName typename = this.getTypeName();
+ hashCode = 31*hashCode + typename.hashCode();
+ } catch(Exception e) {}
+ try {
+ String piname = this.getPIName();
+ if (piname != null) {
+ hashCode = 31*hashCode + piname.hashCode();
+ }
+ } catch (Exception e) {}
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+
+ try {
+ for (java.lang.reflect.Field field: ZorbaXQItemType.class.getFields()) {
+ if (field.getName().startsWith("XQITEMKIND_")) {
+ if (field.getInt(this)==itemKind) {
+ result.append("Item Kind: ").append(field.getName().substring(11));
+ }
+ }
+ if (field.getName().startsWith("XQBASETYPE_")) {
+ if (field.getInt(this)==baseType) {
+ result.append(" Base Type: ").append(field.getName().substring(11));
+ }
+ }
+ }
+ } catch (Exception e){
+ result.append("Item Kind or Base Type error: ").append(e.getLocalizedMessage());
+ }
+
+ return result.toString();
+ }
+
+
+}
=== added file 'swig/xqj/ZorbaXQMetaData.java'
--- swig/xqj/ZorbaXQMetaData.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQMetaData.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import org.zorbaxquery.api.Zorba;
+
+public class ZorbaXQMetaData implements javax.xml.xquery.XQMetaData {
+
+ private int XQJ_MAJOR = 1;
+ private int XQJ_MINOR = 1;
+
+ private boolean closed = false;
+ private XQConnection connection;
+ private Zorba zorba;
+ public ZorbaXQMetaData(XQConnection conn) throws XQException {
+ if (conn.isClosed()) {
+ throw new XQException("This connection is closed");
+ }
+ connection = conn;
+ zorba = ((ZorbaXQConnection)connection).getZorbaInstance();
+ }
+
+ @Override
+ public int getProductMajorVersion() throws XQException {
+ isClosedXQException();
+ return zorba.getMajorVersion();
+ }
+
+ @Override
+ public int getProductMinorVersion() throws XQException {
+ isClosedXQException();
+ return zorba.getMinorVersion();
+ }
+
+ @Override
+ public String getProductName() throws XQException {
+ isClosedXQException();
+ return "Zorba - The XQuery Processor";
+ }
+
+ @Override
+ public String getProductVersion() throws XQException {
+ isClosedXQException();
+ return zorba.getVersion();
+ }
+
+ @Override
+ public int getXQJMajorVersion() throws XQException {
+ isClosedXQException();
+ return XQJ_MAJOR;
+ }
+
+ @Override
+ public int getXQJMinorVersion() throws XQException {
+ isClosedXQException();
+ return XQJ_MINOR;
+ }
+
+ @Override
+ public String getXQJVersion() throws XQException {
+ isClosedXQException();
+ return new String().concat(new Integer(XQJ_MAJOR).toString()).concat(".").concat(new Integer(XQJ_MINOR).toString());
+ }
+
+ @Override
+ public boolean isReadOnly() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public boolean isXQueryXSupported() throws XQException {
+ isClosedXQException();
+ return false; //depends on compilation directive
+ }
+
+ @Override
+ public boolean isTransactionSupported() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public boolean isStaticTypingFeatureSupported() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public boolean isSchemaImportFeatureSupported() throws XQException {
+ isClosedXQException();
+ return true;
+ }
+
+ @Override
+ public boolean isSchemaValidationFeatureSupported() throws XQException {
+ isClosedXQException();
+ return true;
+ }
+
+ @Override
+ public boolean isFullAxisFeatureSupported() throws XQException {
+ isClosedXQException();
+ return true;
+ }
+
+ @Override
+ public boolean isModuleFeatureSupported() throws XQException {
+ isClosedXQException();
+ return true;
+ }
+
+ @Override
+ public boolean isSerializationFeatureSupported() throws XQException {
+ isClosedXQException();
+ return true;
+ }
+
+ @Override
+ public boolean isStaticTypingExtensionsSupported() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public String getUserName() throws XQException {
+ isClosedXQException();
+ return null;
+ }
+
+ @Override
+ public int getMaxExpressionLength() throws XQException {
+ isClosedXQException();
+ return 0;
+ }
+
+ @Override
+ public int getMaxUserNameLength() throws XQException {
+ isClosedXQException();
+ return 0;
+ }
+
+ @Override
+ public boolean wasCreatedFromJDBCConnection() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public boolean isXQueryEncodingDeclSupported() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public Set getSupportedXQueryEncodings() throws XQException {
+ isClosedXQException();
+ Set set = new HashSet();
+ set.add("UTF8");
+ return set;
+
+ }
+
+ @Override
+ public boolean isXQueryEncodingSupported(String string) throws XQException {
+ isClosedXQException();
+ isNullXQException(string);
+ return string.equals("UTF8");
+ }
+
+ @Override
+ public boolean isUserDefinedXMLSchemaTypeSupported() throws XQException {
+ isClosedXQException();
+ return true;
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (connection.isClosed()) {
+ throw new XQException("This connection is closed");
+ }
+ }
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+}
=== added file 'swig/xqj/ZorbaXQPreparedExpression.java'
--- swig/xqj/ZorbaXQPreparedExpression.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQPreparedExpression.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,677 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.CharBuffer;
+import java.util.TimeZone;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQResultSequence;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQSequenceType;
+import javax.xml.xquery.XQStaticContext;
+import org.w3c.dom.Node;
+import org.zorbaxquery.api.XQuery;
+import org.zorbaxquery.api.Zorba;
+import javax.xml.xquery.XQConnection;
+import java.util.Collection;
+import java.util.ArrayList;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.zorbaxquery.api.DynamicContext;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+import org.zorbaxquery.api.ItemFactory;
+import org.zorbaxquery.api.StaticContext;
+import org.zorbaxquery.api.XmlDataManager;
+
+public class ZorbaXQPreparedExpression implements javax.xml.xquery.XQPreparedExpression {
+
+ private XQuery query;
+ private XQConnection connection;
+ private boolean closed;
+ private Collection<XQResultSequence> resultSequences = new ArrayList<XQResultSequence>();
+ private DynamicContext dynamicContext;
+ private XmlDataManager xmlDataManager;
+ private ZorbaXQStaticContext staticContext;
+ private Collection<String> itemsBounded = new ArrayList<String>();
+
+
+ public ZorbaXQPreparedExpression (XQConnection conn, String string) throws XQException {
+ if (conn.isClosed()) {
+ throw new XQException ("Connection is closed");
+ }
+ closed = false;
+ connection = conn;
+ Zorba zorba = ((ZorbaXQConnection)connection).getZorbaInstance();
+ try {
+ query = zorba.compileQuery(string);
+ dynamicContext = query.getDynamicContext();
+ xmlDataManager = ((ZorbaXQConnection)connection).getZorbaInstance().getXmlDataManager();
+ } catch (Exception e) {
+ throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
+
+ }
+ }
+ public ZorbaXQPreparedExpression (XQConnection conn, String string, XQStaticContext sc) throws XQException {
+ if (conn.isClosed()) {
+ throw new XQException ("Connection is closed");
+ }
+ closed = false;
+ connection = conn;
+ Zorba zorba = ((ZorbaXQConnection)connection).getZorbaInstance();
+ try {
+ query = zorba.compileQuery(string, ((ZorbaXQStaticContext)sc).getZorbaStaticContext());
+ dynamicContext = query.getDynamicContext();
+ xmlDataManager = ((ZorbaXQConnection)connection).getZorbaInstance().getXmlDataManager();
+ } catch (Exception e) {
+ throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
+
+ }
+ }
+
+ @Override
+ public void cancel() throws XQException {
+ isClosedXQException();
+
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public void close() throws XQException {
+ closed = true;
+ for (XQResultSequence sequence: resultSequences) {
+ sequence.close();
+ }
+ if (query!=null) {
+ query.delete();
+ }
+ }
+
+ @Override
+ public XQResultSequence executeQuery() throws XQException {
+ isClosedXQException();
+ XQResultSequence result = null;
+ try {
+ result = new ZorbaXQResultSequence(connection, query, true);
+ } catch (Exception e) {
+ throw new XQException("Error executing query: " + e.getLocalizedMessage());
+ }
+ resultSequences.add(result);
+ return result;
+ }
+
+ @Override
+ public QName[] getAllExternalVariables() throws XQException {
+ isClosedXQException();
+ Collection<QName> result = new ArrayList<QName>();
+ Iterator iter = new Iterator();
+ query.getExternalVariables(iter);
+ iter.open();
+ Item item = new Item();
+ while (iter.next(item)) {
+ result.add(new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()));
+ }
+ iter.close();
+ iter.delete();
+ return result.toArray(new QName[0]);
+ }
+
+
+ private boolean isExternal(String varName) {
+ boolean found=false;
+ Iterator iter = new Iterator();
+ query.getExternalVariables(iter);
+ iter.open();
+ Item item = new Item();
+ while (iter.next(item)) {
+ if (item.getLocalName().equalsIgnoreCase(varName)) {
+ found = true;
+ }
+ }
+ iter.close();
+ iter.delete();
+ return found;
+ }
+
+ @Override
+ public QName[] getAllUnboundExternalVariables() throws XQException {
+ isClosedXQException();
+
+ Collection<QName> result = new ArrayList<QName>();
+ Iterator iter = new Iterator();
+ query.getExternalVariables(iter);
+ Item item = new Item();
+ iter.open();
+ while (iter.next(item)) {
+ boolean found = false;
+ for (String key: itemsBounded){
+ if (item.getLocalName().equalsIgnoreCase(key)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ result.add(new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()));
+ }
+ }
+ iter.close();
+ iter.delete();
+ return result.toArray(new QName[0]);
+ }
+
+ @Override
+ public XQSequenceType getStaticResultType() throws XQException {
+ isClosedXQException();
+ XQSequenceType result = new ZorbaXQSequenceType(new ZorbaXQItemType(XQItemType.XQITEMKIND_ITEM), XQSequenceType.OCC_ZERO_OR_MORE );
+ return result;
+ }
+
+ @Override
+ public XQSequenceType getStaticVariableType(QName varName) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ XQSequenceType result = null;
+ Iterator iter = new Iterator();
+ query.getExternalVariables(iter);
+ iter.open();
+ Item item = new Item();
+ while (iter.next(item)) {
+ if ( item.getLocalName().equalsIgnoreCase(varName.getLocalPart()) &&
+ item.getNamespace().equalsIgnoreCase(varName.getNamespaceURI()) &&
+ item.getPrefix().equalsIgnoreCase(varName.getPrefix()) ) {
+ if (item.getType().getStringValue().equals("xs:QName")) {
+ result = new ZorbaXQSequenceType(new ZorbaXQItemType(XQItemType.XQITEMKIND_ITEM), XQItemType.OCC_ZERO_OR_MORE);
+ } else {
+ result = new ZorbaXQSequenceType(new ZorbaXQItemType(item), XQItemType.OCC_ZERO_OR_MORE);
+ }
+
+ }
+ }
+ iter.close();
+ iter.delete();
+ if (result==null) {
+ throw new XQException("Item not found");
+ }
+ return result;
+ }
+
+ @Override
+ public XQStaticContext getStaticContext() throws XQException {
+ isClosedXQException();
+ if (staticContext==null) {
+ staticContext = new ZorbaXQStaticContext(query.getStaticContext());
+ }
+ return staticContext;
+ }
+
+ @Override
+ public TimeZone getImplicitTimeZone() throws XQException {
+ isClosedXQException();
+ Integer timeZone = (dynamicContext.getImplicitTimezone()/60); // in minutes
+ TimeZone result = TimeZone.getTimeZone("GMT"+timeZone.toString());
+ return result;
+ }
+
+ @Override
+ public void bindAtomicValue(QName varName, String value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ isNullXQException(type);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ if (type.getItemKind()!=XQItemType.XQITEMKIND_ATOMIC) {
+ throw new XQException ("Item kind is not atomic.");
+ }
+ try {
+ XQItem xqitem = connection.createItemFromAtomicValue(value, type);
+ Item item = ((ZorbaXQItem)xqitem).getZorbaItem();
+ dynamicContext.setVariable(varName.getLocalPart(), item);
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding the atomic value: " + e.getLocalizedMessage());
+ }
+
+ }
+
+ @Override
+ public void bindString(QName varName, String value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ isNullXQException(value);
+ if (type==null) {
+ type = ((ZorbaXQConnection)connection).createAtomicType(XQItemType.XQBASETYPE_STRING);
+ }
+ try {
+ Iterator iter = new Iterator();
+ boolean found = false;
+ query.getExternalVariables(iter);
+ Item tmpItem = new Item();
+ iter.open();
+ while (iter.next(tmpItem)) {
+ if (tmpItem.getStringValue().equalsIgnoreCase(varName.getLocalPart())) {
+ XQItem item = connection.createItemFromString(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ found=true;
+ }
+ }
+ iter.close();
+ iter.delete();
+ if (!found) {
+ throw new XQException ("The variable: " + varName.getLocalPart() + " doesn't exist.");
+ }
+ } catch (XQException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new XQException ("Error binding string to the defined type: " + e.getLocalizedMessage());
+ }
+
+ }
+
+ @Override
+ public void bindDocument(QName varName, String value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ isNullXQException(value);
+ if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+ throw new XQException ("Invalid type.");
+ }
+ if (type==null) {
+ type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+ }
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("Variable not found in context.");
+ }
+ try {
+ Iterator iter = xmlDataManager.parseXML(value);
+ Item item = new Item();
+ iter.next(item);
+ dynamicContext.setVariable(varName.getLocalPart(), item);
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding document: " + e.getLocalizedMessage());
+ }
+
+ }
+
+ @Override
+ public void bindDocument(QName varName, Reader value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ isNullXQException(value);
+ if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+ throw new XQException ("Invalid type.");
+ }
+ if (type==null) {
+ type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+ }
+ StringBuffer string = new StringBuffer();
+ CharBuffer buffer = CharBuffer.allocate(1024);
+ Writer writer = new StringWriter();
+
+ try {
+ while( value.read(buffer) >= 0 ) {
+ buffer.flip();
+ writer.append(buffer);
+ buffer.clear();
+ }
+ value.close();
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+
+ bindDocument(varName, writer.toString(), baseURI, type);
+ }
+
+ @Override
+ public void bindDocument(QName varName, InputStream value, String baseURI, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ isNullXQException(value);
+ if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+ throw new XQException ("Invalid type.");
+ }
+ if (type==null) {
+ type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+ }
+ StringBuffer out = new StringBuffer ();
+ try {
+ byte[] b = new byte[4096];
+ for (int n; (n = value.read(b)) != -1;) {
+ out.append(new String(b, 0, n));
+ }
+ } catch (Exception ex) {
+ throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+ }
+ bindDocument(varName, out.toString(), baseURI, type);
+ }
+
+ @Override
+ public void bindDocument(QName varName, XMLStreamReader value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ isNullXQException(value);
+ if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+ throw new XQException ("Invalid type.");
+ }
+ if (type==null) {
+ type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+ }
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t;
+ StAXSource source;
+ StAXResult result;
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ Writer writer = new StringWriter();
+ try {
+ XMLStreamWriter xmlStreamWriter = xof.createXMLStreamWriter(writer);
+ t = tf.newTransformer();
+ source = new StAXSource(value);
+ result = new StAXResult(xmlStreamWriter);
+ t.transform(source, result);
+ } catch (Exception ex) {
+ throw new XQException("Error transforming xml expression" + ex.getLocalizedMessage());
+ }
+ bindDocument(varName, writer.toString(), null, type);
+ }
+
+ private String nodeToString(Node node) {
+ StringWriter sw = new StringWriter();
+ try {
+ Transformer t = TransformerFactory.newInstance().newTransformer();
+ t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ t.transform(new DOMSource(node), new StreamResult(sw));
+ } catch (TransformerException te) {
+ System.out.println("nodeToString Transformer Exception" + te.getLocalizedMessage());
+ }
+ return sw.toString();
+ }
+
+ @Override
+ public void bindDocument(QName varName, Source value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+ throw new XQException ("Invalid type.");
+ }
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ if (type==null) {
+ type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+ }
+ if (value instanceof StreamSource) {
+ bindDocument(varName, ((StreamSource)value).getReader(), null, type);
+ } else if (value instanceof SAXSource) {
+ bindDocument(varName, ((SAXSource)value).getInputSource().getCharacterStream(), null, type);
+ } else if (value instanceof DOMSource) {
+ bindDocument(varName, nodeToString(((DOMSource)value).getNode()), null, type);
+ } else {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+
+ @Override
+ public void setImplicitTimeZone(TimeZone value) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ try {
+ dynamicContext.setImplicitTimezone((value.getRawOffset()/60000));
+ } catch (Exception e) {
+ throw new XQException("Error setting implicit TimeZone: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindItem(QName varName, XQItem value) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)value).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding item: " + varName.getLocalPart() + " with error: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindSequence(QName varName, XQSequence value) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ if (value.isClosed()) {
+ throw new XQException ("Sequence is closed.");
+ }
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ if (!value.isOnItem()) {
+ value.next();
+ }
+ Item item = new Item(((ZorbaXQItem)value.getItem()).getZorbaItem());
+ //Item item2 = new Item(item);
+ //String val = item.getStringValue();
+ dynamicContext.setVariable(varName.getLocalPart(), item);
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding item: " + varName.getLocalPart() + " with error: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindObject(QName varName, Object value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ isNullXQException(value);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromObject(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindBoolean(QName varName, boolean value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromBoolean(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindByte(QName varName, byte value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromByte(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindDouble(QName varName, double value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromDouble(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindFloat(QName varName, float value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromFloat(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindInt(QName varName, int value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromInt(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindLong(QName varName, long value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromLong(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindNode(QName varName, Node value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(value);
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromNode(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void bindShort(QName varName, short value, XQItemType type) throws XQException {
+ isClosedXQException();
+ isNullXQException(varName);
+ if (!isExternal(varName.getLocalPart())) {
+ throw new XQException ("The bound variable must be declared external in the prepared expression.");
+ }
+ try {
+ XQItem item = connection.createItemFromShort(value, type);
+ dynamicContext.setVariable(varName.getLocalPart(), ((ZorbaXQItem)item).getZorbaItem());
+ itemsBounded.add(varName.getLocalPart());
+ } catch (Exception e) {
+ throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+ }
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This prepared expression is closed");
+ }
+ }
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+}
=== added file 'swig/xqj/ZorbaXQResultItem.java'
--- swig/xqj/ZorbaXQResultItem.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQResultItem.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import org.zorbaxquery.api.Item;
+
+public class ZorbaXQResultItem extends ZorbaXQItem implements javax.xml.xquery.XQResultItem {
+
+ private XQConnection connection;
+
+
+ public ZorbaXQResultItem(Item item, XQConnection conn) {
+ super(item);
+ connection = conn;
+ }
+
+ @Override
+ public XQConnection getConnection() throws XQException {
+ if (super.isClosed()) {
+ throw new XQException("Object closed");
+ }
+ return connection;
+ }
+
+
+
+}
=== added file 'swig/xqj/ZorbaXQResultSequence.java'
--- swig/xqj/ZorbaXQResultSequence.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQResultSequence.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,464 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+
+public class ZorbaXQResultSequence implements javax.xml.xquery.XQResultSequence {
+
+ private boolean closed = false;
+ private boolean delivered = false;
+ //private boolean isonitem = false;
+ private boolean consumedItem = false;
+ private boolean iterDeleted = false;
+
+ private XQConnection connection = null;
+ private Iterator iter = null;
+ private ZorbaXQResultItem current = null;
+ private Collection<ZorbaXQResultItem> items = new ArrayList<ZorbaXQResultItem>();
+ private org.zorbaxquery.api.XQuery lQuery=null;
+ private boolean preparedExpression;
+
+ public ZorbaXQResultSequence(XQConnection conn, org.zorbaxquery.api.XQuery query, boolean prepared) {
+ lQuery = query;
+ iter = query.iterator();
+ iter.open();
+ connection = conn;
+ preparedExpression = prepared;
+ }
+
+ @Override
+ public XQConnection getConnection() throws XQException {
+ isClosedXQException();
+ return connection;
+ }
+
+ @Override
+ public boolean absolute(int i) throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public void afterLast() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public void beforeFirst() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public void close() throws XQException {
+ if (!closed) {
+ closed = true;
+ for (ZorbaXQResultItem xitem: items){
+ xitem.close();
+ }
+ items.removeAll(items);
+ if (!iterDeleted) {
+ if (iter.isOpen()) {
+ iter.close();
+ iter.delete();
+ }
+ if (!preparedExpression) {
+ lQuery.delete();
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public int count() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public int getPosition() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean isOnItem() throws XQException {
+ isClosedXQException();
+ return (current!=null);
+ }
+
+ @Override
+ public boolean isScrollable() throws XQException {
+ isClosedXQException();
+ return false;
+ }
+
+ @Override
+ public boolean first() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public XQItem getItem() throws XQException {
+ isClosedXQException();
+ isItemDeliveredXQException();
+ isOnItemXQException();
+
+ delivered = true;
+ consumedItem = true;
+ return current;
+ }
+
+ @Override
+ public XMLStreamReader getSequenceAsStream() throws XQException {
+ isClosedXQException();
+ isConsumedXQException();
+ Properties properties = null;
+ String str = getSequenceAsString(properties);
+ XMLInputFactory fac = XMLInputFactory.newInstance();
+ Reader read = new StringReader(str);
+ XMLStreamReader result = null;
+ try {
+ result = fac.createXMLStreamReader(read);
+ } catch (XMLStreamException ex) {
+ throw new XQException("Problem reading the stream: " + str + " - with error: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public String getSequenceAsString(Properties prprts) throws XQException {
+ isClosedXQException();
+ isConsumedXQException();
+ String result = null;
+ try {
+ /*
+ if (item.isNode() && item.getNodeKind()==3) { //attribute node
+ resultString = resultString.concat(item.getStringValue()).concat(" ");
+ } else {
+ resultString = resultString.concat(item.serialize().replace(">", ">").replace("<", "<")).concat(" ");
+ }
+ *
+ */
+ if (iter.isOpen()) {
+ iter.close();
+ iter.delete();
+ }
+ iterDeleted = true;
+ consumedItem = true;
+ result = lQuery.execute().replace(">", ">").replace("<", "<");
+ } catch (Exception e) {
+ throw new XQException("Error getting stream: " + e.getLocalizedMessage());
+ } finally {
+ if (!preparedExpression) {
+ lQuery.delete();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isAfterLast() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean isFirst() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean isLast() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean last() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean next() throws XQException {
+ isClosedXQException();
+ Item lItem = new Item();
+ current = null;
+ if (iter.next(lItem)) {
+ current = new ZorbaXQResultItem(lItem, connection);
+ items.add(current);
+ delivered = false;
+ lItem.delete();
+ }
+ return (current != null);
+ }
+
+ @Override
+ public boolean previous() throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public boolean relative(int i) throws XQException {
+ isClosedXQException();
+ throw new XQException("This sequence is forward-only");
+ }
+
+ @Override
+ public void writeSequence(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(out);
+ if (isOnItem()) {
+ getItem().writeItem(out, prprts);
+ }
+ while (next()) {
+ getItem().writeItem(out, prprts);
+ }
+ }
+
+ @Override
+ public void writeSequence(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(writer);
+ if (isOnItem()) {
+ getItem().writeItem(writer, prprts);
+ }
+ while (next()) {
+ getItem().writeItem(writer, prprts);
+ }
+ }
+
+ @Override
+ public void writeSequenceToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isNullXQException(ch);
+ if (isOnItem()) {
+ getItem().writeItemToSAX(ch);
+ }
+ while (next()) {
+ getItem().writeItemToSAX(ch);
+ }
+ }
+
+ @Override
+ public void writeSequenceToResult(Result result) throws XQException {
+ isClosedXQException();
+ isNullXQException(result);
+ if (isOnItem()) {
+ getItem().writeItemToResult(result);
+ }
+ while (next()) {
+ getItem().writeItemToResult(result);
+ }
+ }
+
+ @Override
+ public boolean getBoolean() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getBoolean();
+ }
+
+ @Override
+ public byte getByte() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getByte();
+ }
+
+ @Override
+ public double getDouble() throws XQException {
+ isClosedXQException();
+
+ return getItem().getDouble();
+ }
+
+ @Override
+ public float getFloat() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getFloat();
+ }
+
+ @Override
+ public int getInt() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getInt();
+ }
+
+ @Override
+ public XQItemType getItemType() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return current.getItemType();
+ }
+
+ @Override
+ public String getAtomicValue() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getAtomicValue();
+ }
+
+ @Override
+ public long getLong() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getLong();
+ }
+
+ @Override
+ public Node getNode() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getNode();
+ }
+
+ @Override
+ public URI getNodeUri() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return current.getNodeUri();
+ }
+
+ @Override
+ public Object getObject() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getObject();
+ }
+
+ @Override
+ public XMLStreamReader getItemAsStream() throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ return getItem().getItemAsStream();
+ }
+
+ @Override
+ public String getItemAsString(Properties prprts) throws XQException {
+ isClosedXQException();
+ return getItem().getItemAsString(prprts);
+ }
+
+ @Override
+ public short getShort() throws XQException {
+ isClosedXQException();
+ return getItem().getShort();
+ }
+
+ @Override
+ public boolean instanceOf(XQItemType xqit) throws XQException {
+ isClosedXQException();
+ isOnItemXQException();
+ isNullXQException(xqit);
+ return current.instanceOf(xqit);
+ }
+
+ @Override
+ public void writeItem(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(out);
+ isNullXQException(prprts);
+ getItem().writeItem(out, prprts);
+ }
+
+ @Override
+ public void writeItem(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(writer);
+ isNullXQException(prprts);
+ getItem().writeItem(writer, prprts);
+ }
+
+ @Override
+ public void writeItemToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isNullXQException(ch);
+ getItem().writeItemToSAX(ch);
+ }
+
+ @Override
+ public void writeItemToResult(Result result) throws XQException {
+ isClosedXQException();
+ isNullXQException(result);
+ getItem().writeItemToResult(result);
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This sequence is closed");
+ }
+ }
+ private void isConsumedXQException() throws XQException {
+ if (consumedItem) {
+ throw new XQException("Items already consumed");
+ }
+ }
+ private void isItemDeliveredXQException() throws XQException {
+ if (delivered) {
+ throw new XQException("Item already consumed");
+ }
+ }
+ private void isOnItemXQException() throws XQException {
+ if (current==null) {
+ throw new XQException("There are no more items to consume");
+ }
+ }
+
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+}
=== added file 'swig/xqj/ZorbaXQResultSequenceScrollable.java'
--- swig/xqj/ZorbaXQResultSequenceScrollable.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQResultSequenceScrollable.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,464 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQResultItem;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+
+public class ZorbaXQResultSequenceScrollable implements javax.xml.xquery.XQResultSequence {
+
+ private boolean closed = false;
+ private boolean forwardOnly = false;
+ private boolean currentItemGet = false;
+ private Collection<XQResultItem> content = new ArrayList<XQResultItem>();
+ private int position = 0;
+ int size = 0;
+ private XQConnection connection = null;
+ boolean preparedExpression;
+
+ public ZorbaXQResultSequenceScrollable(XQConnection conn, org.zorbaxquery.api.XQuery query, boolean prepared) {
+ Iterator iter;
+ iter = query.iterator();
+ iter.open();
+ Item item = new Item();
+ while (iter.next(item)) {
+ XQResultItem rItem = new ZorbaXQResultItem(item, conn);
+ content.add(rItem);
+ }
+ iter.close();
+ iter.delete();
+ size = content.size();
+ connection = conn;
+ preparedExpression = prepared;
+ }
+
+ @Override
+ public boolean absolute(int i) throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ position = 0;
+ if (size>0) {
+ if (i>0) {
+ if (i>size) {
+ position = size+1;
+ } else {
+ position = i;
+ result = true;
+ }
+ } else if(i<0) {
+ if (i>(-size)) {
+ position = size+i+1;
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void afterLast() throws XQException {
+ isClosedXQException();
+ position = size+1;
+ }
+
+ @Override
+ public void beforeFirst() throws XQException {
+ isClosedXQException();
+ position = 0;
+ }
+
+ @Override
+ public void close() throws XQException {
+ closed = true;
+ for (XQItem item: content) {
+ item.close();
+ }
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public int count() throws XQException {
+ isClosedXQException();
+ return size;
+ }
+
+ @Override
+ public int getPosition() throws XQException {
+ isClosedXQException();
+ return position;
+ }
+
+ @Override
+ public boolean isOnItem() throws XQException {
+ isClosedXQException();
+ return (position>0) && (position<(content.size()+1));
+ }
+
+ @Override
+ public boolean isScrollable() throws XQException {
+ isClosedXQException();
+ return !forwardOnly;
+ }
+
+ @Override
+ public boolean first() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (content.size()>0) {
+ position = 1;
+ result = true;
+ }
+ return result;
+ }
+
+ @Override
+ public XQItem getItem() throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ return (XQItem)content.toArray()[position-1];
+ }
+
+ @Override
+ public XMLStreamReader getSequenceAsStream() throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ StringBuffer sb = new StringBuffer();
+ for (XQItem item: content) {
+ sb.append(item.getItemAsString(null));
+ }
+ XMLInputFactory fac = XMLInputFactory.newInstance();
+ Reader read = new StringReader(sb.toString());
+ XMLStreamReader result = null;
+ try {
+ result = fac.createXMLStreamReader(read);
+ } catch (XMLStreamException ex) {
+ throw new XQException("Problem reading the stream: " + sb + " - with error: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public String getSequenceAsString(Properties prprts) throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ StringBuffer sb = new StringBuffer();
+ for (XQItem item: content) {
+ sb.append(item.getItemAsString(null));
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public boolean isAfterLast() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (size>0) {
+ result = position==size+1;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (content.size()>0) {
+ result = position==0;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isFirst() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (content.size()>0) {
+ result = position==1;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isLast() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (size>0) {
+ result = position==size;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean last() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (size>0) {
+ position = size;
+ result = true;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean next() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if ((position<=size) && (size>0)) {
+ result = (position<size);
+ position++;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean previous() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if ((position>0) && (size>0)) {
+ result = (position>1);
+ position--;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean relative(int i) throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if ((i!=0) && (size>0)) {
+ position = position + i;
+ if (position<0) {
+ position = 0;
+ } else if (position>size) {
+ position=size+1;
+ } else {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void writeSequence(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(out);
+ if (isOnItem()) {
+ getItem().writeItem(out, prprts);
+ }
+ while (next()) {
+ getItem().writeItem(out, prprts);
+ }
+ }
+
+ @Override
+ public void writeSequence(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(writer);
+ if (isOnItem()) {
+ getItem().writeItem(writer, prprts);
+ }
+ while (next()) {
+ getItem().writeItem(writer, prprts);
+ }
+ }
+
+ @Override
+ public void writeSequenceToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isNullXQException(ch);
+ if (isOnItem()) {
+ getItem().writeItemToSAX(ch);
+ }
+ while (next()) {
+ getItem().writeItemToSAX(ch);
+ }
+ }
+
+ @Override
+ public void writeSequenceToResult(Result result) throws XQException {
+ isClosedXQException();
+ isNullXQException(result);
+ if (isOnItem()) {
+ getItem().writeItemToResult(result);
+ }
+ while (next()) {
+ getItem().writeItemToResult(result);
+ }
+ }
+
+ @Override
+ public boolean getBoolean() throws XQException {
+ isClosedXQException();
+ return getItem().getBoolean();
+ }
+
+ @Override
+ public byte getByte() throws XQException {
+ isClosedXQException();
+ return getItem().getByte();
+ }
+
+ @Override
+ public double getDouble() throws XQException {
+ isClosedXQException();
+ return getItem().getDouble();
+ }
+
+ @Override
+ public float getFloat() throws XQException {
+ isClosedXQException();
+ return getItem().getFloat();
+ }
+
+ @Override
+ public int getInt() throws XQException {
+ isClosedXQException();
+ return getItem().getInt();
+ }
+
+ @Override
+ public XQItemType getItemType() throws XQException {
+ isClosedXQException();
+ return getItem().getItemType();
+ }
+
+ @Override
+ public String getAtomicValue() throws XQException {
+ isClosedXQException();
+ return getItem().getAtomicValue();
+ }
+
+ @Override
+ public long getLong() throws XQException {
+ isClosedXQException();
+ return getItem().getLong();
+ }
+
+ @Override
+ public Node getNode() throws XQException {
+ isClosedXQException();
+ return getItem().getNode();
+ }
+
+ @Override
+ public URI getNodeUri() throws XQException {
+ isClosedXQException();
+ return getItem().getNodeUri();
+ }
+
+ @Override
+ public Object getObject() throws XQException {
+ isClosedXQException();
+ return getItem().getObject();
+ }
+
+ @Override
+ public XMLStreamReader getItemAsStream() throws XQException {
+ isClosedXQException();
+ return getItem().getItemAsStream();
+ }
+
+ @Override
+ public String getItemAsString(Properties prprts) throws XQException {
+ return getItem().getItemAsString(prprts);
+ }
+
+ @Override
+ public short getShort() throws XQException {
+ isClosedXQException();
+ return getItem().getShort();
+ }
+
+ @Override
+ public boolean instanceOf(XQItemType xqit) throws XQException {
+ isClosedXQException();
+ isNullXQException(xqit);
+ return getItem().instanceOf(xqit);
+ }
+
+ @Override
+ public void writeItem(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(out);
+ getItem().writeItem(out, prprts);
+ }
+
+ @Override
+ public void writeItem(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(writer);
+ getItem().writeItem(writer, prprts);
+ }
+
+ @Override
+ public void writeItemToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isNullXQException(ch);
+ getItem().writeItemToSAX(ch);
+ }
+
+ @Override
+ public void writeItemToResult(Result result) throws XQException {
+ isClosedXQException();
+ isNullXQException(result);
+ getItem().writeItemToResult(result);
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This sequence is closed");
+ }
+ }
+ private void isItemGetXQException() throws XQException {
+ if (forwardOnly && currentItemGet) {
+ throw new XQException("Item already consumed on a forward-only sequence");
+ }
+ }
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+
+ @Override
+ public XQConnection getConnection() throws XQException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
=== added file 'swig/xqj/ZorbaXQSequence.java'
--- swig/xqj/ZorbaXQSequence.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQSequence.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,472 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQSequence;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.zorbaxquery.api.Item;
+
+public class ZorbaXQSequence implements javax.xml.xquery.XQSequence {
+
+ private boolean closed = false;
+ private boolean forwardOnly = true;
+ private boolean currentItemGet = false;
+ private Collection<XQItem> content = new ArrayList<XQItem>();
+ private int position = 0;
+ int size = 0;
+
+ public ZorbaXQSequence(XQSequence sequence) throws XQException {
+ try {
+ while (sequence.next()) {
+ XQItem tmpItem = sequence.getItem();
+ Item item = null;
+ if (tmpItem instanceof ZorbaXQItem) {
+ item = ((ZorbaXQItem)tmpItem).getZorbaItem();
+ } else if (tmpItem instanceof ZorbaXQResultItem) {
+ item = ((ZorbaXQResultItem)tmpItem).getZorbaItem();
+ }
+ content.add(new ZorbaXQItem(item));
+ }
+ size = content.size();
+ } catch (Exception e) {
+ throw new XQException("Error iterating from origin object" + e.getLocalizedMessage());
+ }
+
+ }
+
+ public ZorbaXQSequence(java.util.Iterator iterator) {
+ while (iterator.hasNext()) {
+ Object o = iterator.next();
+ if (o instanceof XQItem) {
+ content.add((XQItem)o);
+ }
+ }
+ size = content.size();
+ }
+
+ @Override
+ public boolean absolute(int i) throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ position = 0;
+ if (size>0) {
+ if (i>0) {
+ if (i>size) {
+ position = size+1;
+ } else {
+ position = i;
+ result = true;
+ }
+ } else if(i<0) {
+ if (i>(-size)) {
+ position = size+i+1;
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void afterLast() throws XQException {
+ isClosedXQException();
+ position = content.size()+1;
+ }
+
+ @Override
+ public void beforeFirst() throws XQException {
+ isClosedXQException();
+ position = 0;
+ }
+
+ @Override
+ public void close() throws XQException {
+ closed = true;
+ for (XQItem item: content) {
+ item.close();
+ }
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public int count() throws XQException {
+ isClosedXQException();
+ return size;
+ }
+
+ @Override
+ public int getPosition() throws XQException {
+ isClosedXQException();
+ return position;
+ }
+
+ @Override
+ public boolean isOnItem() throws XQException {
+ isClosedXQException();
+ return (position>0) && (position<(content.size()+1));
+ }
+
+ @Override
+ public boolean isScrollable() throws XQException {
+ isClosedXQException();
+ return !forwardOnly;
+ }
+
+ @Override
+ public boolean first() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (content.size()>0) {
+ position = 1;
+ result = true;
+ }
+ return result;
+ }
+
+ @Override
+ public XQItem getItem() throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ return (XQItem)content.toArray()[position-1];
+ }
+
+ @Override
+ public XMLStreamReader getSequenceAsStream() throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ StringBuffer sb = new StringBuffer();
+ for (XQItem item: content) {
+ sb.append(item.getItemAsString(null));
+ }
+ XMLInputFactory fac = XMLInputFactory.newInstance();
+ Reader read = new StringReader(sb.toString());
+ XMLStreamReader result = null;
+ try {
+ result = fac.createXMLStreamReader(read);
+ } catch (XMLStreamException ex) {
+ throw new XQException("Problem reading the stream: " + sb + " - with error: " + ex.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public String getSequenceAsString(Properties prprts) throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ StringBuffer sb = new StringBuffer();
+ for (XQItem item: content) {
+ sb.append(item.getItemAsString(null));
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public boolean isAfterLast() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (size>0) {
+ result = position==size+1;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (content.size()>0) {
+ result = position==0;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isFirst() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (content.size()>0) {
+ result = position==1;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isLast() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (size>0) {
+ result = position==size;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean last() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if (size>0) {
+ position = size;
+ result = true;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean next() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if ((position<=size) && (size>0)) {
+ result = (position<size);
+ position++;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean previous() throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if ((position>0) && (size>0)) {
+ result = (position>1);
+ position--;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean relative(int i) throws XQException {
+ isClosedXQException();
+ boolean result = false;
+ if ((i!=0) && (size>0)) {
+ position = position + i;
+ if (position<0) {
+ position = 0;
+ } else if (position>size) {
+ position=size+1;
+ } else {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void writeSequence(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ isNullXQException(out);
+ if (isOnItem()) {
+ getItem().writeItem(out, prprts);
+ }
+ while (next()) {
+ getItem().writeItem(out, prprts);
+ }
+ }
+
+ @Override
+ public void writeSequence(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ isNullXQException(writer);
+ if (isOnItem()) {
+ getItem().writeItem(writer, prprts);
+ }
+ while (next()) {
+ getItem().writeItem(writer, prprts);
+ }
+ }
+
+ @Override
+ public void writeSequenceToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ isNullXQException(ch);
+ if (isOnItem()) {
+ getItem().writeItemToSAX(ch);
+ }
+ while (next()) {
+ getItem().writeItemToSAX(ch);
+ }
+ }
+
+ @Override
+ public void writeSequenceToResult(Result result) throws XQException {
+ isClosedXQException();
+ isItemGetXQException();
+ isNullXQException(result);
+ if (isOnItem()) {
+ getItem().writeItemToResult(result);
+ }
+ while (next()) {
+ getItem().writeItemToResult(result);
+ }
+ }
+
+ @Override
+ public boolean getBoolean() throws XQException {
+ isClosedXQException();
+ return getItem().getBoolean();
+ }
+
+ @Override
+ public byte getByte() throws XQException {
+ isClosedXQException();
+ return getItem().getByte();
+ }
+
+ @Override
+ public double getDouble() throws XQException {
+ isClosedXQException();
+ return getItem().getDouble();
+ }
+
+ @Override
+ public float getFloat() throws XQException {
+ isClosedXQException();
+ return getItem().getFloat();
+ }
+
+ @Override
+ public int getInt() throws XQException {
+ isClosedXQException();
+ return getItem().getInt();
+ }
+
+ @Override
+ public XQItemType getItemType() throws XQException {
+ isClosedXQException();
+ return getItem().getItemType();
+ }
+
+ @Override
+ public String getAtomicValue() throws XQException {
+ isClosedXQException();
+ return getItem().getAtomicValue();
+ }
+
+ @Override
+ public long getLong() throws XQException {
+ isClosedXQException();
+ return getItem().getLong();
+ }
+
+ @Override
+ public Node getNode() throws XQException {
+ isClosedXQException();
+ return getItem().getNode();
+ }
+
+ @Override
+ public URI getNodeUri() throws XQException {
+ isClosedXQException();
+ return getItem().getNodeUri();
+ }
+
+ @Override
+ public Object getObject() throws XQException {
+ isClosedXQException();
+ return getItem().getObject();
+ }
+
+ @Override
+ public XMLStreamReader getItemAsStream() throws XQException {
+ isClosedXQException();
+ return getItem().getItemAsStream();
+ }
+
+ @Override
+ public String getItemAsString(Properties prprts) throws XQException {
+ isClosedXQException();
+ return getItem().getItemAsString(prprts);
+ }
+
+ @Override
+ public short getShort() throws XQException {
+ isClosedXQException();
+ return getItem().getShort();
+ }
+
+ @Override
+ public boolean instanceOf(XQItemType xqit) throws XQException {
+ isClosedXQException();
+ isNullXQException(xqit);
+ return getItem().instanceOf(xqit);
+ }
+
+ @Override
+ public void writeItem(OutputStream out, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(out);
+ getItem().writeItem(out, prprts);
+ }
+
+ @Override
+ public void writeItem(Writer writer, Properties prprts) throws XQException {
+ isClosedXQException();
+ isNullXQException(writer);
+ getItem().writeItem(writer, prprts);
+ }
+
+ @Override
+ public void writeItemToSAX(ContentHandler ch) throws XQException {
+ isClosedXQException();
+ isNullXQException(ch);
+ getItem().writeItemToSAX(ch);
+ }
+
+ @Override
+ public void writeItemToResult(Result result) throws XQException {
+ isClosedXQException();
+ isNullXQException(result);
+ getItem().writeItemToResult(result);
+ }
+
+ private void isClosedXQException() throws XQException {
+ if (closed) {
+ throw new XQException("This sequence is closed");
+ }
+ }
+ private void isItemGetXQException() throws XQException {
+ if (forwardOnly && currentItemGet) {
+ throw new XQException("Item already consumed on a forward-only sequence");
+ }
+ }
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+}
=== added file 'swig/xqj/ZorbaXQSequenceType.java'
--- swig/xqj/ZorbaXQSequenceType.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQSequenceType.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQSequenceType;
+
+
+public class ZorbaXQSequenceType implements javax.xml.xquery.XQSequenceType {
+
+ XQItemType type;
+ int occurence;
+
+ public ZorbaXQSequenceType(XQItemType type, int occurence) {
+ this.type = type;
+ this.occurence = occurence;
+ }
+
+ @Override
+ public XQItemType getItemType() {
+ return type;
+ }
+
+ @Override
+ public int getItemOccurrence() {
+ return occurence;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+
+ try {
+
+ result.append(type.toString());
+
+ for (java.lang.reflect.Field field: ZorbaXQSequenceType.class.getFields()) {
+ if (field.getName().startsWith("OCC_")) {
+ if (field.getInt(this)==occurence) {
+ result.append("Ocurrence: ").append(field.getName().substring(4));
+ }
+ }
+ }
+ } catch (Exception e){
+ result.append("Sequence Type error: ").append(e.getLocalizedMessage());
+ }
+
+ return result.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ boolean result = false;
+ if (o instanceof XQSequenceType) {
+ result = (occurence != XQSequenceType.OCC_EMPTY) &&
+ (type.equals(((XQSequenceType)o).getItemType())) &&
+ (occurence == ((XQSequenceType)o).getItemOccurrence());
+ }
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode;
+ if (occurence == XQSequenceType.OCC_EMPTY) {
+ hashCode = 1;
+ } else {
+ hashCode = occurence * 31 + type.hashCode();
+ }
+ return hashCode;
+ }
+
+}
=== added file 'swig/xqj/ZorbaXQStaticContext.java'
--- swig/xqj/ZorbaXQStaticContext.java 1970-01-01 00:00:00 +0000
+++ swig/xqj/ZorbaXQStaticContext.java 2012-01-07 02:13:25 +0000
@@ -0,0 +1,346 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zorbaxquery.api.xqj;
+
+import javax.xml.xquery.XQConstants;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItemType;
+import org.zorbaxquery.api.StaticContext;
+import org.zorbaxquery.api.TypeIdentifier;
+import org.zorbaxquery.api.ZorbaConstants.BoundarySpaceMode;
+import org.zorbaxquery.api.ZorbaConstants.ConstructionMode;
+import org.zorbaxquery.api.ZorbaConstants.InheritMode;
+import org.zorbaxquery.api.ZorbaConstants.OrderEmptyMode;
+import org.zorbaxquery.api.ZorbaConstants.OrderingMode;
+import org.zorbaxquery.api.ZorbaConstants.PreserveMode;
+
+public class ZorbaXQStaticContext implements javax.xml.xquery.XQStaticContext {
+
+
+ private StaticContext staticContext;
+ private int scrollability = XQConstants.SCROLLTYPE_FORWARD_ONLY;
+ private int holdability = XQConstants.HOLDTYPE_CLOSE_CURSORS_AT_COMMIT;
+ private int queryLang = XQConstants.LANGTYPE_XQUERY;
+ private int binding = XQConstants.BINDING_MODE_IMMEDIATE;
+ String baseURI = null; //Patch for Zorba, bug filed on https://bugs.launchpad.net/zorba/+bug/905028
+ XQItemType contextItemStaticType = null; //Patch for Zorba, TypeIdentifier is not complete
+ protected StaticContext getZorbaStaticContext() {
+ return staticContext;
+ }
+
+ public ZorbaXQStaticContext(StaticContext sc) {
+ staticContext = sc;
+ }
+
+ @Override
+ public String[] getNamespacePrefixes() {
+
+ throw new UnsupportedOperationException("Not supported yet. https://bugs.launchpad.net/zorba/+bug/905035");
+ }
+
+ @Override
+ public String getNamespaceURI(String prefix) throws XQException {
+ isNullXQException(prefix);
+ String result = null;
+ try {
+ result = staticContext.getNamespaceURIByPrefix(prefix);
+ } catch (Exception e) {
+ throw new XQException("Error getting Namespace URI" + e.getLocalizedMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public void declareNamespace(String prefix, String URI) throws XQException {
+ isNullXQException(prefix);
+ isNullXQException(URI);
+ try {
+ staticContext.addNamespace(prefix, URI);
+ } catch (Exception e) {
+ throw new XQException("Error declaring namespace on static context:" + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public String getDefaultElementTypeNamespace() {
+ return staticContext.getDefaultElementAndTypeNamespace();
+ }
+
+ @Override
+ public void setDefaultElementTypeNamespace(String URI) throws XQException {
+ isNullXQException(URI);
+ staticContext.setDefaultElementAndTypeNamespace(URI);
+ }
+
+ @Override
+ public String getDefaultFunctionNamespace() {
+ return staticContext.getDefaultFunctionNamespace();
+ }
+
+ @Override
+ public void setDefaultFunctionNamespace(String URI) throws XQException {
+ isNullXQException(URI);
+ staticContext.setDefaultFunctionNamespace(URI);
+ }
+
+ @Override
+ public XQItemType getContextItemStaticType() {
+ //not very complete implementation
+ //TypeIdentifier type = staticContext.getContextItemStaticType();
+ return contextItemStaticType;
+ }
+
+ @Override
+ public void setContextItemStaticType(XQItemType xqit) throws XQException {
+ contextItemStaticType = xqit;
+ if (xqit instanceof ZorbaXQItemType) {
+ ZorbaXQItemType wrapper = (ZorbaXQItemType) xqit;
+ staticContext.setContextItemStaticType(wrapper.getTypeIdentifier());
+ }
+ }
+
+ @Override
+ public String getDefaultCollation() {
+ return staticContext.getDefaultCollation();
+ }
+
+ @Override
+ public void setDefaultCollation(String URI) throws XQException {
+ isNullXQException(URI);
+ staticContext.setDefaultCollation(URI);
+ }
+
+ @Override
+ public int getConstructionMode() {
+ int result = XQConstants.CONSTRUCTION_MODE_PRESERVE;
+ int mode = staticContext.getConstructionMode();
+ if (mode == ConstructionMode.STRIP_CONSTRUCTION) {
+ result = XQConstants.CONSTRUCTION_MODE_STRIP;
+ }
+ return result;
+ }
+
+ @Override
+ public void setConstructionMode(int i) throws XQException {
+ if (!((i==XQConstants.CONSTRUCTION_MODE_PRESERVE) || (i==XQConstants.CONSTRUCTION_MODE_STRIP))) {
+ throw new XQException("Invalid construction mode.");
+ }
+ int mode = ConstructionMode.STRIP_CONSTRUCTION;
+ if (i==XQConstants.CONSTRUCTION_MODE_PRESERVE) {
+ mode = ConstructionMode.PRESERVE_CONSTRUCTION;
+ }
+ staticContext.setConstructionMode(mode);
+ }
+
+ @Override
+ public int getOrderingMode() {
+ int result = XQConstants.ORDERING_MODE_ORDERED;
+ int mode = staticContext.getOrderingMode();
+ if (mode == OrderingMode.UNORDERED) {
+ result = XQConstants.ORDERING_MODE_UNORDERED;
+ }
+ return result;
+ }
+
+ @Override
+ public void setOrderingMode(int i) throws XQException {
+ if (!((i==XQConstants.ORDERING_MODE_ORDERED) || (i==XQConstants.ORDERING_MODE_UNORDERED))) {
+ throw new XQException("Invalid ordering mode.");
+ }
+ int mode = OrderingMode.ORDERED;
+ if (i==XQConstants.ORDERING_MODE_UNORDERED) {
+ mode = OrderingMode.UNORDERED;
+ }
+ staticContext.setOrderingMode(mode);
+ }
+
+ @Override
+ public int getDefaultOrderForEmptySequences() {
+ int result = XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST;
+ int order = staticContext.getDefaultOrderForEmptySequences();
+ if (order == OrderEmptyMode.EMPTY_LEAST) {
+ result = XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST;
+ }
+ return result;
+ }
+
+ @Override
+ public void setDefaultOrderForEmptySequences(int i) throws XQException {
+ if (!((i == XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST) || (i==XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST))) {
+ throw new XQException("Invalid order specified.");
+ }
+ int result = OrderEmptyMode.EMPTY_GREATEST;
+ if (i == XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST) {
+ result = OrderEmptyMode.EMPTY_LEAST;
+ }
+ staticContext.setDefaultOrderForEmptySequences(result);
+ }
+
+ @Override
+ public int getBoundarySpacePolicy() {
+ int result = XQConstants.BOUNDARY_SPACE_PRESERVE;
+ int boundary = staticContext.getBoundarySpacePolicy();
+ if (boundary == BoundarySpaceMode.STRIP_SPACE) {
+ result = XQConstants.BOUNDARY_SPACE_STRIP;
+ }
+ return result;
+ }
+
+ @Override
+ public void setBoundarySpacePolicy(int i) throws XQException {
+ if (!((i == XQConstants.BOUNDARY_SPACE_PRESERVE) || (i==XQConstants.BOUNDARY_SPACE_STRIP))) {
+ throw new XQException("Invalid boundary specified.");
+ }
+ int result = BoundarySpaceMode.PRESERVE_SPACE;
+ if (i == XQConstants.BOUNDARY_SPACE_STRIP) {
+ result = BoundarySpaceMode.STRIP_SPACE;
+ }
+ staticContext.setBoundarySpacePolicy(result);
+ }
+
+ @Override
+ public int getCopyNamespacesModePreserve() {
+ int result = XQConstants.COPY_NAMESPACES_MODE_NO_PRESERVE;
+ int preserve = staticContext.getCopyNamespacesModePreserve();
+ if (preserve == PreserveMode.PRESERVE) {
+ result = XQConstants.COPY_NAMESPACES_MODE_PRESERVE;
+ }
+ return result;
+ }
+
+ @Override
+ public void setCopyNamespacesModePreserve(int i) throws XQException {
+ if (!((i==XQConstants.COPY_NAMESPACES_MODE_PRESERVE) || (i==XQConstants.COPY_NAMESPACES_MODE_NO_PRESERVE))) {
+ throw new XQException("The specified mode is invalid.");
+ }
+ int inherit = staticContext.getCopyNamespacesModeInherit();
+ int preserve = PreserveMode.NO_PRESERVE;
+ if (i==XQConstants.COPY_NAMESPACES_MODE_PRESERVE) {
+ preserve = PreserveMode.PRESERVE;
+ }
+ staticContext.setCopyNamespacesMode(preserve, inherit);
+ }
+
+ @Override
+ public int getCopyNamespacesModeInherit() {
+ int result = XQConstants.COPY_NAMESPACES_MODE_NO_INHERIT;
+ int inherit = staticContext.getCopyNamespacesModeInherit();
+ if (inherit == InheritMode.INHERIT) {
+ result = XQConstants.COPY_NAMESPACES_MODE_INHERIT;
+ }
+ return result;
+ }
+
+ @Override
+ public void setCopyNamespacesModeInherit(int i) throws XQException {
+ if (!((i==XQConstants.COPY_NAMESPACES_MODE_INHERIT) || (i==XQConstants.COPY_NAMESPACES_MODE_NO_INHERIT))) {
+ throw new XQException("The specified mode is invalid.");
+ }
+ int preserve = staticContext.getCopyNamespacesModePreserve();
+ int inherit = InheritMode.NO_INHERIT;
+ if (i==XQConstants.COPY_NAMESPACES_MODE_INHERIT) {
+ inherit = InheritMode.INHERIT;
+ }
+ staticContext.setCopyNamespacesMode(preserve, inherit);
+ }
+
+ @Override
+ public String getBaseURI() {
+ if (baseURI==null) {
+ return staticContext.getBaseURI();
+ } else {
+ return baseURI;
+ }
+ }
+
+ @Override
+ public void setBaseURI(String URI) throws XQException {
+ isNullXQException(URI);
+ staticContext.setBaseURI(URI);
+ baseURI = URI;
+ }
+
+ @Override
+ public int getBindingMode() {
+ return binding;
+ }
+
+ @Override
+ public void setBindingMode(int i) throws XQException {
+ if (!((i==XQConstants.BINDING_MODE_DEFERRED) || (i==XQConstants.BINDING_MODE_IMMEDIATE))) {
+ throw new XQException("The specified mode is invalid.");
+ }
+ binding = i;
+ }
+
+ @Override
+ public int getHoldability() {
+ return holdability;
+ }
+
+ @Override
+ public void setHoldability(int i) throws XQException {
+ if (!((i==XQConstants.HOLDTYPE_HOLD_CURSORS_OVER_COMMIT) || (i==XQConstants.HOLDTYPE_CLOSE_CURSORS_AT_COMMIT))) {
+ throw new XQException ("Invalid holdability parameter.");
+ }
+ holdability = i;
+ }
+
+ @Override
+ public int getQueryLanguageTypeAndVersion() {
+ return queryLang;
+ }
+
+ @Override
+ public void setQueryLanguageTypeAndVersion(int i) throws XQException {
+ if (!((i==XQConstants.LANGTYPE_XQUERY) || (i==XQConstants.LANGTYPE_XQUERYX))) {
+ throw new XQException ("Invalid holdability parameter.");
+ }
+ queryLang = i;
+ }
+
+ @Override
+ public int getScrollability() {
+ return scrollability;
+ }
+
+ @Override
+ public void setScrollability(int i) throws XQException {
+ if (!((i==XQConstants.SCROLLTYPE_FORWARD_ONLY) || (i==XQConstants.SCROLLTYPE_SCROLLABLE))) {
+ throw new XQException ("Invalid scroll type.");
+ }
+ scrollability = i;
+ }
+
+ @Override
+ public int getQueryTimeout() {
+ return 0;
+ }
+
+ @Override
+ public void setQueryTimeout(int i) throws XQException {
+ if (i<0) {
+ throw new XQException("Value can't be negative.");
+ }
+ }
+
+ private void isNullXQException(Object value) throws XQException {
+ if (value==null) {
+ throw new XQException("Parameter shouldn't be null");
+ }
+ }
+
+}
=== added directory 'swig/xqj/tck'
=== added file 'swig/xqj/tck/junit-4.9.jar'
Binary files swig/xqj/tck/junit-4.9.jar 1970-01-01 00:00:00 +0000 and swig/xqj/tck/junit-4.9.jar 2012-01-07 02:13:25 +0000 differ
=== added file 'swig/xqj/tck/xqj_test.bat.in'
--- swig/xqj/tck/xqj_test.bat.in 1970-01-01 00:00:00 +0000
+++ swig/xqj/tck/xqj_test.bat.in 2012-01-07 02:13:25 +0000
@@ -0,0 +1,38 @@
+@ECHO OFF
+
+:: Copyright 2006-2008 The FLWOR Foundation.
+::
+:: Licensed under the Apache License, Version 2.0 (the "License");
+:: you may not use this file except in compliance with the License.
+:: You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing, software
+:: distributed under the License is distributed on an "AS IS" BASIS,
+:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+:: See the License for the specific language governing permissions and
+:: limitations under the License.
+::
+
+SET JAVA_LOAD_PATH=@JAVA_LOAD_PATH@
+SET XQJ_LOAD_PATH=@XQJ_LOAD_PATH@
+SET PATH=%PATH%;%XQJ_LOAD_PATH%
+
+ECHO "xqj_test.bat: Deleting old Java API if found..."
+RD /S /Q "%XQJ_LOAD_PATH%\tck\org"
+DEL "%XQJ_LOAD_PATH%\tck\zorba_api.jar"
+
+ECHO "xqj_test.bat: Compile Java API ..."
+"@Java_JAVAC_EXECUTABLE@" -d tck "%JAVA_LOAD_PATH%\*.java"
+
+ECHO "xqj_test.bat: Creating API JAR..."
+cd tck
+"@Java_JAR_EXECUTABLE@" -cf "zorba_api.jar" org
+cd..
+
+ECHO "xqj_test.bat: Compile XQJ API ..."
+"@Java_JAVAC_EXECUTABLE@" -cp tck\xqjapi.jar;tck -d tck *.java
+
+ECHO "xqj_test.bat: Executing XQJ TCK ..."
+"@Java_JAVA_EXECUTABLE@" -cp tck\xqjapi.jar;tck;tck\xqjtck.jar;tck\junit-4.9.jar -Dcom.oracle.xqj.tck.datasource=tck\zorba.properties com.oracle.xqj.tck.AllTests
=== added file 'swig/xqj/tck/xqj_test.sh.in'
--- swig/xqj/tck/xqj_test.sh.in 1970-01-01 00:00:00 +0000
+++ swig/xqj/tck/xqj_test.sh.in 2012-01-07 02:13:25 +0000
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+JAVA_LOAD_PATH=@JAVA_LOAD_PATH@
+XQJ_LOAD_PATH=@XQJ_LOAD_PATH@
+export LD_LIBRARY_PATH=$JAVA_LOAD_PATH
+# The following for Mac OS X
+export DYLD_LIBRARY_PATH=$JAVA_LOAD_PATH
+export CLASSPATH="tck:$XQJ_LOAD_PATH"
+
+echo "\njava_test.sh: Compile Java API ..."
+/usr/bin/javac -d tck $JAVA_LOAD_PATH/*.java
+
+echo "\njava_test.sh: Compile XQJ API ..."
+/usr/bin/javac -cp tck/xqjapi.jar:tck -d tck $XQJ_LOAD_PATH/*.java
+
+echo "\njava_test.sh: Executing XQJ TCK ..."
+/usr/bin/java -Dcom.oracle.xqj.tck.datasource=tck/zorba.properties -cp tck/:tck/xqjapi.jar:tck/xqjtck.jar:tck/junit-4.9.jar com.oracle.xqj.tck.AllTests
=== added file 'swig/xqj/tck/xqjapi.jar'
Binary files swig/xqj/tck/xqjapi.jar 1970-01-01 00:00:00 +0000 and swig/xqj/tck/xqjapi.jar 2012-01-07 02:13:25 +0000 differ
=== added file 'swig/xqj/tck/xqjtck.jar'
Binary files swig/xqj/tck/xqjtck.jar 1970-01-01 00:00:00 +0000 and swig/xqj/tck/xqjtck.jar 2012-01-07 02:13:25 +0000 differ
=== added file 'swig/xqj/tck/zorba.properties'
--- swig/xqj/tck/zorba.properties 1970-01-01 00:00:00 +0000
+++ swig/xqj/tck/zorba.properties 2012-01-07 02:13:25 +0000
@@ -0,0 +1,2 @@
+XQDataSourceClassName = org.zorbaxquery.api.xqj.ZorbaXQDataSource
+
=== modified file 'swig/zorba_api.i'
--- swig/zorba_api.i 2011-10-12 20:56:27 +0000
+++ swig/zorba_api.i 2012-01-07 02:13:25 +0000
@@ -16,8 +16,13 @@
%module zorba_api
%include "std_string.i"
+%include "std_pair.i"
%include "exception.i"
+#ifndef SWIGRUBY
+%include "std_vector.i"
+#endif
+
%exception {
try {
$action
@@ -34,6 +39,13 @@
}
}
+#ifndef SWIGRUBY
+namespace std {
+ %template(StringPairVector) vector< pair<string, string> >;
+ %template(StringPair) pair<string, string>;
+}
+#endif
+
%{ // Implementations
@@ -49,11 +61,9 @@
class CompilerHints;
//class DiagnosticHandler;
- class Item;
- class Iterator;
- class XQuery;
class Store;
class Zorba;
+ class Iterator;
class DynamicException;
class XQueryException;
@@ -64,21 +74,32 @@
class UserException;
class ZorbaException;
+ #include "TypeIdentifier.h"
+ #include "Item.h"
+ #include "Iterator.h"
+ #include "DynamicContext.h"
#include "StaticContext.h"
+ #include "XQuery.h"
#include "ItemFactory.h"
-
+ #include "XmlDataManager.h"
%}
-
-
+#ifndef SWIGRUBY
+namespace std {
+ %template(ItemVector) vector<Item>;
+}
+#endif
+
+%include "TypeIdentifier.i"
+%include "Item.i"
+%include "Iterator.i"
+%include "DynamicContext.i"
+%include "CompilerHints.i"
+%include "StaticContext.i"
%include "XQuery.i"
%include "Store.i"
-%include "XmlDataManager.i"
%include "Exceptions.i"
//%include "DiagnosticHandler.i"
-%include "CompilerHints.i"
-%include "StaticContext.i"
%include "Zorba.i"
%include "ItemFactory.i"
-
-
+%include "XmlDataManager.i"
Follow ups