public class AssetURLConnection extends PiggybackURLConnection<AssetURLContext>
PiggybackURLConnection
for motivation.
asset resource location protocol connection.
See AssetURLContext.resolve(String)
how resources are being resolved.
test/lala.txt
is being resolved by
a class test.LaLaTest
, ie. using the asset aware ClassLoader,
one would use the following asset aware filesystem layout:
test/LaLaTest.class assets/test/lala.txtThe above maybe on a plain filesystem, or within a JAR or an APK file, e.g.
jogamp.test.apk
.
The above would result in the following possible URLs
reflecting the plain and resolved state of the asset URL:
0 Entry test/lala.txt 1 Plain asset:test/lala.txt 2 Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
The sub protocol URL of the resolved asset
3 Sub-URL jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txtcan be retrieved using
PiggybackURLConnection.getSubProtocol()
.
In all above cases, the asset entry is test/lala.txt
,
which can be retrieved via getEntryName()
.
AssetURLContext.getClassLoader()
.getResource(String)
,
hence the only requirement for an implementation is to have an asset aware ClassLoader
as described in AssetURLContext.getClassLoader()
.
The Android ClassLoader jogamp.android.launcher.AssetDexClassLoader
resolves the resource as an asset URL in it's ClassLoader.findResource(String)
implementation.
Currently we attach our asset URLStreamHandlerFactory
to allow URL
to handle asset URLs via our asset URLStreamHandler
implementation.
context, subConn, subUrl
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
Constructor and Description |
---|
AssetURLConnection(URL url,
AssetURLContext implHelper) |
Modifier and Type | Method and Description |
---|---|
String |
getEntryName()
Returns the entry name of the asset.
|
connect, getInputStream, getSubProtocol
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
public AssetURLConnection(URL url, AssetURLContext implHelper)
public String getEntryName() throws IOException
PiggybackURLConnection
Plain asset:test/lala.txt Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt Result test/lala.txt
getEntryName
in class PiggybackURLConnection<AssetURLContext>
IOException
- is not connected