org.apache.commons.compress.archivers.zip
Class AbstractUnicodeExtraField

java.lang.Object
  extended by org.apache.commons.compress.archivers.zip.AbstractUnicodeExtraField
All Implemented Interfaces:
ZipExtraField
Direct Known Subclasses:
UnicodeCommentExtraField, UnicodePathExtraField

public abstract class AbstractUnicodeExtraField
extends Object
implements ZipExtraField

A common base class for Unicode extra information extra fields.

This class is not thread-safe

Constructor Summary
protected AbstractUnicodeExtraField()
           
protected AbstractUnicodeExtraField(String text, byte[] bytes)
          Assemble as unicode extension from the name/comment and encoding of the orginal zip entry.
protected AbstractUnicodeExtraField(String text, byte[] bytes, int off, int len)
          Assemble as unicode extension from the name/comment and encoding of the orginal zip entry.
 
Method Summary
 byte[] getCentralDirectoryData()
          The actual data to put into central directory - without Header-ID or length specifier.
 ZipShort getCentralDirectoryLength()
          Length of the extra field in the central directory - without Header-ID or length specifier.
 byte[] getLocalFileDataData()
          The actual data to put into local file data - without Header-ID or length specifier.
 ZipShort getLocalFileDataLength()
          Length of the extra field in the local file data - without Header-ID or length specifier.
 long getNameCRC32()
           
 byte[] getUnicodeName()
           
 void parseFromCentralDirectoryData(byte[] buffer, int offset, int length)
          Doesn't do anything special since this class always uses the same data in central directory and local file data.
 void parseFromLocalFileData(byte[] buffer, int offset, int length)
          Populate data from this array as if it was in local file data.
 void setNameCRC32(long nameCRC32)
           
 void setUnicodeName(byte[] unicodeName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.compress.archivers.zip.ZipExtraField
getHeaderId
 

Constructor Detail

AbstractUnicodeExtraField

protected AbstractUnicodeExtraField()

AbstractUnicodeExtraField

protected AbstractUnicodeExtraField(String text,
                                    byte[] bytes,
                                    int off,
                                    int len)
Assemble as unicode extension from the name/comment and encoding of the orginal zip entry.

Parameters:
text - The file name or comment.
bytes - The encoded of the filename or comment in the zip file.
off - The offset of the encoded filename or comment in bytes.
len - The length of the encoded filename or commentin bytes.

AbstractUnicodeExtraField

protected AbstractUnicodeExtraField(String text,
                                    byte[] bytes)
Assemble as unicode extension from the name/comment and encoding of the orginal zip entry.

Parameters:
text - The file name or comment.
bytes - The encoded of the filename or comment in the zip file.
Method Detail

getNameCRC32

public long getNameCRC32()
Returns:
The CRC32 checksum of the filename or comment as encoded in the central directory of the zip file.

setNameCRC32

public void setNameCRC32(long nameCRC32)
Parameters:
nameCRC32 - The CRC32 checksum of the filename as encoded in the central directory of the zip file to set.

getUnicodeName

public byte[] getUnicodeName()
Returns:
The utf-8 encoded name.

setUnicodeName

public void setUnicodeName(byte[] unicodeName)
Parameters:
unicodeName - The utf-8 encoded name to set.

getCentralDirectoryData

public byte[] getCentralDirectoryData()
The actual data to put into central directory - without Header-ID or length specifier.

Specified by:
getCentralDirectoryData in interface ZipExtraField
Returns:
The CentralDirectoryData value

getCentralDirectoryLength

public ZipShort getCentralDirectoryLength()
Length of the extra field in the central directory - without Header-ID or length specifier.

Specified by:
getCentralDirectoryLength in interface ZipExtraField
Returns:
The CentralDirectoryLength value

getLocalFileDataData

public byte[] getLocalFileDataData()
The actual data to put into local file data - without Header-ID or length specifier.

Specified by:
getLocalFileDataData in interface ZipExtraField
Returns:
The LocalFileDataData value

getLocalFileDataLength

public ZipShort getLocalFileDataLength()
Length of the extra field in the local file data - without Header-ID or length specifier.

Specified by:
getLocalFileDataLength in interface ZipExtraField
Returns:
The LocalFileDataLength value

parseFromLocalFileData

public void parseFromLocalFileData(byte[] buffer,
                                   int offset,
                                   int length)
                            throws ZipException
Populate data from this array as if it was in local file data.

Specified by:
parseFromLocalFileData in interface ZipExtraField
Parameters:
buffer - the buffer to read data from
offset - offset into buffer to read data
length - the length of data
Throws:
ZipException - on error

parseFromCentralDirectoryData

public void parseFromCentralDirectoryData(byte[] buffer,
                                          int offset,
                                          int length)
                                   throws ZipException
Doesn't do anything special since this class always uses the same data in central directory and local file data.

Specified by:
parseFromCentralDirectoryData in interface ZipExtraField
Parameters:
buffer - the buffer to read data from
offset - offset into buffer to read data
length - the length of data
Throws:
ZipException - on error


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.