|
3.0.2: 2012-01-25 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.util.extensions.manager.processor.ExtractResourcesProcessor
public class ExtractResourcesProcessor
A file processor implementation that extracts resources from JAR files. The main target directory must be specified when an instance is constructed. Each processed JAR file is extracted into a subdirectory with the same name as the JAR file. Existing target files are only overwritten if they are different, but a 'forceOverwrite' flag can be set to always overwrite files.
The filter (in the form of a regular expressions pattern) can be specified to limit which files are extracted from the JAR file. The filter is also used to re-write target file names if they need to be different from the file names in the JAR file.
Note! It is recommended that this processor is paired with a
ValidAndNewOrModifiedFilter
since it is usually no
point in extracting resources from invalid extensions.
Field Summary | |
---|---|
private Pattern |
filter
|
private boolean |
forceOverwrite
|
private static Logger |
log
|
private File |
mainDir
|
private int |
numError
|
private int |
numFiles
|
private int |
numTotalExtracted
|
private String |
replacement
|
private ProcessResults |
results
|
Constructor Summary | |
---|---|
ExtractResourcesProcessor(File mainDir,
Pattern filter,
String replacement,
ProcessResults results)
Create a new processor. |
|
ExtractResourcesProcessor(File mainDir,
ProcessResults results)
Create a new processor. |
Method Summary | |
---|---|
void |
begin(ExtensionsManager manager,
int numFiles)
Called by the extensions manager before the processing starts. |
void |
done(ExtensionsManager manager)
Called by the extensions manager after a successful completion of the processing. |
void |
done(ExtensionsManager manager,
Throwable t)
Called by the extensions manager if an exception was thrown by the processor. |
int |
getNumError()
Get the number of files that was had an error. |
int |
getNumExtracted()
Get the total number of resources that was extracts. |
int |
getNumFiles()
Get the number of files that was successfully processed. |
void |
processFile(ExtensionsManager manager,
ExtensionsFile.WriteableExtensionsFile wFile)
Called by the extensions manager for each extensions file that it manages. |
void |
setForceOverwrite(boolean forceOverwrite)
Set a flag indicating if already existing files should always be updated or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger log
private final File mainDir
private boolean forceOverwrite
private final Pattern filter
private final String replacement
private final ProcessResults results
private int numFiles
private int numError
private int numTotalExtracted
Constructor Detail |
---|
public ExtractResourcesProcessor(File mainDir, ProcessResults results)
mainDir
- The main directory to where the resources should be extractedpublic ExtractResourcesProcessor(File mainDir, Pattern filter, String replacement, ProcessResults results)
mainDir
- The main directory to where the resources should be extractedfilter
- A regular expression filter that must match the file name
in the JAR filereplacement
- A replacement string to create a new file name
using Matcher.replaceAll(String)
.Method Detail |
---|
public void begin(ExtensionsManager manager, int numFiles)
ExtensionsFileProcessor
begin
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actionnumFiles
- The number of extension files that is going to be processed this timepublic void processFile(ExtensionsManager manager, ExtensionsFile.WriteableExtensionsFile wFile)
ExtensionsFileProcessor
If the processor throws an exception the manager will abort
processing and call ExtensionsFileProcessor.done(ExtensionsManager, Throwable)
.
Error that are related to a specific file should be catched
by the processor and registered by calling .......
If all files was processed without exceptions the manager
will call ExtensionsFileProcessor.done(ExtensionsManager)
.
Note that the file is read-only to begin with. If the processor
wants to call any write-operation the file must be opened by
calling ExtensionsFile.WriteableExtensionsFile.open()
. It is recommended
that the processor calls ExtensionsFile.WriteableExtensionsFile.close()
once it is done writing.
processFile
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actionwFile
- The file to be processedpublic void done(ExtensionsManager manager)
ExtensionsFileProcessor
done
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actionpublic void done(ExtensionsManager manager, Throwable t)
ExtensionsFileProcessor
done
in interface ExtensionsFileProcessor
manager
- The manager that is executing the actiont
- The exceptionpublic void setForceOverwrite(boolean forceOverwrite)
forceOverwrite
- TRUE to force overwriting existing files,
FALSE to only overwrite files if they are different from
the files in the JARpublic int getNumFiles()
public int getNumError()
public int getNumExtracted()
|
3.0.2: 2012-01-25 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |