Package 

Interface ZipEncoding


  • 
    public interface ZipEncoding
    
                        

    An interface for encoders that do a pretty encoding of ZIP file names.

    There are mostly two implementations, one that uses java.nio Charset and one implementation, which copes with simple 8 bit charsets, because java-1.4 did not support Cp437 in java.nio.

    The main reason for defining an own encoding layer comes from the problems with String.getBytes, which encodes unknown characters as ASCII quotation marks ('?'). Quotation marks are per definition an invalid file name on some operating systems like Windows, which leads to ignored ZIP entries.

    All implementations should implement this interface in a reentrant way.

    • Method Summary

      Modifier and Type Method Description
      abstract boolean canEncode(String name) Check, whether the given string may be losslessly encoded using thisencoding.
      abstract String decode(Array<byte> data)
      abstract ByteBuffer encode(String name) Encode a file name or a comment to a byte array suitable forstoring it to a serialized zip entry.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • canEncode

         abstract boolean canEncode(String name)

        Check, whether the given string may be losslessly encoded using thisencoding.

        Parameters:
        name - A file name or ZIP comment.
      • decode

         abstract String decode(Array<byte> data)
        Parameters:
        data - The byte values to decode.
      • encode

         abstract ByteBuffer encode(String name)

        Encode a file name or a comment to a byte array suitable forstoring it to a serialized zip entry.

        Examples for CP 437 (in pseudo-notation, right hand side isC-style notation):

         encode("\u20AC_for_Dollar.txt") = "%U20AC_for_Dollar.txt"
         encode("\u00D6lf\u00E4sser.txt") = "\231lf\204sser.txt"
        
        Parameters:
        name - A file name or ZIP comment.