KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > query > model > HasPartWithMimeType


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.query.model;
17
18 import org.outerj.daisy.query.QueryContext;
19 import org.outerj.daisy.repository.query.QueryException;
20 import org.outerj.daisy.repository.query.EvaluationContext;
21 import org.outerj.daisy.repository.Document;
22 import org.outerj.daisy.repository.Version;
23
24 import java.sql.PreparedStatement JavaDoc;
25 import java.sql.SQLException JavaDoc;
26
27 public class HasPartWithMimeType extends AbstractPredicateExpr {
28     private final String JavaDoc mimeType;
29
30     public HasPartWithMimeType(String JavaDoc mimeType) {
31         this.mimeType = mimeType;
32     }
33
34     public void prepare(QueryContext context) throws QueryException {
35         // no preparation to be done
36
}
37
38     public boolean evaluate(Document document, Version version, EvaluationContext evaluationContext) throws QueryException {
39         return false;
40     }
41
42     public void generateSql(StringBuffer JavaDoc sql, SqlGenerationContext context) throws QueryException {
43         String JavaDoc alias = context.getNewPartsTableAlias();
44
45         sql.append(alias);
46         sql.append('.');
47         sql.append(SqlGenerationContext.PartsTable.MIMETYPE);
48         sql.append(" LIKE ?");
49     }
50
51     public int bindSql(PreparedStatement JavaDoc stmt, int bindPos, EvaluationContext evaluationContext) throws SQLException JavaDoc {
52         stmt.setString(bindPos, mimeType);
53         bindPos++;
54         return bindPos;
55     }
56
57     public AclConditionViolation isAclAllowed() {
58         return new AclConditionViolation("HasPartWithMimeType is not allowed in ACL conditions");
59     }
60
61     public Tristate appliesTo(Document document) {
62         throw new IllegalStateException JavaDoc();
63     }
64 }
65
Popular Tags