KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > db > impl > DBQuery


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: DBQuery.java,v 1.8 2005/02/21 12:02:50 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.db.impl;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.List JavaDoc;
11
12 /**
13     @author hedgehog
14 */

15
16 public class DBQuery
17     {
18     int argCnt; // number of arguments to query
19
String JavaDoc argType; // list of argument types
20
List JavaDoc argIndex; // index of argument in input
21
int varCnt; // number of variables in query
22
int aliasCnt; // number of tables aliases (scans) in from clause
23
String JavaDoc stmt; // query string
24
VarDesc[] vars; // list of VarIndex, variables referenced in this query
25
int[] resList; // indexes of result columns in mapping
26
int graphId; // id of graph to query
27
String JavaDoc table; // name of table to query
28
IPSet pset; // pset to be queried
29
IRDBDriver driver; // driver for store
30
boolean qryOnlyStmt; // if true, ignore reified statements
31
boolean qryOnlyReif; // if true, ignore asserted statements
32
boolean qryFullReif; // if true, ignore partially reified statements
33
DriverRDB.GenSQLAnd sqlAnd;
34
35     boolean isMultiModel; // true if graph is multi-model
36
boolean isSingleValued; // true if property table is single-valued
37
boolean isCacheable; // true if it is safe to cache compiled query
38
boolean isReifier; // true if query is over a reifier specialized graph
39
boolean isEmpty; // true if compiler determines query has no results
40

41     
42     public DBQuery ( SpecializedGraph sg, List JavaDoc varList,
43         boolean queryOnlyStmt, boolean queryOnlyReif, boolean queryFullReif ) {
44
45         argCnt = 0;
46         argType = "";
47         argIndex = new ArrayList JavaDoc();
48         aliasCnt = 0;
49         stmt = "";
50         isMultiModel = true; // for now
51
isSingleValued = false; // for now
52
isCacheable = true;
53         if ( sg != null ) {
54             pset = sg.getPSet();
55             isReifier = sg instanceof SpecializedGraphReifier;
56             isEmpty = false;
57             graphId = sg.getGraphId();
58             table = pset.getTblName();
59             driver = pset.driver();
60         } else {
61             pset = null;
62             isReifier = false;
63             isEmpty = true;
64             driver = null;
65         }
66         sqlAnd = new IRDBDriver.GenSQLAnd();
67         qryOnlyStmt = queryOnlyStmt;
68         qryOnlyReif = queryOnlyReif;
69         qryFullReif = queryFullReif;
70         // array of variable bound by query
71
vars = new VarDesc[varList.size()];
72         for ( varCnt=0; varCnt<varList.size(); varCnt++ ) {
73             vars[varCnt] = (VarDesc) varList.get(varCnt);
74         }
75
76     }
77     
78     public VarDesc getBinding ( int i ) {
79         return vars[i];
80     }
81
82     public VarDesc findBinding ( String JavaDoc v ) {
83         int i;
84         for ( i=0; i<vars.length; i++ ) {
85             if ( vars[i].var.getName().equals(v) )
86                 return vars[i];
87         }
88         return null;
89     }
90         
91     public void newAlias() {
92         aliasCnt++;
93     }
94     
95 }
96
97 /*
98     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
99     All rights reserved.
100
101     Redistribution and use in source and binary forms, with or without
102     modification, are permitted provided that the following conditions
103     are met:
104
105     1. Redistributions of source code must retain the above copyright
106        notice, this list of conditions and the following disclaimer.
107
108     2. Redistributions in binary form must reproduce the above copyright
109        notice, this list of conditions and the following disclaimer in the
110        documentation and/or other materials provided with the distribution.
111
112     3. The name of the author may not be used to endorse or promote products
113        derived from this software without specific prior written permission.
114
115     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
116     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
117     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
118     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
119     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
120     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
121     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
122     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
124     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
125 */

126
Popular Tags