ro.isdc.wro.model.resource.locator.wildcard
Class DefaultWildcardStreamLocator

java.lang.Object
  extended by ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator
All Implemented Interfaces:
WildcardExpandedHandlerAware, WildcardStreamLocator
Direct Known Subclasses:
JarWildcardStreamLocator

public class DefaultWildcardStreamLocator
extends Object
implements WildcardStreamLocator, WildcardExpandedHandlerAware

Default implementation of WildcardStreamLocator.

Author:
Alex Objelean

Field Summary
static String RECURSIVE_WILDCARD
          Character to distinguish wildcard inside the uri.
 
Constructor Summary
DefaultWildcardStreamLocator()
          Creates a WildcardStream locator which doesn't care about detecting duplicate resources.
 
Method Summary
protected  void handleFoundResources(Collection<File> files)
          The default implementation does nothing.
 boolean hasWildcard(String uri)
          
 InputStream locateStream(String uri, File folder)
          Locates the stream based on the fileName containing the wildcard and the folder where to search.
 void setWildcardExpanderHandler(Transformer<Collection<File>> handler)
          Sets the handler to be used by the implementing class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECURSIVE_WILDCARD

public static final String RECURSIVE_WILDCARD
Character to distinguish wildcard inside the uri.

See Also:
Constant Field Values
Constructor Detail

DefaultWildcardStreamLocator

public DefaultWildcardStreamLocator()
Creates a WildcardStream locator which doesn't care about detecting duplicate resources.

Method Detail

hasWildcard

public boolean hasWildcard(String uri)

Specified by:
hasWildcard in interface WildcardStreamLocator
Parameters:
uri - to check
Returns:
true if the uri contains a wildcard.

locateStream

public InputStream locateStream(String uri,
                                File folder)
                         throws IOException
Locates the stream based on the fileName containing the wildcard and the folder where to search.

Specified by:
locateStream in interface WildcardStreamLocator
Parameters:
uri - the resource of the uri to locate. This uri should be exactly the same as defined in Resource.
folder - parent from where the search of fileNameWithWildcard should start.
Returns:
InputStream to the resources collection matching the wildcard.
Throws:
IOException - if folder is invalid or when I/O error occurs while locating the stream.

handleFoundResources

protected void handleFoundResources(Collection<File> files)
                             throws IOException
The default implementation does nothing. Useful for unit test to check if the order is as expected.

Parameters:
files - a collection of found resources after the wildcard has beed applied on the searched folder.
Throws:
IOException

setWildcardExpanderHandler

public void setWildcardExpanderHandler(Transformer<Collection<File>> handler)
Sets the handler to be used by the implementing class.

Specified by:
setWildcardExpanderHandler in interface WildcardExpandedHandlerAware
Parameters:
handler - a Transformer which does the handler job. The Transformer is not the ideal interface to be used, but it can be a temporary solution until a better one is found.


Copyright © 2008-2011. All Rights Reserved.