KickJava   Java API By Example, From Geeks To Geeks.

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


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

5
6 /* Generated By:JJTree: Do not edit this line. Q_UnaryPlus.java */
7
8 package com.hp.hpl.jena.rdql.parser;
9
10
11 import java.io.PrintWriter JavaDoc;
12 import com.hp.hpl.jena.graph.query.IndexValues;
13 import com.hp.hpl.jena.graph.query.Expression ;
14 import com.hp.hpl.jena.rdql.*;
15
16 public class Q_UnaryPlus extends ExprNode implements ExprNumeric {
17     Expr expr ;
18
19     private String JavaDoc printName = "unaryplus" ;
20     private String JavaDoc opSymbol = "+" ;
21
22     Q_UnaryPlus(int id) { super(id); }
23     Q_UnaryPlus(RDQLParser p, int id) { super(p, id); }
24
25     public NodeValue eval(Query q, IndexValues env)
26     {
27         NodeValue r = expr.eval(q, env) ;
28         if ( ! r.isNumber() )
29             throw new EvalTypeException("Q_UnaryPlus: Wanted a number: got "+expr) ;
30
31         return r ;
32     }
33
34     public void jjtClose()
35     {
36         int n = jjtGetNumChildren() ;
37         if ( n != 1 )
38             throw new QueryException("Q_UnaryPlus: Wrong number of children: "+n) ;
39         expr = (Expr)jjtGetChild(0) ;
40     }
41
42     // -----------
43
// graph.query.Expression
44

45     public boolean isApply() { return true ; }
46     public String JavaDoc getFun() { return super.constructURI(this.getClass().getName()) ; }
47     public int argCount() { return 1; }
48     public Expression getArg(int i)
49     {
50         if ( i == 0 && expr instanceof Expression )
51             return (Expression)expr ;
52         return null;
53     }
54
55     public String JavaDoc asInfixString() { return QueryPrintUtils.asInfixString1(expr, printName, opSymbol) ; }
56
57     public String JavaDoc asPrefixString() { return QueryPrintUtils.asPrefixString(expr, null, printName, opSymbol) ; }
58
59     public void print(PrintWriter JavaDoc pw, int level) { QueryPrintUtils.print(pw, expr, null, printName, opSymbol, level) ; }
60
61     public String JavaDoc toString() { return asInfixString() ; }
62 }
63
64
65 /*
66  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
67  * All rights reserved.
68  *
69  * Redistribution and use in source and binary forms, with or without
70  * modification, are permitted provided that the following conditions
71  * are met:
72  * 1. Redistributions of source code must retain the above copyright
73  * notice, this list of conditions and the following disclaimer.
74  * 2. Redistributions in binary form must reproduce the above copyright
75  * notice, this list of conditions and the following disclaimer in the
76  * documentation and/or other materials provided with the distribution.
77  * 3. The name of the author may not be used to endorse or promote products
78  * derived from this software without specific prior written permission.
79  *
80  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
81  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
82  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
84  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
85  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
86  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
87  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
89  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90  */

91
Popular Tags