public class FileHashcodeMap extends TreeMap<String,String>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
static String |
DELETED_FILE_HASHCODE |
static String |
DIRECTORY_HASHCODE |
static String |
UNKNOWN_DIR_HASHCODE |
static String |
UNKNOWN_FILE_HASHCODE |
| Constructor and Description |
|---|
FileHashcodeMap() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object key) |
String |
convertPath(String path)
Converts the path to the form that will be stored internally.
|
static FileHashcodeMap |
generateFileHashcodeMap(File rootDir,
Pattern ignoreRegex,
Set<String> ignored)
Given a directory, this will recursively traverse that directory's files/subdirectories and
generate the hashcode map for all files it encounters and add that data to the given map.
|
String |
get(Object key) |
Map<String,String> |
getUnknownContent()
If a file was not readable or its hashcode could not be generated for some reason, its path
will be returned as a key to the returned map.
|
static FileHashcodeMap |
loadFromFile(File file)
Loads in the file that contains file/hashcode map data.
|
String |
put(String key,
String value) |
String |
remove(Object key) |
ChangesFileHashcodeMap |
rescan(File rootDir,
Pattern ignoreRegex,
boolean reportNewRootFilesAsNew)
This rescans a set of files (found in this map) and returns a map with an updated, current set of hashcodes.
|
void |
storeToFile(File file)
Takes all map entries in this object and writes them to the given file such that it can later
be loaded in via
loadFromFile(File). |
ceilingEntry, ceilingKey, clear, clone, comparator, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, size, subMap, subMap, tailMap, tailMap, valuesequals, hashCode, isEmpty, toStringpublic static final String UNKNOWN_DIR_HASHCODE
public static final String UNKNOWN_FILE_HASHCODE
public static final String DELETED_FILE_HASHCODE
public static final String DIRECTORY_HASHCODE
public static FileHashcodeMap generateFileHashcodeMap(File rootDir, Pattern ignoreRegex, Set<String> ignored) throws Exception
rootDir).
Also note that ignoreRegex is matched against relative paths.rootDir - existing directory to scan and generate hashcodes for all its filesignoreRegex - a regular expression that indicates which files/directories should be ignored.
If a relative file/directory path matches this regex, it will be skipped.ignored - a set that will contain those files/directories that were ignored while scanning the root dirException - if failed to generate hashcode for the directorypublic static FileHashcodeMap loadFromFile(File file) throws Exception
file - the file to loadExceptionpublic void storeToFile(File file) throws Exception
loadFromFile(File).file - the file to store the entries toException - if failed to store the entries to the given filepublic ChangesFileHashcodeMap rescan(File rootDir, Pattern ignoreRegex, boolean reportNewRootFilesAsNew) throws Exception
DELETED_FILE_HASHCODE.
The root directory is also scanned for new files that are not in this original
map - if new files are found (and they do not match the ignoreRegex), they are added to the
returned map. Note that if reportNewRootFilesAsNew is false, and if new files
are found in the top root directory and they are not related to the deployment fileset,
they will not be added to the returned map.rootDir - directory where the relative paths are expected to beignoreRegex - if relative paths of files under rootDir match this, they will be ignored.
This will eliminate files/directories from being considered "new" because
they aren't in original.reportNewRootFilesAsNew - do not report as new any unrelated files found in the root dirExceptionpublic Map<String,String> getUnknownContent()
UNKNOWN_FILE_HASHCODE.
If a directory was not readable or its list of files could not be retrieved for some reason, its path
will be returned as a key to the returned map. The value will be UNKNOWN_DIR_HASHCODE.null if
the map is fully complete and all content was able to have its hashcodes generated.public boolean containsKey(Object key)
containsKey in interface Map<String,String>containsKey in class TreeMap<String,String>Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.