KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdql > parser > Q_LogicalAnd


1 /*
2  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6 package com.hp.hpl.jena.rdql.parser;
7
8
9 import java.io.PrintWriter JavaDoc;
10 import com.hp.hpl.jena.graph.query.IndexValues ;
11 import com.hp.hpl.jena.graph.query.Expression;
12 import com.hp.hpl.jena.rdql.*;
13
14 /* This file is automatically generated - do not edit.
15  * Arguments:
16  * Name = LogicalAnd
17  * Operator = &&
18  * Print Name = and
19  * Template = ExprBooleanBLANK2.java
20  */

21
22 /**
23  * @author Automatically generated class: Operator: LogicalAnd
24  * @version $Id: Q_LogicalAnd.java,v 1.8 2005/02/21 12:15:44 andy_seaborne Exp $
25  */

26
27 public class Q_LogicalAnd extends ExprNode implements Expr, ExprBoolean
28 {
29     Expr left ;
30     Expr right ;
31
32     private String JavaDoc printName = "and" ;
33     private String JavaDoc opSymbol = "&&" ;
34
35     Q_LogicalAnd(int id) { super(id); }
36
37     Q_LogicalAnd(RDQLParser p, int id) { super(p, id); }
38
39     public NodeValue eval(Query q, IndexValues env)
40     {
41         NodeValue x = left.eval(q, env) ;
42         NodeValue y = right.eval(q, env) ;
43         
44         if ( ! x.isBoolean() )
45             throw new EvalTypeException("Q_LogicalAnd: Wanted a boolean: "+x) ;
46         if ( ! y.isBoolean() )
47             throw new EvalTypeException("Q_LogicalAnd: Wanted a boolean: "+y) ;
48
49         NodeValueSettable result ;
50         if ( x instanceof NodeValueSettable )
51             result = (NodeValueSettable)x ;
52         else if ( y instanceof NodeValueSettable )
53             result = (NodeValueSettable)y ;
54         else
55             result = new WorkingVar() ;
56
57         boolean b = (x.getBoolean() && y.getBoolean()) ;
58         result.setBoolean(b) ;
59         return result ;
60     }
61
62     public void jjtClose()
63     {
64         int n = jjtGetNumChildren() ;
65         if ( n != 2 )
66             throw new QueryException("Q_LogicalAnd: Wrong number of children: "+n) ;
67         
68         left = (Expr)jjtGetChild(0) ;
69         right = (Expr)jjtGetChild(1) ;
70     }
71
72     // -----------
73
// graph.query.Expression
74

75     public boolean isApply() { return true ; }
76     public String JavaDoc getFun() { return super.constructURI(this.getClass().getName()) ; }
77     public int argCount() { return 2; }
78     public Expression getArg(int i)
79     {
80         if ( i == 0 && left instanceof Expression )
81             return (Expression)left ;
82         if ( i == 1 && right instanceof Expression )
83             return (Expression)right ;
84         return null;
85     }
86
87     // ----
88

89     
90     public String JavaDoc asInfixString()
91     {
92         return QueryPrintUtils.asInfixString2(left, right, printName, opSymbol) ;
93     }
94
95     public String JavaDoc asPrefixString()
96     {
97         return QueryPrintUtils.asPrefixString(left, right, printName, opSymbol) ;
98     }
99
100     public void print(PrintWriter JavaDoc pw, int level)
101     {
102         QueryPrintUtils.print(pw, left, right, printName, opSymbol, level) ;
103     }
104
105     public String JavaDoc toString()
106     {
107         return asInfixString() ;
108     }
109 }
110
111 /*
112  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
113  * All rights reserved.
114  *
115  * Redistribution and use in source and binary forms, with or without
116  * modification, are permitted provided that the following conditions
117  * are met:
118  * 1. Redistributions of source code must retain the above copyright
119  * notice, this list of conditions and the following disclaimer.
120  * 2. Redistributions in binary form must reproduce the above copyright
121  * notice, this list of conditions and the following disclaimer in the
122  * documentation and/or other materials provided with the distribution.
123  * 3. The name of the author may not be used to endorse or promote products
124  * derived from this software without specific prior written permission.
125  *
126  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
127  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
128  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
129  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
130  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
131  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
132  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
133  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
134  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
135  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
136  */

137
Popular Tags