Top Description Inners Fields Constructors Methods
java.util.zip

pack-priv Class ZipCoder

extends Object
Class Inheritance
Known Direct Subclasses
java.util.zip.ZipCoder.UTF8ZipCoder
Imports
java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetDecoder, .CharsetEncoder, .CharacterCodingException, .CodingErrorAction, java.util.Arrays, jdk.internal.util.ArraysSupport, sun.nio.cs.UTF_8

Utility class for ZIP file entry name and comment decoding and encoding

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
ZipCoder.Comparison

This enum represents the three possible return values for compare(String, byte[], int, int, boolean) when this method compares a lookup name to a string encoded in the CEN byte array.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Charset
protected CharsetDecoder
private CharsetEncoder
private static final JavaLangAccess
private byte[]
pack-priv static final ZipCoder.UTF8ZipCoder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv int
checkedHash(byte[] a, int off, int len)

pack-priv ZipCoder.Comparison
compare(String
The lookup string to compare with the encoded string.
str
,
byte[]
The byte array holding the encoded string
b
,
int
The offset into the array where the encoded string starts
off
,
int
The length of the encoded string in bytes
len
,
boolean
If true and the strings do not match exactly, a directory match will also be tested
matchDirectory
)

This method is used by ZipFile.Source.getEntryPos when comparing the name being looked up to candidate names encoded in the CEN byte array.

protected CharsetDecoder
private CharsetEncoder
public static ZipCoder
get(Charset charset)

pack-priv byte[]
pack-priv static int
hash(String name)

pack-priv boolean
hasTrailingSlash(byte[] a, int end)

pack-priv boolean
private byte[]
pack-priv String
toString(byte[] ba, int off, int length)

pack-priv String
toString(byte[] ba, int length)

pack-priv String
toString(byte[] ba)

pack-priv static String
toStringUTF8(byte[] ba, int len)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

csback to summary
private final Charset cs
decback to summary
protected CharsetDecoder dec
encback to summary
private CharsetEncoder enc
JLAback to summary
private static final JavaLangAccess JLA
slashBytesback to summary
private byte[] slashBytes
UTF8back to summary
pack-priv static final ZipCoder.UTF8ZipCoder UTF8

Constructor Detail

ZipCoderback to summary
private ZipCoder(Charset cs)

Method Detail

checkedHashback to summary
pack-priv int checkedHash(byte[] a, int off, int len) throws Exception
compareback to summary
pack-priv ZipCoder.Comparison compare(String str, byte[] b, int off, int len, boolean matchDirectory)

This method is used by ZipFile.Source.getEntryPos when comparing the name being looked up to candidate names encoded in the CEN byte array. Since ZipCode.getEntry supports looking up a "dir/" entry by the name "dir", this method can optionally distinguish an exact match from a partial "directory match" (where names only differ by the encoded name having an additional trailing '/') The return values of this method are as follows: If the lookup name is exactly equal to the encoded string, return Comparison#EXACT_MATCH. If the parameter matchDirectory is true and the two strings differ only by the encoded string having an extra trailing '/' character, then return Comparison#DIRECTORY_MATCH. Otherwise, return Comparison#NO_MATCH While a general implementation will need to decode bytes into a String for comparison, this can be avoided if the String coder and this ZipCoder are known to encode strings to the same bytes.

Parameters
str:String

The lookup string to compare with the encoded string.

b:byte[]

The byte array holding the encoded string

off:int

The offset into the array where the encoded string starts

len:int

The length of the encoded string in bytes

matchDirectory:boolean

If true and the strings do not match exactly, a directory match will also be tested

decoderback to summary
protected CharsetDecoder decoder()
encoderback to summary
private CharsetEncoder encoder()
getback to summary
public static ZipCoder get(Charset charset)
getBytesback to summary
pack-priv byte[] getBytes(String s)
hashback to summary
pack-priv static int hash(String name)
hasTrailingSlashback to summary
pack-priv boolean hasTrailingSlash(byte[] a, int end)
isUTF8back to summary
pack-priv boolean isUTF8()
slashBytesback to summary
private byte[] slashBytes()
toStringback to summary
pack-priv String toString(byte[] ba, int off, int length)
toStringback to summary
pack-priv String toString(byte[] ba, int length)
toStringback to summary
pack-priv String toString(byte[] ba)
toStringUTF8back to summary
pack-priv static String toStringUTF8(byte[] ba, int len)
java.util.zip back to summary

pack-priv final Enum ZipCoder.Comparison

extends Enum<ZipCoder.Comparison>
Class Inheritance

This enum represents the three possible return values for compare(String, byte[], int, int, boolean) when this method compares a lookup name to a string encoded in the CEN byte array.

Field Summary

Modifier and TypeField and Description
public static final ZipCoder.Comparison
DIRECTORY_MATCH

The lookup string and the encoded string differs only by the encoded string having a trailing '/' character.

public static final ZipCoder.Comparison
EXACT_MATCH

The lookup string is exactly equal to the encoded string.

public static final ZipCoder.Comparison
NO_MATCH

The lookup string and the encoded string do not match.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ZipCoder.Comparison
public static ZipCoder.Comparison[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DIRECTORY_MATCHback to summary
public static final ZipCoder.Comparison DIRECTORY_MATCH

The lookup string and the encoded string differs only by the encoded string having a trailing '/' character.

EXACT_MATCHback to summary
public static final ZipCoder.Comparison EXACT_MATCH

The lookup string is exactly equal to the encoded string.

NO_MATCHback to summary
public static final ZipCoder.Comparison NO_MATCH

The lookup string and the encoded string do not match. (They are neither an exact match or a directory match.)

Constructor Detail

Comparisonback to summary
private Comparison()

Method Detail

valueOfback to summary
public static ZipCoder.Comparison valueOf(String name)
valuesback to summary
public static ZipCoder.Comparison[] values()
java.util.zip back to summary

pack-priv final Class ZipCoder.UTF8ZipCoder

extends ZipCoder
Class Inheritance

Field Summary

Inherited from java.util.zip.ZipCoder:
decUTF8

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv int
checkedHash(byte[] a, int off, int len)

Overrides java.util.zip.ZipCoder.checkedHash.

pack-priv ZipCoder.Comparison
compare(String
The lookup string to compare with the encoded string.
str
,
byte[]
The byte array holding the encoded string
b
,
int
The offset into the array where the encoded string starts
off
,
int
The length of the encoded string in bytes
len
,
boolean
If true and the strings do not match exactly, a directory match will also be tested
matchDirectory
)

Overrides java.util.zip.ZipCoder.compare.

This method is used by ZipFile.Source.getEntryPos when comparing the name being looked up to candidate names encoded in the CEN byte array.

pack-priv byte[]
pack-priv boolean
pack-priv boolean
pack-priv String
toString(byte[] ba, int off, int length)

Overrides java.util.zip.ZipCoder.toString.

Inherited from java.util.zip.ZipCoder:
decodergethashtoStringtoStringtoStringUTF8

Constructor Detail

UTF8ZipCoderback to summary
private UTF8ZipCoder(Charset utf8)

Method Detail

checkedHashback to summary
pack-priv int checkedHash(byte[] a, int off, int len) throws Exception

Overrides java.util.zip.ZipCoder.checkedHash.

Annotations
@Override
compareback to summary
pack-priv ZipCoder.Comparison compare(String str, byte[] b, int off, int len, boolean matchDirectory)

Overrides java.util.zip.ZipCoder.compare.

Doc from java.util.zip.ZipCoder.compare.

This method is used by ZipFile.Source.getEntryPos when comparing the name being looked up to candidate names encoded in the CEN byte array. Since ZipCode.getEntry supports looking up a "dir/" entry by the name "dir", this method can optionally distinguish an exact match from a partial "directory match" (where names only differ by the encoded name having an additional trailing '/') The return values of this method are as follows: If the lookup name is exactly equal to the encoded string, return Comparison#EXACT_MATCH. If the parameter matchDirectory is true and the two strings differ only by the encoded string having an extra trailing '/' character, then return Comparison#DIRECTORY_MATCH. Otherwise, return Comparison#NO_MATCH While a general implementation will need to decode bytes into a String for comparison, this can be avoided if the String coder and this ZipCoder are known to encode strings to the same bytes.

Parameters
str:String

The lookup string to compare with the encoded string.

b:byte[]

The byte array holding the encoded string

off:int

The offset into the array where the encoded string starts

len:int

The length of the encoded string in bytes

matchDirectory:boolean

If true and the strings do not match exactly, a directory match will also be tested

Annotations
@Override
getBytesback to summary
pack-priv byte[] getBytes(String s)

Overrides java.util.zip.ZipCoder.getBytes.

Annotations
@Override
hasTrailingSlashback to summary
pack-priv boolean hasTrailingSlash(byte[] a, int end)

Overrides java.util.zip.ZipCoder.hasTrailingSlash.

Annotations
@Override
isUTF8back to summary
pack-priv boolean isUTF8()

Overrides java.util.zip.ZipCoder.isUTF8.

Annotations
@Override
toStringback to summary
pack-priv String toString(byte[] ba, int off, int length)

Overrides java.util.zip.ZipCoder.toString.

Annotations
@Override