jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
See PiggybackURLConnection
for description and examples.
More...
Public Member Functions | |
abstract ClassLoader | getClassLoader () |
Returns an asset aware ClassLoader. More... | |
String | getImplementedProtocol () |
Returns the specific protocol, constant for this implementation. More... | |
URLConnection | resolve (final String path) throws IOException |
Resolving path to a URL sub protocol and return it's open URLConnection. More... | |
String | getImplementedProtocol () |
Returns the specific protocol, constant for this implementation. More... | |
URLConnection | resolve (String path) throws IOException |
Resolving path to a URL sub protocol and return it's open URLConnection. More... | |
Static Public Member Functions | |
static AssetURLContext | create (final ClassLoader cl) |
static AssetURLStreamHandler | createHandler (final ClassLoader cl) |
static URL | createURL (final String path, final ClassLoader cl) throws MalformedURLException |
Create an asset URL, suitable even w/o the registered asset URLStreamHandler. More... | |
static URL | createURL (final String path) throws MalformedURLException |
Create an asset URL, suitable only with the registered asset URLStreamHandler. More... | |
static URLStreamHandler | getRegisteredHandler () |
Returns the asset handler previously set via registerHandler(ClassLoader) , or null if none was set. More... | |
static boolean | registerHandler (final ClassLoader cl) |
Registers the generic URLStreamHandlerFactory via GenericURLStreamHandlerFactory#register() and if successful sets the asset handler for the given ClassLoader cl . More... | |
static URLConnection | resolve (String path, final ClassLoader cl) throws IOException |
static URLConnection | getResource (final String resourcePath, final ClassLoader cl) |
Locating a resource using the ClassLoader's facilities. More... | |
Static Public Attributes | |
static final String | asset_protocol = "asset" |
The asset URL protocol name asset More... | |
static final String | asset_protocol_prefix = "asset:" |
The asset URL protocol prefix asset: More... | |
static final String | assets_folder = "assets/" |
The optional asset folder name with ending slash assets/ . More... | |
See PiggybackURLConnection
for description and examples.
Definition at line 44 of file AssetURLContext.java.
|
static |
Definition at line 62 of file AssetURLContext.java.
|
static |
Definition at line 71 of file AssetURLContext.java.
|
static |
Create an asset URL, suitable only with the registered asset URLStreamHandler.
This is equivalent with:
return new URL(path.startsWith("asset:") ? path : "asset:" + path);
path | resource path, with or w/o asset: prefix |
MalformedURLException |
Definition at line 104 of file AssetURLContext.java.
|
static |
Create an asset URL, suitable even w/o the registered asset URLStreamHandler.
This is equivalent with:
return new URL(null, path.startsWith("asset:") ? path : "asset:" + path, new AssetURLStreamHandler(cl));
path | resource path, with or w/o asset: prefix |
cl | the ClassLoader used to resolve the location, see getClassLoader() . |
MalformedURLException |
Definition at line 88 of file AssetURLContext.java.
|
abstract |
Returns an asset aware ClassLoader.
The ClassLoader is required to find the asset resource via it's URL findResource(String)
implementation.
It's URL findResource(String)
implementation shall return either an asset URL asset:sub-protocol
or just the sub-protocol URL.
For example, on Android, we redirect all path
request to assets/path
.
String org.jau.net.AssetURLContext.getImplementedProtocol | ( | ) |
Returns the specific protocol, constant for this implementation.
Implements org.jau.net.PiggybackURLContext.
Definition at line 150 of file AssetURLContext.java.
|
static |
Returns the asset handler previously set via registerHandler(ClassLoader)
, or null if none was set.
Definition at line 112 of file AssetURLContext.java.
|
static |
Locating a resource using the ClassLoader's facilities.
Returns the resolved and connected URLConnection or null if not found.
Definition at line 253 of file AssetURLContext.java.
|
static |
Registers the generic URLStreamHandlerFactory via GenericURLStreamHandlerFactory#register()
and if successful sets the asset handler
for the given ClassLoader cl
.
Definition at line 123 of file AssetURLContext.java.
URLConnection org.jau.net.AssetURLContext.resolve | ( | final String | path | ) | throws IOException |
Resolving path to a URL sub protocol and return it's open URLConnection.
This implementation attempts to resolve path
in the following order:
new URL(path)
, use sub-protocol if asset URL getClassLoader()
.getResource(path)
, use sub-protocol if asset URL new File(path).toURI().toURL()
In case of using the ClassLoader (2) and if running on Android, the assets_folder
is being prepended to path
if missing.
Implements org.jau.net.PiggybackURLContext.
Definition at line 170 of file AssetURLContext.java.
|
static |
|
static |
The asset URL protocol name asset
Definition at line 48 of file AssetURLContext.java.
|
static |
The asset URL protocol prefix asset:
Definition at line 51 of file AssetURLContext.java.
|
static |
The optional asset folder name with ending slash assets/
.
Note that the asset folder is not used on all platforms using the asset protocol and you should not rely on it, use AssetURLConnection#getEntryName()
.
Definition at line 60 of file AssetURLContext.java.