From: Wolfgang M. M. <wol...@us...> - 2004-09-12 09:26:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21081/src/org/exist/xquery/functions/util Modified Files: CatchFunction.java DocumentId.java EvalFunction.java LogFunction.java BuiltinFunctions.java ExclusiveLockFunction.java CollectionName.java DescribeFunction.java DocumentName.java SharedLockFunction.java MD5.java Added Files: UtilModule.java Removed Files: ModuleImpl.java Log Message: * Added support for XQuery pragmas to set serialization and watchdog settings. * org.exist.storage.serializers.Serializer now passes all output to an instance of the Receiver interface instead of a SAX ContentHandler. Receiver resembles SAX, but has methods that are closer to eXist's internal storage. For example, it directly accepts a QName in startElement to avoid unnecessary string allocations. * Fixed various performance leaks in cross-document joins. Index: ExclusiveLockFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/ExclusiveLockFunction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExclusiveLockFunction.java 2 Jun 2004 11:33:30 -0000 1.1 --- ExclusiveLockFunction.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 34,38 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("exclusive-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Puts an exclusive lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + --- 34,38 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("exclusive-lock", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Puts an exclusive lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + Index: DocumentName.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DocumentName.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DocumentName.java 8 Jun 2004 08:16:12 -0000 1.3 --- DocumentName.java 12 Sep 2004 09:25:16 -0000 1.4 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-name", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the name of the document to which the passed node belongs.", new SequenceType[] { --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-name", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns the name of the document to which the passed node belongs.", new SequenceType[] { *************** *** 63,67 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.doc.getFileName()); } return Sequence.EMPTY_SEQUENCE; --- 63,67 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.getDocument().getFileName()); } return Sequence.EMPTY_SEQUENCE; --- ModuleImpl.java DELETED --- Index: BuiltinFunctions.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/BuiltinFunctions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BuiltinFunctions.java 28 May 2004 10:54:21 -0000 1.2 --- BuiltinFunctions.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 49,53 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("builtin-functions", UTIL_FUNCTION_NS, "util"), "Returns a sequence containing the QNames of all built-in functions " + "currently known to the system.", --- 49,53 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("builtin-functions", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns a sequence containing the QNames of all built-in functions " + "currently known to the system.", --- NEW FILE: UtilModule.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-03 Wolfgang M. Meier * wol...@ex... * http://exist.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: UtilModule.java,v 1.1 2004/09/12 09:25:16 wolfgang_m Exp $ */ package org.exist.xquery.functions.util; import org.exist.xquery.AbstractInternalModule; import org.exist.xquery.FunctionDef; /** * @author Wolfgang Meier (wol...@ex...) */ public class UtilModule extends AbstractInternalModule { public final static String NAMESPACE_URI = "http://exist-db.org/xquery/util"; public final static String PREFIX = "util"; public final static FunctionDef[] functions = { new FunctionDef(BuiltinFunctions.signature, BuiltinFunctions.class), new FunctionDef(DescribeFunction.signature, DescribeFunction.class), new FunctionDef(EvalFunction.signature, EvalFunction.class), new FunctionDef(MD5.signature, MD5.class), new FunctionDef(DocumentName.signature, DocumentName.class), new FunctionDef(DocumentId.signature, DocumentId.class), new FunctionDef(CollectionName.signature, CollectionName.class), new FunctionDef(LogFunction.signature, LogFunction.class), new FunctionDef(CatchFunction.signature, CatchFunction.class), new FunctionDef(ExclusiveLockFunction.signature, ExclusiveLockFunction.class), new FunctionDef(SharedLockFunction.signature, SharedLockFunction.class) }; public UtilModule() { super(functions); } /* (non-Javadoc) * @see org.exist.xquery.Module#getNamespaceURI() */ public String getNamespaceURI() { return NAMESPACE_URI; } /* (non-Javadoc) * @see org.exist.xquery.Module#getDefaultPrefix() */ public String getDefaultPrefix() { return PREFIX; } } Index: DescribeFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DescribeFunction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DescribeFunction.java 4 Aug 2004 19:00:08 -0000 1.4 --- DescribeFunction.java 12 Sep 2004 09:25:16 -0000 1.5 *************** *** 48,52 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("describe-function", UTIL_FUNCTION_NS, "util"), "Describes a built-in function. Returns an element describing the " + "function signature.", --- 48,52 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("describe-function", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Describes a built-in function. Returns an element describing the " + "function signature.", Index: EvalFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/EvalFunction.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EvalFunction.java 28 Aug 2004 16:20:23 -0000 1.7 --- EvalFunction.java 12 Sep 2004 09:25:16 -0000 1.8 *************** *** 59,63 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("eval", UTIL_FUNCTION_NS, "util"), "Dynamically evaluates its string argument as an XPath/XQuery expression. " + "The argument expression will inherit the current execution context, i.e. all " + --- 59,63 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("eval", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Dynamically evaluates its string argument as an XPath/XQuery expression. " + "The argument expression will inherit the current execution context, i.e. all " + *************** *** 88,92 **** throws XPathException { // get the query expression ! String expr = getArgument(0).eval(contextSequence, contextItem).getStringValue(); if ("".equals(expr.trim())) return new EmptySequence(); --- 88,92 ---- throws XPathException { // get the query expression ! String expr = StringValue.expand(getArgument(0).eval(contextSequence, contextItem).getStringValue()); if ("".equals(expr.trim())) return new EmptySequence(); *************** *** 100,104 **** } LOG.debug("eval: " + expr); ! XQueryLexer lexer = new XQueryLexer(new StringReader(expr)); XQueryParser parser = new XQueryParser(lexer); // shares the context of the outer expression --- 100,104 ---- } LOG.debug("eval: " + expr); ! XQueryLexer lexer = new XQueryLexer(context, new StringReader(expr)); XQueryParser parser = new XQueryParser(lexer); // shares the context of the outer expression Index: CollectionName.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/CollectionName.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollectionName.java 16 Feb 2004 15:59:37 -0000 1.2 --- CollectionName.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("collection-name", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the name of the collection to which the passed node belongs.", new SequenceType[] { --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("collection-name", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns the name of the collection to which the passed node belongs.", new SequenceType[] { *************** *** 63,67 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.doc.getCollection().getName()); } return Sequence.EMPTY_SEQUENCE; --- 63,67 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! return new StringValue(proxy.getDocument().getCollection().getName()); } return Sequence.EMPTY_SEQUENCE; Index: CatchFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/CatchFunction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CatchFunction.java 17 May 2004 11:28:47 -0000 1.2 --- CatchFunction.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("catch", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "This function corresponds to a try-catch statement in Java. The code block " + "in $b will be put inside a try-catch statement. If an exception is thrown while executing " + --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("catch", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "This function corresponds to a try-catch statement in Java. The code block " + "in $b will be put inside a try-catch statement. If an exception is thrown while executing " + *************** *** 86,92 **** if(exClass.getName().equals(e.getClass().getName()) || exClass.isInstance(e)) { LOG.debug("Calling exception handler to process " + e.getClass().getName()); ! ModuleImpl myModule = ! (ModuleImpl) context.getModule(ModuleImpl.NAMESPACE_URI); ! QName exQname = new QName("exception", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX); myModule.declareVariable(exQname, new StringValue(e.getClass().getName())); return getArgument(2).eval(contextSequence, contextItem); --- 86,92 ---- if(exClass.getName().equals(e.getClass().getName()) || exClass.isInstance(e)) { LOG.debug("Calling exception handler to process " + e.getClass().getName()); ! UtilModule myModule = ! (UtilModule) context.getModule(UtilModule.NAMESPACE_URI); ! QName exQname = new QName("exception", UtilModule.NAMESPACE_URI, UtilModule.PREFIX); myModule.declareVariable(exQname, new StringValue(e.getClass().getName())); return getArgument(2).eval(contextSequence, contextItem); Index: DocumentId.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DocumentId.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DocumentId.java 17 Feb 2004 15:04:58 -0000 1.1 --- DocumentId.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 31,35 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-id", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Returns the internal id of the document to which the passed node belongs.", new SequenceType[] { --- 31,35 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("document-id", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Returns the internal id of the document to which the passed node belongs.", new SequenceType[] { *************** *** 50,55 **** if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! String path = proxy.doc.getFileName(); ! return new IntegerValue(proxy.doc.getDocId(), Type.INT); } return Sequence.EMPTY_SEQUENCE; --- 50,55 ---- if(node.getImplementationType() == NodeValue.PERSISTENT_NODE) { NodeProxy proxy = (NodeProxy)node; ! String path = proxy.getDocument().getFileName(); ! return new IntegerValue(proxy.getDocument().getDocId(), Type.INT); } return Sequence.EMPTY_SEQUENCE; Index: SharedLockFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/SharedLockFunction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SharedLockFunction.java 2 Jun 2004 11:33:30 -0000 1.1 --- SharedLockFunction.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 35,39 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("shared-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Puts a shared lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + --- 35,39 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("shared-lock", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Puts a shared lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + Index: LogFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/LogFunction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LogFunction.java 18 Feb 2004 11:14:34 -0000 1.1 --- LogFunction.java 12 Sep 2004 09:25:16 -0000 1.2 *************** *** 42,46 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("log", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Logs the message specified in $b to the current logger. $a indicates " + "the log priority, e.g. 'debug' or 'warn'.", --- 42,46 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("log", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Logs the message specified in $b to the current logger. $a indicates " + "the log priority, e.g. 'debug' or 'warn'.", Index: MD5.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/MD5.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MD5.java 28 May 2004 10:54:21 -0000 1.2 --- MD5.java 12 Sep 2004 09:25:16 -0000 1.3 *************** *** 44,48 **** public final static FunctionSignature signature = new FunctionSignature( ! new QName("md5", UTIL_FUNCTION_NS, "util"), "Generates an MD5 key from a string.", new SequenceType[] { --- 44,48 ---- public final static FunctionSignature signature = new FunctionSignature( ! new QName("md5", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), "Generates an MD5 key from a string.", new SequenceType[] { |