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 package org.apache.chemistry.opencmis.client.api; 20 21 import java.net.URI; 22 import java.net.URL; 23 import java.util.Calendar; 24 import java.util.Date; 25 26 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition; 27 28 /** 29 * Query Statement. 30 * 31 * <p> 32 * Example: <blockquote> 33 * 34 * <pre> 35 * Calendar cal = ... 36 * Folder folder = ... 37 * 38 * QueryStatement qs = session.createQueryStatement("SELECT ?, ? FROM ? WHERE ? > TIMESTAMP ? AND IN_FOLDER(?) OR ? IN (?)"); 39 * 40 * qs.setProperty(1, "cmis:document", "cmis:name"); 41 * qs.setProperty(2, "cmis:document", "cmis:objectId"); 42 * qs.setType(3, "cmis:document"); 43 * 44 * qs.setProperty(4, "cmis:document", "cmis:creationDate"); 45 * qs.setDateTime(5, cal); 46 * 47 * qs.setId(6, folder); 48 * 49 * qs.setProperty(7, "cmis:document", "cmis:createdBy"); 50 * qs.setString(8, "bob", "tom", "lisa"); 51 * 52 * String statement = qs.toQueryString(); 53 * </pre> 54 * 55 * </blockquote> 56 * </p> 57 */ 58 public interface QueryStatement extends Cloneable { 59 60 /** 61 * Sets the designated parameter to the query name of the given type id. 62 */ 63 void setType(int parameterIndex, String typeId); 64 65 /** 66 * Sets the designated parameter to the query name of the given type. 67 */ 68 void setType(int parameterIndex, ObjectType type); 69 70 /** 71 * Sets the designated parameter to the query name of the given property. 72 */ 73 void setProperty(int parameterIndex, String typeId, String propertyId); 74 75 /** 76 * Sets the designated parameter to the query name of the given property. 77 */ 78 void setProperty(int parameterIndex, PropertyDefinition<?> propertyDefinition); 79 80 /** 81 * Sets the designated parameter to the given number. 82 */ 83 void setNumber(int parameterIndex, Number... num); 84 85 /** 86 * Sets the designated parameter to the given string. 87 */ 88 void setString(int parameterIndex, String... str); 89 90 /** 91 * Sets the designated parameter to the given string. It does not escape 92 * backslashes ('\') in front of "%' and '_'. 93 */ 94 void setStringLike(int parameterIndex, String str); 95 96 /** 97 * Sets the designated parameter to the given object id. 98 */ 99 void setId(int parameterIndex, ObjectId... id); 100 101 /** 102 * Sets the designated parameter to the given URI. 103 */ 104 void setUri(int parameterIndex, URI... uri); 105 106 /** 107 * Sets the designated parameter to the given URL. 108 */ 109 void setUrl(int parameterIndex, URL... url); 110 111 /** 112 * Sets the designated parameter to the given boolean. 113 */ 114 void setBoolean(int parameterIndex, boolean... bool); 115 116 /** 117 * Sets the designated parameter to the given timestamp. 118 */ 119 void setDateTime(int parameterIndex, Calendar... cal); 120 121 /** 122 * Sets the designated parameter to the given timestamp. 123 */ 124 void setDateTime(int parameterIndex, Date... date); 125 126 /** 127 * Sets the designated parameter to the given timestamp. 128 */ 129 void setDateTime(int parameterIndex, long... ms); 130 131 /** 132 * Returns the query statement. 133 */ 134 String toQueryString(); 135 136 /** 137 * Executes the query. 138 * 139 * @see Session#query(String, boolean) 140 */ 141 ItemIterable<QueryResult> query(boolean searchAllVersions); 142 143 /** 144 * Executes the query. 145 * 146 * @see Session#query(String, boolean, OperationContext) 147 */ 148 ItemIterable<QueryResult> query(boolean searchAllVersions, OperationContext context); 149 }