|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.emf.ecore.resource.impl.URIConverterImpl
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 | |
static class |
URIConverterImpl.PlatformResourceOutputStream
An output stream that transfers its contents to an IFile upon closing. |
static interface |
URIConverterImpl.URIMap
A map that remaps URIs. |
static class |
URIConverterImpl.WorkbenchHelper
Isolated Eclipse workbench utilities. |
Field Summary | |
protected URIConverterImpl.URIMap |
uriMap
The URI map. |
protected static IWorkspaceRoot |
workspaceRoot
The cached Eclipse workspace. |
Fields inherited from interface org.eclipse.emf.ecore.resource.URIConverter |
URI_MAP |
Constructor Summary | |
URIConverterImpl()
Creates an instance. |
Method Summary | |
protected InputStream |
createFileInputStream(String filePath)
Creates an input stream for the file path and returns it. |
protected OutputStream |
createFileOutputStream(String filePath)
Creates an output stream for the file path and returns it. |
InputStream |
createInputStream(URI uri)
Creates an input stream for the URI and returns it. |
OutputStream |
createOutputStream(URI uri)
Creates an output stream for the URI and returns it. |
protected InputStream |
createPlatformResourceInputStream(String platformResourcePath)
Creates an input stream for the platform resource path and returns it. |
protected OutputStream |
createPlatformResourceOutputStream(String platformResourcePath)
Creates an output stream for the platform resource path and returns it. |
protected InputStream |
createURLInputStream(URI uri)
Creates an input stream for the URI, assuming it's a URL, and returns it. |
protected OutputStream |
createURLOutputStream(URI uri)
Creates an output stream for the URI, assuming it's a URL, and returns it. |
protected URIConverterImpl.URIMap |
getInternalURIMap()
Returns the internal version of the URI map. |
Map |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static IWorkspaceRoot workspaceRoot
protected URIConverterImpl.URIMap uriMap
Constructor Detail |
public URIConverterImpl()
Method Detail |
public OutputStream createOutputStream(URI uri) throws IOException
This implementation normalizes
the URI and uses that as the basis for further processing.
It factors out the URI schemes file
and platform
(with leading resource
segment)
for special processing by
createFileOutputStream
and
createPlatformResourceOutputStream
, respectively.
The file-based URI is converted
to a file path, e.g.,
file:///C:/directory/file -> C:/directory/fileand the platform-based URI is converted to a platform path by trimming the leading
platform:/resource
, e.g.,
platform:/resource/project/directory/file -> /project/directory/fileAll other cases are handled as standard URLs by
createURLOutputStream
.
createOutputStream
in interface URIConverter
IOException
- if there is a problem obtaining an open output stream.protected OutputStream createFileOutputStream(String filePath) throws IOException
This implementation allocates a FileOutputStream
and creates subdirectories as necessary.
IOException
- if there is a problem obtaining an open output stream.protected OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException
This implementation does one of two things, depending on the runtime environment.
If there is an Eclipse workspace, it delegates to
WorkbenchHelper.createPlatformResourceOutputStream
,
which gives the expected Eclipse behaviour.
Otherwise, the resolved
URI
is delegated to createOutputStream
for recursive processing.
IOException
- if there is a problem obtaining an open output stream or a valid interpretation of the path.EcorePlugin.resolvePlatformResourcePath(String)
protected OutputStream createURLOutputStream(URI uri) throws IOException
IOException
- if there is a problem obtaining an open output stream.public InputStream createInputStream(URI uri) throws IOException
This implementation normalizes
the URI and uses that as the basis for further processing.
It factors out the URI schemes file
and platform
(with leading resource
segment)
for special processing by
createFileInputStream
and
createPlatformResourceInputStream
, respectively.
The file-based URI is converted
to a file path, e.g.,
file:///C:/directory/file -> C:/directory/fileand the platform-based URI is converted to a platform path by trimming the leading
platform:/resource
, e.g.,
platform:/resource/project/directory/file -> /project/directory/fileAll other cases are handled as standard URLs by
createURLInputStream
.
createInputStream
in interface URIConverter
IOException
- if there is a problem obtaining an open input stream.protected InputStream createFileInputStream(String filePath) throws IOException
This implementation allocates a FileInputStream
.
IOException
- if there is a problem obtaining an open input stream.protected InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException
This implementation does one of two things, depending on the runtime environment.
If there is an Eclipse workspace, it delegates to
WorkbenchHelper.createPlatformResourceInputStream
,
which gives the expected Eclipse behaviour.
Otherwise, the resolved
URI
is delegated to createInputStream
for recursive processing.
IOException
- if there is a problem obtaining an open input stream or a valid interpretation of the path.EcorePlugin.resolvePlatformResourcePath(String)
protected InputStream createURLInputStream(URI uri) throws IOException
IOException
- if there is a problem obtaining an open input stream.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 Map 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 URIConverterImpl.URIMap getInternalURIMap()
|
Copyright 2001-2004 IBM Corporation and others. All Rights Reserved. |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |