|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ungoverned.moduleloader.JarResourceSource
public class JarResourceSource
This class implements a ResourceSource for retrieving resources from a JAR file. The approach used by this implementation is to defer opening the JAR file until a request for a resource is made.
ResourceSource
Constructor Summary | |
---|---|
JarResourceSource(java.io.File file)
Constructs an instance using the specified file as the source of the JAR file. |
|
JarResourceSource(java.lang.String fileName)
Constructs an instance using the specified file name as the source of the JAR file. |
Method Summary | |
---|---|
void |
close()
This method deinitializes the resource source by closing the associated JAR file if it is open. |
protected void |
finalize()
Closes the JAR file if it has not already been closed. |
byte[] |
getBytes(java.lang.String name)
This method returns a byte array of the specified resource's contents. |
boolean |
hasResource(java.lang.String name)
This method returns a boolean indicating whether the resource source contains the specified resource. |
void |
open()
This method initializes the resource source. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JarResourceSource(java.lang.String fileName)
Constructs an instance using the specified file name as the source of the JAR file.
fileName
- the name of the JAR file to be used as the source.public JarResourceSource(java.io.File file)
Constructs an instance using the specified file as the source of the JAR file.
file
- the JAR file to be used as the source.Method Detail |
---|
protected void finalize()
Closes the JAR file if it has not already been closed.
finalize
in class java.lang.Object
public void open()
This method initializes the resource source. Since opening the JAR file is deferred until a request for a resource is actually made, this method really only sets a flag indicating that the resource source has been initialized.
open
in interface ResourceSource
public void close()
This method deinitializes the resource source by closing the associated JAR file if it is open.
close
in interface ResourceSource
public boolean hasResource(java.lang.String name) throws java.lang.IllegalStateException
ResourceSource
This method returns a boolean indicating whether the resource source contains the specified resource.
hasResource
in interface ResourceSource
name
- the name of the resource whose existence is being checked.
java.lang.IllegalStateException
- if the resource source has not
been opened.public byte[] getBytes(java.lang.String name) throws java.lang.IllegalStateException
ResourceSource
This method returns a byte array of the specified resource's contents.
getBytes
in interface ResourceSource
name
- the name of the resource to retrieve.
java.lang.IllegalStateException
- if the resource source has not
been opened.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |