|
From: <pm_...@us...> - 2011-05-14 13:30:06
|
Revision: 4338
http://mxquery.svn.sourceforge.net/mxquery/?rev=4338&view=rev
Author: pm_fischer
Date: 2011-05-14 13:29:59 +0000 (Sat, 14 May 2011)
Log Message:
-----------
do not use complete subtype substitution in native function calls,
extend with Integer and byte types
Modified Paths:
--------------
trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-13 21:42:26 UTC (rev 4337)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/NativeFuncCall.java 2011-05-14 13:29:59 UTC (rev 4338)
@@ -29,7 +29,6 @@
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.EmptySequenceIterator;
import ch.ethz.mxquery.model.Iterator;
@@ -77,12 +76,21 @@
// 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());
+ int type = tok.getEventType();//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.INTEGER:
+ case Type.INT:
+ invocationParams[i] = new Integer((int)tok.getLong());
+ invocationParamsTypes[i] = Integer.TYPE;
+ break;
+ case Type.BYTE:
+ invocationParams[i] = new Byte((byte)tok.getLong());
+ invocationParamsTypes[i] = Byte.TYPE;
+ break;
case Type.STRING:
case Type.ANY_URI:
invocationParams[i] = new String(tok.getText());
Modified: trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java
===================================================================
--- trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java 2011-05-13 21:42:26 UTC (rev 4337)
+++ trunk/MXQuery_Testing/src/ch/ethz/mxquery/test/JavaImportTests.java 2011-05-14 13:29:59 UTC (rev 4338)
@@ -46,5 +46,17 @@
assertEquals("false", resultBuffer.toString().trim() );
};
+ public void test_int_arg() throws Exception{
+ String query = "declare namespace jint ='java:java.lang.Integer'; jint:bitCount(42)";
+ doQuery(prepareQuery(query, false,false, false, false, false));
+ System.out.println(resultBuffer.toString());
+ assertEquals("3", resultBuffer.toString().trim() );
+ };
+ public void test_byte_arg() throws Exception{
+ String query = "declare namespace jint ='java:java.lang.Byte'; jint:toString(xs:byte(42))";
+ doQuery(prepareQuery(query, false,false, false, false, false));
+ System.out.println(resultBuffer.toString());
+ assertEquals("42", resultBuffer.toString().trim() );
+ };
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|