KickJava   Java API By Example, From Geeks To Geeks.

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


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_URI.java */
7
8 package com.hp.hpl.jena.rdql.parser;
9
10 import com.hp.hpl.jena.rdql.Query;
11
12 public class Q_QuotedURI extends Q_URI {
13     // Also supports old-style "quoted qnames" (i.e. qnames inside <>)
14
// Old RDQL used to always use quoted items for qnames and full URIs.
15

16     // The form actually coming from the parser.
17
String JavaDoc seen = "" ;
18
19     // This is set false until the Q_URI is transformed into absolute form
20
// or it is known to be.
21

22     boolean isAbsolute = false ;
23
24     Q_QuotedURI(int id)
25     {
26         super(id);
27     }
28
29     Q_QuotedURI(RDQLParser p, int id)
30     {
31         super(p, id);
32     }
33
34     void set(String JavaDoc s)
35     {
36         seen = s ;
37     }
38
39     public void jjtClose()
40     {
41         // Can't convert to absolute form until the entire query is parsed.
42
// Don't need to do %-escape processing here because we work in string-space.
43
// Easier to work on the version of URIs with the escape sequences still in.
44
//seen = processEscapes(seen) ;
45
super._setURI(seen);
46     }
47
48     public void postParse(Query query)
49     {
50         super.postParse(query) ;
51         if ( ! isAbsolute )
52             absolute(query) ;
53     }
54
55     static final String JavaDoc prefixOperator = ":" ;
56
57     private void absolute(Query query)
58     {
59         if ( query == null )
60         {
61             // Only occurs during testing when we jump straight into the parser.
62
isAbsolute = true ;
63             return ;
64         }
65             
66         int i = seen.indexOf(prefixOperator) ;
67         if ( i < 0 )
68         {
69             isAbsolute = true ;
70             return ;
71         }
72
73         String JavaDoc prefix = seen.substring(0,i) ;
74         
75         String JavaDoc full = query.getPrefix(prefix) ;
76
77         if ( full == null )
78         {
79             isAbsolute = true ;
80             return ;
81         }
82
83         String JavaDoc remainder = seen.substring(i+prefixOperator.length()) ;
84         super._setURI(full+remainder) ;
85         isAbsolute = true ;
86     }
87     
88     public static Q_URI makeURI(String JavaDoc s)
89     {
90         Q_URI uri = new Q_URI(0) ;
91         uri._setURI(s) ;
92         return uri ;
93     }
94
95
96     // Override these to retain prefix (old style qnames in <> quotes)
97

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

134
Popular Tags