org.eclipse.emf.ecore.resource.impl
Class ExtensibleURIConverterImpl

java.lang.Object
  extended by org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl
All Implemented Interfaces:
URIConverter
Direct Known Subclasses:
URIConverterImpl

public class ExtensibleURIConverterImpl
extends java.lang.Object
implements URIConverter

A highly functional and extensible URI converter implementation.

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.


Nested Class Summary
protected static class ExtensibleURIConverterImpl.ContentHandlerList
           
protected static class ExtensibleURIConverterImpl.URIHandlerList
           
static interface ExtensibleURIConverterImpl.URIMap
          A map that remaps URIs.
 
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.resource.URIConverter
URIConverter.Cipher, URIConverter.Readable, URIConverter.ReadableInputStream, URIConverter.Writeable, URIConverter.WriteableOutputStream
 
Field Summary
protected  ExtensibleURIConverterImpl.ContentHandlerList contentHandlers
           
protected  ExtensibleURIConverterImpl.URIHandlerList uriHandlers
           
protected  ExtensibleURIConverterImpl.URIMap uriMap
          The URI map.
 
Fields inherited from interface org.eclipse.emf.ecore.resource.URIConverter
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_URI_CONVERTER, RESPONSE_TIME_STAMP_PROPERTY, URI_MAP
 
Constructor Summary
ExtensibleURIConverterImpl()
          Creates an instance.
ExtensibleURIConverterImpl(java.util.Collection<URIHandler> uriHandlers, java.util.Collection<ContentHandler> contentHandlers)
          Creates an instance.
 
Method Summary
 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 ContentHandlers.
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 URIHandlers.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uriHandlers

protected ExtensibleURIConverterImpl.URIHandlerList uriHandlers

contentHandlers

protected ExtensibleURIConverterImpl.ContentHandlerList contentHandlers

uriMap

protected ExtensibleURIConverterImpl.URIMap uriMap
The URI map.

Constructor Detail

ExtensibleURIConverterImpl

public ExtensibleURIConverterImpl()
Creates an instance.


ExtensibleURIConverterImpl

public ExtensibleURIConverterImpl(java.util.Collection<URIHandler> uriHandlers,
                                  java.util.Collection<ContentHandler> contentHandlers)
Creates an instance.

Method Detail

getURIHandlers

public EList<URIHandler> getURIHandlers()
Description copied from interface: URIConverter
Returns the list of URIHandlers.

Specified by:
getURIHandlers in interface URIConverter
Returns:
the list of URIHandlers.

getURIHandler

public URIHandler getURIHandler(URI uri)
Description copied from interface: URIConverter
Returns the first URI handler in the list of URI handlers which can handle the given URI.

Specified by:
getURIHandler in interface URIConverter
Parameters:
uri - the URI for which to find a handler.
Returns:
the first URI handler in the list of URI handlers which can handle the given URI.

getContentHandlers

public EList<ContentHandler> getContentHandlers()
Description copied from interface: URIConverter
Returns the list of ContentHandlers.

Specified by:
getContentHandlers in interface URIConverter
Returns:
the list of ContentHandlers.

createOutputStream

public java.io.OutputStream createOutputStream(URI uri)
                                        throws java.io.IOException
Description copied from interface: URIConverter
Creates an output stream for the URI and returns it; it has the same effect as calling createOutputStream(uri, null).

Specified by:
createOutputStream in interface URIConverter
Returns:
an open output stream.
Throws:
java.io.IOException - if there is a problem obtaining an open output stream.
See Also:
URIConverter.createOutputStream(URI, Map)

createOutputStream

public java.io.OutputStream createOutputStream(URI uri,
                                               java.util.Map<?,?> options)
                                        throws java.io.IOException
Description copied from interface: URIConverter
Creates an output stream for the URI and returns it.

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.

Specified by:
createOutputStream in interface URIConverter
Parameters:
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.
Returns:
an open output stream.
Throws:
java.io.IOException - if there is a problem obtaining an open output stream.

createInputStream

public java.io.InputStream createInputStream(URI uri)
                                      throws java.io.IOException
Description copied from interface: URIConverter
Creates an input stream for the URI and returns it; it has the same effect as calling createInputStream(uri, null).

Specified by:
createInputStream in interface URIConverter
Parameters:
uri - the URI for which to create the input stream.
Returns:
an open input stream.
Throws:
java.io.IOException - if there is a problem obtaining an open input stream.
See Also:
URIConverter.createInputStream(URI, Map)

createInputStream

public java.io.InputStream createInputStream(URI uri,
                                             java.util.Map<?,?> options)
                                      throws java.io.IOException
Description copied from interface: URIConverter
Creates an input stream for the URI and returns it.

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.

Specified by:
createInputStream in interface URIConverter
Parameters:
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.
Returns:
an open input stream.
Throws:
java.io.IOException - if there is a problem obtaining an open input stream.

delete

public void delete(URI uri,
                   java.util.Map<?,?> options)
            throws java.io.IOException
Description copied from interface: URIConverter
Deletes the contents of the given URI.

Specified by:
delete in interface URIConverter
Parameters:
uri - the URI to consider.
options - options to influence how the contents are deleted, or null if there are no options.
Throws:
java.io.IOException - if there is a problem deleting the contents.

contentDescription

public java.util.Map<java.lang.String,?> contentDescription(URI uri,
                                                            java.util.Map<?,?> options)
                                                     throws java.io.IOException
Description copied from interface: URIConverter
Returns a map from String properties to their corresponding values representing a description the given URI's contents. See the content handler for more details.

Specified by:
contentDescription in interface URIConverter
Parameters:
uri - the URI to consider.
options - options to influence how the content description is determined, or null if there are no options.
Returns:
a map from String properties to their corresponding values representing a description the given URI's contents.
Throws:
java.io.IOException - if there is a problem accessing the contents.
See Also:
ContentHandler.contentDescription(URI, InputStream, Map, Map)

exists

public boolean exists(URI uri,
                      java.util.Map<?,?> options)
Description copied from interface: URIConverter
Returns whether the given URI has contents. If the URI exists it will be possible to create an input stream.

Specified by:
exists in interface URIConverter
Parameters:
uri - the URI to consider.
options - options to influence how the existence determined, or null if there are no options.
Returns:
whether the given URI has contents.

getAttributes

public java.util.Map<java.lang.String,?> getAttributes(URI uri,
                                                       java.util.Map<?,?> options)
Description copied from interface: URIConverter
Returns a map from String attributes to their corresponding values representing information about various aspects of the URI's state. The 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.

Specified by:
getAttributes in interface URIConverter
Parameters:
uri - the URI to consider.
options - options to influence how the attributes are determined, or null if there are no options.
Returns:
a map from String attributes to their corresponding values representing information about various aspects of the URI's state.

setAttributes

public void setAttributes(URI uri,
                          java.util.Map<java.lang.String,?> attributes,
                          java.util.Map<?,?> options)
                   throws java.io.IOException
Description copied from interface: URIConverter
Updates the map from String attributes to their corresponding values representing information about various aspects of the URI's state. Unsupported or unchangeable attributes are ignored.

Specified by:
setAttributes in interface URIConverter
Parameters:
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.
Throws:
java.io.IOException - if there is a problem updating the attributes.

normalize

public URI normalize(URI uri)
Returns the normalized form of the URI.

This implementation does precisely and only the typical thing. It calls itself recursively so that mapped chains are followed.

Specified by:
normalize in interface URIConverter
Parameters:
uri - the URI to normalize.
Returns:
the normalized form.
See Also:
EcorePlugin.getPlatformResourceMap()

getURIMap

public java.util.Map<URI,URI> getURIMap()
Description copied from interface: URIConverter
Returns the map used for remapping a logical URI to a physical URI when 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.d
will map to
  platform:/resource/example/a/b/c.d
A matching instance mapping is considered first. If there isn't one, the folder mappings are considered starting with the longest prefix.

Specified by:
getURIMap in interface URIConverter
Returns:
the map used for remapping a logical URI to a physical URI.
See Also:
URIConverter.normalize(URI), URIConverter.URI_MAP

getInternalURIMap

protected ExtensibleURIConverterImpl.URIMap getInternalURIMap()
Returns the internal version of the URI map.

Returns:
the internal version of the URI map.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.