com.jme.util.resource
Class RelativeResourceLocator

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

public class RelativeResourceLocator
extends java.lang.Object
implements ResourceLocator

A conservative ResourceLocator implementation that adds to the search path just the parent directory of the specified URI, and it is only used for resources requested with relative paths.

Relative paths may have multiple segments, like a/b/c.txt, they just can't be absolute, like /a/b.c.txt.

It is basic behavior of relative URL lookups that a lookup of "x" relative to "/a/b" would match both "/a/x" and "/a/b/x".

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

Constructor Summary
RelativeResourceLocator(java.net.URI baseUri)
           
RelativeResourceLocator(java.net.URL baseUrl)
          Convenience wrapper
 
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

RelativeResourceLocator

public RelativeResourceLocator(java.net.URI baseUri)

RelativeResourceLocator

public RelativeResourceLocator(java.net.URL baseUrl)
                        throws java.net.URISyntaxException
Convenience wrapper

Throws:
java.net.URISyntaxException - if input URL is invalid. Only doing this due to Java language contraints. Would prefer to throw an unchecked exception for this.
See Also:
RelativeResourceLocator(URI)
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