diff options
Diffstat (limited to 'src/java/com/jogamp/common/net/AssetURLStreamHandler.java')
-rw-r--r-- | src/java/com/jogamp/common/net/AssetURLStreamHandler.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/net/AssetURLStreamHandler.java b/src/java/com/jogamp/common/net/AssetURLStreamHandler.java new file mode 100644 index 0000000..8d95b2d --- /dev/null +++ b/src/java/com/jogamp/common/net/AssetURLStreamHandler.java @@ -0,0 +1,37 @@ +package com.jogamp.common.net; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +import com.jogamp.common.net.AssetURLConnection; + +/** + * {@link URLStreamHandler} to handle the asset protocol. + * + * <p> + * This is the <i>asset</i> URLStreamHandler variation + * for manual use. + * </p> + * <p> + * It requires passing a valid {@link AssetURLContext} + * for construction, hence it's not suitable for the pkg factory model. + * </p> + */ +public class AssetURLStreamHandler extends URLStreamHandler { + AssetURLContext ctx; + + public AssetURLStreamHandler(AssetURLContext ctx) { + this.ctx = ctx; + } + + @Override + protected URLConnection openConnection(URL u) throws IOException { + final AssetURLConnection c = new AssetURLConnection(u, ctx); + c.connect(); + return c; + } + + +} |