com.jme.util.resource
Class AbsoluteResourceLocator

java.lang.Object
  extended by com.jme.util.resource.AbsoluteResourceLocator
All Implemented Interfaces:
ResourceLocator

public class AbsoluteResourceLocator
extends java.lang.Object
implements ResourceLocator

A conservative ResourceLocator implementation that only resolves resources with absolute resource name paths. It may be used in two ways

Either way, lookups succeed only for resources requested with absolute paths, and there is no recursion.

This ResourceLocator is specifically NOT for loading resources from the Classpath. Use *Classpath*ResourceLocator class(es) for that purpose.

Author:
Blaine Simpson (blaine dot simpson at admc dot com)
See Also:
ResourceLocator

Constructor Summary
AbsoluteResourceLocator()
          Instantiate a locator for any resource present at the specified absolute resource path.
AbsoluteResourceLocator(java.net.URI baseUri)
          Instantiate a locator for resources residing underneath the specified base URI, and requested with absolute path.
 
Method Summary
 java.net.URL locateResource(java.lang.String resourceName)
          Locates a resource according to the strategy of the resource locator implementation (subclass).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbsoluteResourceLocator

public AbsoluteResourceLocator()
Instantiate a locator for any resource present at the specified absolute resource path.


AbsoluteResourceLocator

public AbsoluteResourceLocator(java.net.URI baseUri)
Instantiate a locator for resources residing underneath the specified base URI, and requested with absolute path.

To restrict to any absolute paths within a URI base, use a URI path of just "/", like new URI("http://acme.com/") or new File("/").toURI().

A rather non-intuitive aspect of Java file URIs, is that a trailing "/" will be truncated unless the item is present and is a directory... And also that resolution of URL paths ending with /, like "/home/blaine/info.txt/" will succeed and can read the file.

Parameters:
baseURI - IMPORTANT: The whole purpose here is to specify a path with an absolue path to validate against. Therefore, to cover an entire web site, you must use http://pub.admc.com/, not http://pub.admc.com.
Throws:
java.lang.IllegalArgumentException - if the specified baseUri does not have an absolue URI path, or is otherwise unacceptable.
Method Detail

locateResource

public java.net.URL locateResource(java.lang.String resourceName)
Description copied from interface: ResourceLocator
Locates a resource according to the strategy of the resource locator implementation (subclass).

Specified by:
locateResource in interface ResourceLocator
Parameters:
resourceName - the name of the resource to locate; it this is a path it must be slash separated (no backslashes)
Returns:
a URL for the resource, null if the resource was not found
See Also:
SimpleResourceLocator, MultiFormatResourceLocator