KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > query > rdb > lib > BasicRdbStringQueryLeaf


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2004 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre
22  */

23
24 package org.objectweb.medor.query.rdb.lib;
25
26 import java.util.ArrayList JavaDoc;
27
28 import org.objectweb.jorm.type.api.PType;
29 import org.objectweb.medor.api.MedorException;
30 import org.objectweb.medor.api.QueryLeafException;
31 import org.objectweb.medor.datasource.api.DataStore;
32 import org.objectweb.medor.expression.api.Expression;
33 import org.objectweb.medor.expression.api.ParameterOperand;
34 import org.objectweb.medor.query.api.FilteredQueryTree;
35 import org.objectweb.medor.query.rdb.api.RdbField;
36 import org.objectweb.medor.query.rdb.api.RdbStringQueryLeaf;
37
38 /**
39  *
40  * This class represents a QueryLeaf that maps onto a relational database store.
41  */

42 public class BasicRdbStringQueryLeaf extends BasicRdbQueryLeaf
43     implements RdbStringQueryLeaf, FilteredQueryTree {
44
45     protected Expression sqlFilter;
46     
47     public BasicRdbStringQueryLeaf() {
48     }
49
50     /**
51      * Constructs a BasicRdbStringQueryLeaf from an SQL string.
52      */

53     public BasicRdbStringQueryLeaf(DataStore ds,
54                                    String JavaDoc query,
55                                    String JavaDoc nodeName) {
56         super(nodeName, ds, query);
57     }
58
59     public RdbField addRdbField(String JavaDoc name, PType type, String JavaDoc colName) {
60         RdbField f = new BasicRdbField(name, type, colName, this);
61         name2field.put(f.getName(), f);
62         fields.add(f);
63         return f;
64     }
65
66     public String JavaDoc getSqlRequest(ParameterOperand[] pos,
67             boolean rangeStartAt,
68             boolean rangeSize) {
69         return query;
70     }
71
72     public String JavaDoc getSqlRequest(ParameterOperand[] pos,
73                                 ArrayList JavaDoc al,
74                                 boolean rangeStartAt,
75                                 boolean rangeSize) throws MedorException {
76         if (al == null) {
77             return getSqlRequest(pos, rangeStartAt, rangeSize);
78         } else {
79             throw new MedorException("Request with selectList not supported");
80         }
81     }
82
83     public String JavaDoc getSelectList(String JavaDoc selectList,
84                                 ArrayList JavaDoc selectFields,
85                                 boolean qualified) throws MedorException {
86         throw new QueryLeafException("Unsupported method getSelectList for BasicRdbStringQueryLeaf");
87     }
88
89     public Expression getQueryFilter() {
90         return sqlFilter;
91     }
92
93     public void setQueryFilter(Expression exp) {
94         this.sqlFilter = exp;
95     }
96 }
97
Popular Tags