KickJava   Java API By Example, From Geeks To Geeks.

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


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

6
7 package com.hp.hpl.jena.db.impl;
8
9 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     
51     public void bindToCol ( int tblAlias, char colId ) {
52         if ( isBoundToCol )
53             throw new JenaException("Variable bound twice to column");
54         isBoundToCol = true;
55         alias = tblAlias;
56         column = colId;
57         return;
58     }
59     
60     public boolean isBoundToCol() { return isBoundToCol; }
61     public boolean isArgVar() { return isArgVar; }
62 }
63
64 /*
65     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
66     All rights reserved.
67
68     Redistribution and use in source and binary forms, with or without
69     modification, are permitted provided that the following conditions
70     are met:
71
72     1. Redistributions of source code must retain the above copyright
73        notice, this list of conditions and the following disclaimer.
74
75     2. Redistributions in binary form must reproduce the above copyright
76        notice, this list of conditions and the following disclaimer in the
77        documentation and/or other materials provided with the distribution.
78
79     3. The name of the author may not be used to endorse or promote products
80        derived from this software without specific prior written permission.
81
82     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
83     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
84     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
85     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
86     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
87     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
88     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
89     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
91     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92 */

93
Popular Tags