org.entityfs.util.zip
Class EntityIteratorToZipEntryInfoIteratorAdapter

java.lang.Object
  extended by org.entityfs.util.zip.EntityIteratorToZipEntryInfoIteratorAdapter
All Implemented Interfaces:
Iterator<ZipEntryInfo>
Direct Known Subclasses:
EntityIteratorToJarEntryInfoIteratorAdapter

public class EntityIteratorToZipEntryInfoIteratorAdapter
extends Object
implements Iterator<ZipEntryInfo>

This is an adapter between an EntityView Iterator and the ZipEntryInfo Iterator needed by ZipCreator for Zip files where all entry names should be constructed relative to one directory name.

This is used when creating Zip files with files from one source directory hierarchy.

Since:
1.0
Author:
Karl Gustafsson
See Also:
CompoundZipEntryInfoProvider

Constructor Summary
EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir, Iterator<? extends EntityView> adapted)
          Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied directory.
EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir, Iterator<? extends EntityView> adapted, AbsoluteLocation baseLocation)
          Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied relative location.
EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir, Iterator<? extends EntityView> adapted, AbsoluteLocation baseLocation, ZipEntryInfoProvider eip)
          Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied relative location.
EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir, Iterator<? extends EntityView> adapted, ZipEntryInfoProvider eip)
          Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied directory.
 
Method Summary
protected  ZipEntryInfo createZipEntryInfo(EntityView ev)
          This can be overridden by subclasses to create other kinds of ZipEntryInfo objects.
protected  DirectoryView getBaseDir()
           
protected  ZipEntryInfoProvider getExtraInfoProvider()
          Get the provider class used to add extra information to ZipEntry objects.
 boolean hasNext()
           
 ZipEntryInfo next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityIteratorToZipEntryInfoIteratorAdapter

public EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir,
                                                   Iterator<? extends EntityView> adapted)
Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied directory.

Parameters:
baseDir - The directory that ZipEntryInfo locations will be created relative to.
adapted - The iterator to adapt.

EntityIteratorToZipEntryInfoIteratorAdapter

public EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir,
                                                   Iterator<? extends EntityView> adapted,
                                                   AbsoluteLocation baseLocation)
Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied relative location.

Parameters:
baseDir - The directory that ZipEntryInfo locations will be created relative to.
adapted - The iterator to adapt.
baseLocation - The base path of the zip entries.

EntityIteratorToZipEntryInfoIteratorAdapter

public EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir,
                                                   Iterator<? extends EntityView> adapted,
                                                   ZipEntryInfoProvider eip)
Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied directory.

Parameters:
baseDir - The directory that ZipEntryInfo locations will be created relative to.
adapted - The iterator to adapt.
eip - A provider of extra ZipEntry information.

EntityIteratorToZipEntryInfoIteratorAdapter

public EntityIteratorToZipEntryInfoIteratorAdapter(DirectoryView baseDir,
                                                   Iterator<? extends EntityView> adapted,
                                                   AbsoluteLocation baseLocation,
                                                   ZipEntryInfoProvider eip)
Create an EntityIteratorToZipEntryInfoIteratorAdapter that will create ZipEntryInfo objects with a location relative to the supplied relative location.

Parameters:
baseDir - The directory that ZipEntryInfo locations will be created relative to.
adapted - The iterator to adapt.
baseLocation - The base path of the zip entries.
eip - A provider of extra ZipEntry information.
Method Detail

getBaseDir

protected DirectoryView getBaseDir()

getExtraInfoProvider

protected ZipEntryInfoProvider getExtraInfoProvider()
Get the provider class used to add extra information to ZipEntry objects.

Returns:
The extra info provider or null if not set.

createZipEntryInfo

protected ZipEntryInfo createZipEntryInfo(EntityView ev)
This can be overridden by subclasses to create other kinds of ZipEntryInfo objects.

Parameters:
ev - The entity to create the object for.
Returns:
The ZipEntryInfo object for the entity. If this method returns null, the entry should not be included in the Zip file.

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<ZipEntryInfo>

next

public ZipEntryInfo next()
Specified by:
next in interface Iterator<ZipEntryInfo>

remove

public void remove()
Specified by:
remove in interface Iterator<ZipEntryInfo>
Throws:
UnsupportedOperationException - Always.