From 2ff11e6114d3f2bf98af997272f46fab5b2caa31 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Thu, 26 Jan 2006 01:39:38 +0000 Subject: [PATCH] XPath function usage exceptions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2211 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/search/NodeServiceXPath.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source/java/org/alfresco/repo/search/NodeServiceXPath.java b/source/java/org/alfresco/repo/search/NodeServiceXPath.java index b78a65fd82..8479cc53fe 100644 --- a/source/java/org/alfresco/repo/search/NodeServiceXPath.java +++ b/source/java/org/alfresco/repo/search/NodeServiceXPath.java @@ -380,12 +380,11 @@ public class NodeServiceXPath extends BaseXPath public Object call(Context context, List args) throws FunctionCallException { - if (args.size() == 1) + if (args.size() != 1) { - return evaluate(context.getNodeSet(), args.get(0), context.getNavigator()); + throw new FunctionCallException("contains() usage: contains('pattern')"); } - - throw new FunctionCallException("contains() requires one argument."); + return evaluate(context.getNodeSet(), args.get(0), context.getNavigator()); } public Object evaluate(List nodes, Object pattern, Navigator nav) @@ -403,8 +402,9 @@ public class NodeServiceXPath extends BaseXPath } else if (nav.isAttribute(nodes.get(0))) { - qname = QName.createQName(nav.getAttributeNamespaceUri(nodes.get(0)), ISO9075.decode(nav - .getAttributeName(nodes.get(0)))); + qname = QName.createQName( + nav.getAttributeNamespaceUri(nodes.get(0)), + ISO9075.decode(nav.getAttributeName(nodes.get(0)))); nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent; } @@ -463,7 +463,9 @@ public class NodeServiceXPath extends BaseXPath } else if (nav.isAttribute(target)) { - qname = QName.createQName(nav.getAttributeNamespaceUri(target), ISO9075.decode(nav.getAttributeName(target))); + qname = QName.createQName( + nav.getAttributeNamespaceUri(target), + ISO9075.decode(nav.getAttributeName(target))); nodeRef = ((DocumentNavigator.Property) target).parent; }