1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 package org.apache.chemistry.opencmis.jcr.query; 21 22 /** 23 * This result type of {@link EvaluatorXPath} provides means for partially evaluating 24 * the underlying query's condition. This allows to determine whether there is a semantically 25 * equivalent translation from the CMIS query's where clause to an XPath condition. 26 * <br/> 27 * Specifically <code>EvaluatorXPath</code> only supports a single folder predicate. That 28 * is the original CMIS query must not contain more than one IN_TREE or IN_FOLDER 29 * predicate respectively. Furthermore that single folder predicate must be affirmative. 30 * A literal <code>p</code> in a boolean expression <code>X</code> is affirmative if there 31 * exists a boolean expression <code>Y</code> such that <code>p ∧ Y = X</code>. 32 * <em>Note</em>: a single folder predicate is affirmative if any only if 33 * {@link #eval(Boolean) <code>eval(false)</code>} return <code>false</code>. 34 * <br/> 35 * Only if both conditions hold will the XPath translation provided the {@link #xPath()} 36 * method be valid. 37 */ 38 public interface XPathBuilder { 39 40 /** 41 * Translation of the underlying CMIS query's where clause to a XPath condition. 42 * The string is only valid if there is no more than one folder predicate and 43 * the folder predicate is in affirmative position. 44 */ 45 String xPath(); 46 47 /** 48 * Evaluate the query condition for a given valuation of the folder predicate terms. 49 * 50 * @param folderPredicateValuation valuation for the folder predicate terms. Use <code>null</code> 51 * for none. 52 * @return result of the partial evaluation. <code>null</code> means that the value of the 53 * query condition is not determined the value passed for <code>folderPredicateValuation</code>. 54 */ 55 Boolean eval(Boolean folderPredicateValuation); 56 57 /** 58 * The folder predicates contained in this query's condition. 59 */ 60 Iterable<XPathBuilder> folderPredicates(); 61 }