Class ContextConnection
- java.lang.Object
-
- java.net.URLConnection
-
- org.apache.sling.launchpad.base.impl.ContextConnection
-
public class ContextConnection extends URLConnection
TheContextConnectionextends thejava.net.URLConnectionto provide access to a resource which is available fromLaunchpadContentProviderprovided toSling.This class is implemented by actually connecting to a resource URL which is provided by the resource provider and delegating the relevant method calls. Currently only
getContentLength(),getContentType(),getInputStream()andgetLastModified()are supported.
-
-
Field Summary
-
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()Accesses the the resource from the underlaying resource provider at the URL's path.intgetContentLength()Returns the length in bytes of the resource or -1 if this connection has not been connected yet.StringgetContentType()Returns a guess at the content type of the resource ornullif this connection has not been connected yet.InputStreamgetInputStream()Returns aInputStreamon the resource.longgetLastModified()Returns the last modification timestamp of the resource or -1 if this connection has not been connected yet.-
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLengthLong, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
-
-
-
-
Method Detail
-
connect
public void connect() throws IOExceptionAccesses the the resource from the underlaying resource provider at the URL's path.- Specified by:
connectin classURLConnection- Throws:
IOException
-
getContentLength
public int getContentLength()
Returns the length in bytes of the resource or -1 if this connection has not been connected yet.- Overrides:
getContentLengthin classURLConnection
-
getContentType
public String getContentType()
Returns a guess at the content type of the resource ornullif this connection has not been connected yet.- Overrides:
getContentTypein classURLConnection
-
getInputStream
public InputStream getInputStream() throws IOException
Returns aInputStreamon the resource. If this connection is not connected yet, the conneciton is opened.- Overrides:
getInputStreamin classURLConnection- Throws:
IOException- may be thrown if an error occurrs opening the connection or accessing the content as anInputStream.
-
getLastModified
public long getLastModified()
Returns the last modification timestamp of the resource or -1 if this connection has not been connected yet.- Overrides:
getLastModifiedin classURLConnection
-
-