49 |
* Constructs an <code>RDFURI</code> using the specified URI. |
* Constructs an <code>RDFURI</code> using the specified URI. |
50 |
* |
* |
51 |
* @param uri the URI to use for this RDF URI. |
* @param uri the URI to use for this RDF URI. |
52 |
|
* @throws URISyntaxException if the supplied <code>String</code> |
53 |
|
* does not form a valid URI. |
54 |
|
*/ |
55 |
|
public RDFURI(String uri) |
56 |
|
throws URISyntaxException |
57 |
|
{ |
58 |
|
this(new URI(uri)); |
59 |
|
} |
60 |
|
|
61 |
|
/** |
62 |
|
* Constructs an <code>RDFURI</code> using the specified URI. |
63 |
|
* |
64 |
|
* @param uri the URI to use for this RDF URI. |
65 |
*/ |
*/ |
66 |
public RDFURI(URI uri) |
public RDFURI(URI uri) |
67 |
{ |
{ |
83 |
} |
} |
84 |
|
|
85 |
/** |
/** |
86 |
* Returns a clone of the URI used by this RDF URI. |
* Returns he URI used by this RDF URI. |
87 |
* |
* |
88 |
* @return a clone of the URI. |
* @return the URI. |
89 |
*/ |
*/ |
90 |
public URI getURI() |
public URI getURI() |
91 |
{ |
{ |
92 |
try |
/* URIs are immutable, so we don't need to clone */ |
93 |
{ |
return uri; |
|
return new URI(uri.toString()); |
|
|
} |
|
|
catch (URISyntaxException e) |
|
|
{ |
|
|
throw new IllegalStateException("The URI is invalid.", e); |
|
|
} |
|
94 |
} |
} |
95 |
|
|
96 |
/** |
/** |
100 |
*/ |
*/ |
101 |
public RDFURI clone() |
public RDFURI clone() |
102 |
{ |
{ |
103 |
Object clonedObject = super.clone(); |
try |
104 |
RDFURI clone = (RDFURI) clonedObject; |
{ |
105 |
clone.setURI(getURI()); |
Object clonedObject = super.clone(); |
106 |
return clone; |
RDFURI clone = (RDFURI) clonedObject; |
107 |
|
clone.setURI(new URI(uri.toString())); |
108 |
|
return clone; |
109 |
|
} |
110 |
|
catch (URISyntaxException e) |
111 |
|
{ |
112 |
|
throw new IllegalStateException("Invalid URI detected in cloning.",e); |
113 |
|
} |
114 |
} |
} |
115 |
|
|
116 |
/** |
/** |
123 |
this.uri = uri; |
this.uri = uri; |
124 |
} |
} |
125 |
|
|
126 |
|
/** |
127 |
|
* Returns true if the specified object is a RDF URI and |
128 |
|
* is equal to this one. |
129 |
|
* |
130 |
|
* @param object the object to compare. |
131 |
|
*/ |
132 |
|
public boolean equals(Object obj) |
133 |
|
{ |
134 |
|
if (super.equals(obj)) |
135 |
|
{ |
136 |
|
RDFURI rdfUri = (RDFURI) obj; |
137 |
|
return uri.equals(rdfUri.getURI()); |
138 |
|
} |
139 |
|
return false; |
140 |
|
} |
141 |
|
|
142 |
|
/** |
143 |
|
* Returns the hashcode of this RDF URI. This is calculated using |
144 |
|
* the uri's hash code and that of the superclass. |
145 |
|
* |
146 |
|
* @return the hashcode for this RDF URI. |
147 |
|
*/ |
148 |
|
public int hashCode() |
149 |
|
{ |
150 |
|
return super.hashCode() + 17 * uri.hashCode(); |
151 |
|
} |
152 |
|
|
153 |
} |
} |