|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.jogamp.common.net.AssetURLContext
public abstract class AssetURLContext
See PiggybackURLConnection for description and examples.
| Field Summary | |
|---|---|
static String |
asset_protocol
The asset URL protocol name asset |
static String |
asset_protocol_prefix
The asset URL protocol prefix asset: |
static String |
assets_folder
The optional asset folder name with ending slash assets/. |
| Constructor Summary | |
|---|---|
AssetURLContext()
|
|
| Method Summary | |
|---|---|
static AssetURLContext |
create(ClassLoader cl)
|
static AssetURLStreamHandler |
createHandler(ClassLoader cl)
|
static URL |
createURL(String path)
Create an asset URL, suitable only with the registered asset URLStreamHandler. |
static URL |
createURL(String path,
ClassLoader cl)
Create an asset URL, suitable even w/o the registered asset URLStreamHandler. |
abstract ClassLoader |
getClassLoader()
Returns an asset aware ClassLoader. |
String |
getImplementedProtocol()
Returns the specific protocol, constant for this implementation. |
static URLStreamHandler |
getRegisteredHandler()
Returns the asset handler previously set via registerHandler(ClassLoader),
or null if none was set. |
static boolean |
registerHandler(ClassLoader cl)
Registers the generic URLStreamHandlerFactory via GenericURLStreamHandlerFactory.register()
and if successful sets the asset handler for the given ClassLoader cl. |
URLConnection |
resolve(String path)
Resolving path to a URL sub protocol and return it's open URLConnection |
static URLConnection |
resolve(String path,
ClassLoader cl)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String asset_protocol
asset
public static final String asset_protocol_prefix
asset:
public static final String assets_folder
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().
| Constructor Detail |
|---|
public AssetURLContext()
| Method Detail |
|---|
public static AssetURLContext create(ClassLoader cl)
public static AssetURLStreamHandler createHandler(ClassLoader cl)
public static URL createURL(String path,
ClassLoader cl)
throws MalformedURLException
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: prefixcl - the ClassLoader used to resolve the location, see getClassLoader().
MalformedURLException
public static URL createURL(String path)
throws MalformedURLException
This is equivalent with:
return new URL(path.startsWith("asset:") ? path : "asset:" + path);
path - resource path, with or w/o asset: prefix
MalformedURLExceptionpublic static URLStreamHandler getRegisteredHandler()
registerHandler(ClassLoader),
or null if none was set.
public static boolean registerHandler(ClassLoader cl)
GenericURLStreamHandlerFactory.register()
and if successful sets the asset handler for the given ClassLoader cl.
public abstract ClassLoader getClassLoader()
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.
public String getImplementedProtocol()
PiggybackURLContext
getImplementedProtocol in interface PiggybackURLContext
public URLConnection resolve(String path)
throws IOException
This implementation attempts to resolve path in the following order:
new URL(path), use sub-protocol if asset URLgetClassLoader().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.
resolve in interface PiggybackURLContextIOException
public static URLConnection resolve(String path,
ClassLoader cl)
throws IOException
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||