KickJava   Java API By Example, From Geeks To Geeks.

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


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

5
6
7 package com.hp.hpl.jena.rdql.parser;
8 import com.hp.hpl.jena.graph.Node ;
9 import com.hp.hpl.jena.rdql.*;
10
11 public class Q_QName extends Q_URI
12 {
13     // The form actually coming from the parser.
14
String JavaDoc seen = "";
15     String JavaDoc prefix = null ;
16     String JavaDoc lcname = null ;
17     
18     public Q_QName(int id)
19     {
20         super(id);
21     }
22
23     public Q_QName(RDQLParser p, int id)
24     {
25         super(p, id);
26     }
27
28     void set(String JavaDoc s)
29     {
30         seen = s ;
31     }
32     
33     public void jjtClose()
34     {
35         if ( jjtGetNumChildren() != 2 )
36             throw new RDQL_InternalErrorException("Q_QName: expected 2 children: got "+jjtGetNumChildren()) ;
37         prefix = ((Q_Identifier)jjtGetChild(0)).id ;
38         lcname = ((Q_Identifier)jjtGetChild(1)).id ;
39         seen = prefix+":"+lcname ;
40         //super.setURI(seen) ;
41
}
42
43     public void postParse(Query query)
44     {
45         super.postParse(query) ;
46
47         if ( isNode() )
48             // Already done.
49
return ;
50         String JavaDoc full = query.getPrefix(prefix) ;
51
52         if ( full == null )
53             throw new QueryException("Query error: QName '"+seen+"' can not be expanded.") ;
54
55         super._setNode(Node.createURI(full+lcname)) ;
56     }
57     
58
59
60     
61     public String JavaDoc asQuotedString() { return seen ; }
62     
63     public String JavaDoc asUnquotedString() { return seen ; }
64     // Must return the expanded form
65
public String JavaDoc valueString() { return super.getURI() ; }
66
67     public String JavaDoc toString() { return seen ; }
68 }
69
70 /*
71  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
72  * All rights reserved.
73  *
74  * Redistribution and use in source and binary forms, with or without
75  * modification, are permitted provided that the following conditions
76  * are met:
77  * 1. Redistributions of source code must retain the above copyright
78  * notice, this list of conditions and the following disclaimer.
79  * 2. Redistributions in binary form must reproduce the above copyright
80  * notice, this list of conditions and the following disclaimer in the
81  * documentation and/or other materials provided with the distribution.
82  * 3. The name of the author may not be used to endorse or promote products
83  * derived from this software without specific prior written permission.
84  *
85  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
86  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
87  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
88  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
89  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
90  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
91  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
92  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
93  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
94  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95  */

96
Popular Tags