aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/net/AssetURLStreamHandler.java
blob: 6760646d52f4f22bc8046e018ee033f6410f3f97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
    }


}