Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 61264 invoked from network); 4 Jul 2007 14:07:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jul 2007 14:07:25 -0000 Received: (qmail 5679 invoked by uid 500); 4 Jul 2007 14:07:28 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 5653 invoked by uid 500); 4 Jul 2007 14:07:27 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 5644 invoked by uid 99); 4 Jul 2007 14:07:27 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jul 2007 07:07:27 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jul 2007 07:07:24 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id F0E281A981A; Wed, 4 Jul 2007 07:07:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r553213 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java Date: Wed, 04 Jul 2007 14:07:03 -0000 To: commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070704140703.F0E281A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mreutegg Date: Wed Jul 4 07:07:02 2007 New Revision: 553213 URL: http://svn.apache.org/viewvc?view=rev&rev=553213 Log: JCR-981: XPath relative path support missing for "is null" and "is not null" Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java?view=diff&rev=553213&r1=553212&r2=553213 ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java Wed Jul 4 07:07:02 2007 @@ -38,6 +38,7 @@ import org.apache.jackrabbit.name.QName; import org.apache.jackrabbit.name.NameFormat; import org.apache.jackrabbit.name.Path; +import org.apache.jackrabbit.name.MalformedPathException; import org.apache.jackrabbit.util.ISO8601; import org.apache.jackrabbit.util.ISO9075; import org.apache.commons.collections.map.ReferenceMap; @@ -235,6 +236,11 @@ private final List exceptions = new ArrayList(); /** + * Temporary relative path + */ + private Path.PathBuilder tmpRelPath; + + /** * Creates a new XPathQueryBuilder instance. * * @param statement the XPath statement. @@ -361,6 +367,7 @@ RelationQueryNode isNull = new RelationQueryNode(queryNode, RelationQueryNode.OPERATION_NULL); + applyRelativePath(isNull); node.childrenAccept(this, isNull); NotQueryNode notNode = (NotQueryNode) queryNode; NAryQueryNode parent = (NAryQueryNode) notNode.getParent(); @@ -368,9 +375,10 @@ parent.addOperand(isNull); } else { // not null expression - RelationQueryNode notNull - = new RelationQueryNode(queryNode, + RelationQueryNode notNull = + new RelationQueryNode(queryNode, RelationQueryNode.OPERATION_NOT_NULL); + applyRelativePath(notNull); node.childrenAccept(this, notNull); ((NAryQueryNode) queryNode).addOperand(notNull); } @@ -380,6 +388,15 @@ } else if (queryNode.getType() == QueryNode.TYPE_TEXTSEARCH || queryNode.getType() == QueryNode.TYPE_RELATION) { node.childrenAccept(this, queryNode); + } else { + // step within a predicate + RelationQueryNode tmp = new RelationQueryNode( + null, RelationQueryNode.OPERATION_NOT_NULL); + node.childrenAccept(this, tmp); + if (tmpRelPath == null) { + tmpRelPath = new Path.PathBuilder(); + } + tmpRelPath.addLast(tmp.getRelativePath().getNameElement()); } } break; @@ -508,6 +525,26 @@ } //----------------------< internal >---------------------------------------- + + /** + * Applies {@link #tmpRelPath} to node and reset the path to + * null. + * + * @param node a relation query node. + */ + private void applyRelativePath(RelationQueryNode node) { + if (tmpRelPath != null) { + try { + Path relPath = tmpRelPath.getPath(); + for (int i = 0; i < relPath.getLength(); i++) { + node.addPathElement(relPath.getElement(i)); + } + } catch (MalformedPathException e) { + // should never happen + } + tmpRelPath = null; + } + } /** * Creates a LocationStepQueryNode at the current position