Package com.sun.corba.ee.impl.encoding
Class CodeSetConversion
- java.lang.Object
-
- com.sun.corba.ee.impl.encoding.CodeSetConversion
-
public class CodeSetConversion extends java.lang.Object
Collection of classes, interfaces, and factory methods for CORBA code set conversion. This is mainly used to shield other code from the sun.io converters which might change, as well as provide some basic translation from conversion to CORBA error exceptions. Some extra work is required here to facilitate the way CORBA says it uses UTF-16 as of the 00-11-03 spec. REVISIT - Since the nio.Charset and nio.Charset.Encoder/Decoder use NIO ByteBuffer and NIO CharBuffer, the interaction and interface between this class and the CDR streams should be looked at more closely for optimizations to avoid unnecessary copying of data between char[] & CharBuffer and byte[] & ByteBuffer, especially DirectByteBuffers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CodeSetConversion.BTCConverter
Abstraction for byte to char conversion.private static class
CodeSetConversion.CodeSetConversionHolder
static class
CodeSetConversion.CTBConverter
Abstraction for char to byte conversion.private class
CodeSetConversion.JavaBTCConverter
Implementation of BTCConverter which uses a sun.io.ByteToCharConverter for the real work.private class
CodeSetConversion.JavaCTBConverter
Implementation of CTBConverter which uses a nio.Charset.CharsetEncoder to do the real work.private class
CodeSetConversion.UTF16BTCConverter
Special converter for UTF16 since it's required to optionally support a byte order marker while the internal Java converters either require it or require that it isn't there.private class
CodeSetConversion.UTF16CTBConverter
Special UTF16 converter which can either always write a BOM or use a specified byte order without one.
-
Field Summary
Fields Modifier and Type Field Description private CodeSetCache
cache
private java.lang.ThreadLocal<java.util.HashMap<OSFCodeSetRegistry.Entry,CodeSetConversion.BTCConverter>>
cacheBTCC
private java.lang.ThreadLocal<java.util.HashMap<OSFCodeSetRegistry.Entry,CodeSetConversion.CTBConverter>>
cacheCTBC
private static int
FALLBACK_CODESET
private static OMGSystemException
omgWrapper
private static ORBUtilSystemException
wrapper
-
Constructor Summary
Constructors Modifier Constructor Description private
CodeSetConversion()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CodeSetConversion.BTCConverter
getBTCConverter(OSFCodeSetRegistry.Entry codeset)
BTCConverter factory for single byte or variable width encodings.CodeSetConversion.BTCConverter
getBTCConverter(OSFCodeSetRegistry.Entry codeset, java.nio.ByteOrder defaultByteOrder)
BTCConverter factory for fixed width multibyte encodings.CodeSetConversion.CTBConverter
getCTBConverter(OSFCodeSetRegistry.Entry codeset)
CTB converter factory for single byte or variable length encodings.(package private) CodeSetConversion.CTBConverter
getCTBConverter(OSFCodeSetRegistry.Entry codeset, boolean littleEndian, boolean useByteOrderMarkers)
CTB converter factory for multibyte (mainly fixed) encodings.static CodeSetConversion
impl()
CodeSetConversion is a singleton, and this is the access point.CodeSetComponentInfo.CodeSetContext
negotiate(CodeSetComponentInfo client, CodeSetComponentInfo server)
Perform the code set negotiation algorithm and come up with the two encodings to use.private int
selectEncoding(CodeSetComponentInfo.CodeSetComponent client, CodeSetComponentInfo.CodeSetComponent server)
Follows the code set negotiation algorithm in CORBA formal 99-10-07 13.7.2.
-
-
-
Field Detail
-
wrapper
private static final ORBUtilSystemException wrapper
-
omgWrapper
private static final OMGSystemException omgWrapper
-
FALLBACK_CODESET
private static final int FALLBACK_CODESET
- See Also:
- Constant Field Values
-
cache
private CodeSetCache cache
-
cacheBTCC
private java.lang.ThreadLocal<java.util.HashMap<OSFCodeSetRegistry.Entry,CodeSetConversion.BTCConverter>> cacheBTCC
-
cacheCTBC
private java.lang.ThreadLocal<java.util.HashMap<OSFCodeSetRegistry.Entry,CodeSetConversion.CTBConverter>> cacheCTBC
-
-
Method Detail
-
getCTBConverter
public CodeSetConversion.CTBConverter getCTBConverter(OSFCodeSetRegistry.Entry codeset)
CTB converter factory for single byte or variable length encodings.- Parameters:
codeset
- Codeset to get converter for- Returns:
- Char-to-Byte Converter for codeset
-
getCTBConverter
CodeSetConversion.CTBConverter getCTBConverter(OSFCodeSetRegistry.Entry codeset, boolean littleEndian, boolean useByteOrderMarkers)
CTB converter factory for multibyte (mainly fixed) encodings. Because of the awkwardness with byte order markers and the possibility of using UCS-2, you must specify both the endianness of the stream as well as whether or not to use byte order markers if applicable. UCS-2 has no byte order markers. UTF-16 has optional markers. If you select useByteOrderMarkers, there is no guarantee that the encoding will use the endianness specified.
-
getBTCConverter
public CodeSetConversion.BTCConverter getBTCConverter(OSFCodeSetRegistry.Entry codeset)
BTCConverter factory for single byte or variable width encodings.- Parameters:
codeset
- Codeset to get converter for- Returns:
- new Byte-to-Char Converter
-
getBTCConverter
public CodeSetConversion.BTCConverter getBTCConverter(OSFCodeSetRegistry.Entry codeset, java.nio.ByteOrder defaultByteOrder)
BTCConverter factory for fixed width multibyte encodings.- Parameters:
codeset
- Codeset to get converter fordefaultByteOrder
- Order of bytes in the codeset- Returns:
- Converter for a codeset
-
selectEncoding
private int selectEncoding(CodeSetComponentInfo.CodeSetComponent client, CodeSetComponentInfo.CodeSetComponent server)
Follows the code set negotiation algorithm in CORBA formal 99-10-07 13.7.2. Returns the proper negotiated OSF character encoding number or CodeSetConversion.FALLBACK_CODESET.
-
negotiate
public CodeSetComponentInfo.CodeSetContext negotiate(CodeSetComponentInfo client, CodeSetComponentInfo server)
Perform the code set negotiation algorithm and come up with the two encodings to use.- Parameters:
client
- Info from the clientserver
- Info from the server- Returns:
- Resulted negotiated encoding context
-
impl
public static CodeSetConversion impl()
CodeSetConversion is a singleton, and this is the access point.- Returns:
- A holder for
CodeSetConversion
-
-