net.larsan.urd.util.fileset
Class JarFileSet.JarResource

java.lang.Object
  |
  +--net.larsan.urd.util.fileset.ResourceBase
        |
        +--net.larsan.urd.util.fileset.JarFileSet.JarResource
All Implemented Interfaces:
Certifiable, Resource
Enclosing class:
JarFileSet

public static class JarFileSet.JarResource
extends ResourceBase
implements Certifiable

Inner class for a resource within a jar archive.


Field Summary
 
Fields inherited from class net.larsan.urd.util.fileset.ResourceBase
errorHandler, filePath, size, visited
 
Constructor Summary
JarFileSet.JarResource(java.io.File file, java.util.jar.JarFile jarFile, java.lang.String filePath)
          Contruct the resource with a jar file, and a path (within the archive).
JarFileSet.JarResource(java.io.File file, java.util.jar.JarFile jarFile, java.lang.String filePath, long visited, ErrorHandler handler)
          Contruct the resource with a jar file, a path (within the archive) and a time when it was visited.
 
Method Summary
 void destroy()
          Destroy this resource.
 boolean exists()
          Check if the resource is valid.
 byte[] getBytes()
          Get a byte array from the file.
 java.security.cert.Certificate[] getCertificates()
          Get certificates for this entry.
 java.net.URL getCodeSource()
          Get the code source.
 java.io.InputStream getStream()
          Get a byte stream from the file.
 java.net.URL getURL()
          Get a URL to the resource.
 
Methods inherited from class net.larsan.urd.util.fileset.ResourceBase
equals, getErrorHandler, getFileSize, getPath, getVisitedTime, hashCode, report, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarFileSet.JarResource

public JarFileSet.JarResource(java.io.File file,
                              java.util.jar.JarFile jarFile,
                              java.lang.String filePath,
                              long visited,
                              ErrorHandler handler)
Contruct the resource with a jar file, a path (within the archive) and a time when it was visited.

Parameters:
file - JAR archive file
jarFile - Jar file object
filePath - File path within archive
visited - Time of file scan

JarFileSet.JarResource

public JarFileSet.JarResource(java.io.File file,
                              java.util.jar.JarFile jarFile,
                              java.lang.String filePath)
Contruct the resource with a jar file, and a path (within the archive).

Parameters:
file - JAR archive file
jarFile - Jar file object
filePath - File path within archive
Method Detail

destroy

public void destroy()
Destroy this resource.


getStream

public java.io.InputStream getStream()
Get a byte stream from the file. Should the resource have been disabled or removed before this method is called it will return null.

Specified by:
getStream in interface Resource
Specified by:
getStream in class ResourceBase
Returns:
A file input stream from the resource, or null if disabled
Throws:
java.io.IOException - On IO errors

getBytes

public byte[] getBytes()
Get a byte array from the file. Should the resource have been disabled or removed before this method is called it will return null.

Specified by:
getBytes in interface Resource
Specified by:
getBytes in class ResourceBase
Returns:
A byte array from the resource, or null if disabled
Throws:
java.io.IOException - On IO errors

getURL

public java.net.URL getURL()
Get a URL to the resource. Should the resource have been disabled or removed before this method is called it will return null.

Specified by:
getURL in interface Resource
Specified by:
getURL in class ResourceBase
Returns:
The resource URL, or null if disabled

getCodeSource

public java.net.URL getCodeSource()
Get the code source.

Specified by:
getCodeSource in interface Resource
Returns:
The resource code source

exists

public boolean exists()
Check if the resource is valid. This should return false if the underlying file have is removed or unusable.

Specified by:
exists in class ResourceBase
Returns:
True if the resource is still valid

getCertificates

public java.security.cert.Certificate[] getCertificates()
Get certificates for this entry. Returns null if the entry is not signed or not found.

Specified by:
getCertificates in interface Certifiable
Specified by:
getCertificates in class ResourceBase
Returns:
A Certificate array, or null if not signed.