You can subscribe to this list here.
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(71) |
Jun
(43) |
Jul
(9) |
Aug
(10) |
Sep
(21) |
Oct
(38) |
Nov
|
Dec
(11) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2012 |
Jan
|
Feb
(21) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <pm_...@us...> - 2011-05-05 07:30:48
|
Revision: 4314
http://mxquery.svn.sourceforge.net/mxquery/?rev=4314&view=rev
Author: pm_fischer
Date: 2011-05-05 07:30:42 +0000 (Thu, 05 May 2011)
Log Message:
-----------
wrapped object token, split atomic item factory
Added Paths:
-----------
trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/WrappedObjectToken.java
trunk/MXQuery/src/ch/ethz/mxquery/xdmio/SharedAtomicItemFactory.java
Added: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/WrappedObjectToken.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/WrappedObjectToken.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/xdm/WrappedObjectToken.java 2011-05-05 07:30:42 UTC (rev 4314)
@@ -0,0 +1,18 @@
+package ch.ethz.mxquery.datamodel.xdm;
+
+import ch.ethz.mxquery.datamodel.types.Type;
+/**
+ * Generic Java Object wrapper to handle imported Java classes
+ * @author Peter Fischer
+ *
+ */
+public class WrappedObjectToken extends Token {
+ Object wrappedObject;
+ public WrappedObjectToken(Object objectToWrap) {
+ super(Type.ITEM,null,null);
+ wrappedObject = objectToWrap;
+ }
+ public Object getWrappedObject() {
+ return wrappedObject;
+ }
+}
Added: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/SharedAtomicItemFactory.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/SharedAtomicItemFactory.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/SharedAtomicItemFactory.java 2011-05-05 07:30:42 UTC (rev 4314)
@@ -0,0 +1,471 @@
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * 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 ch.ethz.mxquery.xdmio;
+
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.MXQueryBigDecimal;
+import ch.ethz.mxquery.datamodel.MXQueryBinary;
+import ch.ethz.mxquery.datamodel.MXQueryDate;
+import ch.ethz.mxquery.datamodel.MXQueryDateTime;
+import ch.ethz.mxquery.datamodel.MXQueryDouble;
+import ch.ethz.mxquery.datamodel.MXQueryDuration;
+import ch.ethz.mxquery.datamodel.MXQueryFloat;
+import ch.ethz.mxquery.datamodel.MXQueryGregorian;
+import ch.ethz.mxquery.datamodel.MXQueryTime;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.AnyURIToken;
+import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
+import ch.ethz.mxquery.datamodel.xdm.DateTimeToken;
+import ch.ethz.mxquery.datamodel.xdm.DateToken;
+import ch.ethz.mxquery.datamodel.xdm.DecimalToken;
+import ch.ethz.mxquery.datamodel.xdm.DoubleToken;
+import ch.ethz.mxquery.datamodel.xdm.DurationToken;
+import ch.ethz.mxquery.datamodel.xdm.FloatToken;
+import ch.ethz.mxquery.datamodel.xdm.GregorianToken;
+import ch.ethz.mxquery.datamodel.xdm.LongToken;
+import ch.ethz.mxquery.datamodel.xdm.QNameToken;
+import ch.ethz.mxquery.datamodel.xdm.TextToken;
+import ch.ethz.mxquery.datamodel.xdm.TimeToken;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.exceptions.TypeException;
+import ch.ethz.mxquery.iterators.TokenIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+/**
+ * Factory to create items of all atomic types in XDM
+ * @author Peter Fischer
+ *
+ */
+ class SharedAtomicItemFactory {
+ /**
+ * Creates an AnyURI Item
+ * @param uri the String to be represented as anyURI item
+ * @return an XDM Iterator representing the constructed AnyURI Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createAnyURI(final String uri) throws MXQueryException{
+ return createTextTypeItem(null, uri, Type.ANY_URI);
+ }
+ /**
+ * Creates a Base 64 Binary Item
+ * @param base64Val String representation of a Base 64 value
+ * @return an XDM Iterator representing the constructed Base 64 Binary Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createBase64Binary(String base64Val) throws MXQueryException {
+ MXQueryBinary bin = new MXQueryBinary(base64Val,Type.BASE64_BINARY);
+ return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+ /**
+ * Creates a Base 64 Binary Item
+ * @param binValue binary values to be represented as Base 64
+ * @return an XDM Iterator representing the constructed Base 64 Binary Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createBase64Binary(byte [] binValue) throws MXQueryException {
+ MXQueryBinary bin = new MXQueryBinary(binValue,Type.BASE64_BINARY);
+ return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+
+ /**
+ * Creates a Boolean Item
+ * @param val the boolean value for the item
+ * @return an XDM Iterator representing the constructed Boolean Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createBoolean(boolean val) throws MXQueryException{
+ BooleanToken myToken;
+ if (val)
+ myToken = BooleanToken.TRUE_TOKEN;
+ else
+ myToken = BooleanToken.FALSE_TOKEN;
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Byte Item
+ * @param bVal the byte value for the item
+ * @return an XDM Iterator representing the constructed Byte Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createByte(byte bVal) throws MXQueryException {
+ LongToken myToken = new LongToken(Type.BYTE,null,bVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Date Item
+ * @param dVal a String expressing the date for this item (XML Schema/XQuery format)
+ * @return an XDM Iterator representing the constructed Date Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createDate(String dVal) throws MXQueryException{
+ MXQueryDate date = new MXQueryDate(dVal);
+ return new TokenIterator(null,new DateToken(null,date),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a DateTime Item
+ * @param dTimeVal a String expressing the dateTime for this item (XML Schema/XQuery format)
+ * @return an XDM Iterator representing the constructed DateTim Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createDateTime(String dTimeVal) throws MXQueryException{
+ MXQueryDateTime dateTime = new MXQueryDateTime(dTimeVal);
+ return new TokenIterator(null,new DateTimeToken(null,dateTime),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Duration Item
+ * @param durVal a String expressing the duration for this item (XML Schema/XQuery format)
+ * @return an XDM Iterator representing the constructed Duration Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createDuration(String durVal) throws MXQueryException{
+ MXQueryDuration dur = new MXQueryDuration(durVal);
+ return new TokenIterator(null,new DurationToken(null,dur),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Decimal Item
+ * @param dVal a MXQueryBigDecimal expressing the decimal value for this item
+ * @return an XDM Iterator representing the constructed Decimal Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createDecimal(MXQueryBigDecimal dVal) throws MXQueryException{
+ return new TokenIterator(null, new DecimalToken(null,dVal),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Double Item
+ * @param dVal a MXQueryDouble expressing the double value for this item
+ * @return an XDM Iterator representing the constructed Double Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createDouble(MXQueryDouble dVal) throws MXQueryException{
+ return new TokenIterator(null,new DoubleToken(null,dVal),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Float Item
+ * @param fVal a MXQueryFloat expressing the float value for this item
+ * @return an XDM Iterator representing the constructed Float Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createFloat(MXQueryFloat fVal) throws MXQueryException{
+ return new TokenIterator(null,new FloatToken(null,fVal),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Gregorian Day Item
+ * @param gDayVal the day number (1-31) expressing the Gregorian Day for this item
+ * @return an XDM Iterator representing the constructed Gregorian Day Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createGDay(int gDayVal) throws MXQueryException{
+ MXQueryGregorian gDay = new MXQueryGregorian(0,0,gDayVal,0,Type.G_DAY);
+ return new TokenIterator(null,new GregorianToken(null,gDay),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Gregorian Month Item
+ * @param gMonthVal the month number (1-12) expressing the Gregorian Month for this item
+ * @return an XDM Iterator representing the constructed Gregorian Month Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createGMonth(int gMonthVal) throws MXQueryException{
+ MXQueryGregorian gMonth = new MXQueryGregorian(0,gMonthVal,0,0,Type.G_MONTH);
+ return new TokenIterator(null,new GregorianToken(null,gMonth),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Gregorian MonthDay Item
+ * @param gMonthVal gMonthVal the month number (1-12) expressing the Gregorian Month for this item
+ * @param gDayVal the day number (1-31) expressing the Gregorian Day for this item
+ * @return an XDM Iterator representing the constructed Gregorian MonthDay Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createGMonthDay(int gMonthVal, int gDayVal) throws MXQueryException {
+ MXQueryGregorian gMonthDay = new MXQueryGregorian(0,gMonthVal,gDayVal,0,Type.G_MONTH_DAY);
+ return new TokenIterator(null,new GregorianToken(null,gMonthDay),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Gregorian Year Item
+ * @param gYearVal the year number expressing the Gregorian Year for this item
+ * @return an XDM Iterator representing the constructed Gregorian Year Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createGYear(int gYearVal) throws MXQueryException {
+ MXQueryGregorian gYear = new MXQueryGregorian(gYearVal,0,0,0,Type.G_YEAR);
+ return new TokenIterator(null,new GregorianToken(null,gYear),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Gregorian YearMonth Item
+ * @param gYearVal gYearVal the year number expressing the Gregorian Year for this item
+ * @param gMonthVal gMonthVal the month number (1-12) expressing the Gregorian Month for this item
+ * @return an XDM Iterator representing the constructed Gregorian YearMonth Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createGYearMonth(int gYearVal,int gMonthVal) throws MXQueryException {
+ MXQueryGregorian gYearMonth = new MXQueryGregorian(gYearVal,gMonthVal,0,0,Type.G_YEAR_MONTH);
+ return new TokenIterator(null,new GregorianToken(null,gYearMonth),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Hex Binary Item from a string representation
+ * @param hexVal a string expressing the hex binary value for this item
+ * @return an XDM Iterator representing the constructed HexBinary Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createHexBinary(String hexVal) throws MXQueryException {
+ MXQueryBinary bin = new MXQueryBinary(hexVal,Type.HEX_BINARY);
+ return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+ /**
+ * Creates a Hex Binary Item from a binary representation
+ * @param binValue a byte array expressing the hex binary value for this item
+ * @return an XDM Iterator representing the constructed HexBinary Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createHexBinary(byte [] binValue) throws MXQueryException {
+ MXQueryBinary bin = new MXQueryBinary(binValue,Type.HEX_BINARY);
+ return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+ /**
+ * Creates an Int Item
+ * @param intVal an integer expressing the int value for this item
+ * @return an XDM Iterator representing the constructed Int Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createInt(int intVal) throws MXQueryException {
+ LongToken myToken = new LongToken(Type.INT,null,intVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates an Integer Item
+ * @param intVal an integer expressing the integer value for this item
+ * @return an XDM Iterator representing the constructed Integer Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createInteger(long intVal) throws MXQueryException {
+ LongToken myToken = new LongToken(Type.INTEGER,null,intVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Long Item
+ * @param longVal a long expressing the long value for this item
+ * @return an XDM Iterator representing the constructed Long Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createLong(long longVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.LONG,null,longVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a NCName Item
+ * @param ncname a String expressing the NCNAME value for this item
+ * @return an XDM Iterator representing the constructed NCNAME Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createNCName(final String ncname) throws MXQueryException{
+ return createTextTypeItem(null, ncname, Type.NCNAME);
+ }
+ /**
+ * Creates a Negative Integer Item
+ * @param longVal a long expressing the negative integer value for this item
+ * @return an XDM Iterator representing the constructed Negative Integer Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createNegativeInteger(long longVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.NEGATIVE_INTEGER,null,longVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Non-Negative Integer Item
+ * @param longVal a long expressing the non-negative integer value for this item
+ * @return an XDM Iterator representing the constructed Non-Negative Integer Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createNonNegativeInteger(long longVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.NON_NEGATIVE_INTEGER,null,longVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Non-Positive Integer Item
+ * @param longVal a long expressing the non-positive integer value for this item
+ * @return an XDM Iterator representing the constructed Non-Positive Integer Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createNonPositiveInteger(long longVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.NON_POSITIVE_INTEGER,null,longVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Positive Integer Item
+ * @param longVal a long expressing the positive integer value for this item
+ * @return an XDM Iterator representing the constructed Positive Integer Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createPositiveInteger(long longVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.POSITIVE_INTEGER,null,longVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a QName Item
+ * @param prefix a string representing the namespace prefix
+ * @param localName a string representing the local name
+ * @return an XDM Iterator representing the constructed QName Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createQName(String prefix, String localName) throws MXQueryException{
+ QName qn = new QName(prefix,localName);
+ return new TokenIterator(null,new QNameToken(null,qn),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a qualified QName Item
+ * @param namespace a string representing the namespace URI
+ * @param prefix a string representing the namespace prefix
+ * @param localName a string representing the local name
+ * @return an XDM Iterator representing the constructed QName Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createQName(String namespace, String prefix, String localName) throws MXQueryException{
+ QName qn = new QName(namespace, prefix,localName);
+ return new TokenIterator(null,new QNameToken(null,qn),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a Short Item
+ * @param shortVal a short expressing the short value for this item
+ * @return an XDM Iterator representing the constructed Short Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createShort(short shortVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.SHORT,null,shortVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates a String Item
+ * @param str a String expressing the string value for this item
+ * @return an XDM Iterator representing the constructed String Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createString(final String str) throws MXQueryException{
+ return createTextTypeItem(null, str, Type.STRING);
+ }
+ /**
+ * Creates a Time Item
+ * @param timeVal a string expressing the time value for this item (XML Schema/XQuery format)
+ * @return an XDM Iterator representing the constructed Time Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createTime(String timeVal) throws MXQueryException{
+ MXQueryTime time = new MXQueryTime(timeVal);
+ return new TokenIterator(null, new TimeToken(null,time),QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates an Unsigned Byte Item
+ * @param ubVal a short expressing the unsigned byte value for this item
+ * @return an XDM Iterator representing the constructed Unsigned Byte Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createUnsignedByte(short ubVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.UNSIGNED_BYTE,null,ubVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates an Unsigned Int Item
+ * @param usVal a long expressing the unsigned int value for this item
+ * @return an XDM Iterator representing the constructed Unsigned Int Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createUnsignedInt(long usVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.UNSIGNED_INT,null,usVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates an Unsigned Long Item. Note: Unsigned Long is limited to the signed long space in MXQuery
+ * @param ulVal a long expressing the unsigned long value for this item
+ * @return an XDM Iterator representing the constructed Unsigned Long Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createUnsignedLong(long ulVal) throws MXQueryException {
+ LongToken myToken = new LongToken(Type.UNSIGNED_LONG,null,ulVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Creates an Unsigned Short Item
+ * @param uiVal an integer expressing the unsigned short value for this item
+ * @return an XDM Iterator representing the constructed Unsigned Short Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createUnsignedShort(int uiVal) throws MXQueryException{
+ LongToken myToken = new LongToken(Type.UNSIGNED_SHORT,null,uiVal);
+ return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+
+ /**
+ * Creates a untyped atomic Item
+ * @param str a String expressing the string value for this item
+ * @return an XDM Iterator representing the constructed String Item
+ * @throws MXQueryException
+ */
+ public static XDMIterator createUntypedAtomic(final String str) throws MXQueryException{
+ return createTextTypeItem(null, str, Type.UNTYPED_ATOMIC);
+ }
+
+ private static XDMIterator createTextTypeItem (Context ctx, String value, int type) throws MXQueryException {
+
+ TokenInterface myToken;
+
+ int checkType = Type.getEventTypeSubstituted(type, Context.getDictionary());
+
+ switch (checkType) {
+ case Type.STRING:
+ case Type.UNTYPED:
+ myToken = new TextToken(type, null, value,null);
+ break;
+
+ case Type.UNTYPED_ATOMIC:
+ myToken = new UntypedAtomicToken(null, value);
+ break;
+
+ case Type.ANY_URI:
+ myToken = new AnyURIToken(null, value);
+ break;
+ default:
+ throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Incorrect type passed: " + Type.getTypeQName(type, Context.getDictionary()),QueryLocation.OUTSIDE_QUERY_LOC );
+ }
+ return new TokenIterator(ctx,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ }
+ /**
+ * Create an atomic type item from the given Java object
+ * An error is raised there is no matching atomic type or if values are incorrect
+ * @param val A Java object to be converted into a XDM atomic type
+ * @return an XDMIterator producing this atomic type
+ * @throws MXQueryException
+ */
+ public static XDMIterator createAtomicItemType(Object val) throws MXQueryException{
+ // use getName() as it available on all platforms
+ if(val.getClass().getName().equals("java.lang.Boolean"))
+ return createBoolean(((Boolean)val).booleanValue());
+ if(val.getClass().getName().equals("java.lang.Byte"))
+ return createByte(((Byte)val).byteValue());
+ if(val.getClass().getName().equals("java.lang.Integer"))
+ return createInt(((Integer)val).intValue());
+ if(val.getClass().getName().equals("java.lang.Long"))
+ return createLong(((Long)val).longValue());
+ if(val.getClass().getName().equals("java.lang.Short"))
+ return createShort(((Short)val).shortValue());
+ if(val.getClass().getName().equals("java.lang.String"))
+ return createString((String)val);
+ throw new MXQueryException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Could not convert to atomic type", QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-05 07:23:49
|
Revision: 4313
http://mxquery.svn.sourceforge.net/mxquery/?rev=4313&view=rev
Author: pm_fischer
Date: 2011-05-05 07:23:40 +0000 (Thu, 05 May 2011)
Log Message:
-----------
Import functionality for Java methods/objects (initial version)
- same syntax and semantics as Saxon-PE/EE, BaseX, eXist, Qizx
- added "wrapped object" to XDM implementation
- currently limited support for data types, needs to be extended
- partial tests for import
Cleanup up wrong use of error codes in XQIB (E0017, not A0017)
AtomicItemFactory
- now has a method to take any Java object
- split into common part (all platforms) and platform-specific part
for more data types
Modified Paths:
--------------
trunk/MXQuery/build.xml
trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java
trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
trunk/MXQuery/src/ch/ethz/mxquery/query/parser/PatternDataHelper.java
trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/StreamStoreInput.java
trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java
trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddEventListener.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/RemoveEventListener.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/pattern/PatternClauseTests.java
Added Paths:
-----------
trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java
Modified: trunk/MXQuery/build.xml
===================================================================
--- trunk/MXQuery/build.xml 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/build.xml 2011-05-05 07:23:40 UTC (rev 4313)
@@ -426,6 +426,7 @@
<delete file="${midptmp.dir}/ch/ethz/mxquery/iterators/PGFLWORIterator.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/iterators/PGroupBy.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/iterators/CommandLineInIterator.java"/>
+ <delete file="${xqibtmp.dir}/ch/ethz/mxquery/iterators/NativeFuncCall.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/iterators/forseq/ForseqWindowIndexIterator.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/iterators/forseq/ForseqWindowEarlyBinding.java"/>
<delete file="${midptmp.dir}/ch/ethz/mxquery/iterators/forseq/ForseqWindowEarlyBindingParallel.java"/>
@@ -607,6 +608,7 @@
<delete file="${xqibtmp.dir}/ch/ethz/mxquery/iterators/forseq/ForseqWindowIndexIterator.java"/>
<delete file="${xqibtmp.dir}/ch/ethz/mxquery/iterators/forseq/ForseqWindowEarlyBinding.java"/>
<delete file="${xqibtmp.dir}/ch/ethz/mxquery/iterators/forseq/ForseqWindowEarlyBindingParallel.java"/>
+ <delete file="${xqibtmp.dir}/ch/ethz/mxquery/iterators/NativeFuncCall.java"/>
<delete file="${xqibtmp.dir}/ch/ethz/mxquery/util/UnicodeInputStream.java"/>
<delete file="${xqibtmp.dir}/ch/ethz/mxquery/util/UnicodeReader.java"/>
<delete file="${xqibtmp.dir}/ch/ethz/mxquery/functions/mxq/DirectXMLWrapperIterator.java"/>
@@ -675,9 +677,9 @@
<copy todir="${xqibtmp.dir}" overwrite="yes"><fileset dir="${xqibsrc.dir}"/></copy>
+ <copy file="${midpsrc.dir}/ch/ethz/mxquery/functions/NativeFunctionImporter.java" todir="${customtmp.dir}/ch/ethz/mxquery/functions/" overwrite="yes" />
<copy file="${midpsrc.dir}/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java" todir="${customtmp.dir}/ch/ethz/mxquery/sms/MMimpl/" overwrite="yes" />
- <copy file="${midpsrc.dir}/ch/ethz/mxquery/bindings/WindowBuffer.java" todir="${customtmp.dir}/ch/ethz/mxquery/bindings/" overwrite="yes" />
-
+ <copy file="${midpsrc.dir}/ch/ethz/mxquery/bindings/WindowBuffer.java" todir="${customtmp.dir}/ch/ethz/mxquery/bindings/" overwrite="yes" />
</target>
Added: trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java (rev 0)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -0,0 +1,16 @@
+package ch.ethz.mxquery.functions;
+
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+
+public class NativeFunctionImporter {
+
+
+ public static Context getNativeMethods(String className) throws MXQueryException{
+ Context ctx = new Context();
+ throw new MXQueryException(ErrorCodes.A0002_EC_NOT_SUPPORTED, "Import of native methods not supported", QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+}
Added: trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java (rev 0)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -0,0 +1,51 @@
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * 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 ch.ethz.mxquery.xdmio;
+
+
+import ch.ethz.mxquery.datamodel.MXQueryBigDecimal;
+import ch.ethz.mxquery.datamodel.MXQueryDate;
+import ch.ethz.mxquery.datamodel.MXQueryDateTime;
+import ch.ethz.mxquery.datamodel.MXQueryDayTimeDuration;
+import ch.ethz.mxquery.datamodel.MXQueryDouble;
+import ch.ethz.mxquery.datamodel.MXQueryDuration;
+import ch.ethz.mxquery.datamodel.MXQueryFloat;
+import ch.ethz.mxquery.datamodel.MXQueryGregorian;
+import ch.ethz.mxquery.datamodel.MXQueryTime;
+import ch.ethz.mxquery.datamodel.MXQueryYearMonthDuration;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.xdm.DateTimeToken;
+import ch.ethz.mxquery.datamodel.xdm.DateToken;
+import ch.ethz.mxquery.datamodel.xdm.DayTimeDurToken;
+import ch.ethz.mxquery.datamodel.xdm.DurationToken;
+import ch.ethz.mxquery.datamodel.xdm.GregorianToken;
+import ch.ethz.mxquery.datamodel.xdm.TimeToken;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.YearMonthDurToken;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.iterators.TokenIterator;
+import ch.ethz.mxquery.model.XDMIterator;
+
+/**
+ * Factory to create items of all atomic types in XDM
+ * @author Peter Fischer
+ *
+ */
+public class XDMAtomicItemFactory extends SharedAtomicItemFactory{
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/datamodel/types/Type.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -799,7 +799,7 @@
public static boolean isNumericPrimitiveType(int type) {
// clean additional info bits
type = type & MASK_CLEAN_ADDITIONAL_INFO;
- return isSubTypeOf(type, DECIMAL, null) || type == DOUBLE || type == FLOAT || type == DECIMAL;
+ return isSubTypeOf(type, DECIMAL, null) || type == DOUBLE || type == FLOAT || type == DECIMAL || type == NUMBER;
// return isSubTypeOf(type, NUMBER);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/exceptions/ErrorCodes.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -141,8 +141,10 @@
public final static QName A0014_Unspecified_Service_Name = new QName(XQStaticContext.URI_ERR,"err","XQST0096");
public final static QName A0015_Unspecified_Endpoint = new QName(XQStaticContext.URI_ERR,"err","XQST0097");
public final static QName A0016_Endpoint_Does_Not_Exist = new QName(XQStaticContext.URI_ERR,"err","XQST0098");
- public final static QName A0017_Duplicate_Pattern_Var = new QName(URI_MXQ_ERR,"app","MXQE0013");
- public final static QName A0017_Missing_Pattern_Var_Decl = new QName(URI_MXQ_ERR,"app","MXQE0013");
+ public final static QName A0017_Duplicate_Pattern_Var = new QName(URI_MXQ_ERR,"app","MXQE0017");
+ public final static QName A0018_Missing_Pattern_Var_Decl = new QName(URI_MXQ_ERR,"app","MXQE0018");
+ public final static QName A0019_Unknown_Class = new QName(URI_MXQ_ERR,"app","MXQE0019");
+ public final static QName A0020_Incompatible_Overload = new QName(URI_MXQ_ERR,"app","MXQE0020");
/* Error codes from Update Facility, version 28.08.2007 */
public final static QName U0001_UPDATE_STATIC_UPDATING_EXPRESSION_NOT_ALLOWED_HERE = new QName(XQStaticContext.URI_ERR,"err","XUST0001");
Added: trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/NativeFunctionImporter.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -0,0 +1,192 @@
+package ch.ethz.mxquery.functions;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.exceptions.StaticException;
+import ch.ethz.mxquery.iterators.NativeFuncCall;
+import ch.ethz.mxquery.model.XDMIterator;
+
+public class NativeFunctionImporter {
+
+ static class MethodData {
+ Class baseClass;
+ String methodName;
+ TypeInfo [] paramTypes;
+ TypeInfo returnType;
+
+ public MethodData(Class baseClass, String methodName,
+ TypeInfo[] paramTypes, TypeInfo returnType) {
+ super();
+ this.baseClass = baseClass;
+ this.methodName = methodName;
+ this.paramTypes = paramTypes;
+ this.returnType = returnType;
+ }
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((baseClass == null) ? 0 : baseClass.hashCode());
+ result = prime * result
+ + ((methodName == null) ? 0 : methodName.hashCode());
+ result = prime * result + paramTypes.length;
+ return result;
+ }
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MethodData other = (MethodData) obj;
+ if (baseClass == null) {
+ if (other.baseClass != null)
+ return false;
+ } else if (!baseClass.equals(other.baseClass))
+ return false;
+ if (methodName == null) {
+ if (other.methodName != null)
+ return false;
+ } else if (!methodName.equals(other.methodName))
+ return false;
+ if (paramTypes == null) {
+ if (other.paramTypes != null)
+ return false;
+ }else if (paramTypes.length != other.paramTypes.length)
+ return false;
+ return true;
+ }
+
+ }
+
+ public static Context getNativeMethods(String className) throws MXQueryException{
+ Context ctx = new Context();
+ try {
+ Class toImport = Class.forName(className);
+
+ Map functions = new HashMap();
+
+ Constructor [] constructors = toImport.getConstructors();
+ for (int i=0;i<constructors.length;i++) {
+ Constructor cur = constructors[i];
+ int mod = cur.getModifiers();
+ if (Modifier.isPublic(mod)) {
+ TypeInfo [] params;
+ Class [] paramTypes = cur.getParameterTypes();
+ params = new TypeInfo[paramTypes.length];
+ for (int j=0;j<params.length;j++) {
+ params[j] = getXQueryType(paramTypes[j]);
+ }
+ MethodData md = new MethodData(toImport, "new", params, new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE));
+ if (!functions.containsKey(md))
+ functions.put(md,md);
+ else {
+ MethodData existingMd = (MethodData)functions.get(md);
+ for (int j=0;j<existingMd.paramTypes.length;j++) {
+ if (!params[j].equals(existingMd.paramTypes [j])) {
+ if (Type.isNumericPrimitiveType(params[j].getType()) && Type.isNumericPrimitiveType(existingMd.paramTypes[j].getType()))
+ existingMd.paramTypes[j] = new TypeInfo(Type.NUMBER,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ else
+ if (Type.isAtomicType(params[j].getType(), Context.getDictionary()) && Type.isAtomicType(existingMd.paramTypes[j].getType(),Context.getDictionary()))
+ existingMd.paramTypes[j] = new TypeInfo(Type.ANY_ATOMIC_TYPE,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ else
+ existingMd.paramTypes[j] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ }
+ }
+ }
+
+ }
+ }
+
+ Method [] methods = toImport.getMethods();
+
+ for (int i=0;i<methods.length;i++) {
+ Method cur = methods[i];
+ int mod = cur.getModifiers();
+ if (Modifier.isPublic(mod)) {
+ String name = cur.getName();
+ Class [] paramTypes = cur.getParameterTypes();
+ TypeInfo [] params = new TypeInfo[paramTypes.length];
+ if (Modifier.isStatic(mod)) {
+ params = new TypeInfo[paramTypes.length];
+ for (int j=0;j<params.length;j++) {
+ params[j] = getXQueryType(paramTypes[j]);
+ }
+ }
+ else {
+ params = new TypeInfo[paramTypes.length+1];
+ params[0] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ for (int j=1;j<params.length;j++) {
+ params[j] = getXQueryType(paramTypes[j-1]);
+ }
+ }
+ TypeInfo resultType = getXQueryType(cur.getReturnType());
+ MethodData md = new MethodData(toImport, name, params, resultType);
+ if (!functions.containsKey(md))
+ functions.put(md,md);
+ else {
+ MethodData existingMd = (MethodData)functions.get(md);
+ for (int j=0;j<existingMd.paramTypes.length;j++) {
+ if (!params[j].equals(existingMd.paramTypes [j])) {
+ if (Type.isNumericPrimitiveType(params[j].getType()) && Type.isNumericPrimitiveType(existingMd.paramTypes[j].getType()))
+ existingMd.paramTypes[j] = new TypeInfo(Type.NUMBER,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ else
+ existingMd.paramTypes[j] = new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ //throw new StaticException(ErrorCodes.A0020_Incompatible_Overload, "Overloaded Java Function "+className+"."+name+" could not be mapped", QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+ }
+ }
+
+ }
+ }
+ java.util.Iterator allFuncts = functions.values().iterator();
+ while (allFuncts.hasNext()) {
+ MethodData md = (MethodData)allFuncts.next();
+ QName qn = new QName("java:"+className,"javamethod",md.methodName);
+ FunctionSignature fs = new FunctionSignature(qn, md.paramTypes,FunctionSignature.EXTERNAL_FUNCTION,XDMIterator.EXPR_CATEGORY_SEQUENTIAL,true,false);
+ Function fn = new Function(null, fs, new NativeFuncCall(ctx, md.paramTypes, toImport, md.methodName, md.returnType, null, XDMIterator.EXPR_CATEGORY_SIMPLE, QueryLocation.OUTSIDE_QUERY_LOC), null, 0);
+ ctx.addFunction(fn);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new StaticException(ErrorCodes.A0019_Unknown_Class, "Class "+className+" could not be found", QueryLocation.OUTSIDE_QUERY_LOC);
+ }
+ return ctx;
+ }
+ private static TypeInfo getXQueryType(Class class1) {
+
+ if (class1.isPrimitive()) {
+ if (class1.getName().equals("long"))
+ return new TypeInfo(Type.LONG,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ if (class1.getName().equals("double"))
+ return new TypeInfo(Type.DOUBLE,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ if (class1.getName().equals("float"))
+ return new TypeInfo(Type.FLOAT,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ if (class1.getName().equals("int"))
+ return new TypeInfo(Type.INT,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ if (class1.getName().equals("boolean"))
+ return new TypeInfo(Type.BOOLEAN,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ System.out.println(class1.getPackage()+" "+class1.getName());
+ return new TypeInfo(Type.UNTYPED_ATOMIC,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ }
+ if (class1.getName().equals("java.lang.String"))
+ return new TypeInfo(Type.STRING,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ if (class1.getName().equals("java.lang.Double"))
+ return new TypeInfo(Type.DOUBLE,Type.OCCURRENCE_IND_EXACTLY_ONE);
+ if (class1.getName().equals("java.lang.Float"))
+ return new TypeInfo(Type.FLOAT,Type.OCCURRENCE_IND_EXACTLY_ONE);
+
+ return new TypeInfo(Type.ITEM,Type.OCCURRENCE_IND_ZERO_OR_MORE);
+ }
+}
Added: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java (rev 0)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -0,0 +1,312 @@
+/* Copyright 2006 - 2009 ETH Zurich
+ *
+ * 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 ch.ethz.mxquery.iterators;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Vector;
+
+import ch.ethz.mxquery.contextConfig.Context;
+import ch.ethz.mxquery.datamodel.types.Type;
+import ch.ethz.mxquery.datamodel.types.TypeInfo;
+import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
+import ch.ethz.mxquery.datamodel.xdm.WrappedObjectToken;
+import ch.ethz.mxquery.exceptions.DynamicException;
+import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.exceptions.MXQueryException;
+import ch.ethz.mxquery.exceptions.QueryLocation;
+import ch.ethz.mxquery.functions.fn.DataValuesIterator;
+import ch.ethz.mxquery.model.CurrentBasedIterator;
+import ch.ethz.mxquery.model.Iterator;
+import ch.ethz.mxquery.model.XDMIterator;
+import ch.ethz.mxquery.xdmio.XDMAtomicItemFactory;
+
+public class NativeFuncCall extends CurrentBasedIterator {
+ //protected QName[] paramNames;
+
+ Class native_function;
+ String methodName;
+ protected XDMIterator resultSeqTypeIt;
+
+ protected TypeInfo[] paramTypes;
+
+ protected TypeInfo returnType;
+
+ private int sigExpressionCategory = EXPR_CATEGORY_SIMPLE;
+
+ public NativeFuncCall(Context ctx, TypeInfo[] paramTypes,
+ Class function, String methodName, TypeInfo returnType, XDMIterator returnSeqTypeIt, int exprCategory, QueryLocation location) throws MXQueryException {
+ super(ctx, location);
+ this.native_function = function;
+ this.resultSeqTypeIt = returnSeqTypeIt;
+ //this.paramNames = paramNames;
+ this.native_function = function;
+ this.methodName = methodName;
+ this.returnType = returnType;
+ this.paramTypes = paramTypes;
+ this.sigExpressionCategory = exprCategory;
+ //function.setResettable(true);
+ }
+
+ protected void init() throws MXQueryException {
+
+ if (resultSeqTypeIt != null) {
+ resultSeqTypeIt.setResettable(true);
+ resultSeqTypeIt.reset();
+ }
+ //function.setResettable(true);
+ Object [] invocationParams = new Object[subIters.length];
+ Class [] invocationParamsTypes = new Class[subIters.length];
+ Object instanceToCall = null;
+ for (int i = 0; i < this.subIters.length; i++) {
+ TokenInterface tok = subIters[i].next();
+ // For now, just take exactly a single value
+ if (tok.getEventType()==Type.END_SEQUENCE || subIters[i].next().getEventType() != Type.END_SEQUENCE)
+ throw new DynamicException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE, "Expected a single item", loc);
+ int type = Type.getEventTypeSubstituted(tok.getEventType(), Context.getDictionary());
+ switch (type) {
+ case Type.DOUBLE:
+ invocationParams[i] = new Double(tok.getDouble().getValue());
+ invocationParamsTypes[i] = Double.TYPE;
+ break;
+ case Type.STRING:
+ case Type.ANY_URI:
+ invocationParams[i] = new String(tok.getText());
+ invocationParamsTypes[i] = invocationParams[i].getClass();
+ break;
+ case Type.ITEM:
+ if (i==0 && tok instanceof WrappedObjectToken) {
+ WrappedObjectToken wrap = (WrappedObjectToken) tok;
+ instanceToCall = wrap.getWrappedObject();
+ } else
+ throw new DynamicException(ErrorCodes.A0002_EC_NOT_SUPPORTED, "Type "+Type.getTypeQName(tok.getEventType(), Context.getDictionary())+" not implemented in Java calls", loc);
+ break;
+ default:
+ throw new DynamicException(ErrorCodes.A0002_EC_NOT_SUPPORTED, "Type "+Type.getTypeQName(tok.getEventType(), Context.getDictionary())+" not implemented in Java calls", loc);
+ }
+
+
+ }
+ // On instance methods, take away the first parameter, since it is the instance reference
+ if (instanceToCall != null) {
+ Class [] allTypes = invocationParamsTypes;
+ Object [] allParams = invocationParams;
+ invocationParamsTypes = new Class[allTypes.length-1];
+ invocationParams = new Object[allParams.length-1];
+ System.arraycopy(allTypes, 1, invocationParamsTypes, 0, invocationParamsTypes.length);
+ System.arraycopy(allParams, 1, invocationParams, 0, invocationParams.length);
+
+ }
+
+ try {
+ Object res;
+ if (methodName.equals("new")) {
+ Constructor con = native_function.getConstructor(invocationParamsTypes);
+ res = con.newInstance(invocationParams);
+ }
+ else {
+ Method meth = native_function.getMethod(methodName, invocationParamsTypes);
+ res = meth.invoke(instanceToCall, invocationParams);
+ }
+
+ try {
+ this.current = XDMAtomicItemFactory.createAtomicItemType(res);
+ }catch (MXQueryException me) {
+ WrappedObjectToken wrap = new WrappedObjectToken(res);
+ this.current = new TokenIterator(context, wrap, loc, false);
+ }
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //this.current = new TokenIterator(context, 42,Type.INT, loc);
+ }
+
+ public TokenInterface next() throws MXQueryException {
+ if (this.called == 0) {
+ this.init();
+ }
+ this.called++;
+ return this.current.next();
+ }
+
+ public void setContext(Context context, boolean recursive) throws MXQueryException {
+ if (subIters != null && recursive) {
+ for (int i=0;i<subIters.length;i++)
+ subIters[i].setContext(context, recursive);
+ }
+
+ }
+
+ public void setResettable(boolean r) throws MXQueryException {
+ for (int i = 0; i < this.subIters.length; i++) {
+ this.subIters[i].setResettable(r);
+ }
+ resettable = r;
+ }
+
+ public XDMIterator staticInit() throws MXQueryException {
+ super.staticInit();
+ //function.staticInit();
+ return this;
+ }
+
+
+ protected void resetImpl() throws MXQueryException {
+ for (int i = 0; i < this.subIters.length; i++) {
+ this.subIters[i].reset();
+ }
+ super.resetImpl();
+ }
+
+ public void setSubIters(XDMIterator[] subIt) throws MXQueryException {
+ if (subIt == null) {
+ return;
+ }
+ if (paramTypes != null) {
+ // Insert fn:data if input is expected to be atomic
+ for (int i = 0;i<subIt.length;i++) {
+ subIt[i] = insertAtomizationCast(paramTypes[i], subIt[i]);
+ }
+
+ }
+ subIters = subIt;
+ }
+
+ private XDMIterator insertAtomizationCast(TypeInfo parType, XDMIterator toAdapt) {
+ if (parType != null && parType.getType() != TypeInfo.UNDEFINED
+ && Type.isAtomicType(parType.getType(), Context.getDictionary()))
+ toAdapt = DataValuesIterator.getDataIterator(toAdapt, toAdapt.getContext());
+
+ if (parType != null && parType.getType() != TypeInfo.UNDEFINED &&
+ (parType.getType() != Type.END_SEQUENCE) &&
+ parType.getType() != Type.ANY_ATOMIC_TYPE && !Type.isNode(parType.getType())
+ && !Type.isTypeOrSubTypeOf(toAdapt.getStaticType().getType(),parType.getType(), Context.getDictionary()) && parType.getType() != Type.ITEM)
+ toAdapt = new CastAsIterator(toAdapt.getContext(), toAdapt, parType, false, true,loc);
+ return toAdapt;
+ }
+
+ protected XDMIterator copy(Context context, XDMIterator[] subIters, Vector nestedPredCtxStack) throws MXQueryException {
+ NativeFuncCall copy = new NativeFuncCall(
+ context,
+ Iterator.copyTypeInfos(paramTypes),
+ native_function,
+ methodName,
+ returnType.copy(),
+ resultSeqTypeIt==null?null:resultSeqTypeIt.copy(context, null, false, nestedPredCtxStack), exprCategory,loc);
+
+ copy.exprCategory = exprCategory;
+ copy.sigExpressionCategory = sigExpressionCategory;
+ copy.subIters = subIters;
+
+ return copy;
+ }
+
+// public int getExprTypeShallow() throws MXQueryException {
+// boolean hasUpdates = false;
+// if (subIters != null) {
+// hasUpdates = checkArguments(hasUpdates,isScripting);
+// }
+//
+// if (hasUpdates)
+// exprCategory = EXPR_CATEGORY_UPDATING;
+// else
+// exprCategory = sigExpressionCategory;
+// return exprCategory;
+// }
+
+// protected void checkExpressionTypes() throws MXQueryException {
+// boolean hasUpdates = false;
+// if (subIters != null) {
+// hasUpdates = checkArguments(hasUpdates,isScripting);
+// }
+//
+// if (exprCategory == EXPR_CATEGORY_UNDETERMINED) {
+// try {
+// int funcCat = function.getExpressionCategoryType(isScripting);
+// if (funcCat != sigExpressionCategory && funcCat != EXPR_CATEGORY_UNDETERMINED)
+// if(!isScripting) {
+// if (funcCat != XDMIterator.EXPR_CATEGORY_VACUOUS)
+// switch (sigExpressionCategory) {
+// case XDMIterator.EXPR_CATEGORY_UPDATING:
+// throw new StaticException(ErrorCodes.U0002_UPDATE_STATIC_NONUPDATING_EXPRESSION_NOT_ALLOWED_HERE,"Simple body not allowed in updating/sequential function", loc);
+// case XDMIterator.EXPR_CATEGORY_SIMPLE:
+// throw new StaticException(ErrorCodes.U0001_UPDATE_STATIC_UPDATING_EXPRESSION_NOT_ALLOWED_HERE,"Updating body not allowed in non-updating function", loc);
+// }
+// } else {
+// switch (sigExpressionCategory) {
+// case EXPR_CATEGORY_SIMPLE:
+// if (funcCat != EXPR_CATEGORY_VACUOUS)
+// throw new StaticException(ErrorCodes.SX0008_FUNCTION_BODY_CATEGORY_INCONSITENT,"Updating/Sequential body not allowed in non-updating function", loc);
+// break;
+// case EXPR_CATEGORY_UPDATING:
+// if (funcCat == EXPR_CATEGORY_SEQUENTIAL)
+// throw new StaticException(ErrorCodes.SX0008_FUNCTION_BODY_CATEGORY_INCONSITENT,"Sequential body not allowed in non-updating function", loc);
+// break;
+// case EXPR_CATEGORY_SEQUENTIAL:
+// if (funcCat == EXPR_CATEGORY_UPDATING)
+// throw new StaticException(ErrorCodes.SX0008_FUNCTION_BODY_CATEGORY_INCONSITENT,"Updating body not allowed in sequential function", loc);
+// }
+// }
+// }catch (NullPointerException ne) {
+// // could not look up the function
+// }
+// }
+// if (hasUpdates && sigExpressionCategory != EXPR_CATEGORY_UPDATING)
+// exprCategory = EXPR_CATEGORY_UPDATING;
+// else
+// exprCategory = sigExpressionCategory;
+// }
+//
+// private boolean checkArguments(boolean hasUpdates,boolean isScripting) throws MXQueryException {
+// if (!isScripting)
+// checkExprSimpleOnly(subIters,isScripting);
+// else {
+// switch (sigExpressionCategory) {
+// case EXPR_CATEGORY_SIMPLE:
+// case EXPR_CATEGORY_UPDATING:
+// hasUpdates = checkExprNoSequential(subIters,isScripting);
+// break;
+// case EXPR_CATEGORY_SEQUENTIAL:
+// checkExprSimpleOnly(subIters,isScripting);
+// }
+// }
+// return hasUpdates;
+// }
+
+
+ //It was not overwritten!
+ public TypeInfo getStaticType(){
+ return returnType;
+ }
+
+}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/Parser.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -48,6 +48,7 @@
import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.functions.Function;
import ch.ethz.mxquery.functions.FunctionSignature;
+import ch.ethz.mxquery.functions.NativeFunctionImporter;
import ch.ethz.mxquery.functions.fn.BooleanIterator;
import ch.ethz.mxquery.functions.fn.Collection;
import ch.ethz.mxquery.functions.fn.CountIterator;
@@ -897,14 +898,8 @@
"Error while parsing: '=' expected!");
}
- String uri = null;
+ String uri = StringLiteralAsString(true);
- XDMIterator it = StringLiteral();
- if (it != null) {
- TokenInterface tok = it.next();
- uri = tok.getText();
- }
-
if (uri == null) {
generateStaticError(
ErrorCodes.E0003_STATIC_NOT_A_VALID_GRAMMAR_ELEMENT,
@@ -941,6 +936,10 @@
ErrorCodes.E0033_STATIC_MODULE_MULTIPLE_BINDINGS_FOR_SAME_PREFIX,
"Multiple declarations of Namespace " + name);
ctx.addNamespace(new Namespace(name, uri));
+ if (uri.startsWith("java:")) {
+ Context javamod = NativeFunctionImporter.getNativeMethods(uri.substring(5));
+ importModuleFunctionsVariables(uri, name, javamod);
+ }
declaredNamespaces.add(name);
return true;
@@ -2543,7 +2542,7 @@
if (varData == null)
generateStaticError(
- ErrorCodes.A0017_Missing_Pattern_Var_Decl,
+ ErrorCodes.A0018_Missing_Pattern_Var_Decl,
"Variable declaration '"
+ varQName1
+ "' is spurious, not needed by the pattern definition");
@@ -2591,7 +2590,7 @@
if (patVar.size() != declVar.size()) {
generateStaticError(
- ErrorCodes.A0017_Missing_Pattern_Var_Decl,
+ ErrorCodes.A0018_Missing_Pattern_Var_Decl,
"Not all variables used in the pattern have been declared");
}
// with all variable information present, we can now check
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/parser/PatternDataHelper.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/parser/PatternDataHelper.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/parser/PatternDataHelper.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -303,7 +303,7 @@
if (!var.contains(v1))
var.add(v1);
else
- throw new StaticException(ErrorCodes.A0017_Missing_Pattern_Var_Decl, "Variable "+v1+" is used multiple times in the pattern", QueryLocation.OUTSIDE_QUERY_LOC);
+ throw new StaticException(ErrorCodes.A0018_Missing_Pattern_Var_Decl, "Variable "+v1+" is used multiple times in the pattern", QueryLocation.OUTSIDE_QUERY_LOC);
}
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/StreamStoreInput.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/StreamStoreInput.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/StreamStoreInput.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -135,7 +135,7 @@
break;
}
- if ( Type.isAtomicType(type, null) || Type.isTextNode(type)) {
+ if ( Type.isAtomicType(type, null) || Type.isTextNode(type) || type == Type.ITEM) {
event = 1;
if (level == 0) {
buffer.newItem();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/sms/MMimpl/TokenBufferStore.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -308,7 +308,7 @@
break;
}
- if ( Type.isAtomicType(type, Context.getDictionary()) || type == Type.UNTYPED) {
+ if ( Type.isAtomicType(type, Context.getDictionary()) || type == Type.UNTYPED || type == Type.ITEM) {
if (level == 0) {
indexNewNode();
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/XDMAtomicItemFactory.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -15,37 +15,34 @@
package ch.ethz.mxquery.xdmio;
-import ch.ethz.mxquery.contextConfig.Context;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+
import ch.ethz.mxquery.datamodel.MXQueryBigDecimal;
-import ch.ethz.mxquery.datamodel.MXQueryBinary;
import ch.ethz.mxquery.datamodel.MXQueryDate;
import ch.ethz.mxquery.datamodel.MXQueryDateTime;
+import ch.ethz.mxquery.datamodel.MXQueryDayTimeDuration;
import ch.ethz.mxquery.datamodel.MXQueryDouble;
import ch.ethz.mxquery.datamodel.MXQueryDuration;
import ch.ethz.mxquery.datamodel.MXQueryFloat;
import ch.ethz.mxquery.datamodel.MXQueryGregorian;
import ch.ethz.mxquery.datamodel.MXQueryTime;
-import ch.ethz.mxquery.datamodel.QName;
+import ch.ethz.mxquery.datamodel.MXQueryYearMonthDuration;
import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.xdm.AnyURIToken;
-import ch.ethz.mxquery.datamodel.xdm.BooleanToken;
import ch.ethz.mxquery.datamodel.xdm.DateTimeToken;
import ch.ethz.mxquery.datamodel.xdm.DateToken;
-import ch.ethz.mxquery.datamodel.xdm.DecimalToken;
-import ch.ethz.mxquery.datamodel.xdm.DoubleToken;
+import ch.ethz.mxquery.datamodel.xdm.DayTimeDurToken;
import ch.ethz.mxquery.datamodel.xdm.DurationToken;
-import ch.ethz.mxquery.datamodel.xdm.FloatToken;
import ch.ethz.mxquery.datamodel.xdm.GregorianToken;
-import ch.ethz.mxquery.datamodel.xdm.LongToken;
-import ch.ethz.mxquery.datamodel.xdm.QNameToken;
-import ch.ethz.mxquery.datamodel.xdm.TextToken;
import ch.ethz.mxquery.datamodel.xdm.TimeToken;
import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.datamodel.xdm.UntypedAtomicToken;
-import ch.ethz.mxquery.exceptions.ErrorCodes;
+import ch.ethz.mxquery.datamodel.xdm.YearMonthDurToken;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
-import ch.ethz.mxquery.exceptions.TypeException;
import ch.ethz.mxquery.iterators.TokenIterator;
import ch.ethz.mxquery.model.XDMIterator;
@@ -54,395 +51,101 @@
* @author Peter Fischer
*
*/
-public class XDMAtomicItemFactory {
- /**
- * Creates an AnyURI Item
- * @param uri the String to be represented as anyURI item
- * @return an XDM Iterator representing the constructed AnyURI Item
- * @throws MXQueryException
- */
- public static XDMIterator createAnyURI(final String uri) throws MXQueryException{
- return createTextTypeItem(null, uri, Type.ANY_URI);
- }
+public class XDMAtomicItemFactory extends SharedAtomicItemFactory{
/**
- * Creates a Base 64 Binary Item
- * @param base64Val String representation of a Base 64 value
- * @return an XDM Iterator representing the constructed Base 64 Binary Item
+ * Create an atomic type item from the given Java object
+ * An error is raised there is no matching atomic type or if values are incorrect
+ * @param val A Java object to be converted into a XDM atomic type
+ * @return an XDMIterator producing this atomic type
* @throws MXQueryException
*/
- public static XDMIterator createBase64Binary(String base64Val) throws MXQueryException {
- MXQueryBinary bin = new MXQueryBinary(base64Val,Type.BASE64_BINARY);
- return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
- }
- /**
- * Creates a Base 64 Binary Item
- * @param binValue binary values to be represented as Base 64
- * @return an XDM Iterator representing the constructed Base 64 Binary Item
- * @throws MXQueryException
- */
- public static XDMIterator createBase64Binary(byte [] binValue) throws MXQueryException {
- MXQueryBinary bin = new MXQueryBinary(binValue,Type.BASE64_BINARY);
- return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
- }
+ public static XDMIterator createAtomicItemType(Object val) throws MXQueryException{
+ if(val.getClass() == Float.class)
+ return createFloat(new MXQueryFloat(((Float)val).floatValue()));
+ if(val.getClass() == Double.class)
+ return createDouble(new MXQueryDouble(((Double)val).doubleValue()));
+ if(val.getClass() == BigDecimal.class)
+ return createDecimal(new MXQueryBigDecimal((BigDecimal)val));
+ if(val.getClass() == BigInteger.class) {
+ return createInteger(((BigInteger)val).longValue());
+ }
+ if(val instanceof Duration) {
+ Duration dur = (Duration)val;
+ TokenInterface tok;
+ if (dur.getYears() == 0 && dur.getMonths() == 0) {
+ MXQueryDayTimeDuration durDay = new MXQueryDayTimeDuration(dur.getSign(),dur.getDays(),dur.getHours(),dur.getMinutes(),dur.getSeconds(),0);
+ tok = new DayTimeDurToken(null,durDay);
+ } else if (dur.getDays() == 0 && dur.getHours() == 0 && dur.getMinutes() == 0 && dur.getSeconds() == 0) {
+ MXQueryYearMonthDuration durYear = new MXQueryYearMonthDuration(dur.getSign(),dur.getYears(),dur.getMonths());
+ tok = new YearMonthDurToken(null,durYear);
+ } else {
+ MXQueryDayTimeDuration durDay = new MXQueryDayTimeDuration(dur.getSign(),dur.getDays(),dur.getHours(),dur.getMinutes(),dur.getSeconds(),0);
+ MXQueryYearMonthDuration durYear = new MXQueryYearMonthDuration(dur.getSign(),dur.getYears(),dur.getMonths());
+ MXQueryDuration durMX = new MXQueryDuration(durYear,durDay);
+ tok = new DurationToken(null,durMX);
+ }
+ return new TokenIterator(null,tok,QueryLocation.OUTSIDE_QUERY_LOC,false);
+ }
+ if (val instanceof XMLGregorianCalendar) {
+ XMLGregorianCalendar greg = (XMLGregorianCalendar)val;
+ TokenInterface tok = null;
+ if (greg.getYear() != DatatypeConstants.FIELD_UNDEFINED) {
+ if (greg.getMonth() != DatatypeConstants.FIELD_UNDEFINED) {
+ if (greg.getDay() != DatatypeConstants.FIELD_UNDEFINED) {
+ if (greg.getHour() != DatatypeConstants.FIELD_UNDEFINED) {
+ // Year, Month, Day, Hour = dateTime
- /**
- * Creates a Boolean Item
- * @param val the boolean value for the item
- * @return an XDM Iterator representing the constructed Boolean Item
- * @throws MXQueryException
- */
- public static XDMIterator createBoolean(boolean val) throws MXQueryException{
- BooleanToken myToken;
- if (val)
- myToken = BooleanToken.TRUE_TOKEN;
- else
- myToken = BooleanToken.FALSE_TOKEN;
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Byte Item
- * @param bVal the byte value for the item
- * @return an XDM Iterator representing the constructed Byte Item
- * @throws MXQueryException
- */
- public static XDMIterator createByte(byte bVal) throws MXQueryException {
- LongToken myToken = new LongToken(Type.BYTE,null,bVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Date Item
- * @param dVal a String expressing the date for this item (XML Schema/XQuery format)
- * @return an XDM Iterator representing the constructed Date Item
- * @throws MXQueryException
- */
- public static XDMIterator createDate(String dVal) throws MXQueryException{
- MXQueryDate date = new MXQueryDate(dVal);
- return new TokenIterator(null,new DateToken(null,date),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a DateTime Item
- * @param dTimeVal a String expressing the dateTime for this item (XML Schema/XQuery format)
- * @return an XDM Iterator representing the constructed DateTim Item
- * @throws MXQueryException
- */
- public static XDMIterator createDateTime(String dTimeVal) throws MXQueryException{
- MXQueryDateTime dateTime = new MXQueryDateTime(dTimeVal);
- return new TokenIterator(null,new DateTimeToken(null,dateTime),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Duration Item
- * @param durVal a String expressing the duration for this item (XML Schema/XQuery format)
- * @return an XDM Iterator representing the constructed Duration Item
- * @throws MXQueryException
- */
- public static XDMIterator createDuration(String durVal) throws MXQueryException{
- MXQueryDuration dur = new MXQueryDuration(durVal);
- return new TokenIterator(null,new DurationToken(null,dur),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Decimal Item
- * @param dVal a MXQueryBigDecimal expressing the decimal value for this item
- * @return an XDM Iterator representing the constructed Decimal Item
- * @throws MXQueryException
- */
- public static XDMIterator createDecimal(MXQueryBigDecimal dVal) throws MXQueryException{
- return new TokenIterator(null, new DecimalToken(null,dVal),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Double Item
- * @param dVal a MXQueryDouble expressing the double value for this item
- * @return an XDM Iterator representing the constructed Double Item
- * @throws MXQueryException
- */
- public static XDMIterator createDouble(MXQueryDouble dVal) throws MXQueryException{
- return new TokenIterator(null,new DoubleToken(null,dVal),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Float Item
- * @param fVal a MXQueryFloat expressing the float value for this item
- * @return an XDM Iterator representing the constructed Float Item
- * @throws MXQueryException
- */
- public static XDMIterator createFloat(MXQueryFloat fVal) throws MXQueryException{
- return new TokenIterator(null,new FloatToken(null,fVal),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Gregorian Day Item
- * @param gDayVal the day number (1-31) expressing the Gregorian Day for this item
- * @return an XDM Iterator representing the constructed Gregorian Day Item
- * @throws MXQueryException
- */
- public static XDMIterator createGDay(int gDayVal) throws MXQueryException{
- MXQueryGregorian gDay = new MXQueryGregorian(0,0,gDayVal,0,Type.G_DAY);
- return new TokenIterator(null,new GregorianToken(null,gDay),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Gregorian Month Item
- * @param gMonthVal the month number (1-12) expressing the Gregorian Month for this item
- * @return an XDM Iterator representing the constructed Gregorian Month Item
- * @throws MXQueryException
- */
- public static XDMIterator createGMonth(int gMonthVal) throws MXQueryException{
- MXQueryGregorian gMonth = new MXQueryGregorian(0,gMonthVal,0,0,Type.G_MONTH);
- return new TokenIterator(null,new GregorianToken(null,gMonth),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Gregorian MonthDay Item
- * @param gMonthVal gMonthVal the month number (1-12) expressing the Gregorian Month for this item
- * @param gDayVal the day number (1-31) expressing the Gregorian Day for this item
- * @return an XDM Iterator representing the constructed Gregorian MonthDay Item
- * @throws MXQueryException
- */
- public static XDMIterator createGMonthDay(int gMonthVal, int gDayVal) throws MXQueryException {
- MXQueryGregorian gMonthDay = new MXQueryGregorian(0,gMonthVal,gDayVal,0,Type.G_MONTH_DAY);
- return new TokenIterator(null,new GregorianToken(null,gMonthDay),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Gregorian Year Item
- * @param gYearVal the year number expressing the Gregorian Year for this item
- * @return an XDM Iterator representing the constructed Gregorian Year Item
- * @throws MXQueryException
- */
- public static XDMIterator createGYear(int gYearVal) throws MXQueryException {
- MXQueryGregorian gYear = new MXQueryGregorian(gYearVal,0,0,0,Type.G_YEAR);
- return new TokenIterator(null,new GregorianToken(null,gYear),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Gregorian YearMonth Item
- * @param gYearVal gYearVal the year number expressing the Gregorian Year for this item
- * @param gMonthVal gMonthVal the month number (1-12) expressing the Gregorian Month for this item
- * @return an XDM Iterator representing the constructed Gregorian YearMonth Item
- * @throws MXQueryException
- */
- public static XDMIterator createGYearMonth(int gYearVal,int gMonthVal) throws MXQueryException {
- MXQueryGregorian gYearMonth = new MXQueryGregorian(gYearVal,gMonthVal,0,0,Type.G_YEAR_MONTH);
- return new TokenIterator(null,new GregorianToken(null,gYearMonth),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Hex Binary Item from a string representation
- * @param hexVal a string expressing the hex binary value for this item
- * @return an XDM Iterator representing the constructed HexBinary Item
- * @throws MXQueryException
- */
- public static XDMIterator createHexBinary(String hexVal) throws MXQueryException {
- MXQueryBinary bin = new MXQueryBinary(hexVal,Type.HEX_BINARY);
- return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
- }
- /**
- * Creates a Hex Binary Item from a binary representation
- * @param binValue a byte array expressing the hex binary value for this item
- * @return an XDM Iterator representing the constructed HexBinary Item
- * @throws MXQueryException
- */
- public static XDMIterator createHexBinary(byte [] binValue) throws MXQueryException {
- MXQueryBinary bin = new MXQueryBinary(binValue,Type.HEX_BINARY);
- return new TokenIterator(null,bin,QueryLocation.OUTSIDE_QUERY_LOC);
- }
- /**
- * Creates an Int Item
- * @param intVal an integer expressing the int value for this item
- * @return an XDM Iterator representing the constructed Int Item
- * @throws MXQueryException
- */
- public static XDMIterator createInt(int intVal) throws MXQueryException {
- LongToken myToken = new LongToken(Type.INT,null,intVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates an Integer Item
- * @param intVal an integer expressing the integer value for this item
- * @return an XDM Iterator representing the constructed Integer Item
- * @throws MXQueryException
- */
- public static XDMIterator createInteger(long intVal) throws MXQueryException {
- LongToken myToken = new LongToken(Type.INTEGER,null,intVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Long Item
- * @param longVal a long expressing the long value for this item
- * @return an XDM Iterator representing the constructed Long Item
- * @throws MXQueryException
- */
- public static XDMIterator createLong(long longVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.LONG,null,longVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a NCName Item
- * @param ncname a String expressing the NCNAME value for this item
- * @return an XDM Iterator representing the constructed NCNAME Item
- * @throws MXQueryException
- */
- public static XDMIterator createNCName(final String ncname) throws MXQueryException{
- return createTextTypeItem(null, ncname, Type.NCNAME);
- }
- /**
- * Creates a Negative Integer Item
- * @param longVal a long expressing the negative integer value for this item
- * @return an XDM Iterator representing the constructed Negative Integer Item
- * @throws MXQueryException
- */
- public static XDMIterator createNegativeInteger(long longVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.NEGATIVE_INTEGER,null,longVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Non-Negative Integer Item
- * @param longVal a long expressing the non-negative integer value for this item
- * @return an XDM Iterator representing the constructed Non-Negative Integer Item
- * @throws MXQueryException
- */
- public static XDMIterator createNonNegativeInteger(long longVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.NON_NEGATIVE_INTEGER,null,longVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Non-Positive Integer Item
- * @param longVal a long expressing the non-positive integer value for this item
- * @return an XDM Iterator representing the constructed Non-Positive Integer Item
- * @throws MXQueryException
- */
- public static XDMIterator createNonPositiveInteger(long longVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.NON_POSITIVE_INTEGER,null,longVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Positive Integer Item
- * @param longVal a long expressing the positive integer value for this item
- * @return an XDM Iterator representing the constructed Positive Integer Item
- * @throws MXQueryException
- */
- public static XDMIterator createPositiveInteger(long longVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.POSITIVE_INTEGER,null,longVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a QName Item
- * @param prefix a string representing the namespace prefix
- * @param localName a string representing the local name
- * @return an XDM Iterator representing the constructed QName Item
- * @throws MXQueryException
- */
- public static XDMIterator createQName(String prefix, String localName) throws MXQueryException{
- QName qn = new QName(prefix,localName);
- return new TokenIterator(null,new QNameToken(null,qn),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a qualified QName Item
- * @param namespace a string representing the namespace URI
- * @param prefix a string representing the namespace prefix
- * @param localName a string representing the local name
- * @return an XDM Iterator representing the constructed QName Item
- * @throws MXQueryException
- */
- public static XDMIterator createQName(String namespace, String prefix, String localName) throws MXQueryException{
- QName qn = new QName(namespace, prefix,localName);
- return new TokenIterator(null,new QNameToken(null,qn),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a Short Item
- * @param shortVal a short expressing the short value for this item
- * @return an XDM Iterator representing the constructed Short Item
- * @throws MXQueryException
- */
- public static XDMIterator createShort(short shortVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.SHORT,null,shortVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates a String Item
- * @param str a String expressing the string value for this item
- * @return an XDM Iterator representing the constructed String Item
- * @throws MXQueryException
- */
- public static XDMIterator createString(final String str) throws MXQueryException{
- return createTextTypeItem(null, str, Type.STRING);
- }
- /**
- * Creates a Time Item
- * @param timeVal a string expressing the time value for this item (XML Schema/XQuery format)
- * @return an XDM Iterator representing the constructed Time Item
- * @throws MXQueryException
- */
- public static XDMIterator createTime(String timeVal) throws MXQueryException{
- MXQueryTime time = new MXQueryTime(timeVal);
- return new TokenIterator(null, new TimeToken(null,time),QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates an Unsigned Byte Item
- * @param ubVal a short expressing the unsigned byte value for this item
- * @return an XDM Iterator representing the constructed Unsigned Byte Item
- * @throws MXQueryException
- */
- public static XDMIterator createUnsignedByte(short ubVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.UNSIGNED_BYTE,null,ubVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates an Unsigned Int Item
- * @param usVal a long expressing the unsigned int value for this item
- * @return an XDM Iterator representing the constructed Unsigned Int Item
- * @throws MXQueryException
- */
- public static XDMIterator createUnsignedInt(long usVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.UNSIGNED_INT,null,usVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates an Unsigned Long Item. Note: Unsigned Long is limited to the signed long space in MXQuery
- * @param ulVal a long expressing the unsigned long value for this item
- * @return an XDM Iterator representing the constructed Unsigned Long Item
- * @throws MXQueryException
- */
- public static XDMIterator createUnsignedLong(long ulVal) throws MXQueryException {
- LongToken myToken = new LongToken(Type.UNSIGNED_LONG,null,ulVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
- /**
- * Creates an Unsigned Short Item
- * @param uiVal an integer expressing the unsigned short value for this item
- * @return an XDM Iterator representing the constructed Unsigned Short Item
- * @throws MXQueryException
- */
- public static XDMIterator createUnsignedShort(int uiVal) throws MXQueryException{
- LongToken myToken = new LongToken(Type.UNSIGNED_SHORT,null,uiVal);
- return new TokenIterator(null,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
- }
+ MXQueryDateTime dat = new MXQueryDateTime(greg.toXMLFormat());
+ tok = new DateTimeToken(null,dat);
- /**
- * Creates a untyped atomic Item
- * @param str a String expressing the string value for this item
- * @return an XDM Iterator representing the constructed String Item
- * @throws MXQueryException
- */
- public static XDMIterator createUntypedAtomic(final String str) throws MXQueryException{
- return createTextTypeItem(null, str, Type.UNTYPED_ATOMIC);
- }
-
- private static XDMIterator createTextTypeItem (Context ctx, String value, int type) throws MXQueryException {
-
- TokenInterface myToken;
-
- int checkType = Type.getEventTypeSubstituted(type, Context.getDictionary());
-
- switch (checkType) {
- case Type.STRING:
- case Type.UNTYPED:
- myToken = new TextToken(type, null, value,null);
- break;
+ } else {
+ MXQueryDate dat = new MXQueryDate(greg.toXMLFormat());
+ tok = new DateToken(null,dat);
+ }
+ } else {
+ // Year, Month, no Day = gYearMonth
+ MXQueryGregorian mxqG = new MXQueryGregorian(greg.getYear(),greg.getMonth(),0,0,Type.G_YEAR_MONTH);
+ tok = new GregorianToken(null,mxqG);
- case Type.UNTYPED_ATOMIC:
- myToken = new UntypedAtomicToken(null, value);
- break;
-
- case Type.ANY_URI:
- myToken = new AnyURIToken(null, value);
- break;
- default:
- throw new TypeException(ErrorCodes.E0004_TYPE_INAPPROPRIATE_TYPE,"Incorrect type passed: " + Type.getTypeQName(type, Context.getDictionary()),QueryLocation.OUTSIDE_QUERY_LOC );
+ }
+ } else {
+ // Year, no month = gYear
+ MXQueryGregorian mxqG = new MXQueryGregorian(greg.getYear(),0,0,0,Type.G_YEAR);
+ tok = new GregorianToken(null,mxqG);
}
- return new TokenIterator(ctx,myToken,QueryLocation.OUTSIDE_QUERY_LOC, false);
+ } else {
+ if (greg.getMonth() != DatatypeConstants.FIELD_UNDEFINED) {
+ if (greg.getDay() != DatatypeConstants.FIELD_UNDEFINED) {
+ // no year, month+day present: gMonthDay
+ MXQueryGregorian mxqG = new MXQueryGregorian(0,greg.getMonth(),greg.getDay(),0,Type.G_MONTH_DAY);
+ tok = new GregorianToken(null,mxqG);
+ } else {
+ // no year, month present, no day: gMonthDay
+ MXQueryGregorian mxqG = new MXQueryGregorian(0,greg.getMonth(),0,0,Type.G_MONTH);
+ tok = new GregorianToken(null,mxqG);
+ }
+ } else {
+ if (greg.getDay() != DatatypeConstants.FIELD_UNDEFINED) {
+ // no year, no month, but day: gDay
+ MXQueryGregorian mxqG = new MXQueryGregorian(0,0,greg.getDay(),0,Type.G_DAY);
+ tok = new GregorianToken(null,mxqG);
+
+ } else {
+ // time
+ MXQueryTime dat = new MXQueryTime(greg.toXMLFormat());
+ tok = new TimeToken(null,dat);
+
+ }
+ }
+ }
+ return new TokenIterator(null,tok,QueryLocation.OUTSIDE_QUERY_LOC,false);
}
-
+
+ // if (val instanceof QName) {
+ // QName qn = (QName) val;
+ // QNameToken qnt = new QNameToken(null, new ch.ethz.mxquery.datamodel.QName(qn.getNamespaceURI(),qn.getLocalPart(),qn.getPrefix()));
+ // return new TokenIterator(null,qnt,QueryLocation.OUTSIDE_QUERY_LOC,false);
+ // }
+ return SharedAtomicItemFactory.createAtomicItemType(val);
+ }
}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/extensionsModules/expathhttp/HttpIO.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -185,7 +185,7 @@
if (this.getContext().getRootContext()
.getFunction(asynchandlername, 1) == null) {
throw new MXQueryException(
- ErrorCodes.A0017_Missing_Pattern_Var_Decl,
+ ErrorCodes.E0017_STATIC_DOESNT_MATCH_FUNCTION_SIGNATURE,
"the eventhandler with the name "
+ asynchandlername.toString()
+ " is not available in an asynchronous expath call",
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddEventListener.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddEventListener.java 2011-05-05 07:18:53 UTC (rev 4312)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/b/AddEventListener.java 2011-05-05 07:23:40 UTC (rev 4313)
@@ -98,7 +98,7 @@
// qfunctionname.setNamespaceURI(this.getContext().getNamespace(qfunctionname.getNamespacePrefix()...
[truncated message content] |
|
From: <pm_...@us...> - 2011-05-05 07:19:03
|
Revision: 4312
http://mxquery.svn.sourceforge.net/mxquery/?rev=4312&view=rev
Author: pm_fischer
Date: 2011-05-05 07:18:53 +0000 (Thu, 05 May 2011)
Log Message:
-----------
initial version of Java object import tests
Added Paths:
-----------
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java
Added: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java (rev 0)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java 2011-05-05 07:18:53 UTC (rev 4312)
@@ -0,0 +1,13 @@
+package ch.ethz.mxquery.test;
+
+import ch.ethz.mxquery.testsuite.XQueryTestBase;
+
+
+public class JavaImportTests extends XQueryTestBase{
+ public void test_parse_namespacedef_static() throws Exception{
+ String query = "declare namespace jmath = \"java:java.lang.Math\"; 1";
+ prepareQuery(query, false,false, false, false, false);
+ //System.out.println(myBuffer.toString());
+ //assertEquals("1 2 1", resultBuffer.toString().trim() );
+ };
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <max...@us...> - 2011-05-04 21:48:49
|
Revision: 4311
http://mxquery.svn.sourceforge.net/mxquery/?rev=4311&view=rev
Author: maxspeicher
Date: 2011-05-04 21:48:40 +0000 (Wed, 04 May 2011)
Log Message:
-----------
- changed to namespace ch.ethz.repackaged for repackaged JARs
- added refactoring of XQJ package to build file
Modified Paths:
--------------
trunk/MXQuery/android/lib/jsr173_1.0_api-repackaged.jar
trunk/MXQuery/android/lib/xqjapi-repackaged.jar
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataFactory.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java
trunk/MXQuery/build.xml
Removed Paths:
-------------
trunk/MXQuery/android/ant-contrib-1.0b3.jar
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/FlatItem.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/Item.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/ItemAccessor.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataSource.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQMetaData.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQSequence.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQStaticContext.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQType.java
trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/TreeItem.java
Deleted: trunk/MXQuery/android/ant-contrib-1.0b3.jar
===================================================================
(Binary files differ)
Modified: trunk/MXQuery/android/lib/jsr173_1.0_api-repackaged.jar
===================================================================
(Binary files differ)
Modified: trunk/MXQuery/android/lib/xqjapi-repackaged.jar
===================================================================
(Binary files differ)
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/FlatItem.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/FlatItem.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/FlatItem.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,264 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.util.Properties;
-
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-
-import org.w3c.dom.Node;
-
-import ch.ethz.mxquery.contextConfig.Context;
-import ch.ethz.mxquery.datamodel.MXQueryDouble;
-import ch.ethz.mxquery.datamodel.MXQueryNumber;
-import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.types.TypeInfo;
-import ch.ethz.mxquery.datamodel.types.TypeLexicalConstraints;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.iterators.TokenIterator;
-import ch.ethz.mxquery.model.XDMIterator;
-import ch.ethz.mxquery.util.PlatformDependentUtils;
-import ch.ethz.xquery.XQException;
-
-public class FlatItem implements Item {
-
- TokenInterface tk;
- private boolean closed = false;
-
- public FlatItem(TokenInterface tk){
- this.tk = tk;
- }
-
- public void close() {
- closed = true;
- this.tk = null;
- }
-
- public String getAtomicValue() throws XQException {
- if (Type.isSubTypeOf(tk.getEventType(), Type.ANY_ATOMIC_TYPE, null)) {
- return tk.getValueAsString();
- }
- throw new XQException("Failed to getAtomicValue: item is a node, or is closed");
- }
-
- public boolean getBoolean() throws XQException {
- if (Type.isTypeOrSubTypeOf(tk.getEventType(), Type.BOOLEAN, Context.getDictionary())) {
- return tk.getBoolean();
- }
- throw new XQException("Failed to getBoolean: item is a node, or is closed");
- }
-
- public byte getByte() throws XQException {
- int targetType = Type.BYTE;
- return (byte)checkIntType(targetType);
- }
-
- public double getDouble() throws XQException {
- if (Type.isTypeOrSubTypeOf(tk.getEventType(), Type.DOUBLE, Context.getDictionary())) {
- MXQueryDouble doub = null;
- doub = tk.getDouble();
- return doub.getValue();
- }
- throw new XQException("Failed to getDouble: item is a node, or is closed");
- }
-
- public float getFloat() throws XQException {
- if (Type.isTypeOrSubTypeOf(tk.getEventType(), Type.FLOAT, Context.getDictionary())) {
- MXQueryDouble doub = null;
- doub = tk.getDouble();
- return (float)doub.getValue();
- }
- throw new XQException("Failed to getFloat: item is a node, or is closed");
- }
-
- public int getInt() throws XQException {
- int targetType = Type.INT;
- return (int)checkIntType(targetType);
- }
-
- public String getItemAsString(Properties props) throws XQException {
- if (Type.isTypeOrSubTypeOf(tk.getEventType(), Type.ANY_ATOMIC_TYPE, Context.getDictionary())) {
- return getAtomicValue();
- }
- throw new XQException("Failed to getItemAsString: ");
- }
-
-
- public long getLong() throws XQException {
- int targetType = Type.INTEGER;
- return checkIntType(targetType);
- }
-
- public short getShort() throws XQException {
- int targetType = Type.SHORT;
- return (short)checkIntType(targetType);
- }
-
- private long checkIntType(int targetType) throws XQException {
- if (Type.isTypeOrSubTypeOf(tk.getEventType(), Type.DECIMAL, Context.getDictionary())){
- long res = tk.getLong();
- if (!Type.isTypeOrSubTypeOf(tk.getEventType(), Type.INTEGER, Context.getDictionary())){
- MXQueryNumber num = tk.getNumber();
- try {
- res = num.getLongValue();
- } catch (MXQueryException e) {
- throw new XQException("Invalid value for getXXX() operation");
- }
- if (num.compareTo(res)!= 0) {
- throw new XQException("Invalid value for getXXX() operation");
- }
- }
- try {
- if (!TypeLexicalConstraints.satisfyIntegerRange(targetType, res))
- throw new XQException("Invalid value for getXXX() operation");
- } catch (MXQueryException e) {
- throw new XQException(e.toString());
- }
-
- return res;
- }
- throw new XQException("Failed to getByte: item is a node, or is closed");
- }
-
-
- public boolean isClosed() {
- return this.closed;
- }
-
- public TypeInfo getType() {
- return new TypeInfo(tk.getEventType(),Type.OCCURRENCE_IND_EXACTLY_ONE);
- }
-
- public XDMIterator getAsIterator() throws XQException{
- try {
- return new TokenIterator(null,tk,null, false);
- } catch (MXQueryException me) {
- throw new XQException(me.toString());
- }
- }
-
- public Object getObject() throws XQException {
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.STRING,Context.getDictionary())) {
- return getItemAsString(null);
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.ANY_URI,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.UNTYPED_ATOMIC,Context.getDictionary())) {
- return getItemAsString(null);
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.FLOAT,Context.getDictionary())) {
- return new Float(getFloat());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.DOUBLE,Context.getDictionary())) {
- return new Double(getDouble());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.BYTE,Context.getDictionary())) {
- return new Byte(getByte());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.SHORT,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.UNSIGNED_BYTE,Context.getDictionary())) {
- return new Short(getShort());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.INT,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.UNSIGNED_SHORT,Context.getDictionary())) {
- return new Integer(getInt());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.LONG,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.UNSIGNED_INT,Context.getDictionary())) {
- return new Long(getLong());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.INTEGER,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.UNSIGNED_LONG,Context.getDictionary())) {
- return BigInteger.valueOf(getLong());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.DECIMAL,Context.getDictionary())) {
- return new BigDecimal(tk.getValueAsString());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.BOOLEAN,Context.getDictionary())) {
- return new Boolean(tk.getBoolean());
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.BASE64_BINARY,Context.getDictionary())) {
- return tk.getBinary().getValue();
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.HEX_BINARY,Context.getDictionary())) {
- return tk.getBinary().getValue();
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.DATE,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.DATE_TIME,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.TIME,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.G_DAY,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.G_MONTH,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.G_MONTH_DAY,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.G_YEAR,Context.getDictionary())||
- Type.isTypeOrSubTypeOf(tk.getEventType(),Type.G_YEAR_MONTH,Context.getDictionary())) {
- try {
- return DatatypeFactory.newInstance().newXMLGregorianCalendar(getItemAsString(null));
- } catch (DatatypeConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //XMLGregorianCalendarImpl.parse(getItemAsString(null));
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(), Type.QNAME, Context.getDictionary())) {
- ch.ethz.mxquery.datamodel.QName qn = tk.getQNameTokenValue();
- return PlatformDependentUtils.getJavaxQName(qn);
- }
-
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.DAY_TIME_DURATION,Context.getDictionary())) {
- try {
- return DatatypeFactory.newInstance().newDurationDayTime(getItemAsString(null));
- } catch (DatatypeConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.DURATION,Context.getDictionary())) {
- try {
- return DatatypeFactory.newInstance().newDuration(getItemAsString(null));
- } catch (DatatypeConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (Type.isTypeOrSubTypeOf(tk.getEventType(),Type.YEAR_MONTH_DURATION,Context.getDictionary())) {
- try {
- return DatatypeFactory.newInstance().newDurationYearMonth(getItemAsString(null));
- } catch (DatatypeConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-
- throw new XQException("Unsupported type for getObject");
-
- }
-
- public Node getNode() throws XQException {
- // TODO Auto-generated method stub
- throw new XQException("getNode() not possible on atomic types");
- }
-
- public URI getNodeUri() throws XQException{
- throw new XQException("getNodeUri not possible on atomic types");
- }
-
-}
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/Item.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/Item.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/Item.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,61 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.w3c.dom.Node;
-
-import ch.ethz.mxquery.datamodel.types.TypeInfo;
-import ch.ethz.mxquery.model.XDMIterator;
-import ch.ethz.xquery.XQException;
-
-public interface Item {
-
- void close();
-
- String getAtomicValue() throws XQException;
-
- boolean getBoolean() throws XQException;
-
- byte getByte() throws XQException;
-
- double getDouble() throws XQException;
-
- float getFloat() throws XQException;
-
- int getInt() throws XQException;
-
- String getItemAsString(Properties props) throws XQException;
-
- XDMIterator getAsIterator() throws XQException;
-
- long getLong() throws XQException;
-
- short getShort() throws XQException;
-
- boolean isClosed();
-
- TypeInfo getType();
-
- Object getObject() throws XQException;
-
- Node getNode() throws XQException;
-
- URI getNodeUri() throws XQException;
-
-}
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/ItemAccessor.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/ItemAccessor.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/ItemAccessor.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,122 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.io.IOException;
-import java.util.Vector;
-
-import ch.ethz.mxquery.datamodel.types.Type;
-import ch.ethz.mxquery.datamodel.xdm.Token;
-import ch.ethz.mxquery.datamodel.xdm.TokenInterface;
-import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.model.Iterator;
-import ch.ethz.mxquery.model.XDMIterator;
-import ch.ethz.mxquery.query.PreparedStatement;
-import ch.ethz.mxquery.util.PlatformDependentUtils;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQQueryException;
-
-public class ItemAccessor {
-
- private XDMIterator iter;
- private PreparedStatement statement;
- //private Iterator retIter;
-
-// private boolean startTagStarted = false;
-// private boolean endTagFound = false;
-
- public ItemAccessor(XDMIterator iter){
- this.iter = iter;
- }
-
- public ItemAccessor(PreparedStatement statement) throws XQException {
- this.statement = statement;
- try {
- this.iter = statement.evaluate();
- } catch (MXQueryException e) {
- throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
- }
- }
-
-// public boolean hasNext() {
-// // TODO Auto-generated method stub
-// return false;
-// }
-
- public Object next() throws MXQueryException, IOException {
- int depth = 0;
- int curDepth;
- boolean flag = true;
-
-// startTagStarted = false;
-// endTagFound = false;
-
- Vector v = new Vector();
-
- //StringBuffer myBuffer = new StringBuffer();
-
- //this.retIter = this.iter.
-
- TokenInterface tok = iter.next();
- curDepth = depth;
-
- if(Type.isAtomicType(tok.getEventType(), null)){
- return new FlatItem(tok);
- }
-
- if(tok.getEventType() != Type.END_SEQUENCE){
-
- while(tok.getEventType() !=Type.END_SEQUENCE && flag){
-
- if (Type.isStartType(tok.getEventType())){
- depth++;
- } else if (Type.isEndType(tok.getEventType())){
- depth--;
- }
-
-
- v.add(tok);
-
- if(depth != curDepth){
- tok = iter.next();
- } else {
- flag = false;
- }
- }
- return new TreeItem(v);
-
- }
- if (tok == Token.END_SEQUENCE_TOKEN) {
- if (iter.getExpressionCategoryType(false) == Iterator.EXPR_CATEGORY_UPDATING) {
- iter.getPendingUpdateList().apply();
- statement.serializeStores(false);
- }
- }
-
- return null;
-
- }
-
- public XDMIterator getIterator(){
- return iter;
- }
-
- public void remove() {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQConnection.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,218 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.Vector;
-
-import ch.ethz.mxquery.query.XQCompiler;
-import ch.ethz.mxquery.query.PreparedStatement;
-import ch.ethz.mxquery.query.impl.CompilerImpl;
-import ch.ethz.mxquery.util.PlatformDependentUtils;
-import ch.ethz.mxquery.contextConfig.CompilerOptions;
-import ch.ethz.mxquery.contextConfig.Context;
-import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.xquery.XQConnection;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQExpression;
-import ch.ethz.xquery.XQMetaData;
-import ch.ethz.xquery.XQPreparedExpression;
-import ch.ethz.xquery.XQQueryException;
-import ch.ethz.xquery.XQStaticContext;
-
-public class MXQueryXQConnection extends MXQueryXQDataFactory implements
-XQConnection {
-
- MXQueryXQStaticContext runtime;
- private int languageLevel = 0;
- private Vector expStore = new Vector();
- CompilerOptions co = new CompilerOptions();
-
- public MXQueryXQConnection(MXQueryXQDataSource src) {
- // Query root context (=? static context) per connections
- runtime = new MXQueryXQStaticContext(new Context());
- }
-
- public MXQueryXQConnection(MXQueryXQDataSource src, int mode) {
- // Query root context (=? static context) per connections
- runtime = new MXQueryXQStaticContext(new Context());
- languageLevel = mode;
- }
-
-
- public void clearWarnings() throws XQException {
- checkNotClosed();
- // TODO Auto-generated method stub
-
- }
-
- public void close() throws XQException {
- for(int i = 0; i < this.expStore.size(); i ++){
- if(this.expStore.get(i) instanceof MXQueryXQExpression)
- ((MXQueryXQExpression) this.expStore.get(i)).close();
- else
- ((MXQueryXQPreparedExpression) this.expStore.get(i)).close();
- }
- closed = true;
- }
-
- public void commit() throws XQException {
- checkNotClosed();
- // TODO NoOp
-
- }
-
- public XQExpression createExpression(XQStaticContext properties)
- throws XQException {
- if (properties == null) {
- throw new XQException("Static Context is null");
- }
- checkNotClosed();
- MXQueryXQExpression mxExp = new MXQueryXQExpression(this, (MXQueryXQStaticContext)properties, languageLevel);
- this.expStore.add(mxExp);
- return mxExp;
- }
-
- public XQExpression createExpression() throws XQException {
- checkNotClosed();
- MXQueryXQExpression mxExp = new MXQueryXQExpression(this, new MXQueryXQStaticContext(runtime), languageLevel);
- this.expStore.add(mxExp);
- return mxExp;
- }
-
- public XQMetaData getMetaData() throws XQException {
- checkNotClosed();
- return new MXQueryXQMetaData(this);
- }
-
- public String getMetaDataProperty(String key) throws XQException {
- checkNotClosed();
- throw new UnsupportedOperationException("Metadata is not yet implemented");
- }
-
- public String[] getSupportedMetaDataPropertyNames() throws XQException {
- checkNotClosed();
- throw new UnsupportedOperationException("Metadata is not yet implemented");
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public XQPreparedExpression prepareExpression(InputStream xquery)
- throws XQException {
- if (xquery == null)
- throw new XQException("Query is null");
- return prepareExpression(xquery, new MXQueryXQStaticContext(runtime));
- }
-
- public XQPreparedExpression prepareExpression(InputStream xquery,
- XQStaticContext properties) throws XQException {
- if (xquery == null)
- throw new XQException("Query is null");
- return prepareExpression(new InputStreamReader(xquery), properties);
- }
-
- public XQPreparedExpression prepareExpression(Reader xquery)
- throws XQException {
- checkNotClosed();
- if (xquery == null)
- throw new XQException("Query is null");
- return prepareExpression(xquery, new MXQueryXQStaticContext(runtime));
- }
-
- public XQPreparedExpression prepareExpression(Reader xquery,
- XQStaticContext properties) throws XQException {
- checkNotClosed();
- if (xquery == null)
- throw new XQException("Input is a null value");
- String expr = "";
- String str;
- try {
- BufferedReader br = new BufferedReader(xquery);
- while((str = br.readLine()) != null){
- expr += str;
- }
- } catch (IOException e) {
- throw new XQQueryException(e.toString());
- }
- return prepareExpression(expr, properties);
-
- }
-
- public XQPreparedExpression prepareExpression(String xquery)
- throws XQException {
- if (xquery == null)
- throw new XQException("Query is null");
- return prepareExpression(xquery, new MXQueryXQStaticContext(runtime));
- }
-
- public XQPreparedExpression prepareExpression(String xquery,
- XQStaticContext properties) throws XQException {
- checkNotClosed();
- if (xquery == null)
- throw new XQException("Query is null");
- MXQueryXQStaticContext ctx = runtime;
- if (properties != null)
- ctx = (MXQueryXQStaticContext)properties;
- else
- throw new XQException("Static context is null");
- try {
- XQCompiler compiler = new CompilerImpl();
- PreparedStatement statement = compiler.compile(ctx.runtime, xquery,co, null, null);
- MXQueryXQPreparedExpression mxPreExp = new MXQueryXQPreparedExpression(this, statement);
- this.expStore.add(mxPreExp);
- return mxPreExp;
- } catch (MXQueryException e) {
- throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
- }
- }
-
- public void rollback() throws XQException {
- checkNotClosed();
- }
-
-
- public boolean getAutoCommit() throws XQException {
- return true;
- }
-
-
- public XQStaticContext getStaticContext() throws XQException {
- checkNotClosed();
- return new MXQueryXQStaticContext(runtime);
- }
-
-
- public void setAutoCommit(boolean autoCommit) throws XQException {
- if (autoCommit == false)
- throw new XQException("Disabling autocommit not supported");
-
- }
-
-
- public void setStaticContext(XQStaticContext properties) throws XQException {
- checkNotClosed();
- if (properties == null)
- throw new XQException("Static Context is null");
- runtime = ((MXQueryXQStaticContext)properties);
- }
-
-}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataFactory.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataFactory.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataFactory.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -75,14 +75,14 @@
import ch.ethz.mxquery.util.StringReader;
import ch.ethz.mxquery.xdmio.XDMInputFactory;
import ch.ethz.mxquery.xdmio.XMLSource;
-import ch.ethz.namespace.QName;
-import ch.ethz.stream.XMLStreamReader;
-import ch.ethz.xquery.XQDataFactory;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQItem;
-import ch.ethz.xquery.XQItemType;
-import ch.ethz.xquery.XQSequence;
-import ch.ethz.xquery.XQSequenceType;
+import ch.ethz.repackaged.namespace.QName;
+import ch.ethz.repackaged.stream.XMLStreamReader;
+import ch.ethz.repackaged.xquery.XQDataFactory;
+import ch.ethz.repackaged.xquery.XQException;
+import ch.ethz.repackaged.xquery.XQItem;
+import ch.ethz.repackaged.xquery.XQItemType;
+import ch.ethz.repackaged.xquery.XQSequence;
+import ch.ethz.repackaged.xquery.XQSequenceType;
public class MXQueryXQDataFactory implements XQDataFactory {
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataSource.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataSource.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDataSource.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,92 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.util.Properties;
-
-import ch.ethz.xquery.XQConnection;
-import ch.ethz.xquery.XQDataSource;
-import ch.ethz.xquery.XQException;
-
-public class MXQueryXQDataSource implements
-XQDataSource {
-
- public static final int XQJ_NORMAL_MODE = 0;
- public static final int XQJ_UPDATE_MODE = 1;
- public static final int XQJ_SCRIPTING_MODE = 2;
-
- private int languageLevel = 0;
-
- PrintWriter logger;
-
- public MXQueryXQDataSource() {
- }
-
- public MXQueryXQDataSource(int mode) {
- languageLevel = mode;
- }
-
- public XQConnection getConnection() throws XQException {
- return new MXQueryXQConnection(this, languageLevel);
- }
-
- public XQConnection getConnection(Connection con) throws XQException {
- throw new XQException("MXQuery cannot connect to a JDBC data source");
- }
-
- public XQConnection getConnection(String username, String password)
- throws XQException {
- return getConnection();
- }
-
- public PrintWriter getLogWriter() {
- return logger;
- }
-
- public int getLoginTimeout() {
- return 0;
- }
-
- public String getProperty(String name) throws XQException {
- throw new XQException("Getting property "+name+" not supported");
- }
-
- public String[] getSupportedPropertyNames() {
- String[] names =
- { };
- return names;
- }
-
- public void setLogWriter(PrintWriter out) throws XQException {
- logger = out;
- }
-
- public void setLoginTimeout(int seconds) throws XQException {
- // No-Op
- }
-
- public void setProperties(Properties props) throws XQException {
- throw new XQException("Setting properties not supported");
- }
-
- public void setProperty(String name, String value) throws XQException {
- throw new XQException("Setting property "+name+" not supported");
-
- }
-
-}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQDynamicContext.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -68,14 +68,14 @@
import ch.ethz.mxquery.util.StringReader;
import ch.ethz.mxquery.xdmio.XDMInputFactory;
import ch.ethz.mxquery.xdmio.XMLSource;
-import ch.ethz.namespace.QName;
-import ch.ethz.stream.XMLStreamReader;
-import ch.ethz.xquery.XQDynamicContext;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQItem;
-import ch.ethz.xquery.XQItemType;
-import ch.ethz.xquery.XQQueryException;
-import ch.ethz.xquery.XQSequence;
+import ch.ethz.repackaged.namespace.QName;
+import ch.ethz.repackaged.stream.XMLStreamReader;
+import ch.ethz.repackaged.xquery.XQDynamicContext;
+import ch.ethz.repackaged.xquery.XQException;
+import ch.ethz.repackaged.xquery.XQItem;
+import ch.ethz.repackaged.xquery.XQItemType;
+import ch.ethz.repackaged.xquery.XQQueryException;
+import ch.ethz.repackaged.xquery.XQSequence;
public abstract class MXQueryXQDynamicContext implements XQDynamicContext {
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQExpression.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,194 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.Vector;
-
-import ch.ethz.mxquery.contextConfig.CompilerOptions;
-import ch.ethz.mxquery.contextConfig.Context;
-import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.model.XDMIterator;
-import ch.ethz.mxquery.query.PreparedStatement;
-import ch.ethz.mxquery.query.XQCompiler;
-import ch.ethz.mxquery.query.impl.CompilerImpl;
-import ch.ethz.mxquery.util.PlatformDependentUtils;
-import ch.ethz.mxquery.util.StringReader;
-import ch.ethz.mxquery.xdmio.StoreSet;
-import ch.ethz.xquery.XQConstants;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQExpression;
-import ch.ethz.xquery.XQQueryException;
-import ch.ethz.xquery.XQResultSequence;
-import ch.ethz.xquery.XQStaticContext;
-
-public class MXQueryXQExpression extends MXQueryXQDynamicContext implements
-XQExpression {
-
- MXQueryXQConnection conn;
- private int languageLevel = 0;
- private boolean cancel;
- MXQueryXQStaticContext runtime;
- private Thread t;
- MXQueryXQSequence seq;
- CompilerOptions co = new CompilerOptions();
-
- public MXQueryXQExpression(MXQueryXQConnection connection, MXQueryXQStaticContext properties, int mode) {
- conn = connection;
- runtime = properties;
- languageLevel = mode;
- }
-
- protected void checkNotClosed() throws XQException {
- if (conn.isClosed()) {
- close();
- }
- if (isClosed()) {
- throw new XQException("Expression has been closed");
- }
- }
-
- public void cancel() throws XQException {
- checkNotClosed();
- if(t != null)
- this.cancel = true;
- }
-
- public void close() throws XQException {
- if(seq != null)
- this.seq.close();
- closed = true;
- }
-
- public void executeCommand(Reader command) throws XQException {
- checkNotClosed();
- throw new XQException("MXQuery does not recognize any non-XQuery commands");
- }
-
- public void executeCommand(String command) throws XQException {
- checkNotClosed();
- throw new XQException("MXQuery does not recognize any non-XQuery commands");
- }
-
- public XQResultSequence executeQuery(InputStream query) throws XQException {
- if (query == null)
- throw new XQException("query is null");
- return executeQuery(new InputStreamReader(query));
- }
-
- public XQResultSequence executeQuery(Reader query) throws XQException {
- checkNotClosed();
- try {
- t = Thread.currentThread();
- String expr = "";
- String str;
- BufferedReader br = new BufferedReader(query);
- while((str = br.readLine()) != null){
- expr += str;
- }
- XQCompiler compiler = new CompilerImpl();
- // checking the language level
- if (languageLevel == MXQueryXQDataSource.XQJ_UPDATE_MODE) {
- co.setUpdate(true);
- StoreSet ss = runtime.getEngineContext().getStores();
- ss.setSerializeStores(true);
- } else if (languageLevel == MXQueryXQDataSource.XQJ_SCRIPTING_MODE) {
- co.setUpdate(true);
- StoreSet ss = runtime.getEngineContext().getStores();
- ss.setSerializeStores(true);
- }
- PreparedStatement statement = compiler.compile(runtime.getEngineContext(), expr,co, null, null);
- XDMIterator iter;
- if(this.cancel){
- this.cancel = false;
- throw new XQException("Expression has been closed");
- } else {
- iter = statement.evaluate();
- }
- if(this.cancel){
- this.cancel = false;
- throw new XQException("Expression has been closed");
- } else {
- t = null;
- if(this.conn.getStaticContext().getScrollability() == XQConstants.SCROLLTYPE_FORWARD_ONLY) {
- //return new MXQueryXQForwardSequence(iter, conn, this);
- return new MXQueryXQForwardSequence(statement, conn, this);
- }
- Vector store = new Vector();
- int i = 0;
- //MXQueryXQForwardSequence mSeq = new MXQueryXQForwardSequence(iter, conn,this);
- MXQueryXQForwardSequence mSeq = new MXQueryXQForwardSequence(statement, conn,this);
- while(mSeq.next()){
- store.add(i++,mSeq.getItem());
- }
- this.seq = new MXQueryXQSequence(store, this.conn);
- return seq;
- }
-
- } catch (MXQueryException e) {
- throw new XQQueryException(e.toString(),PlatformDependentUtils.getJavaxQName(e.getErrorCode()));
- } catch (IOException e) {
- throw new XQQueryException(e.toString());
- }
- }
-
- public XQResultSequence executeQuery(String query) throws XQException {
- checkNotClosed();
- if (query == null)
- throw new XQException("query is null");
- return executeQuery(new StringReader(query));
- }
-
- public int getQueryLanguageTypeAndVersion() throws XQException {
- return XQConstants.LANGTYPE_XQUERY;
- }
-
- public int getQueryTimeout() throws XQException {
- checkNotClosed();
- return 0;
- }
-
- public boolean isClosed() {
- if (conn.isClosed()) {
- closed = true;
- }
- return closed;
- }
-
- public void setQueryTimeout(int seconds) throws XQException {
- checkNotClosed();
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
-
- //@Override
- protected Context getRuntime() {
- if(this.runtime != null){
- return this.runtime.getEngineContext();
- }
- return null;
- }
-
- public XQStaticContext getStaticContext() throws XQException {
- checkNotClosed();
- return runtime;
- }
-
-}
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQForwardSequence.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -31,13 +31,13 @@
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.query.PreparedStatement;
import ch.ethz.mxquery.util.PlatformDependentUtils;
-import ch.ethz.stream.XMLStreamReader;
-import ch.ethz.xquery.XQConnection;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQItem;
-import ch.ethz.xquery.XQItemType;
-import ch.ethz.xquery.XQQueryException;
-import ch.ethz.xquery.XQResultSequence;
+import ch.ethz.repackaged.stream.XMLStreamReader;
+import ch.ethz.repackaged.xquery.XQConnection;
+import ch.ethz.repackaged.xquery.XQException;
+import ch.ethz.repackaged.xquery.XQItem;
+import ch.ethz.repackaged.xquery.XQItemType;
+import ch.ethz.repackaged.xquery.XQQueryException;
+import ch.ethz.repackaged.xquery.XQResultSequence;
public class MXQueryXQForwardSequence implements XQResultSequence {
Modified: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQItem.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -36,12 +36,12 @@
import ch.ethz.mxquery.datamodel.types.TypeInfo;
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.xdmio.xmlAdapters.Token2SaxAdapter;
-import ch.ethz.namespace.QName;
-import ch.ethz.stream.XMLStreamReader;
-import ch.ethz.xquery.XQConnection;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQItemType;
-import ch.ethz.xquery.XQResultItem;
+import ch.ethz.repackaged.namespace.QName;
+import ch.ethz.repackaged.stream.XMLStreamReader;
+import ch.ethz.repackaged.xquery.XQConnection;
+import ch.ethz.repackaged.xquery.XQException;
+import ch.ethz.repackaged.xquery.XQItemType;
+import ch.ethz.repackaged.xquery.XQResultItem;
public class MXQueryXQItem implements XQResultItem {
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQMetaData.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQMetaData.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQMetaData.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,164 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.util.Set;
-
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQMetaData;
-
-public class MXQueryXQMetaData implements XQMetaData {
-
- MXQueryXQConnection connection;
-
- public MXQueryXQMetaData(MXQueryXQConnection connection) {
- this.connection = connection;
- }
-
- public int getMaxExpressionLength() throws XQException {
- // TODO Auto-generated method stub
- connection.checkNotClosed();
- return 0;
- }
-
- public int getMaxUserNameLength() throws XQException {
- // TODO Auto-generated method stub
- connection.checkNotClosed();
- return 0;
- }
-
- public int getProductMajorVersion() throws XQException {
- connection.checkNotClosed();
- return 1;
- }
-
- public int getProductMinorVersion() throws XQException {
- connection.checkNotClosed();
- return 4;
- }
-
- public String getProductName() throws XQException {
- connection.checkNotClosed();
- return "MXQuery";
- }
-
- public String getProductVersion() throws XQException {
- connection.checkNotClosed();
- return "0.6.0";
- }
-
- public Set getSupportedXQueryEncodings() throws XQException {
- // TODO Auto-generated method stub
- connection.checkNotClosed();
- return null;
- }
-
- public String getUserName() throws XQException {
- // TODO Auto-generated method stub
- connection.checkNotClosed();
- return null;
- }
-
- public int getXQJMajorVersion() throws XQException {
- connection.checkNotClosed();
- return 1;
- }
-
- public int getXQJMinorVersion() throws XQException {
- connection.checkNotClosed();
- return 0;
- }
-
- public String getXQJVersion() throws XQException {
- connection.checkNotClosed();
- return "1.0";
- }
-
- public boolean isFullAxisFeatureSupported() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isModuleFeatureSupported() throws XQException {
- connection.checkNotClosed();
- return true;
- }
-
- public boolean isReadOnly() throws XQException {
- //TODO: Real checking
- connection.checkNotClosed();
- return true;
- }
-
- public boolean isSchemaImportFeatureSupported() throws XQException {
- connection.checkNotClosed();
- return true;
- }
-
- public boolean isSchemaValidationFeatureSupported() throws XQException {
- connection.checkNotClosed();
- return true;
- }
-
- public boolean isSerializationFeatureSupported() throws XQException {
- connection.checkNotClosed();
- return true;
- }
-
- public boolean isStaticTypingExtensionsSupported() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isStaticTypingFeatureSupported() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isTransactionSupported() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isUserDefinedXMLSchemaTypeSupported() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isXQueryEncodingDeclSupported() throws XQException {
- // TODO Auto-generated method stub
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isXQueryEncodingSupported(String encoding)
- throws XQException {
- // TODO Auto-generated method stub
- connection.checkNotClosed();
- return false;
- }
-
- public boolean isXQueryXSupported() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
- public boolean wasCreatedFromJDBCConnection() throws XQException {
- connection.checkNotClosed();
- return false;
- }
-
-}
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQPreparedExpression.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,191 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.util.Vector;
-
-import ch.ethz.mxquery.contextConfig.Context;
-import ch.ethz.mxquery.datamodel.types.TypeInfo;
-import ch.ethz.mxquery.exceptions.MXQueryException;
-import ch.ethz.mxquery.model.VariableHolder;
-import ch.ethz.mxquery.model.XDMIterator;
-import ch.ethz.mxquery.query.PreparedStatement;
-import ch.ethz.mxquery.query.impl.PreparedStatementImpl;
-import ch.ethz.mxquery.util.PlatformDependentUtils;
-import ch.ethz.namespace.QName;
-import ch.ethz.xquery.XQConstants;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQPreparedExpression;
-import ch.ethz.xquery.XQQueryException;
-import ch.ethz.xquery.XQResultSequence;
-import ch.ethz.xquery.XQSequenceType;
-import ch.ethz.xquery.XQStaticContext;
-
-public class MXQueryXQPreparedExpression extends MXQueryXQDynamicContext
- implements XQPreparedExpression {
-
- PreparedStatement exp;
- PreparedStatement pristineCopy;
- //private boolean scrollable;
- private MXQueryXQConnection connection;
- MXQueryXQSequence seq;
-
- protected MXQueryXQPreparedExpression(MXQueryXQConnection connection,
- PreparedStatement expression) throws XQException {
- this.connection = connection;
- this.pristineCopy = expression;
- try {
- exp = pristineCopy.copy();
- } catch (MXQueryException e) {
- throw new XQException("Could not create Expression"+e);
- }
- //this.scrollable = connection.getStaticContext().getScrollability() == XQConstants.SCROLLTYPE_SCROLLABLE;
- }
-
- protected void checkNotClosed() throws XQException {
- if (isClosed()) {
- throw new XQException("Expression has been closed");
- }
- }
-
- public void cancel() throws XQException {
- checkNotClosed();
- }
-
- public void clearWarnings() throws XQException {
- // TODO Auto-generated method stub
-
- }
-
- public void close() throws XQException {
- if(seq != null)
- this.seq.close();
- if (exp!=null)
- try {
- exp.close();
- } catch (MXQueryException e) {
- throw new XQQueryException(e.toString());
- }
- closed = true;
- }
-
- public XQResultSequence executeQuery() throws XQException {
- checkNotClosed();
- try {
- XDMIterator iter = exp.evaluate();
- exp = pristineCopy.copy();
- if(connection.getStaticContext().getScrollability() == XQConstants.SCROLLTYPE_FORWARD_ONLY)
- return new MXQueryXQForwardSequence(iter, connection,this);
- Vector store = new Vector();
- int i = 0;
- MXQueryXQForwardSequence mSeq = new MXQueryXQForwardSequence(iter, connection,this);
- while(mSeq.next()){
- store.add(i++,mSeq.getItem());
- }
- this.seq = new MXQueryXQSequence(store, connection);
- return seq;
- } catch (MXQueryException de) {
- throw new XQQueryException(de.toString(),PlatformDependentUtils.getJavaxQName(de.getErrorCode()));
- }
- }
-
- public QName[] getAllExternalVariables() throws XQException {
- checkNotClosed();
- Vector vec = exp.getExternalVariables();
- QName [] ret = new QName[vec.size()];
- for (int i=0;i<vec.size();i++) {
- ch.ethz.mxquery.datamodel.QName qn = (ch.ethz.mxquery.datamodel.QName)vec.elementAt(i);
- ret[i] = PlatformDependentUtils.getJavaxQName(qn);
- }
- return ret;
- }
-
- public int getQueryTimeout() throws XQException {
- checkNotClosed();
- return 0;
- }
-
- public XQSequenceType getStaticResultType() throws XQException {
- checkNotClosed();
- TypeInfo mxqType = exp.getStaticReturnType();
- return new MXQueryXQType(mxqType);
- }
-
- public XQSequenceType getStaticVariableType(QName name) throws XQException {
- // TODO Auto-generated method stub
- checkNotClosed();
- if(name == null){
- throw new XQException("Variable name cannot be null");
- }
- QName[] allVar = this.getAllExternalVariables();
- //TypeInfo type = new TypeInfo();
- int i=0;
- for(i=0; i < allVar.length; i++){
- if(allVar[i].equals(name)){
- try {
- VariableHolder var;
- if(name.getPrefix().equals(""))
- var = this.getRuntime().getVariable(new ch.ethz.mxquery.datamodel.QName(name.getNamespaceURI(),null, name.getLocalPart()));
- else
- var = this.getRuntime().getVariable(new ch.ethz.mxquery.datamodel.QName(name.getNamespaceURI(), name.getPrefix(), name.getLocalPart()));
- TypeInfo ti = var.getType();
- return new MXQueryXQType(ti);
- } catch (MXQueryException e) {
- throw new XQException(e.toString());
- }
- }
- }
- if(i >= allVar.length)
- throw new XQException("the variable does not exist in the static context of the expression");
- return null;
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public void setQueryTimeout(int seconds) throws XQException {
- if (seconds < 0)
- throw new XQException("Invalid value for Query Timeout");
-
- }
-
-
- //@Override
- protected Context getRuntime() {
- if(exp instanceof PreparedStatementImpl){
- return (Context)((PreparedStatementImpl)this.exp).getContext();
- }
- return null;
- }
-
- public QName[] getAllUnboundExternalVariables() throws XQException {
- checkNotClosed();
- Vector vec = exp.getUnresolvedExternalVariables();
- QName [] ret = new QName[vec.size()];
- for (int i=0;i<vec.size();i++) {
- ch.ethz.mxquery.datamodel.QName qn = (ch.ethz.mxquery.datamodel.QName)vec.elementAt(i);
- ret[i] = PlatformDependentUtils.getJavaxQName(qn);
- }
- return ret;
- }
-
- public XQStaticContext getStaticContext() throws XQException {
- checkNotClosed();
- return new MXQueryXQStaticContext(getRuntime());
- }
-
-}
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQSequence.java
===================================================================
--- trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQSequence.java 2011-05-04 19:41:26 UTC (rev 4310)
+++ trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQSequence.java 2011-05-04 21:48:40 UTC (rev 4311)
@@ -1,385 +0,0 @@
-/* Copyright 2006 - 2009 ETH Zurich
- *
- * 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 ch.ethz.mxquery.xqj;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.net.URI;
-import java.util.Properties;
-import java.util.Vector;
-
-import javax.xml.transform.Result;
-
-import org.w3c.dom.Node;
-import org.xml.sax.ContentHandler;
-
-import ch.ethz.stream.XMLStreamReader;
-import ch.ethz.xquery.XQConnection;
-import ch.ethz.xquery.XQException;
-import ch.ethz.xquery.XQItem;
-import ch.ethz.xquery.XQItemType;
-import ch.ethz.xquery.XQQueryException;
-import ch.ethz.xquery.XQResultSequence;
-
-public class MXQueryXQSequence implements XQResultSequence {
-
- private int position = 0;
- private boolean closed = false;
-
- private MXQueryXQConnection connection;
- private XQItem currentItem;
- private Vector store;
-
- MXQueryXQSequence(Vector s, MXQueryXQConnection conn){
-
- this.store = s;
- this.connection = conn;
- }
-
- public void clearWarnings() {
- // TODO Auto-generated method stub
-
- }
-
- public XQConnection getConnection() throws XQException {
- this.checkNotClosed();
- return connection;
-
- }
-
- public String getAtomicValue() throws XQException {
- return getCurrentXQItem().getAtomicValue();
- }
-
- public boolean getBoolean() throws XQException {
- return getCurrentXQItem().getBoolean();
- }
-
- public byte getByte() throws XQException {
- return getCurrentXQItem().getByte();
- }
-
- public double getDouble() throws XQException {
- return getCurrentXQItem().getDouble();
- }
-
- public float getFloat() throws XQException {
- return getCurrentXQItem().getFloat();
- }
-
- public int getInt() throws XQException {
- return getCurrentXQItem().getInt();
- }
-
- public XQItemType getItemType() throws XQException {
- return getCurrentXQItem().getItemType();
- }
-
- public long getLong() throws XQException {
- return getCurrentXQItem().getLong();
- }
-
- public Node getNode() throws XQException {
- return getCurrentXQItem().getNode();
- }
-
- public URI getNodeUri() throws XQException {
- return getCurrentXQItem().getNodeUri();
- }
-
- public Object getObject() throws XQException {
- return getCurrentXQItem().getObject();
- }
-
- public short getShort() throws XQException {
- return getCurrentXQItem().getShort();
- }
-
- public boolean instanceOf(XQItemType type) throws XQException {
- return getCurrentXQItem().instanceOf(type);
- }
-
- public void writeItem(OutputStream os, Properties props) throws XQException {
- getCurrentXQItem().writeItem(os, props);
-
- }
-
- public void writeItem(Writer ow, Properties props) throws XQException {
- checkNotClosed();
- getCurrentXQItem().writeItem(ow, props);
- }
-
- public void writeItemToSAX(ContentHandler saxHandler) throws XQException {
- getCurrentXQItem().writeItemToSAX(saxHandler);
- }
-
- public boolean absolute(int itempos) throws XQException {
- checkNotClosed();
- if(itempos > 0){
- this.position = itempos;
- } else if (itempos == 0){
- this.position = itempos;
- } else {
- this.position = this.store.size() + itempos + 1;
- }
- if(this.position < 1 || this.position > this.store.size()){
- return false;
- }
- return true;
- }
-
- public void afterLast() throws XQException {
- checkNotClosed();
- position = this.store.size()+1;
- }
-
- public void beforeFirst() throws XQException {
- checkNotClosed();
- this.position = 0;
- }
-
- public void close() throws XQException {
- closed = true;
- for(int i = 0; i < this.store.size(); i++){
- ((MXQueryXQItem)store.get(i)).close();
- }
- this.store.removeAllElements();
- }
-
- public int count() throws XQException {
- checkNotClosed();
- return this.store.size();
- }
-
- public boolean first() throws XQException {
- checkNotClosed();
- if(this.store.size() < 1){
- return false;
- }
- this.position = 1;
- return true;
- }
-
- public XQItem getItem() throws XQException {
- checkNotClosed();
- if(this.position < 1 || this.position > this.store.size()){
- throw new XQException("Error in retrieving item!");
- }
- this.currentItem = (XQItem) this.store.get(position-1);
- return this.currentItem;
- }
-
- public int getPosition() throws XQException {
- checkNotClosed();
- return this.position;
- }
-
- public String getSequenceAsString(Properties props) throws XQException {
- checkNotClosed();
- StringBuffer sb = new StringBuffer();
- if(this.position == 0)
- next();
- sb.append(getCurrentXQItem().getItemAsString(props));
- while (next()) {
- sb.append(" " + getCurrentXQItem().getItemAsString(props));
- }
- return sb.toString();
- }
-
- public boolean isAfterLast() throws XQException {
- checkNotClosed();
- if(this.position == this.store.size()+1){
- return true;
- }
- return false;
- }
-
- public boolean isBeforeFirst() throws XQException {
- checkNotClosed();
- if(this.store.size() == 0){
- return false;
- }
- if(this.position == 0){
- return true;
- }
- return false;
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public boolean isFirst() throws XQException {
- checkNotClosed();
- if(this.position == 1){
- return true;
- }
- return false;
- }
-
- public boolean isLast() throws XQException {
- checkNotClosed();
- if(this.store.size() == 0){
- return false;
- }
- if(this.position == this.store.size()){
- return true;
- }
- return false;
- }
-
- public boolean isOnItem() throws XQException {
- checkNotClosed();
- if(this.position < 1 || this.position > this.store.size()){
- return false;
- }
- return true;
- }
-
- public boolean isScrollable() throws XQException {
- checkNotClosed();
- return true;
- }
-
- public boolean last() throws XQException {
- checkNotClosed();
- if(this.store.size() < 1){
- return false;
- }
- this.position = this.store.size();
- return true;
- }
-
- public boolean next() throws XQException {
- checkNotClosed();
- this.position++;
- if(this.position < 1 || this.position > this.store.size()){
- return false;
- }
- return true;
- }
-
- public boolean previous() throws XQException {
- checkNotClosed();
- if(this.position == -1){
- this.position = this.store.size()+1;
- }
- if(this.position <= 1){
- return false;
- }
- this.position--;
- return true;
- }
-
- public boolean relative(int itempos) throws XQException {
- checkNotClosed();
- this.position = this.position + itempos;
- if(this.position < 1){
- this.position = 0;
- return false;
- }
- if(this.position > this.store.size()){
- this.position = this.store.size() + 1;
- return false;
- }
- //this.position = pos;
- return true;
- }
-
- public void writeSequence(OutputStream os, Properties props)
- throws XQException {
- checkNotClosed();
- boolean hasItem = true;
- if(this.position == 0)
- hasItem = this.next();
- while (hasItem) {
- getCurrentXQItem().writeItem(os, props);
- try {
- os.write(' ');
- } catch (IOException e) {
- throw new XQQueryException("Could not write sequence "+e);
- }
- hasItem = next();
- };
- }
-
- public void writeSequence(Writer ow, Properties props) throws XQException {
- checkNotClosed();
- boolean hasItem = true;
- if(this.position == 0)
- hasItem = this.next();
- while (hasItem){
- getCurrentXQItem().writeItem(ow, props);
- try {
- ow.write(' ');
- } catch (IOException e) {
- throw new XQQueryException("Could not write sequence "+e);
- }
- hasItem = next();
- };
- }
-
- public void writeSequenceToSAX(ContentHandler saxhdlr) throws XQException {
- // TODO Auto-generated method stub
-
- }
-
- private void checkNotClosed() throws XQException {
- if (closed || this.connection.isClosed()) {
- throw new XQException("The XQSequence has been closed");
- }
- }
- private XQItem getCurrentXQItem() throws XQException {
- checkNotClosed();
- if (position == 0) {
- throw new XQException("The XQSequence is positioned before the first item");
- } else if (position < 0) {
- throw new XQException("The XQSequence is positioned after the last item");
- }
- this.currentItem = (XQItem) this.store.get(position-1);
- return this.currentItem;
- }
-
- public XMLStreamReader getSequenceAsStream() throws XQException {
- checkNotClosed();
- position = this.count() + 1;
- return null;
- }
-
- public void writeSequenceToResult(Result result) throws XQException {
- // TODO Auto-generated method stub
-
- }
-
- public XMLStreamReader getItemAsStream() throws XQException {
- checkNotClosed();
- if (isOnItem()) {
- return getCurrentXQItem().getItemAsStream();
- } else
- throw new XQException("The XQSequence is not positioned on an item");
- }
-
- public String getItemAsString(Properties props) throws XQException {
- this.checkNotClosed();
- return getCurrentXQItem().getItemAsString(props);
- }
-
- public void writeItemToResult(Result result) throws XQException {
- getCurrentXQItem().writeItemToResult(result);
- }
-
-}
Deleted: trunk/MXQuery/android/src/ch/ethz/mxquery/xqj/MXQueryXQStaticContext.java
=================================================================...
[truncated message content] |
|
From: <tim...@us...> - 2011-05-04 19:41:33
|
Revision: 4310
http://mxquery.svn.sourceforge.net/mxquery/?rev=4310&view=rev
Author: timchurch
Date: 2011-05-04 19:41:26 +0000 (Wed, 04 May 2011)
Log Message:
-----------
Updated ant build file to create jar file for android
Modified Paths:
--------------
trunk/MXQuery/build.xml
Removed Paths:
-------------
trunk/MXQuery/android/src/ch/ethz/mxquery/android/
Modified: trunk/MXQuery/build.xml
===================================================================
--- trunk/MXQuery/build.xml 2011-05-04 14:46:27 UTC (rev 4309)
+++ trunk/MXQuery/build.xml 2011-05-04 19:41:26 UTC (rev 4310)
@@ -1061,6 +1061,8 @@
<!-- Android Build Target START-->
<property name="android.dir" value="${root.dir}/android"/>
+ <property name="androidtmp.dir" value="${customtmp.dir}"/>
+ <property name="androidsrc.dir" value="${android.dir}/src"/>
<!-- define "if" statement used below -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
@@ -1072,13 +1074,114 @@
<!-- import sdk.dir property if not on Jenkins -->
<property file="${android.dir}/local.properties"/>
- <if>
- <isset property="sdk.dir"/>
- <then>
- <import file="${android.dir}/build-android.xml"/>
- </then>
- </if>
+ <!-- build Android version -->
+ <target name="android-prepare">
+
+ <!-- merge branches -->
+ <echo message="Merging source trees"/>
+ <delete>
+ <fileset dir="${androidtmp.dir}/">
+ <include name="**/*"/>
+ </fileset>
+ </delete>
+ <copy todir="${androidtmp.dir}">
+ <fileset dir="${src.dir}"/>
+ </copy>
+ <copy todir="${androidtmp.dir}" overwrite="yes">
+ <fileset dir="${androidsrc.dir}"/>
+ </copy>
+
+ <!-- remove unsupported classes -->
+ <echo message="Removing unsupported classes"/>
+ <delete dir="${androidtmp.dir}/ch/ethz/mxquery/dmcq/"/>
+ <delete>
+ <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/functions/fn/">
+ <include name="NormalizeUnicode.java"/>
+ </fileset>
+ </delete>
+ <delete>
+ <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/query/webservice/">
+ <include name="MultipleXQueryServer.java"/>
+ <include name="SingleXQueryServer.java"/>
+ <include name="XSPMain.java"/>
+ </fileset>
+ </delete>
+ <delete>
+ <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/util/">
+ <include name="MultipleSchemaExposer.java"/>
+ <include name="PerfTools.java"/>
+ <include name="SingleSchemaExposer.java"/>
+ </fileset>
+ </delete>
+ <delete>
+ <fileset dir="${androidtmp.dir}/ch/ethz/mxquery/xdmio/xmlAdapters/">
+ <include name="NonValidatingStaxAdapter.java"/>
+ <include name="Token2StaxAdapter.java"/>
+ </fileset>
+ </delete>
+ <delete>
+ <fileset dir="${androidtmp.dir}/examples/">
+ <include name="InputOutputExample.java"/>
+ <include name="StreamStatsDemo.java"/>
+ <include name="XQJExample.java"/>
+ </fileset>
+ </delete>
+ </target>
+
+ <!-- Android-relevant libraries -->
+ <path id="android.lib.path">
+ <fileset dir="./lib">
+ <include name="**/*.jar" />
+ </fileset>
+ <fileset dir="${android.dir}/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ </path>
+
+ <target name="compile-android" depends="clean,android-prepare">
+ <depend srcdir="${customtmp.dir}"
+ destdir="${build.dir}"
+ cache="depcache"
+ closure="yes"
+ />
+ <javac source="1.5"
+ srcdir="${customtmp.dir}"
+ destdir="${build.dir}"
+ target="1.5"
+ classpathref="project.class.path"
+ debug="${debug}"
+ optimize="${optimize}"
+ extdirs="">
+ <classpath>
+ <path refid="android.lib.path" />
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="jar-android" depends="compile-android">
+ <echo message="Creating jar archive..."/>
+ <unjar src="${resources.dir}/kxml2-min-2.3.0.jar" dest="${build.dir}"></unjar>
+ <unjar src="${resources.dir}/xmlpull_1_1_3_4c.jar" dest="${build.dir}"></unjar>
+ <unjar src="${resources.dir}/jax-1_1-fr-qname-class.jar" dest="${build.dir}"></unjar>
+ <unjar src="${resources.dir}/xercesImpl.jar" dest="${build.dir}"></unjar>
+ <unjar src="${android.dir}/lib/jsr173_1.0_api-repackaged.jar" dest="${build.dir}"></unjar>
+ <unjar src="${resources.dir}/tagsoup-1.2.jar" dest="${build.dir}"></unjar>
+ <unjar src="${android.dir}/lib/xqjapi-repackaged.jar" dest="${build.dir}"></unjar>
+ <unjar src="${resources.dir}/commons-cli-1.2.jar" dest="${build.dir}"></unjar>
+ <jar jarfile="${dist.dir}/mxquery-android.jar">
+ <fileset dir="${build.dir}" excludes="examples/**/*.*"/>
+ <fileset dir="${src.dir}" includes="ch/**/*.xq"/>
+ <fileset dir="${src.dir}" includes="ch/**/*.xml"/>
+ <fileset dir="${src.dir}" includes="ch/**/*.txt"/>
+ <manifest>
+ <attribute name="Built-By" value="Tim und Max"/>
+ </manifest>
+ </jar>
+ </target>
+
+
+
<!-- Android Build Target END -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tim...@us...> - 2011-05-04 14:46:33
|
Revision: 4309
http://mxquery.svn.sourceforge.net/mxquery/?rev=4309&view=rev
Author: timchurch
Date: 2011-05-04 14:46:27 +0000 (Wed, 04 May 2011)
Log Message:
-----------
Creating separate sub-directory for Android demo application
Added Paths:
-----------
trunk/MXQuery_Android_App/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pm_...@us...> - 2011-05-03 13:24:52
|
Revision: 4308
http://mxquery.svn.sourceforge.net/mxquery/?rev=4308&view=rev
Author: pm_fischer
Date: 2011-05-03 13:24:45 +0000 (Tue, 03 May 2011)
Log Message:
-----------
- only copy anonymous updateable stores. When named, keep a single
instance
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStore.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/testsuite/TestSuiteUpdate.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStore.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStore.java 2011-05-03 09:46:28 UTC (rev 4307)
+++ trunk/MXQuery/src/ch/ethz/mxquery/update/store/llImpl/LLStore.java 2011-05-03 13:24:45 UTC (rev 4308)
@@ -1188,10 +1188,13 @@
}
public Source copySource(Context ctx, Vector nestedPredCtxStack) throws MXQueryException {
- if (uri == null || uri.startsWith("SimpleStore_"))
+ if (uri == null || uri.startsWith("SimpleStore_")) {
uri = "SimpleStore_"
+ Integer.toString(++storeSet.urilessCounter);
return new LLStore(uri, storeSet,initialSource.copy(ctx, null, false, nestedPredCtxStack));
+ } else {
+ return this;
+ }
}
public boolean isModified() {
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/testsuite/TestSuiteUpdate.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/testsuite/TestSuiteUpdate.java 2011-05-03 09:46:28 UTC (rev 4307)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/testsuite/TestSuiteUpdate.java 2011-05-03 13:24:45 UTC (rev 4308)
@@ -637,7 +637,7 @@
}
}
- boolean resetFiles = false;
+ boolean resetFiles = true;
if (resetFiles) {
SVNWCClient svnClient = new SVNWCClient((ISVNAuthenticationManager)null,null);
try {
@@ -701,7 +701,7 @@
}
}
- boolean resetFiles = false;
+ boolean resetFiles = true;
if (resetFiles) {
SVNWCClient svnClient = new SVNWCClient((ISVNAuthenticationManager)null,null);
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|