|
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] |