Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.emory.mathcs.util.classloader
Class ResourceHandle  view ResourceHandle download ResourceHandle.java

java.lang.Object
  extended byedu.emory.mathcs.util.classloader.ResourceHandle
Direct Known Subclasses:
ResourceLoader.JarResourceHandle

public abstract class ResourceHandle
extends java.lang.Object

This class represents a handle (a connection) to some resource, which may be a class, native library, text file, image, etc. Handles are returned by ResourceLoader's get methods. Having the resource handle, in addition to accessing the resource data (using methods getInputStream() 55 or getBytes() 55 ) as well as access resource metadata, such as attributes, certificates, etc.

As soon as the handle is no longer in use, it should be explicitly close() 55 d, similarly to I/O streams.

Version:
1.0

Constructor Summary
ResourceHandle()
           
 
Method Summary
 void close()
          Closes a connection to the resource indentified by this handle.
 java.util.jar.Attributes getAttributes()
          Return the Attributes of the resource, or null if none.
 byte[] getBytes()
          Returns this resource data as an array of bytes.
 java.security.cert.Certificate[] getCertificates()
          Return the Certificates of the resource, or null if none.
abstract  java.net.URL getCodeSourceURL()
          Returns the CodeSource URL for the class or resource.
abstract  int getContentLength()
          Returns the length of this resource data, or -1 if unknown.
abstract  java.io.InputStream getInputStream()
          Returns and InputStream for reading this resource data.
 java.util.jar.Manifest getManifest()
          Returns the Manifest of the JAR file from which this resource was loaded, or null if none.
abstract  java.lang.String getName()
          Return the name of the resource.
abstract  java.net.URL getURL()
          Returns the URL of the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceHandle

public ResourceHandle()
Method Detail

getName

public abstract java.lang.String getName()
Return the name of the resource. The name is a "/"-separated path name that identifies the resource.


getURL

public abstract java.net.URL getURL()
Returns the URL of the resource.


getCodeSourceURL

public abstract java.net.URL getCodeSourceURL()
Returns the CodeSource URL for the class or resource.


getInputStream

public abstract java.io.InputStream getInputStream()
                                            throws java.io.IOException
Returns and InputStream for reading this resource data.


getContentLength

public abstract int getContentLength()
                              throws java.io.IOException
Returns the length of this resource data, or -1 if unknown.


getBytes

public byte[] getBytes()
                throws java.io.IOException
Returns this resource data as an array of bytes.


getManifest

public java.util.jar.Manifest getManifest()
                                   throws java.io.IOException
Returns the Manifest of the JAR file from which this resource was loaded, or null if none.


getCertificates

public java.security.cert.Certificate[] getCertificates()
Return the Certificates of the resource, or null if none.


getAttributes

public java.util.jar.Attributes getAttributes()
                                       throws java.io.IOException
Return the Attributes of the resource, or null if none.


close

public void close()
Closes a connection to the resource indentified by this handle. Releases any I/O objects associated with the handle.