KickJava   Java API By Example, From Geeks To Geeks.

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


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.rdql.*;
12
13 /* This file is automatically generated - do not edit.
14  * Arguments:
15  * Name = GreaterThanOrEqual
16  * Operator = >=
17  * Print Name = ge
18  * Template = ExprBooleanNumericBLANK2.java
19  */

20
21 /**
22  * @author Automatically generated class: Operator: GreaterThanOrEqual
23  * @version $Id: Q_GreaterThanOrEqual.java,v 1.8 2005/02/21 12:15:43 andy_seaborne Exp $
24  */

25
26 public class Q_GreaterThanOrEqual extends ExprNode implements Expr, ExprBoolean
27 {
28     Expr left ;
29     Expr right ;
30
31     private String JavaDoc printName = "ge" ;
32     private String JavaDoc opSymbol = ">=" ;
33
34     Q_GreaterThanOrEqual(int id) { super(id); }
35
36     Q_GreaterThanOrEqual(RDQLParser p, int id) { super(p, id); }
37
38     public NodeValue eval(Query q, IndexValues env)
39     {
40         NodeValue x = left.eval(q, env) ;
41         NodeValue y = right.eval(q, env) ;
42         
43         if ( ! x.isNumber() )
44             throw new EvalTypeException("Q_GreaterThanOrEqual: Wanted a numeric: "+x) ;
45         if ( ! y.isNumber() )
46             throw new EvalTypeException("Q_GreaterThanOrEqual: Wanted a numeric: "+y) ;
47
48         NodeValueSettable result ;
49         if ( x instanceof NodeValueSettable )
50             result = (NodeValueSettable)x ;
51         else if ( y instanceof NodeValueSettable )
52             result = (NodeValueSettable)y ;
53         else
54             result = new WorkingVar() ;
55             
56         boolean b ;
57
58         if ( x.isInt() && y.isInt() )
59             b = (x.getInt() >= y.getInt()) ;
60         else
61             b = (x.getDouble() >= y.getDouble()) ;
62
63         result.setBoolean(b) ;
64         return result ;
65     }
66
67     public void jjtClose()
68     {
69         int n = jjtGetNumChildren() ;
70         if ( n != 2 )
71             throw new QueryException("Q_GreaterThanOrEqual: Wrong number of children: "+n) ;
72         
73         left = (Expr)jjtGetChild(0) ;
74         right = (Expr)jjtGetChild(1) ;
75     }
76
77     public String JavaDoc asInfixString()
78     {
79         return QueryPrintUtils.asInfixString2(left, right, printName, opSymbol) ;
80     }
81
82     public String JavaDoc asPrefixString()
83     {
84         return QueryPrintUtils.asPrefixString(left, right, printName, opSymbol) ;
85     }
86
87     public void print(PrintWriter JavaDoc pw, int level)
88     {
89         QueryPrintUtils.print(pw, left, right, printName, opSymbol, level) ;
90     }
91
92     public String JavaDoc toString()
93     {
94         return asInfixString() ;
95     }
96 }
97
98 /*
99  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
100  * All rights reserved.
101  *
102  * Redistribution and use in source and binary forms, with or without
103  * modification, are permitted provided that the following conditions
104  * are met:
105  * 1. Redistributions of source code must retain the above copyright
106  * notice, this list of conditions and the following disclaimer.
107  * 2. Redistributions in binary form must reproduce the above copyright
108  * notice, this list of conditions and the following disclaimer in the
109  * documentation and/or other materials provided with the distribution.
110  * 3. The name of the author may not be used to endorse or promote products
111  * derived from this software without specific prior written permission.
112  *
113  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
114  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
115  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
116  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
117  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
118  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
119  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
120  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
121  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
122  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
123  */

124
Popular Tags