TrueZIP 6.8

de.schlichtherle.io.archive.spi
Class AbstractArchiveDriver

java.lang.Object
  extended by de.schlichtherle.io.archive.spi.AbstractArchiveDriver
All Implemented Interfaces:
ArchiveDriver, Serializable
Direct Known Subclasses:
TarDriver, ZipDriver

public abstract class AbstractArchiveDriver
extends Object
implements ArchiveDriver, Serializable

An abstract archive driver implementation to ease the task of developing an archive driver. It provides default implementations for character sets and icon handling.

Since TrueZIP 6.4, this class is serializable in order to meet the requirements of the File class.

Since:
TrueZIP 6.0
Version:
$Id: AbstractArchiveDriver.java,v 1.5 2010/08/30 22:02:17 christian_schlichtherle Exp $
Author:
Christian Schlichtherle
See Also:
Serialized Form

Nested Class Summary
protected static class AbstractArchiveDriver.InconsistentCharsetSupportError
          Thrown to indicate that the character set implementation in the Java Runtime Environment (JRE) for the Java Standard Edition (JSE) is broken and needs fixing.
 
Constructor Summary
protected AbstractArchiveDriver(String charset, Icon openIcon, Icon closedIcon)
          Constructs a new abstract archive driver.
 
Method Summary
protected  void ensureEncodable(String entryName)
          Ensures that the given entry name is representable in this driver's character set charset.
 String getCharset()
          Returns the value of the property charset which was provided to the constructor.
 Icon getClosedIcon(Archive archive)
          Returns the value of the property closedIcon which was provided to the constructor.
 String getEncoding()
          Deprecated. Use getCharset() instead.
 Icon getOpenIcon(Archive archive)
          Returns the value of the property openIcon which was provided to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.schlichtherle.io.archive.spi.ArchiveDriver
createArchiveEntry, createInputArchive, createOutputArchive, equals, hashCode
 

Constructor Detail

AbstractArchiveDriver

protected AbstractArchiveDriver(String charset,
                                Icon openIcon,
                                Icon closedIcon)
Constructs a new abstract archive driver.

Parameters:
charset - The name of a character set to use by default for all entry names and probably other meta data when reading or writing archive files.
openIcon - The icon to return by getOpenIcon(de.schlichtherle.io.archive.Archive). May be null.
closedIcon - The icon to return by getClosedIcon(de.schlichtherle.io.archive.Archive). May be null.
Throws:
NullPointerException - If charset is null.
UnsupportedCharsetException - If charset is not supported by both the JSE 1.1 API and JSE 1.4 API.
AbstractArchiveDriver.InconsistentCharsetSupportError - If charset is supported by the JSE 1.1 API, but not the JSE 1.4 API, or vice versa.
Method Detail

ensureEncodable

protected final void ensureEncodable(String entryName)
                              throws CharConversionException
Ensures that the given entry name is representable in this driver's character set charset. Should be called by sub classes in their implementation of the method ArchiveDriver.createArchiveEntry(de.schlichtherle.io.archive.Archive, java.lang.String, de.schlichtherle.io.archive.spi.ArchiveEntry).

Parameters:
entryName - A valid archive entry name - null is not permissible.
Throws:
CharConversionException - If the entry name contains characters which cannot get encoded.
See Also:
getCharset(), Requirements for Archive Entry Names

getCharset

public final String getCharset()
Returns the value of the property charset which was provided to the constructor.


getEncoding

public final String getEncoding()
Deprecated. Use getCharset() instead.


getOpenIcon

public final Icon getOpenIcon(Archive archive)
Returns the value of the property openIcon which was provided to the constructor.

Specified by:
getOpenIcon in interface ArchiveDriver
Parameters:
archive - Ignored.
Returns:
The icon that should be displayed for the given archive if is is open/expanded in the view. If null is returned, a default icon should be used.

getClosedIcon

public final Icon getClosedIcon(Archive archive)
Returns the value of the property closedIcon which was provided to the constructor.

Specified by:
getClosedIcon in interface ArchiveDriver
Parameters:
archive - Ignored.
Returns:
The icon that should be displayed for the given archive if is is closed/collapsed in the view. If null is returned, a default icon should be used.

TrueZIP 6.8

Copyright © 2005-2010 Schlichtherle IT Services. All Rights Reserved.