public class ResourceReference extends Object implements Serializable
URL instances to
refer to resources and to aid in converting existing code to use
ResourceReference instead the public API follows that of URL
where possible.| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
ResourceReference(Plugin plugin,
String path)
Creates a new instance that references a resource within a given
Plugin. |
ResourceReference(ResourceReference context,
String path)
Creates a new instance that references a resource identified by resolving
the path against an existing
ResourceReference. |
ResourceReference(URI uri)
Create a new instance that references a resource described by a
URI. |
ResourceReference(URL url)
Create a new instance that references a resource accessible via a known
URL. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
URLConnection |
openConnection()
Returns a
URLConnection instance that
represents a connection to the resource referred to by this
ResourceReference. |
InputStream |
openStream()
Opens a connection to this
ResourceReference and returns an
InputStream for reading from that connection. |
String |
toExternalForm() |
String |
toString() |
URI |
toURI() |
URL |
toURL()
Creates a
URL instance that can be used to access the
underlying resource. |
public ResourceReference(URL url) throws URISyntaxException
URL. While a useful constructor in it's own right this
also allows old applications that contain URLs as parameters to PRs that
now take a ResourceReference to continue to work as the URL will
get passed into this constructor automatically as the application is
reloaded.url - the URL of the resource you wish to referenceURISyntaxException - if the URL does not strictly conform to RFC 2396 or if it cannot
be converted to an absolute URIpublic ResourceReference(URI uri) throws URISyntaxException
URI.uri - the URI of the resource you wish to referenceURISyntaxException - if the URI is not absolutepublic ResourceReference(Plugin plugin, String path) throws URISyntaxException
Plugin.plugin - a Plugin against which to resolve the
path. Can be null, but only if the path can be parsed as an
absolute URIpath - the path to the resource which will be resolved against the
PluginURISyntaxException - if the reference cannot be converted to an absolute URIpublic ResourceReference(ResourceReference context, String path) throws URISyntaxException
ResourceReference.context - a ResourceReference against which to resolve the path. Can
be null, but only if the path can be parsed as an absolute URIpath - the path to the resource which will be resolved against the
context.URISyntaxException - if the reference cannot be converted to an absolute URIpublic InputStream openStream() throws IOException
ResourceReference and returns an
InputStream for reading from that connection. This method is a
shorthand for: toURL().openConnection().getInputStream()
IOException - if an I/O exception occurs.public URLConnection openConnection() throws IOException
URLConnection instance that
represents a connection to the resource referred to by this
ResourceReference.
It should be noted that a URLConnection instance does not establish the actual network connection on creation. This will happen only when calling URLConnection.connect().
This method is a shorthand for:toURL().openConnection()
URLConnection linking to the
underlying resource.IOException - if an I/O exception occurs.public URL toURL() throws IOException
URL instance that can be used to access the
underlying resource. It should be noted that the result is not guaranteed
to be valid long term and should never be persisted. If you want persistent
access then store the ResourceReference instance instead.URL that currently gives access to the
referenced resource.IOException - if an I/O exception occurs.public URI toURI()
public String toExternalForm()
Copyright © 2024 GATE. All rights reserved.