01: /*
02: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: [See end of file]
04: $Id: Node_URI.java,v 1.16 2008/01/02 12:06:55 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.graph;
08:
09: import com.hp.hpl.jena.rdf.model.impl.Util;
10: import com.hp.hpl.jena.shared.*;
11:
12: /**
13: RDF nodes with a global identity given by a URI.
14: @author kers
15: */
16: public class Node_URI extends Node_Concrete {
17: protected Node_URI(Object uri) {
18: super (uri);
19: }
20:
21: public String getURI() {
22: return (String) label;
23: }
24:
25: public Object visitWith(NodeVisitor v) {
26: return v.visitURI(this , (String) label);
27: }
28:
29: public boolean isURI() {
30: return true;
31: }
32:
33: /**
34: Answer a String representing the node, taking into account the PrefixMapping.
35: The horrible test against null is a stopgap to avoid a circularity issue.
36: TODO fix the circularity issue
37: */
38: public String toString(PrefixMapping pm, boolean quoting) {
39: return pm == null ? (String) label : pm
40: .shortForm((String) label);
41: }
42:
43: public boolean equals(Object other) {
44: return other instanceof Node_URI && same((Node_URI) other);
45: }
46:
47: final boolean same(Node_URI other) {
48: return label.equals(other.label);
49: }
50:
51: public String getNameSpace() {
52: String s = (String) label;
53: return s.substring(0, Util.splitNamespace(s));
54: }
55:
56: public String getLocalName() {
57: String s = (String) label;
58: return s.substring(Util.splitNamespace(s));
59: }
60:
61: public boolean hasURI(String uri) {
62: return label.equals(uri);
63: }
64:
65: }
66:
67: /*
68: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
69: All rights reserved.
70:
71: Redistribution and use in source and binary forms, with or without
72: modification, are permitted provided that the following conditions
73: are met:
74:
75: 1. Redistributions of source code must retain the above copyright
76: notice, this list of conditions and the following disclaimer.
77:
78: 2. Redistributions in binary form must reproduce the above copyright
79: notice, this list of conditions and the following disclaimer in the
80: documentation and/or other materials provided with the distribution.
81:
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: */
|