Top Description Fields Constructors Methods
com.jogamp.common.net

public abstract Class PiggybackURLConnection<I extends PiggybackURLContext>

extends URLConnection
Class Inheritance
Known Direct Subclasses
com.jogamp.common.net.AssetURLConnection
Imports
java.io.IOException, .InputStream, java.net.URL, .URLConnection

Generic resource location protocol connection, using another sub-protocol as the vehicle for a piggyback protocol.

The details of the sub-protocol can be queried using getSubProtocol().

See example in AssetURLConnection.

Field Summary

Modifier and TypeField and Description
protected I
protected URLConnection
protected URL
Inherited from java.net.URLConnection:
allowUserInteractionconnecteddoInputdoOutputifModifiedSinceurluseCaches

Constructor Summary

AccessConstructor and Description
protected
PiggybackURLConnection(final URL
the specific URL for this instance
url
,
final I
the piggyback context, defining state independent code and constants
context
)

Method Summary

Modifier and TypeMethod and Description
public synchronized void
public abstract String
getEntryName()

Returns the entry name of the asset.

public InputStream
getInputStream()

Overrides java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection.
public URL
getSubProtocol()

Returns the resolved sub protocol of the asset or null, ie:

Plain     asset:test/lala.txt
Resolved  asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
Result          jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
Inherited from java.net.URLConnection:
addRequestPropertygetAllowUserInteractiongetConnectTimeoutgetContentgetContentgetContentEncodinggetContentLengthgetContentLengthLonggetContentTypegetDategetDefaultAllowUserInteractiongetDefaultRequestPropertygetDefaultUseCachesgetDefaultUseCachesgetDoInputgetDoOutputgetExpirationgetFileNameMapgetHeaderFieldgetHeaderFieldgetHeaderFieldDategetHeaderFieldIntgetHeaderFieldKeygetHeaderFieldLonggetHeaderFieldsgetIfModifiedSincegetLastModifiedgetOutputStreamgetPermissiongetReadTimeoutgetRequestPropertiesgetRequestPropertygetURLgetUseCachesguessContentTypeFromNameguessContentTypeFromStreamsetAllowUserInteractionsetConnectTimeoutsetContentHandlerFactorysetDefaultAllowUserInteractionsetDefaultRequestPropertysetDefaultUseCachessetDefaultUseCachessetDoInputsetDoOutputsetFileNameMapsetIfModifiedSincesetReadTimeoutsetRequestPropertysetUseCachestoString

Field Detail

contextback to summary
protected I context
subConnback to summary
protected URLConnection subConn
subUrlback to summary
protected URL subUrl

Constructor Detail

PiggybackURLConnectionback to summary
protected PiggybackURLConnection(final URL url, final I context)
Parameters
url:URL

the specific URL for this instance

context:I

the piggyback context, defining state independent code and constants

Method Detail

connectback to summary
public synchronized void connect() throws IOException

Implements abstract java.net.URLConnection.connect.

Doc from java.net.URLConnection.connect.

Resolves the URL via PiggybackURLContext#resolve(String), see AssetURLContext#resolve(String) for an example.

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

If the connect method is called when the connection has already been opened (indicated by the connected field having the value true), the call is ignored.

URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while opening the connection.
getEntryNameback to summary
public abstract String getEntryName() throws IOException

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
Exceptions
IOException:
is not connected
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides java.net.URLConnection.getInputStream.

Doc from java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown when reading from the returned input stream if the read timeout expires before data is available for read.

Returns:InputStream

an input stream that reads from this open connection.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs while creating the input stream.
getSubProtocolback to summary
public URL getSubProtocol() throws IOException

Returns the resolved sub protocol of the asset or null, ie:

Plain     asset:test/lala.txt
Resolved  asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
Result          jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt
Exceptions
IOException:
is not connected