TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.fs.archive
Class FsCharsetArchiveDriver<E extends FsArchiveEntry>

java.lang.Object
  extended by de.schlichtherle.truezip.fs.FsDriver
      extended by de.schlichtherle.truezip.fs.archive.FsArchiveDriver<E>
          extended by de.schlichtherle.truezip.fs.archive.FsCharsetArchiveDriver<E>
All Implemented Interfaces:
EntryFactory<E>

@Immutable
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public abstract class FsCharsetArchiveDriver<E extends FsArchiveEntry>
extends FsArchiveDriver<E>

An abstract base class of an archive driver which provides convenient methods for dealing with the character set supported by a particular archive type. This class is intended to be used to implement archive types with a defined character set, e.g. the ZIP file format with its IBM437 character set or the TAR file format with its US-ASCII character set.

Implementations must be immutable.

Author:
Christian Schlichtherle

Nested Class Summary
private  class FsCharsetArchiveDriver.ThreadLocalEncoder
           
 
Field Summary
private  Charset charset
           
private  FsCharsetArchiveDriver.ThreadLocalEncoder encoder
           
 
Constructor Summary
protected FsCharsetArchiveDriver(Charset charset)
          Constructs a new character set archive driver.
 
Method Summary
protected  void assertEncodable(String name)
          Ensures that the given entry name can be encoded by this driver's character set.
 Charset getCharset()
          Returns the character set provided to the constructor.
 String toString()
          Returns a string representation of this object for debugging and logging purposes.
protected static String toZipOrTarEntryName(String name, Entry.Type type)
          Fixes the given entry name so that it forms a valid entry name for ZIP or TAR files by ensuring that the returned entry name ends with the separator character '/' if and only if type is DIRECTORY.
 
Methods inherited from class de.schlichtherle.truezip.fs.archive.FsArchiveDriver
getClosedIcon, getOpenIcon, getPool, isFederated, newController, newInputShop, newOutputShop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.schlichtherle.truezip.entry.EntryFactory
newEntry
 

Field Detail

charset

private final Charset charset

encoder

private final FsCharsetArchiveDriver.ThreadLocalEncoder encoder
Constructor Detail

FsCharsetArchiveDriver

protected FsCharsetArchiveDriver(Charset charset)
Constructs a new character set archive driver.

Parameters:
charset - the character set to use for encoding entry names and probably other meta data when reading or writing an archive file.
Method Detail

getCharset

public Charset getCharset()
Returns the character set provided to the constructor. This can be safely overriden, but must return the same object on every call.

Returns:
The character set to use for encoding entry names and probably other meta data when reading or writing an archive file.

toZipOrTarEntryName

protected static String toZipOrTarEntryName(String name,
                                            Entry.Type type)
Fixes the given entry name so that it forms a valid entry name for ZIP or TAR files by ensuring that the returned entry name ends with the separator character '/' if and only if type is DIRECTORY.

Parameters:
name - an entry name.
type - an entry type.
Returns:
The fixed entry name.

assertEncodable

protected final void assertEncodable(String name)
                              throws CharConversionException
Ensures that the given entry name can be encoded by this driver's character set. Should be called by sub classes in their implementation of the method EntryFactory.newEntry(java.lang.String, de.schlichtherle.truezip.entry.Entry.Type, de.schlichtherle.truezip.entry.Entry).

Parameters:
name - an entry name.
Throws:
CharConversionException - If the path name contains characters which cannot get encoded.
See Also:
getCharset()

toString

public String toString()
Returns a string representation of this object for debugging and logging purposes.

Overrides:
toString in class FsDriver

TrueZIP Kernel 7.0-rc2

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