sk.baka.webvm.analyzer.classloader
Class JarResourceLink

java.lang.Object
  extended by sk.baka.webvm.analyzer.classloader.ResourceLink
      extended by sk.baka.webvm.analyzer.classloader.JarResourceLink
All Implemented Interfaces:
Serializable

final class JarResourceLink
extends ResourceLink

Provides package information for an on-disk jar file.

Author:
Martin Vysny

Constructor Summary
JarResourceLink(File jarFile, String fullEntryName, boolean isRoot)
           
 
Method Summary
 File getContainer()
          Returns a file link to the resource container containing these links.
 String getFullName()
          Returns a full name, including parent packages and full path to the root.
 long getLength()
          Returns length of underlying resource.
 String getName()
          Returns the package/resource name.
 boolean isPackage()
          Checks if resource denoted by this object is actually a package, or just a resource file.
 boolean isRoot()
          Checks if this resource link denotes a root of a jar/directory.
 List<ResourceLink> list()
          Lists all direct child packages and items of this package.
 InputStream open()
          Opens a stream to the file denoted by this link.
 List<ResourceLink> search(String substring)
          Performs a search for given substring.
 String toString()
           
 
Methods inherited from class sk.baka.webvm.analyzer.classloader.ResourceLink
assertNotPackage, assertPackage, findFirstByName, getNames, listAndGroup, newFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JarResourceLink

JarResourceLink(File jarFile,
                String fullEntryName,
                boolean isRoot)
Method Detail

list

public List<ResourceLink> list()
                        throws IOException
Description copied from class: ResourceLink
Lists all direct child packages and items of this package. It is invalid to call this method on a non-package resource.

Specified by:
list in class ResourceLink
Returns:
list of all children.
Throws:
IOException - on i/o error

isPackage

public boolean isPackage()
Description copied from class: ResourceLink
Checks if resource denoted by this object is actually a package, or just a resource file.

Specified by:
isPackage in class ResourceLink
Returns:
true if this is a package, false otherwise. Root link is always a package.

open

public InputStream open()
                 throws IOException
Description copied from class: ResourceLink
Opens a stream to the file denoted by this link. It is invalid to call this method on a package resource.

Specified by:
open in class ResourceLink
Returns:
the file contents.
Throws:
IOException - on i/o error

getName

public String getName()
Description copied from class: ResourceLink
Returns the package/resource name. Does not include names of the parent packages nor any slash characters. Name of the root package is a full directory/jar file name.

Specified by:
getName in class ResourceLink
Returns:
the name of the resource denoted by this link.

getLength

public long getLength()
               throws IOException
Description copied from class: ResourceLink
Returns length of underlying resource.

Specified by:
getLength in class ResourceLink
Returns:
the length or -1 if not known or invoked on a package.
Throws:
IOException - on i/o error

isRoot

public boolean isRoot()
Description copied from class: ResourceLink
Checks if this resource link denotes a root of a jar/directory.

Specified by:
isRoot in class ResourceLink
Returns:
true if this is a jar/directory root, false otherwise.

getContainer

public File getContainer()
Description copied from class: ResourceLink
Returns a file link to the resource container containing these links. Required to be valid only for root links.

Specified by:
getContainer in class ResourceLink
Returns:
file denoting the container or null.

toString

public String toString()
Overrides:
toString in class ResourceLink

search

public List<ResourceLink> search(String substring)
                          throws IOException
Description copied from class: ResourceLink
Performs a search for given substring. The substring matching must be performed in the last resource path item only - i.e. the function will match the following for "a": /a, /a/a, /b/a, but not /a/b.

Specified by:
search in class ResourceLink
Parameters:
substring - a string to search, must not be null.
Returns:
non-null list of matched resources, may be empty.
Throws:
IOException - on i/o error

getFullName

public String getFullName()
Description copied from class: ResourceLink
Returns a full name, including parent packages and full path to the root. Must not end with a slash.

Specified by:
getFullName in class ResourceLink
Returns:
a full name.


Copyright © 2010 Baka. All Rights Reserved.