KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: Free.java,v 1.5 2005/02/21 12:02:53 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.Domain;
11 import com.hp.hpl.jena.graph.query.Element;
12 import com.hp.hpl.jena.shared.JenaException;
13
14 /**
15     A binding instance of a variable. It accepts any node and records it in the supplied
16     Domain at the index allocated to it when it is created.
17     
18     @author hedgehog
19 */

20 public class Free extends Element
21     {
22         
23     /**
24         Track a (free) variable element: it will later be bound during compilation.
25     */

26     
27     private Node_Variable var;
28     private int listIx; // index of variable in varList.
29
private int mapIx; // index of (arg) variable in Mapping
30
private boolean isListed; // true when variable is in varList
31
private boolean isArgument; // true when variable can be bound by an argument
32

33     public Free( Node n ) {
34         super( );
35         var = (Node_Variable) n;
36         isArgument = false;
37         isListed = false;
38     }
39     
40     public int getListing()
41     {
42         if ( isListed ) return listIx;
43         else throw new JenaException("UnListed variable");
44     }
45
46     public void setListing ( int ix )
47         {
48         if ( isListed )
49             throw new JenaException("Relisting of variable");
50         isListed = true;
51         listIx = ix;
52         }
53         
54     public void setIsArg ( int ix ) { isArgument = true; mapIx = ix; }
55     public boolean isArg() { return isArgument; }
56     
57     public int getMapping()
58     {
59         if ( isArgument ) return mapIx;
60         else throw new JenaException("Unmapped variable");
61     }
62
63     public boolean isListed() { return isListed; }
64     
65     public Node_Variable var() {
66         return var;
67     }
68
69     public boolean match( Domain d, Node x )
70         {throw new JenaException("Attempt to match a free variable");
71         }
72     
73     public Node asNodeMatch( Domain d ) {
74         throw new JenaException("asNodeMatch not supported");
75     }
76     
77     public String JavaDoc toString()
78         { return "<Free " + listIx + ">"; }
79     }
80
81 /*
82     (c) Copyright 2002, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
83     All rights reserved.
84
85     Redistribution and use in source and binary forms, with or without
86     modification, are permitted provided that the following conditions
87     are met:
88
89     1. Redistributions of source code must retain the above copyright
90        notice, this list of conditions and the following disclaimer.
91
92     2. Redistributions in binary form must reproduce the above copyright
93        notice, this list of conditions and the following disclaimer in the
94        documentation and/or other materials provided with the distribution.
95
96     3. The name of the author may not be used to endorse or promote products
97        derived from this software without specific prior written permission.
98
99     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
100     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
101     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
102     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
103     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
104     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
105     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
106     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
108     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109 */

110
Popular Tags