de.schlichtherle.truezip.fs.archive
Class FsCharsetArchiveDriver<E extends FsArchiveEntry>
java.lang.Object
de.schlichtherle.truezip.fs.FsDriver
de.schlichtherle.truezip.fs.archive.FsArchiveDriver<E>
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
|
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. |
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. |
charset
private final Charset charset
encoder
private final FsCharsetArchiveDriver.ThreadLocalEncoder encoder
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.
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()
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.