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.ObjectCollection 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 classCodeSetConversion.BTCConverterAbstraction for byte to char conversion.private static classCodeSetConversion.CodeSetConversionHolderstatic classCodeSetConversion.CTBConverterAbstraction for char to byte conversion.private classCodeSetConversion.JavaBTCConverterImplementation of BTCConverter which uses a sun.io.ByteToCharConverter for the real work.private classCodeSetConversion.JavaCTBConverterImplementation of CTBConverter which uses a nio.Charset.CharsetEncoder to do the real work.private classCodeSetConversion.UTF16BTCConverterSpecial 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 classCodeSetConversion.UTF16CTBConverterSpecial 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 CodeSetCachecacheprivate java.lang.ThreadLocal<java.util.HashMap<OSFCodeSetRegistry.Entry,CodeSetConversion.BTCConverter>>cacheBTCCprivate java.lang.ThreadLocal<java.util.HashMap<OSFCodeSetRegistry.Entry,CodeSetConversion.CTBConverter>>cacheCTBCprivate static intFALLBACK_CODESETprivate static OMGSystemExceptionomgWrapperprivate static ORBUtilSystemExceptionwrapper
-
Constructor Summary
Constructors Modifier Constructor Description privateCodeSetConversion()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CodeSetConversion.BTCConvertergetBTCConverter(OSFCodeSetRegistry.Entry codeset)BTCConverter factory for single byte or variable width encodings.CodeSetConversion.BTCConvertergetBTCConverter(OSFCodeSetRegistry.Entry codeset, java.nio.ByteOrder defaultByteOrder)BTCConverter factory for fixed width multibyte encodings.CodeSetConversion.CTBConvertergetCTBConverter(OSFCodeSetRegistry.Entry codeset)CTB converter factory for single byte or variable length encodings.(package private) CodeSetConversion.CTBConvertergetCTBConverter(OSFCodeSetRegistry.Entry codeset, boolean littleEndian, boolean useByteOrderMarkers)CTB converter factory for multibyte (mainly fixed) encodings.static CodeSetConversionimpl()CodeSetConversion is a singleton, and this is the access point.CodeSetComponentInfo.CodeSetContextnegotiate(CodeSetComponentInfo client, CodeSetComponentInfo server)Perform the code set negotiation algorithm and come up with the two encodings to use.private intselectEncoding(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
-
-