org.jacorb.orb.giop
Class CodeSet

java.lang.Object
  extended by org.jacorb.orb.giop.CodeSet

public class CodeSet
extends java.lang.Object

Version:
$Id: CodeSet.java,v 1.26 2009-05-03 21:35:55 andre.spiegel Exp $
Author:
Gerald Brose

Nested Class Summary
static interface CodeSet.InputBuffer
          This interface represents a buffer from which character data can be read.
static interface CodeSet.OutputBuffer
          Represents a buffer to which character data may be written.
 
Constructor Summary
CodeSet(int id, java.lang.String name)
           
 
Method Summary
static void configure(org.jacorb.config.Configuration config)
          configure configures the logger and codesets.
static ServiceContext createCodesetContext(CodeSet tcs, CodeSet tcsw)
           
static java.lang.String csName(int cs)
           
 int get_wstring_size(java.lang.String string, int startPos, int currentPos)
          Returns the length of the string just written to the buffer.
static CodeSet getCodeSet(int id)
          Returns the code set which matches the specified ID.
static CodeSet getCodeSet(java.lang.String name)
          Returns the code set which matches the specified name, which should either be the canonical name of a supported encoding or the hex representation of its ID.
static CodeSetContext getCodeSetContext(ServiceContext[] contexts)
           
static CodeSet getCodeSetIfMatched(int localCodeSetId, CodeSetComponent remote)
           
 int getId()
          Returns the CORBA-standard id for this code set.
static CodeSetComponentInfo getLocalCodeSetComponentInfo()
           
static CodeSet getMatchingCodeSet(CodeSetComponent local, CodeSetComponent remote, boolean wide)
           
 java.lang.String getName()
          Returns the canonical name of this code set.
static CodeSet getNegotiatedCodeSet(CodeSetComponentInfo serverCodeSetInfo, boolean wide)
           
static CodeSet getTCSDefault()
           
static CodeSet getTCSWDefault()
           
static void main(java.lang.String[] args)
           
 char read_wchar(CodeSet.InputBuffer buffer, int giop_minor, boolean littleEndian)
          Reads a wide character from the specified buffer.
 java.lang.String read_wstring(CodeSet.InputBuffer buffer, int lengthIndicator, int giop_minor, boolean littleEndian)
          Reads a wide string from the buffer.
protected  java.lang.String readGiop12WString(CodeSet.InputBuffer buffer, int size, int giop_minor)
          Reads a wide string from the buffer according to GIOP 1.2.
 boolean supportsCharacterData(boolean wide)
          Returns true if this codeset supports the specified character type.
 boolean supportsWideCharacterData()
          Returns true if this codeset supports multie-byte characters
 boolean write_bom(boolean configuredForBom)
          Returns true if this code set requires byte-order-markers to be written to the beginning of a stream of text.
 void write_char(CodeSet.OutputBuffer buffer, char c, boolean write_bom, boolean write_length, int giop_minor)
          Writes a character to the buffer with the appropriate encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeSet

public CodeSet(int id,
               java.lang.String name)
Method Detail

csName

public static java.lang.String csName(int cs)

configure

public static void configure(org.jacorb.config.Configuration config)
                      throws org.jacorb.config.ConfigurationException
configure configures the logger and codesets. It is synchronized as the configuration parameters are static and therefore we do not want to 'collide' with another init. This class does not implement configurable which ideally it should. However as this method is static it would conflict with it.

Parameters:
config - a Configuration value
Throws:
org.jacorb.config.ConfigurationException - if an error occurs

getCodeSet

public static CodeSet getCodeSet(java.lang.String name)
Returns the code set which matches the specified name, which should either be the canonical name of a supported encoding or the hex representation of its ID.

Parameters:
name - the string used to select a codeset.
Returns:
the matching code set or NULL_CODE_SET if there are no matches.

getCodeSet

public static CodeSet getCodeSet(int id)
Returns the code set which matches the specified ID.


getTCSDefault

public static CodeSet getTCSDefault()

getTCSWDefault

public static CodeSet getTCSWDefault()

createCodesetContext

public static ServiceContext createCodesetContext(CodeSet tcs,
                                                  CodeSet tcsw)

getCodeSetContext

public static CodeSetContext getCodeSetContext(ServiceContext[] contexts)

getLocalCodeSetComponentInfo

public static CodeSetComponentInfo getLocalCodeSetComponentInfo()

getNegotiatedCodeSet

public static CodeSet getNegotiatedCodeSet(CodeSetComponentInfo serverCodeSetInfo,
                                           boolean wide)

getMatchingCodeSet

public static CodeSet getMatchingCodeSet(CodeSetComponent local,
                                         CodeSetComponent remote,
                                         boolean wide)

getCodeSetIfMatched

public static CodeSet getCodeSetIfMatched(int localCodeSetId,
                                          CodeSetComponent remote)

supportsCharacterData

public boolean supportsCharacterData(boolean wide)
Returns true if this codeset supports the specified character type.

Parameters:
wide -

supportsWideCharacterData

public boolean supportsWideCharacterData()
Returns true if this codeset supports multie-byte characters


getId

public int getId()
Returns the CORBA-standard id for this code set.


getName

public java.lang.String getName()
Returns the canonical name of this code set.


write_bom

public boolean write_bom(boolean configuredForBom)
Returns true if this code set requires byte-order-markers to be written to the beginning of a stream of text.

Parameters:
configuredForBom - true if the orb has been configured to write byte-order-markers.

read_wchar

public char read_wchar(CodeSet.InputBuffer buffer,
                       int giop_minor,
                       boolean littleEndian)
Reads a wide character from the specified buffer.

Parameters:
buffer - the buffer containing the data.
giop_minor - the low-order byte of the giop version (1.x is assumed)
littleEndian - true if the character is to be read low end first
Returns:
the wide character.

read_wstring

public java.lang.String read_wstring(CodeSet.InputBuffer buffer,
                                     int lengthIndicator,
                                     int giop_minor,
                                     boolean littleEndian)
Reads a wide string from the buffer. The length indicator is presumed already to have been read.

Parameters:
buffer - the buffer from which to read the string
lengthIndicator - the length indicator already read
giop_minor - the low-order byte of the giop version (1.x is assumed)
littleEndian - true if the characters are to be read low end first
Returns:
a string possibly containing wide characters.

write_char

public void write_char(CodeSet.OutputBuffer buffer,
                       char c,
                       boolean write_bom,
                       boolean write_length,
                       int giop_minor)
Writes a character to the buffer with the appropriate encoding.

Parameters:
buffer - the buffer to which the character is written
c - the character to write
write_bom - true if a byte-order-marker (indicating big-endian) should be written
write_length - true if the length of the character should be written
giop_minor - the low-order byte of the giop version (1.x is assumed)

get_wstring_size

public int get_wstring_size(java.lang.String string,
                            int startPos,
                            int currentPos)
Returns the length of the string just written to the buffer.

Parameters:
string - the string written
startPos - the starting position at which the string was written
currentPos - the current buffer position

readGiop12WString

protected final java.lang.String readGiop12WString(CodeSet.InputBuffer buffer,
                                                   int size,
                                                   int giop_minor)
Reads a wide string from the buffer according to GIOP 1.2. The length indicator is presumed already to have been read.

Parameters:
buffer - the buffer from which to read the string
size - the length indicator already read
giop_minor - the low-order byte of the giop version (must be >= 2)
Returns:
a string possibly containing wide characters.

main

public static void main(java.lang.String[] args)