com.atlassian.modzdetector
Class HashRegistry

java.lang.Object
  extended by com.atlassian.modzdetector.HashRegistry

public class HashRegistry
extends java.lang.Object

Represents a stateful hash registry to which resources can be cumulatively added using register(String, java.io.InputStream). Its operation is modal. By default resources are registered as filesystem loadable resources. Calling setClasspathMode() means subsequent registrations indicate that resources are to be loaded from the claspath when modifications or removals are to be detected.


Field Summary
static java.lang.String PREFIX_CLASSPATH
          Indicates that the name is registered as a classpath resource.
static java.lang.String PREFIX_FILESYSTEM
          Indicates that the name is registered as a filesystem resource.
 
Constructor Summary
HashRegistry()
          Constructor using default algorithm and file name.
HashRegistry(HashAlgorithm algorithm, java.lang.String fileName)
          Creates a HashRegistry that uses the given algorithm and filename.
HashRegistry(java.lang.String fileName)
           
 
Method Summary
 void register(java.lang.String name, java.io.InputStream contents)
          Registers a hash for the resource with the given name and contents.
 void registerFilesystem(java.io.File root, java.io.FileFilter filter)
          Registers a whole filesystem under the given root for each file that matches filter.
 void registerFilesystm(java.io.File root)
          Registers a whole filesystem under the given root.
 void setClasspathMode()
           
 void setFilesystemMode()
           
 java.io.File store()
          Writes the registry to a file with the configured name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX_CLASSPATH

public static final java.lang.String PREFIX_CLASSPATH
Indicates that the name is registered as a classpath resource.

See Also:
Constant Field Values

PREFIX_FILESYSTEM

public static final java.lang.String PREFIX_FILESYSTEM
Indicates that the name is registered as a filesystem resource.

See Also:
Constant Field Values
Constructor Detail

HashRegistry

public HashRegistry()
Constructor using default algorithm and file name.


HashRegistry

public HashRegistry(java.lang.String fileName)

HashRegistry

public HashRegistry(HashAlgorithm algorithm,
                    java.lang.String fileName)
Creates a HashRegistry that uses the given algorithm and filename.

Parameters:
algorithm - the hashing algorithm.
fileName - the filename to write the registry to.
Method Detail

setClasspathMode

public void setClasspathMode()

setFilesystemMode

public void setFilesystemMode()

register

public void register(java.lang.String name,
                     java.io.InputStream contents)
Registers a hash for the resource with the given name and contents.

Parameters:
name - the name of the resource relative to a cwd or docroot.
contents - will be closed before this method completes.

registerFilesystm

public void registerFilesystm(java.io.File root)
Registers a whole filesystem under the given root. Sets the mode to filesystem mode.

Parameters:
root - the root of the filesystem to register.

registerFilesystem

public void registerFilesystem(java.io.File root,
                               java.io.FileFilter filter)
Registers a whole filesystem under the given root for each file that matches filter. Directories that do not match the filter will not be entered.

Parameters:
root - the root of the filesystem to register.
filter - the filter that all files must match in order to be registered.

store

public java.io.File store()
                   throws java.io.IOException
Writes the registry to a file with the configured name.

Returns:
the File written to.
Throws:
java.io.IOException - if the file cannot be written.


Copyright © 2011 Atlassian. All Rights Reserved.