01: /*
02: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: [See end of file]
04: $Id: VarDesc.java,v 1.5 2008/01/02 12:08:24 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.db.impl;
08:
09: import com.hp.hpl.jena.graph.*;
10: import com.hp.hpl.jena.graph.query.Mapping;
11: import com.hp.hpl.jena.shared.JenaException;
12:
13: /**
14: @author hedgehog
15: */
16:
17: public class VarDesc {
18:
19: Node_Variable var; // variable
20: boolean isArgVar; // true if variable is bound to an argument
21: boolean isBoundToCol; // true once variable is bound to a column
22: int resIx; // index of var in result list (isArgVar==false)
23: int mapIx; // index into arg mapping (isArgVar==true)
24: int alias; // alias of table that binds var
25: char column; // column id of table that bind var
26:
27: public VarDesc(Node v, int mapix, int resix) {
28: var = (Node_Variable) v;
29: isArgVar = true;
30: mapIx = mapix;
31: resIx = resix;
32: isBoundToCol = false;
33: }
34:
35: public VarDesc(Node v, int resix) {
36: var = (Node_Variable) v;
37: isArgVar = false;
38: mapIx = -1;
39: resIx = resix;
40: isBoundToCol = false;
41: }
42:
43: public void bindToVarMap(Mapping varMap) {
44: if (isArgVar)
45: throw new JenaException("Variable bound twice to argument");
46: mapIx = varMap.newIndex(var);
47: return;
48: }
49:
50: public void bindToCol(int tblAlias, char colId) {
51: if (isBoundToCol)
52: throw new JenaException("Variable bound twice to column");
53: isBoundToCol = true;
54: alias = tblAlias;
55: column = colId;
56: return;
57: }
58:
59: public boolean isBoundToCol() {
60: return isBoundToCol;
61: }
62:
63: public boolean isArgVar() {
64: return isArgVar;
65: }
66: }
67:
68: /*
69: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
70: All rights reserved.
71:
72: Redistribution and use in source and binary forms, with or without
73: modification, are permitted provided that the following conditions
74: are met:
75:
76: 1. Redistributions of source code must retain the above copyright
77: notice, this list of conditions and the following disclaimer.
78:
79: 2. Redistributions in binary form must reproduce the above copyright
80: notice, this list of conditions and the following disclaimer in the
81: documentation and/or other materials provided with the distribution.
82:
83: 3. The name of the author may not be used to endorse or promote products
84: derived from this software without specific prior written permission.
85:
86: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
87: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
88: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
89: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
90: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
91: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
92: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
93: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
94: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
95: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96: */
|