GlueGen
v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java (public API).
PiggybackURLConnection.java
Go to the documentation of this file.
1
package
com.jogamp.common.net;
2
3
import
java.io.IOException;
4
import
java.io.InputStream;
5
import
java.net.URL;
6
import
java.net.URLConnection;
7
8
/**
9
* Generic resource location protocol connection,
10
* using another sub-protocol as the vehicle for a piggyback protocol.
11
* <p>
12
* The details of the sub-protocol can be queried using {@link #getSubProtocol()}.
13
* </p>
14
* <p>
15
* See example in {@link AssetURLConnection}.
16
* </p>
17
*/
18
public
abstract
class
PiggybackURLConnection
<I
extends
PiggybackURLContext
> extends URLConnection {
19
protected
URL
subUrl
;
20
protected
URLConnection
subConn
;
21
protected
I
context
;
22
23
/**
24
* @param url the specific URL for this instance
25
* @param context the piggyback context, defining state independent code and constants
26
*/
27
protected
PiggybackURLConnection
(
final
URL url,
final
I
context
) {
28
super(url);
29
this.context =
context
;
30
}
31
32
/**
33
* <p>
34
* Resolves the URL via {@link PiggybackURLContext#resolve(String)},
35
* see {@link AssetURLContext#resolve(String)} for an example.
36
* </p>
37
*
38
* {@inheritDoc}
39
*/
40
@Override
41
public
synchronized
void
connect
() throws IOException {
42
if
(!connected) {
43
subConn
=
context
.resolve(url.getPath());
44
subUrl
=
subConn
.getURL();
45
connected =
true
;
46
}
47
}
48
49
@Override
50
public
InputStream
getInputStream
() throws IOException {
51
if
(!connected) {
52
throw
new
IOException(
"not connected"
);
53
}
54
return
subConn
.getInputStream();
55
}
56
57
/**
58
* Returns the <i>entry name</i> of the asset.
59
* <pre>
60
* Plain asset:test/lala.txt
61
* Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
62
* Result test/lala.txt
63
* </pre>
64
* @throws IOException is not connected
65
**/
66
public
abstract
String
getEntryName
() throws IOException;
67
68
/**
69
* Returns the resolved <i>sub protocol</i> of the asset or null, ie:
70
* <pre>
71
* Plain asset:test/lala.txt
72
* Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
73
* Result jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
74
* </pre>
75
*
76
* @throws IOException is not connected
77
*/
78
public URL
getSubProtocol
() throws IOException {
79
if
(!connected) {
80
throw
new
IOException(
"not connected"
);
81
}
82
return
subUrl
;
83
}
84
}
com.jogamp.common.net.PiggybackURLConnection
Generic resource location protocol connection, using another sub-protocol as the vehicle for a piggyb...
Definition:
PiggybackURLConnection.java:18
com.jogamp.common.net.PiggybackURLConnection.PiggybackURLConnection
PiggybackURLConnection(final URL url, final I context)
Definition:
PiggybackURLConnection.java:27
com.jogamp.common.net.PiggybackURLConnection.subConn
URLConnection subConn
Definition:
PiggybackURLConnection.java:20
com.jogamp.common.net.PiggybackURLConnection.connect
synchronized void connect()
Definition:
PiggybackURLConnection.java:41
com.jogamp.common.net.PiggybackURLConnection.getInputStream
InputStream getInputStream()
Definition:
PiggybackURLConnection.java:50
com.jogamp.common.net.PiggybackURLConnection.context
I context
Definition:
PiggybackURLConnection.java:21
com.jogamp.common.net.PiggybackURLConnection.getEntryName
abstract String getEntryName()
Returns the entry name of the asset.
com.jogamp.common.net.PiggybackURLConnection.subUrl
URL subUrl
Definition:
PiggybackURLConnection.java:19
com.jogamp.common.net.PiggybackURLConnection.getSubProtocol
URL getSubProtocol()
Returns the resolved sub protocol of the asset or null, ie:
Definition:
PiggybackURLConnection.java:78
com.jogamp.common.net.PiggybackURLContext
See PiggybackURLConnection for description and examples.
Definition:
PiggybackURLContext.java:9
src
java
com
jogamp
common
net
PiggybackURLConnection.java
Generated by
1.9.4