Package com.jogamp.common.net
Class AssetURLConnection
- java.lang.Object
-
- java.net.URLConnection
-
- com.jogamp.common.net.PiggybackURLConnection<AssetURLContext>
-
- com.jogamp.common.net.AssetURLConnection
-
public class AssetURLConnection extends PiggybackURLConnection<AssetURLContext>
See base classPiggybackURLConnection
for motivation.asset resource location protocol connection.
See
AssetURLContext.resolve(String)
how resources are being resolved.Example:
Assuming the plain asset entrytest/lala.txt
is being resolved by a classtest.LaLaTest
, ie. using the asset aware ClassLoader, one would use the following asset aware filesystem layout:test/LaLaTest.class assets/test/lala.txt
The 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.txt
can be retrieved usingPiggybackURLConnection.getSubProtocol()
. In all above cases, the asset entry istest/lala.txt
, which can be retrieved viagetEntryName()
.General Implementation Notes:
An asset URL is resolved usingAssetURLContext.getClassLoader()
.getResource(String)
, hence the only requirement for an implementation is to have an asset aware ClassLoader as described inAssetURLContext.getClassLoader()
.Warning:
Since the asset protocol is currently not being implemented on all platform with an appropriate ClassLoader, a user shall not create the asset URL manually.
Android Implementation Notes:
The Android ClassLoader
AssetDexClassLoader
resolves the resource as an asset URL in it'sClassLoader.findResource(String)
implementation.Currently we attach our asset
URLStreamHandlerFactory
to allowURL
to handle asset URLs via our assetURLStreamHandler
implementation.
-
-
Field Summary
-
Fields inherited from class com.jogamp.common.net.PiggybackURLConnection
context, subConn, subUrl
-
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
-
-
Constructor Summary
Constructors Constructor Description AssetURLConnection(URL url, AssetURLContext implHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getEntryName()
Returns the entry name of the asset.-
Methods inherited from class com.jogamp.common.net.PiggybackURLConnection
connect, getInputStream, getSubProtocol
-
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, 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, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
-
-
-
-
Constructor Detail
-
AssetURLConnection
public AssetURLConnection(URL url, AssetURLContext implHelper)
-
-
Method Detail
-
getEntryName
public String getEntryName() throws IOException
Description copied from class:PiggybackURLConnection
Returns the entry name of the asset.Plain asset:test/lala.txt Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt Result test/lala.txt
- Specified by:
getEntryName
in classPiggybackURLConnection<AssetURLContext>
- Throws:
IOException
- is not connected
-
-