Charset to encode names.
The methods of this class are reentrant.
| Modifier and Type | Field and Description |
|---|---|
| private final Charset | |
| private static final char[] | |
| private static final char | |
| private static final byte[] | |
| private static final String | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv | NioZipEncoding(final Charset
The character set to use. charset, final boolean should invalid characters be replaced, or reported. useReplacement)Constructs an NioZipEncoding using the given charset. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canEncode(final String
A file name or ZIP comment. name)Implements org. |
| public String | decode(final byte[]
The byte values to decode. data)Implements org. |
| public ByteBuffer | encode(final String
A file name or ZIP comment. name)Implements org. |
| private static ByteBuffer | |
| private static CharBuffer | |
| private static int | Returns: estimated size in bytes.encoder to use for estimates enc, final int number of characters remaining charCount)Estimate the size needed for remaining characters |
| private static int | Returns: estimated size in bytes.encoder to use for estimates enc, final int number of characters in string charChount)Estimate the initial encoded size (in bytes) for a character buffer. |
| public Charset | getCharset()
Implements org. |
| private CharsetDecoder | |
| private CharsetEncoder |
| charset | back to summary |
|---|---|
| private final Charset charset | |
| HEX_CHARS | back to summary |
|---|---|
| private static final char[] HEX_CHARS | |
| REPLACEMENT | back to summary |
|---|---|
| private static final char REPLACEMENT | |
| REPLACEMENT_BYTES | back to summary |
|---|---|
| private static final byte[] REPLACEMENT_BYTES | |
| REPLACEMENT_STRING | back to summary |
|---|---|
| private static final String REPLACEMENT_STRING | |
| useReplacement | back to summary |
|---|---|
| private final boolean useReplacement | |
| NioZipEncoding | back to summary |
|---|---|
| pack-priv NioZipEncoding(final Charset charset, final boolean useReplacement) Constructs an NioZipEncoding using the given charset.
| |
| canEncode | back to summary |
|---|---|
| public boolean canEncode(final String name) Implements org. Doc from org. Check, whether the given string may be losslessly encoded using this encoding.
| |
| decode | back to summary |
|---|---|
| public String decode(final byte[] data) throws IOException Implements org.
| |
| encode | back to summary |
|---|---|
| public ByteBuffer encode(final String name) Implements org. Doc from org. Encode a file name or a comment to a byte array suitable for storing it to a serialized ZIP entry. Examples for CP 437 (in pseudo-notation, right hand side is C-style notation):
encode("€_for_Dollar.txt") = "%U20AC_for_Dollar.txt"
encode("Ölfässer.txt") = "\231lf\204sser.txt"
| |
| encodeFully | back to summary |
|---|---|
| private static ByteBuffer encodeFully(final CharsetEncoder enc, final CharBuffer cb, final ByteBuffer out) | |
| encodeSurrogate | back to summary |
|---|---|
| private static CharBuffer encodeSurrogate(final CharBuffer cb, final char c) | |
| estimateIncrementalEncodingSize | back to summary |
|---|---|
| private static int estimateIncrementalEncodingSize(final CharsetEncoder enc, final int charCount) Estimate the size needed for remaining characters
| |
| estimateInitialBufferSize | back to summary |
|---|---|
| private static int estimateInitialBufferSize(final CharsetEncoder enc, final int charChount) Estimate the initial encoded size (in bytes) for a character buffer. The estimate assumes that one character consumes uses the maximum length encoding, whilst the rest use an average size encoding. This accounts for any BOM for UTF-16, at the expense of a couple of extra bytes for UTF-8 encoded ASCII.
| |
| getCharset | back to summary |
|---|---|
| public Charset getCharset() Implements org. Doc from org. Provides access to the character set associated with an object. This allowsNIOoriented code to use more natural character encoding/decoding methods, whilst allowing existing code to continue to rely on special-case error handling for UTF-8. | |
| newDecoder | back to summary |
|---|---|
| private CharsetDecoder newDecoder() | |
| newEncoder | back to summary |
|---|---|
| private CharsetEncoder newEncoder() | |