|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.nio.charset.CharsetEncoder
com.beetstra.jutf7.UTF7StyleCharsetEncoder
class UTF7StyleCharsetEncoder
The CharsetEncoder used to encode both variants of the UTF-7 charset and the modified-UTF-7 charset.
Please note this class does not behave strictly according to the specification in
Sun Java VMs before 1.6. This is done to get around a bug in the implementation
of CharsetEncoder.encode(CharBuffer)
. Unfortunately, that method
cannot be overridden.
Field Summary | |
---|---|
(package private) static boolean |
useUglyHackToForceCallToFlushInJava5
|
Constructor Summary | |
---|---|
UTF7StyleCharsetEncoder(UTF7StyleCharset cs,
Base64Util base64,
boolean strict)
|
Method Summary | |
---|---|
protected CoderResult |
encodeLoop(CharBuffer in,
ByteBuffer out)
Note that this method might return CoderResult.OVERFLOW , even
though there is sufficient space available in the output buffer. |
protected CoderResult |
implFlush(ByteBuffer out)
Note that this method might return CoderResult.OVERFLOW (as is
required by the specification) if insufficient space is available in the output
buffer. |
protected void |
implReset()
|
Methods inherited from class java.nio.charset.CharsetEncoder |
---|
averageBytesPerChar, canEncode, canEncode, charset, encode, encode, flush, implOnMalformedInput, implOnUnmappableCharacter, implReplaceWith, isLegalReplacement, malformedInputAction, maxBytesPerChar, onMalformedInput, onUnmappableCharacter, replacement, replaceWith, reset, unmappableCharacterAction |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static boolean useUglyHackToForceCallToFlushInJava5
Constructor Detail |
---|
UTF7StyleCharsetEncoder(UTF7StyleCharset cs, Base64Util base64, boolean strict)
Method Detail |
---|
protected void implReset()
implReset
in class CharsetEncoder
protected CoderResult implFlush(ByteBuffer out)
Note that this method might return CoderResult.OVERFLOW
(as is
required by the specification) if insufficient space is available in the output
buffer. However, calling it again on JDKs before Java 6 triggers a bug in
CharsetEncoder.flush(ByteBuffer)
causing it to throw an
IllegalStateException (the buggy method is final
, thus cannot be
overridden).
implFlush
in class CharsetEncoder
out
- The output byte buffer
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out)
Note that this method might return CoderResult.OVERFLOW
, even
though there is sufficient space available in the output buffer. This is done
to force the broken implementation of
CharsetEncoder.encode(CharBuffer)
to call flush
(the buggy method is final
, thus cannot be overridden).
However, String.getBytes() fails if CoderResult.OVERFLOW is returned, since this assumes it always allocates sufficient bytes (maxBytesPerChar * nr_of_chars). Thus, as an extra check, the size of the input buffer is compared against the size of the output buffer. A static variable is used to indicate if a broken java version is used.
It is not possible to directly write the last few bytes, since more bytes might be waiting to be encoded then those available in the input buffer.
encodeLoop
in class CharsetEncoder
in
- The input character bufferout
- The output byte buffer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |