public class ExtensibleURIConverterImpl extends java.lang.Object implements URIConverter
This implementation provides seamless transparent Eclipse integration
by supporting the platform:/resource
mechanism both inside of Eclipse and outside of Eclipse.
Furthermore, although the implementation imports
both org.eclipse.core.runtime
and org.eclipse.core.resources
,
and hence requires the Eclipse libraries at development time,
the implementation does not require them at runtime.
Clients of this implementation must be cautious if they wish to maintain this platform neutral behaviour.
Modifier and Type | Class and Description |
---|---|
protected static class |
ExtensibleURIConverterImpl.ContentHandlerList |
protected static class |
ExtensibleURIConverterImpl.URIHandlerList |
static interface |
ExtensibleURIConverterImpl.URIMap
A map that remaps URIs.
|
URIConverter.Cipher, URIConverter.Loadable, URIConverter.Readable, URIConverter.ReadableInputStream, URIConverter.Saveable, URIConverter.Writeable, URIConverter.WriteableOutputStream
Modifier and Type | Field and Description |
---|---|
protected ExtensibleURIConverterImpl.ContentHandlerList |
contentHandlers |
protected ExtensibleURIConverterImpl.URIHandlerList |
uriHandlers |
protected ExtensibleURIConverterImpl.URIMap |
uriMap
The URI map.
|
ATTRIBUTE_ARCHIVE, ATTRIBUTE_DIRECTORY, ATTRIBUTE_EXECUTABLE, ATTRIBUTE_HIDDEN, ATTRIBUTE_LENGTH, ATTRIBUTE_READ_ONLY, ATTRIBUTE_TIME_STAMP, INSTANCE, NULL_TIME_STAMP, OPTION_REQUESTED_ATTRIBUTES, OPTION_RESPONSE, OPTION_TIMEOUT, OPTION_URI_CONVERTER, RESPONSE_TIME_STAMP_PROPERTY, RESPONSE_URI, URI_MAP
Constructor and Description |
---|
ExtensibleURIConverterImpl()
Creates an instance.
|
ExtensibleURIConverterImpl(java.util.Collection<URIHandler> uriHandlers,
java.util.Collection<ContentHandler> contentHandlers)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,?> |
contentDescription(URI uri,
java.util.Map<?,?> options)
Returns a map from String properties to their corresponding values representing a description the given URI's contents.
|
java.io.InputStream |
createInputStream(URI uri)
Creates an input stream for the URI and returns it;
it has the same effect as calling
createInputStream(uri, null) . |
java.io.InputStream |
createInputStream(URI uri,
java.util.Map<?,?> options)
Creates an input stream for the URI and returns it.
|
java.io.OutputStream |
createOutputStream(URI uri)
Creates an output stream for the URI and returns it;
it has the same effect as calling
createOutputStream(uri, null) . |
java.io.OutputStream |
createOutputStream(URI uri,
java.util.Map<?,?> options)
Creates an output stream for the URI and returns it.
|
void |
delete(URI uri,
java.util.Map<?,?> options)
Deletes the contents of the given URI.
|
boolean |
exists(URI uri,
java.util.Map<?,?> options)
Returns whether the given URI has contents.
|
java.util.Map<java.lang.String,?> |
getAttributes(URI uri,
java.util.Map<?,?> options)
Returns a map from String attributes to their corresponding values representing information about various aspects of the URI's state.
|
EList<ContentHandler> |
getContentHandlers()
Returns the list of
ContentHandler s. |
protected ExtensibleURIConverterImpl.URIMap |
getInternalURIMap()
Returns the internal version of the URI map.
|
URIHandler |
getURIHandler(URI uri)
Returns the first URI handler in the
list of URI handlers which can handle the given URI. |
EList<URIHandler> |
getURIHandlers()
Returns the list of
URIHandler s. |
java.util.Map<URI,URI> |
getURIMap()
Returns the map used for remapping a logical URI to a physical URI when
normalizing . |
URI |
normalize(URI uri)
Returns the normalized form of the URI.
|
void |
setAttributes(URI uri,
java.util.Map<java.lang.String,?> attributes,
java.util.Map<?,?> options)
Updates the map from String attributes to their corresponding values representing information about various aspects of the URI's state.
|
protected ExtensibleURIConverterImpl.URIHandlerList uriHandlers
protected ExtensibleURIConverterImpl.ContentHandlerList contentHandlers
protected ExtensibleURIConverterImpl.URIMap uriMap
public ExtensibleURIConverterImpl()
public ExtensibleURIConverterImpl(java.util.Collection<URIHandler> uriHandlers, java.util.Collection<ContentHandler> contentHandlers)
public EList<URIHandler> getURIHandlers()
URIConverter
URIHandler
s.getURIHandlers
in interface URIConverter
URIHandler
s.public URIHandler getURIHandler(URI uri)
URIConverter
list
of URI handlers which can handle
the given URI.getURIHandler
in interface URIConverter
uri
- the URI for which to find a handler.public EList<ContentHandler> getContentHandlers()
URIConverter
ContentHandler
s.getContentHandlers
in interface URIConverter
ContentHandler
s.public java.io.OutputStream createOutputStream(URI uri) throws java.io.IOException
URIConverter
createOutputStream(uri, null)
.createOutputStream
in interface URIConverter
java.io.IOException
- if there is a problem obtaining an open output stream.URIConverter.createOutputStream(URI, Map)
public java.io.OutputStream createOutputStream(URI uri, java.util.Map<?,?> options) throws java.io.IOException
URIConverter
It normalizes
the URI and uses that as the basis for further processing.
Special requirements, such as an Eclipse file refresh,
are handled by the default implementation
.
createOutputStream
in interface URIConverter
uri
- the URI for which to create the output stream.options
- a map of options to influence the kind of stream that is returned; unrecognized options are ignored and null
is permitted.java.io.IOException
- if there is a problem obtaining an open output stream.public java.io.InputStream createInputStream(URI uri) throws java.io.IOException
URIConverter
createInputStream(uri, null)
.createInputStream
in interface URIConverter
uri
- the URI for which to create the input stream.java.io.IOException
- if there is a problem obtaining an open input stream.URIConverter.createInputStream(URI, Map)
public java.io.InputStream createInputStream(URI uri, java.util.Map<?,?> options) throws java.io.IOException
URIConverter
It normalizes
the URI and uses that as the basis for further processing.
Special requirements, such as an Eclipse file refresh,
are handled by the default implementation
.
createInputStream
in interface URIConverter
uri
- the URI for which to create the input stream.options
- a map of options to influence the kind of stream that is returned; unrecognized options are ignored and null
is permitted.java.io.IOException
- if there is a problem obtaining an open input stream.public void delete(URI uri, java.util.Map<?,?> options) throws java.io.IOException
URIConverter
delete
in interface URIConverter
uri
- the URI to consider.options
- options to influence how the contents are deleted, or null
if there are no options.java.io.IOException
- if there is a problem deleting the contents.public java.util.Map<java.lang.String,?> contentDescription(URI uri, java.util.Map<?,?> options) throws java.io.IOException
URIConverter
content handler
for more details.contentDescription
in interface URIConverter
uri
- the URI to consider.options
- options to influence how the content description is determined, or null
if there are no options.java.io.IOException
- if there is a problem accessing the contents.ContentHandler.contentDescription(URI, InputStream, Map, Map)
public boolean exists(URI uri, java.util.Map<?,?> options)
URIConverter
exists
it will be possible to create
an input stream.exists
in interface URIConverter
uri
- the URI to consider.options
- options to influence how the existence determined, or null
if there are no options.public java.util.Map<java.lang.String,?> getAttributes(URI uri, java.util.Map<?,?> options)
URIConverter
requested attributes option
can be used to specify which properties to fetch;
without that option, all supported attributes will be fetched.
If the URI doesn't not support any particular attribute, an entry for that attribute will not be appear in the result.getAttributes
in interface URIConverter
uri
- the URI to consider.options
- options to influence how the attributes are determined, or null
if there are no options.public void setAttributes(URI uri, java.util.Map<java.lang.String,?> attributes, java.util.Map<?,?> options) throws java.io.IOException
URIConverter
setAttributes
in interface URIConverter
uri
- the URI to consider.attributes
- the new values for the attributes.options
- options to influence how the attributes are updated, or null
if there are no options.java.io.IOException
- if there is a problem updating the attributes.public URI normalize(URI uri)
This implementation does precisely and only the typical
thing.
It calls itself recursively so that mapped chains are followed.
normalize
in interface URIConverter
uri
- the URI to normalize.EcorePlugin.getPlatformResourceMap()
public java.util.Map<URI,URI> getURIMap()
URIConverter
normalizing
.
An implementation will typically also delegate to the global
map,
so registrations made in this map are local to this URI converter,
i.e., they augment or override those of the global map.
The map generally specifies instance to instance mapping,
except for the case that both the key URI and the value URI end with "/",
which specifies a folder to folder mapping.
A folder mapping will remap any URI that has the key as its prefix
,
e.g., if the map contains:
http://www.example.com/ -> platform:/resource/example/then the URI
http://www.example.com/a/b/c.dwill map to
platform:/resource/example/a/b/c.dA matching instance mapping is considered first. If there isn't one, the folder mappings are considered starting with the
longest
prefix.
getURIMap
in interface URIConverter
URIConverter.normalize(URI)
,
URIConverter.URI_MAP
protected ExtensibleURIConverterImpl.URIMap getInternalURIMap()