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.ByteBuffer
byteBuffIn
protected java.nio.ByteBuffer
byteBuffOut
protected java.nio.CharBuffer
charBuff
protected java.nio.charset.CharsetDecoder
decoder
protected java.lang.String
encodeCharsetName
protected java.nio.charset.CharsetEncoder
encoder
protected ICharsetModifiable
modifier
protected java.io.OutputStream
out
-
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 void
consume(int contentLength, java.io.InputStream src)
Request to a consumer to consume specified number of bytes from the input streamvoid
consume(java.lang.String decodeCharsetName, int contentLength, java.io.InputStream src)
Request to a consumer to consume specified number of bytes from the input streamprotected void
encodeSpecialCharacter(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.void
flush()
protected void
transcode(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.Exception
Description copied from interface:IContentConsumer
Request to a consumer to consume specified number of bytes from the input stream- Specified by:
consume
in interfaceIContentConsumer
- Overrides:
consume
in 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.Exception
Description copied from interface:IContentConsumer
Request to a consumer to consume specified number of bytes from the input stream- Specified by:
consume
in interfaceIContentConsumer
- Overrides:
consume
in 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.UnsupportedEncodingException
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.
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.IOException
java.io.UnsupportedEncodingException
-
transcode
protected void transcode(byte[] data, int range) throws java.io.IOException, java.nio.charset.CharacterCodingException
- Throws:
java.io.IOException
java.nio.charset.CharacterCodingException
-
flush
public void flush() throws java.nio.charset.CharacterCodingException, java.io.IOException
- Specified by:
flush
in interfaceIFlushable
- Throws:
java.nio.charset.CharacterCodingException
java.io.IOException
-
-