de.smartics.util.lang.classpath
Class ClassPathDirectoryListing

java.lang.Object
  extended by de.smartics.util.lang.classpath.ClassPathDirectoryListing

public class ClassPathDirectoryListing
     
     
extends Object

Lists the content of a directory on the class path.

Currently only the protocols

  1. file system (file) and
  2. JAR files (jar)

are supported.


Constructor Summary
ClassPathDirectoryListing(ClassLoader classLoader)
          Default constructor.
ClassPathDirectoryListing(ClassPathContext context)
          Default constructor.
 
Method Summary
 ClassPathContext getClassPathContext()
          Returns the context to load the directory listings.
 List<String> list(String resourcePath)
          Lists the contents of the resource path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassPathDirectoryListing

public ClassPathDirectoryListing(ClassLoader classLoader)
                          throws NullPointerException
Default constructor.

Parameters:
classLoader - the class loader to load the directory listings.
Throws:
NullPointerException - if classLoader is null.

ClassPathDirectoryListing

public ClassPathDirectoryListing(ClassPathContext context)
                          throws NullPointerException
Default constructor.

Parameters:
context - the context to load the directory listings.
Throws:
NullPointerException - if classLoader is null.
Method Detail

getClassPathContext

public final ClassPathContext getClassPathContext()
Returns the context to load the directory listings.

Returns:
the context to load the directory listings.

list

public List<String> list(String resourcePath)
                  throws NullPointerException,
                         IllegalArgumentException
Lists the contents of the resource path.

Implementation Notes:
Sub classes may override this method to add additional protocol handlers. Call this method, if the derived handler does not handle the protocol.
Parameters:
resourcePath - the path to the resource whose contents is to be listed. The empty string returns the contents of the class loader's root directory (which is usually the parent class loader's root).
Returns:
the contents of the resource as names. The list may be empty, but is never null.
Throws:
NullPointerException - if resourcePath is null.
IllegalArgumentException - if resource path cannot be resolved to determine the contents. Either the protocol is unknown or there is a problem to access the resource's content physically.


Copyright © 2011-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.