ro.isdc.wro.model.resource.locator
Class ClasspathUriLocator

java.lang.Object
  extended by ro.isdc.wro.model.resource.locator.wildcard.WildcardUriLocatorSupport
      extended by ro.isdc.wro.model.resource.locator.ClasspathUriLocator
All Implemented Interfaces:
UriLocator

public class ClasspathUriLocator
extends WildcardUriLocatorSupport

Implementation of the UriLocator that is able to read a resource from a classpath.

Author:
Alex Objelean

Field Summary
static String ALIAS
          Alias used to register this locator with LocatorProvider.
static String PREFIX
          Prefix of the resource uri used to check if the resource can be read by this UriLocator implementation.
 
Constructor Summary
ClasspathUriLocator()
           
 
Method Summary
 boolean accept(String url)
          Check if this uri can be located by concrete implementation.
static boolean isValid(String uri)
          Check if a uri is a classpath resource.
 InputStream locate(String uri)
          Locates the uri by retrieving the InputStream.
 WildcardStreamLocator newWildcardStreamLocator()
          Builds a JarWildcardStreamLocator in order to get resources from the full classpath.
 
Methods inherited from class ro.isdc.wro.model.resource.locator.wildcard.WildcardUriLocatorSupport
getWildcardStreamLocator, isEnableWildcards, setEnableWildcards
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALIAS

public static final String ALIAS
Alias used to register this locator with LocatorProvider.

See Also:
Constant Field Values

PREFIX

public static final String PREFIX
Prefix of the resource uri used to check if the resource can be read by this UriLocator implementation.

See Also:
Constant Field Values
Constructor Detail

ClasspathUriLocator

public ClasspathUriLocator()
Method Detail

accept

public boolean accept(String url)
Check if this uri can be located by concrete implementation.

Parameters:
url - to read.
Returns:
true if UriLocator is able to return an InputStream of this uri.

isValid

public static boolean isValid(String uri)
Check if a uri is a classpath resource.

Parameters:
uri - to check.
Returns:
true if the uri is a classpath resource.

locate

public InputStream locate(String uri)
                   throws IOException
Locates the uri by retrieving the InputStream. The client is responsible for closing the InputStream.

Parameters:
uri - uri to read.
Returns:
InputStream for the provided uri.
Throws:
IOException - if the resource cannot be read for some reason.

newWildcardStreamLocator

public WildcardStreamLocator newWildcardStreamLocator()
Builds a JarWildcardStreamLocator in order to get resources from the full classpath.

Overrides:
newWildcardStreamLocator in class WildcardUriLocatorSupport
Returns:
default implementation of WildcardStreamLocator.


Copyright © 2008-2013. All Rights Reserved.