com.jogamp.common.net

## Class PiggybackURLConnection<I extends PiggybackURLContext>

- java.lang.Object
- - java.net.URLConnection
  - - com.jogamp.common.net.PiggybackURLConnection<I>

- Direct Known Subclasses:
    AssetURLConnection

      public abstract class PiggybackURLConnection<I extends PiggybackURLContext>
      extends 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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected I` | `context`
    `protected URLConnection` | `subConn`
    `protected URL` | `subUrl`

    - ### Fields inherited from class java.net.URLConnection

      `allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `PiggybackURLConnection(URL url, I context)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `connect()` Resolves the URL via `PiggybackURLContext.resolve(String)`, see `AssetURLContext.resolve(String)` for an example.
    `abstract String` | `getEntryName()` Returns the entry name of the asset.
    `InputStream` | `getInputStream()`
    `URL` | `getSubProtocol()` Returns the resolved sub protocol of the asset or null, ie:

    - ### Methods inherited from class java.net.URLConnection

      `addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, 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, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### subUrl

          protected URL subUrl

    - #### subConn

          protected URLConnection subConn

    - #### context

          protected I extends PiggybackURLContext context

  - ### Constructor Detail

    - #### PiggybackURLConnection

          protected PiggybackURLConnection(URL url,
                                I context)

      Parameters:
        `url` - the specific URL for this instance
        `context` - the piggyback context, defining state independent code and constants

  - ### Method Detail

    - #### connect

          public void connect()
                       throws IOException

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

      Specified by:
        `connect` in class `URLConnection`
      Throws:
        `IOException`

    - #### getInputStream

          public InputStream getInputStream()
                                     throws IOException

      Overrides:
        `getInputStream` in class `URLConnection`
      Throws:
        `IOException`

    - #### getEntryName

          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

      Throws:
        `IOException` - is not connected

    - #### getSubProtocol

          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

      Throws:
        `IOException` - is not connected