KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > arp > XMLNullContext


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: XMLNullContext.java,v 1.5 2005/02/21 12:09:29 andy_seaborne Exp $
5 */

6 package com.hp.hpl.jena.rdf.arp;
7 import java.util.Map JavaDoc;
8
9 /**
10  * @author <a HREF="mailto:Jeremy.Carroll@hp.com">Jeremy Carroll</a>
11  *
12 */

13 class XMLNullContext extends XMLContext implements ARPErrorNumbers {
14     final XMLHandler forErrors;
15     final int errno;
16     final String JavaDoc errmsg;
17     
18     XMLNullContext(XMLHandler f, int eno) {
19         super(null,null);
20         forErrors = f;
21         errno = eno;
22         errmsg = eno==ERR_RESOLVING_URI_AGAINST_NULL_BASE?
23         "Base URI is null, but there are relative URIs to resolve.":
24         "Base URI is \"\", relative URIs left as relative.";
25     }
26     private XMLNullContext(XMLContext document,URI uri,String JavaDoc base,String JavaDoc lang,Map JavaDoc namespaces,
27               XMLNullContext parent) {
28         super(document,uri,base,lang,namespaces);
29         forErrors = parent.forErrors;
30         errno = parent.errno;
31         errmsg = parent.errmsg;
32     }
33     XMLContext clone(XMLContext document,URI uri,String JavaDoc base,String JavaDoc lang,Map JavaDoc namespaces) {
34         return new XMLNullContext(document,uri,base,lang,namespaces, this);
35     }
36
37     String JavaDoc resolve(Location l, String JavaDoc uri) throws MalformedURIException, ParseException {
38         try {
39             URI rslt = new URI(uri);
40             return rslt.getURIString();
41         } catch (RelativeURIException e) {
42         // new Exception().printStackTrace();
43

44             forErrors.parseWarning(errno,
45                l,
46                errmsg);
47             return uri;
48         }
49     }
50     String JavaDoc resolveSameDocRef(Location l, String JavaDoc sameDoc) throws ParseException {
51
52         //new Exception().printStackTrace();
53

54         forErrors.parseWarning(errno,
55                        l,
56                        errmsg);
57        return sameDoc;
58     }
59
60     boolean isSameAsDocument() {
61         return this==document;
62     }
63 }
64
65 /*
66     (c) Copyright 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
73     1. Redistributions of source code must retain the above copyright
74        notice, this list of conditions and the following disclaimer.
75
76     2. Redistributions in binary form must reproduce the above copyright
77        notice, this list of conditions and the following disclaimer in the
78        documentation and/or other materials provided with the distribution.
79
80     3. The name of the author may not be used to endorse or promote products
81        derived from this software without specific prior written permission.
82
83     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
84     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
85     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
86     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
87     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
88     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
89     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
90     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
92     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93 */
Popular Tags