Package ca.cgjennings.io.protocols.res
Class Handler
- java.lang.Object
-
- java.net.URLStreamHandler
-
- ca.cgjennings.io.protocols.MappedURLHandler
-
- ca.cgjennings.io.protocols.res.Handler
-
public class Handler extends MappedURLHandler
A URL protocol handler for theres:
protocol, which accesses application resources.URLs consist of these segments (where [...] indicates an optional segment):
res: [//] [/] [path/]* file
Where:
- [//]
- is optional, but makes it easier to distinguish URLs from files in user-supplied strings.
- [/]
- indicates that the path is not relative to /resources/, but to the default package (/)
- [path/]*
- is zero or more path entries (subfolders)
- [file]
- is the name of the resource file
Note: the unusual class name is required for this class to be used by the default protocol handler factory.
- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description Handler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.net.URL
mapURL(java.net.URL sourceURL)
Maps a URL in the handled protocol to one of the underlying URLs.-
Methods inherited from class ca.cgjennings.io.protocols.MappedURLHandler
getComposedPath, install, mapConnection, openConnection, removeRelativePathComponents
-
-
-
-
Method Detail
-
mapURL
protected java.net.URL mapURL(java.net.URL sourceURL) throws java.io.IOException
Description copied from class:MappedURLHandler
Maps a URL in the handled protocol to one of the underlying URLs. The base class returns the original URL.- Overrides:
mapURL
in classMappedURLHandler
- Parameters:
sourceURL
- a URL in the protocol handled by this handler- Returns:
- a URL using another protocol that maps to the same resource as
this handler, or
null
- Throws:
java.io.IOException
- if an I/O error occurs while composing the new URL
-
-