de.smartics.util.lang.classpath
Class ClassPathContext

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

public final class ClassPathContext
     
     
extends Object

A constraint on resources to be loaded from the class path.


Constructor Summary
ClassPathContext(ClassLoader classLoader, String archiveRoot)
          Default constructor.
 
Method Summary
 URL createUrl(String resource)
          Constructs the URL to the resource.
 boolean equals(Object object)
          Returns true if the given object is semantically equal to the given object, false otherwise.
 URL getResource(String resource)
          Constructs the URL to the resource.
 InputStream getResourceAsStream(String resource)
          Opens the stream to the resource.
 int hashCode()
          Returns the hash code of the object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassPathContext

public ClassPathContext(ClassLoader classLoader,
                        String archiveRoot)
                 throws NullPointerException
Default constructor.

Parameters:
classLoader - the class loader to load the directory listings.
archiveRoot - the value for archiveRoot.
Throws:
NullPointerException - if classLoader is null.
Method Detail

getResource

public URL getResource(String resource)
Constructs the URL to the resource.

Parameters:
resource - the resource whose URL is requested.
Returns:
the URL to the resource or null if the resource cannot be found on the class path.

getResourceAsStream

public InputStream getResourceAsStream(String resource)
Opens the stream to the resource.

Parameters:
resource - the resource whose stream is requested.
Returns:
the stream to the resource or null if the resource cannot be found on the class path. If a stream is returned, the client is responsible to close that stream.

createUrl

public URL createUrl(String resource)
              throws IllegalArgumentException
Constructs the URL to the resource.

Parameters:
resource - the resource whose URL is requested.
Returns:
the constructed URL.
Throws:
IllegalArgumentException - if the URL to the resource cannot be constructed.

hashCode

public int hashCode()
Returns the hash code of the object.

Overrides:
hashCode in class Object
Returns:
the hash code.

equals

public boolean equals(Object object)
Returns true if the given object is semantically equal to the given object, false otherwise.

Overrides:
equals in class Object
Parameters:
object - the instance to compare to.
Returns:
true if the given object is semantically equal to the given object, false otherwise.

toString

public String toString()
Overrides:
toString in class Object


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