org.rhq.core.util.updater
Class InMemoryZipFileVisitor

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

public class InMemoryZipFileVisitor
extends Object
implements ZipUtil.ZipEntryVisitor

A visitor object that will perform some in-memory work for each zip entry it visits.

Author:
John Mazzitelli

Constructor Summary
InMemoryZipFileVisitor(Pattern filesToRealizeRegex, TemplateEngine templateEngine)
          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

InMemoryZipFileVisitor

public InMemoryZipFileVisitor(Pattern filesToRealizeRegex,
                              TemplateEngine templateEngine)
Creates the visitor. When the visitor hits a zip entry whose name matches filesToRealizeRegex, that zip entry will be realized via the template engine prior to its hashcode being computed. In other words the file's hashcode will be computed on the content after its replacement variables have been replaced. 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 collect all zip file entry names and calculate their hashcodes based on all content within the zip file.

Parameters:
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
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.