Class EncodeSpecialStreamingContext
- java.lang.Object
-
- com.microstrategy.webapi.StreamingContext
-
- com.microstrategy.web.app.transforms.EncodeSpecialStreamingContext
-
- All Implemented Interfaces:
IFlushable,IContentConsumer
public class EncodeSpecialStreamingContext extends StreamingContext implements IFlushable
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.ByteBufferbyteBuffInprotected java.nio.ByteBufferbyteBuffOutprotected java.nio.CharBuffercharBuffprotected java.nio.charset.CharsetDecoderdecoderprotected java.lang.StringencodeCharsetNameprotected java.nio.charset.CharsetEncoderencoderprotected ICharsetModifiablemodifierprotected java.io.OutputStreamout-
Fields inherited from class com.microstrategy.webapi.StreamingContext
_canRedirect, _containerServices, _contentLength, _ex, CONTENT_LENGTH_NAME, STREAMING_BUF_SIZE
-
-
Constructor Summary
Constructors Constructor Description EncodeSpecialStreamingContext(ContainerServices cs, java.lang.String encodeName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconsume(int contentLength, java.io.InputStream src)Request to a consumer to consume specified number of bytes from the input streamvoidconsume(java.lang.String decodeCharsetName, int contentLength, java.io.InputStream src)Request to a consumer to consume specified number of bytes from the input streamprotected voidencodeSpecialCharacter(byte b1, byte b2)Encodes one character as Shift JIS
This is done to special-encode some problematic characters into SJIS because they are not properly encoded by Java.voidflush()protected voidtranscode(byte[] data, int range)-
Methods inherited from class com.microstrategy.webapi.StreamingContext
canRedirect, getContextLength, getException, setContentLength
-
-
-
-
Field Detail
-
encoder
protected java.nio.charset.CharsetEncoder encoder
-
decoder
protected java.nio.charset.CharsetDecoder decoder
-
charBuff
protected java.nio.CharBuffer charBuff
-
byteBuffIn
protected java.nio.ByteBuffer byteBuffIn
-
byteBuffOut
protected java.nio.ByteBuffer byteBuffOut
-
encodeCharsetName
protected java.lang.String encodeCharsetName
-
out
protected java.io.OutputStream out
-
modifier
protected ICharsetModifiable modifier
-
-
Constructor Detail
-
EncodeSpecialStreamingContext
public EncodeSpecialStreamingContext(ContainerServices cs, java.lang.String encodeName)
-
-
Method Detail
-
consume
public void consume(int contentLength, java.io.InputStream src) throws java.lang.ExceptionDescription copied from interface:IContentConsumerRequest to a consumer to consume specified number of bytes from the input stream- Specified by:
consumein interfaceIContentConsumer- Overrides:
consumein classStreamingContext- Parameters:
contentLength- number of bytes to consume.src- source input stream- Throws:
java.lang.Exception
-
consume
public void consume(java.lang.String decodeCharsetName, int contentLength, java.io.InputStream src) throws java.lang.ExceptionDescription copied from interface:IContentConsumerRequest to a consumer to consume specified number of bytes from the input stream- Specified by:
consumein interfaceIContentConsumer- Overrides:
consumein classStreamingContext- Parameters:
decodeCharsetName- decoder charset namecontentLength- number of bytes to consume.src- source input stream- Throws:
java.lang.Exception
-
encodeSpecialCharacter
protected void encodeSpecialCharacter(byte b1, byte b2) throws java.io.IOException, java.io.UnsupportedEncodingExceptionEncodes one character as Shift JIS
This is done to special-encode some problematic characters into SJIS because they are not properly encoded by Java.
For more information see: http://www-01.ibm.com/support/docview.wss?rs=133&context=SS5RG2&dc=DB560&dc=DB520&uid=swg21064197&loc=en_US&cs=UTF-8&lang=en&rss=ct133rational In addition to the characters mentioned on this link we also special encode circled numbers from 1 to 20 which also break in Japanese
This can be overwritten to encode extra characters
The recommended overwritten code snippet:
protected void encodeShiftJISCharacter(byte b1, byte b2) throws UnsupportedEncodingException {
if (b1 == 0x15 && b2 == 0x20) {//double dash
pushSpecialChar((byte) 0x81, (byte) 0x5c)
} else {
super.encodeShiftJISCharactor(b1,b2);
}
}- Throws:
java.io.IOExceptionjava.io.UnsupportedEncodingException
-
transcode
protected void transcode(byte[] data, int range) throws java.io.IOException, java.nio.charset.CharacterCodingException- Throws:
java.io.IOExceptionjava.nio.charset.CharacterCodingException
-
flush
public void flush() throws java.nio.charset.CharacterCodingException, java.io.IOException- Specified by:
flushin interfaceIFlushable- Throws:
java.nio.charset.CharacterCodingExceptionjava.io.IOException
-
-