KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > rulesys > impl > EnvironmentFrame


1 /******************************************************************
2  * File: LPEnvironment.java
3  * Created by: Dave Reynolds
4  * Created on: 22-Jul-2003
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: EnvironmentFrame.java,v 1.4 2005/02/21 12:17:40 andy_seaborne Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.reasoner.rulesys.impl;
11
12 import com.hp.hpl.jena.graph.*;
13 import com.hp.hpl.jena.reasoner.rulesys.Rule;
14
15 /**
16  * Represents a single frame in the LP interpreter's environment stack. The
17  * environment stack represents the AND part of the search tree - it is a sequence
18  * of nested predicate calls.
19  * <p>
20  * This is used in the inner loop of the interpreter and so is a pure data structure
21  * not an abstract data type and assumes privileged access to the interpreter state.
22  * </p>
23  *
24  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
25  * @version $Revision: 1.4 $ on $Date: 2005/02/21 12:17:40 $
26  */

27 public class EnvironmentFrame extends FrameObject {
28
29     /** The set of permanent variables Y(i) in use by this frame. */
30     Node[] pVars;
31     
32     /** The code the the clause currently being processed */
33     RuleClauseCode clause;
34     
35     /** The continuation program counter offet in the parent clause's byte code */
36     int cpc;
37     
38     /** The continuation argument counter offset in the parent clause's arg stream */
39     int cac;
40     
41      /**
42      * Constructor
43      * @param clause the compiled code being interpreted by this env frame
44      */

45     public EnvironmentFrame(RuleClauseCode clause) {
46         this.clause = clause;
47     }
48         
49     /**
50      * Allocate a vector of permanent variables for use in the rule execution.
51      */

52     public void allocate(int n) {
53             pVars = new Node[n];
54     }
55            
56     /**
57      * Return the rule associated with this environment, null if no such rule.
58      */

59     public Rule getRule() {
60         if (clause != null) {
61             return clause.rule;
62         } else {
63             return null;
64         }
65     }
66     
67     /**
68      * Printable string for debugging.
69      */

70     public String JavaDoc toString() {
71         if (clause == null || clause.rule == null) {
72             return "[anon]";
73         } else {
74             return "[" + clause.rule.toShortString() + "]";
75         }
76     }
77 }
78
79
80 /*
81     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
82     All rights reserved.
83
84     Redistribution and use in source and binary forms, with or without
85     modification, are permitted provided that the following conditions
86     are met:
87
88     1. Redistributions of source code must retain the above copyright
89        notice, this list of conditions and the following disclaimer.
90
91     2. Redistributions in binary form must reproduce the above copyright
92        notice, this list of conditions and the following disclaimer in the
93        documentation and/or other materials provided with the distribution.
94
95     3. The name of the author may not be used to endorse or promote products
96        derived from this software without specific prior written permission.
97
98     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
99     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
100     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
101     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
102     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
103     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
104     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
105     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
106     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
107     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108 */
Popular Tags