org.rhq.core.util.updater
Class ExtractorZipFileVisitor

java.lang.Object
  extended by org.rhq.core.util.updater.ExtractorZipFileVisitor
All Implemented Interfaces:
ZipUtil.ZipEntryVisitor

public class ExtractorZipFileVisitor
extends Object
implements ZipUtil.ZipEntryVisitor

A visitor object that will extract each zip entry it visits, realizing files that need to have their replacement variables replaced.

Author:
John Mazzitelli

Constructor Summary
ExtractorZipFileVisitor(File rootDir, Pattern filesToRealizeRegex, TemplateEngine templateEngine, Set<String> filesToNotExtract, DeployDifferences diff, boolean dryRun)
          Creates the visitor.
 
Method Summary
 FileHashcodeMap getFileHashcodeMap()
          Returns the file/hashcode data this visitor has collected.
 boolean visit(ZipEntry entry, ZipInputStream stream)
          Visits a specific zip file entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtractorZipFileVisitor

public ExtractorZipFileVisitor(File rootDir,
                               Pattern filesToRealizeRegex,
                               TemplateEngine templateEngine,
                               Set<String> filesToNotExtract,
                               DeployDifferences diff,
                               boolean dryRun)
Creates the visitor. When the visitor hits a zip entry whose name matches filesToRealizeRegex set, that zip entry will be realized via the template engine prior to its hashcode being computed and its file created. If you just want this visitor to walk a zip file without realizing any files, pass in a null pattern or pass in a null template engine. This will, in effect, have this visitor extract all file entries as-is.

Parameters:
rootDir - the top level directory where all zip file entries will be extracted to. In other words, all zip file entries' paths are relative to this directory.
filesToRealizeRegex - pattern of files that are to be realized prior to hashcodes being computed
templateEngine - the template engine that replaces replacement variables in files to be realized
filesToNotExtract - set of files that are not to be extracted from the zip and stored; these are to be skipped
diff - optional object that is told when files are realized
dryRun - if true, this won't actually write files to the filesystem
Method Detail

getFileHashcodeMap

public FileHashcodeMap getFileHashcodeMap()
Returns the file/hashcode data this visitor has collected.

Returns:
map containing filenames (zip file entry names) and their hashcodes

visit

public boolean visit(ZipEntry entry,
                     ZipInputStream stream)
              throws Exception
Description copied from interface: ZipUtil.ZipEntryVisitor
Visits a specific zip file entry. Implementations can read the entry content from the given stream but must not close the stream - the caller of this method will handle the lifecycle of the stream.

Specified by:
visit in interface ZipUtil.ZipEntryVisitor
Parameters:
entry - the entry being visited
stream - the stream containing the zip content
Returns:
the visitor should return true if everything is OK and processing of the zip content should continue; returning false will tell the walker to abort further traversing of the zip content.
Throws:
Exception - if the visitation failed for some reason - this will abort further walking of the zip content


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.