|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator
ro.isdc.wro.model.resource.locator.wildcard.JarWildcardStreamLocator
public class JarWildcardStreamLocator
Resolves classpath resources looking for wildcard patterns in both file system and in JAR files.
The locateStream(String, File) overrides the default strategy defined in
DefaultWildcardStreamLocator and it tries to open the provided file as a JAR. If that's successfully opened
all entries inside this container will be verified against the wildcard pattern. If the JAR-lookup strategy fails,
default strategy is invoked.
For the moment this WildcardStreamLocator only supports a single wildcard.
| Field Summary |
|---|
| Fields inherited from class ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator |
|---|
RECURSIVE_WILDCARD |
| Constructor Summary | |
|---|---|
JarWildcardStreamLocator()
|
|
| Method Summary | |
|---|---|
protected boolean |
accept(JarEntry entry,
String wildcard)
Validates an entry against a wildcard and determines whether the pattern matches or not. |
protected List<String> |
getSupportedContainerExtensions()
Returns a list of file extensions of all valid JAR files. |
InputStream |
locateStream(String uri,
File folder)
Finds the specified URI pattern inside a JAR file. |
protected InputStream |
locateStreamFromJar(String uri,
File jarPath)
Finds the specified wildcard-URI resource(s) inside a JAR file and returns an InputStream to read a bundle
of matching resources. |
protected JarFile |
open(File jarFile)
Opens the specified JAR file and returns a valid handle. |
| Methods inherited from class ro.isdc.wro.model.resource.locator.wildcard.DefaultWildcardStreamLocator |
|---|
handleFoundResources, hasWildcard, setWildcardExpanderHandler |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JarWildcardStreamLocator()
| Method Detail |
|---|
public InputStream locateStream(String uri,
File folder)
throws IOException
locateStream in interface WildcardStreamLocatorlocateStream in class DefaultWildcardStreamLocatoruri - 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.
InputStream to the resources collection matching the wildcard.
IOException - if folder is invalid or when I/O error occurs while locating the stream.protected List<String> getSupportedContainerExtensions()
List of file extensions including the final dot. Valid examples are: .jar, .war. By default it
only supports .jar extension.
protected boolean accept(JarEntry entry,
String wildcard)
InputStream.
entry - Entry to evaluate. It cannot be null.wildcard - Wildcard to match. It cannot be null or empty.
true if the expression matches, false otherwise.protected JarFile open(File jarFile)
jarFile - Location of the valid JAR file to read. It cannot be null.
JarFile to read resources.
IllegalArgumentException - If the file cannot be opened because an IOException.
protected final InputStream locateStreamFromJar(String uri,
File jarPath)
throws IOException
InputStream to read a bundle
of matching resources.
uri - Resource(s) URI to match. It cannot be null or empty.jarPath - A valid JAR file. It cannot be null.
InputStream to read the bundle. Clients are responsible of closing this InputStream
.
IOException - If there's any error reading the JAR file.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||