net.larsan.urd.util.fileset
Class RegexpFileSet

java.lang.Object
  |
  +--net.larsan.urd.util.fileset.FileSet
        |
        +--net.larsan.urd.util.fileset.RegexpFileSet
All Implemented Interfaces:
ResourceLocator
Direct Known Subclasses:
WatchedFileSet

public class RegexpFileSet
extends FileSet

A file set that filters it's scan operation using a regular expression pattern. The pattern is provided in the constructor of this class and cannot be changed afterwards. This file only operates on flat files and will not attempt to open arcives.

This class is recursive by default.

This class is synchronized.

This class does not support signed resources.

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Field Summary
protected  java.util.HashMap resources
          Hash map of path strings mapped to resources.
 
Fields inherited from class net.larsan.urd.util.fileset.FileSet
root
 
Constructor Summary
RegexpFileSet(java.io.File root)
          Construct a file set using a root but without a regular expression.
RegexpFileSet(java.io.File root, java.lang.String regexp)
          Construct a file set using a root folder and a regular expression.
 
Method Summary
 java.security.cert.Certificate[] getCertificates(Resource resource)
          Get the certificates for a resource.
 Resource getResource(java.lang.String path)
          Get a resource from the set.
 java.lang.String[] getResourcePaths()
          Get all available resources ids.
 void scan()
          Perform a new scan of available files for the set.
 
Methods inherited from class net.larsan.urd.util.fileset.FileSet
getErrorHandler, isRecursive, matches, resolvePath, setErrorHandler, setIsRecursive, setRegexpPattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resources

protected java.util.HashMap resources
Hash map of path strings mapped to resources. The file paths will be mapped relative to the file set root without preceeding slash.

Constructor Detail

RegexpFileSet

public RegexpFileSet(java.io.File root,
                     java.lang.String regexp)
              throws java.io.IOException,
                     java.util.regex.PatternSyntaxException
Construct a file set using a root folder and a regular expression. An IOException will be thrown if the root folder does not exists (or is a file) and a PatternSyntaxException if the regular expression is invalid.

Parameters:
root - File set root folder, must exist
regexp - Perl 5 regular expression to filter file set resources with
Throws:
java.io.IOException - If the file set root does not exist, or is a file
java.util.regex.PatternSyntaxException - If the regular expression is not valid

RegexpFileSet

public RegexpFileSet(java.io.File root)
              throws java.io.IOException
Construct a file set using a root but without a regular expression. An IOException will be thrown if the root folder does not exists (or is a file).

Parameters:
root - File set root folder, must exist
Throws:
java.io.IOException - If the file set root does not exist, or is a file
Method Detail

scan

public void scan()
          throws java.io.IOException
Perform a new scan of available files for the set.

The string array returned contains all available resources as identified by their relative path to the file set root.

Specified by:
scan in class FileSet
Returns:
A string array of relative paths, an empty array will be returned if the set is empty
Throws:
An - IOException should the scan fail
java.io.IOException - If the scan fails

getResourcePaths

public java.lang.String[] getResourcePaths()
Get all available resources ids. This arrays should be empty if the file set is empty.

Specified by:
getResourcePaths in class FileSet
Returns:
A string array of relative paths, an empty array will be returned if the set is empty

getResource

public Resource getResource(java.lang.String path)
Get a resource from the set. This should return a Resource if the resource is found or null if not. The parameter should be a relative path as returned by getResourcePaths.

Specified by:
getResource in interface ResourceLocator
Specified by:
getResource in class FileSet
Parameters:
path - A relative path to the resource to get
Returns:
A resource object representing the resource. or null if not found

getCertificates

public java.security.cert.Certificate[] getCertificates(Resource resource)
Get the certificates for a resource. This method always returns null since this file set does not support signed resource

Specified by:
getCertificates in class FileSet
Parameters:
resource - The resource to check for signing certificates
Returns:
Null