Esempio n. 1
0
 /**
  * Verifies that the default encoding (UTF-16) works for wstrings in giop 1.1, which uses the
  * length indicator to specify the number of characters rather than bytes and require a two-byte
  * null terminator. Wide characters in 1.1 do not take width bytes
  */
 @Test
 public void testDefaultEncodingWCharGiop1_1() throws Exception {
   byte[] codedText = {
     0,
     0,
     0,
     5, // string length in bytes, not chars
     0x30,
     (byte) (0xDF & 0xff), // Mitsubishi, in Katakana
     0x30,
     (byte) (0xC4 & 0xff),
     0x30,
     (byte) (0xFA & 0xff),
     0x30,
     (byte) (0xB7 & 0xff),
     0,
     0, // two-byte null terminator
     0x5,
     (byte) (0xD1 & 0xff), // Hebrew letter beis
   };
   CDRInputStream stream = new CDRInputStream(orb, codedText);
   stream.setGIOPMinor(1);
   assertEquals("wstring value", "\u30DF\u30C4\u30FA\u30B7", stream.read_wstring());
   assertEquals("wchar 1", '\u05D1', stream.read_wchar());
   stream.close();
 }
Esempio n. 2
0
 /** Verifies that the UTF-8 encoding works for strings in giop 1.1. */
 @Test
 public void testUTF8EncodingCharGiop1_1() throws Exception {
   byte[] codedText = {
     0, 0, 0, 5, // string length in bytes, including null pointer
     'a', 's', 'd', 'f', 0, // one-byte null terminator
     'x'
   };
   CDRInputStream stream = new CDRInputStream(orb, codedText);
   selectCodeSets(stream, "UTF8", "UTF8");
   stream.setGIOPMinor(1);
   assertEquals("sstring value", "asdf", stream.read_string());
   assertEquals("char 1", 'x', stream.read_char());
   stream.close();
 }
Esempio n. 3
0
  public Any decode(byte[] data) throws FormatMismatch {
    final CDRInputStream in = new CDRInputStream(orb, data);

    try {
      in.setGIOPMinor(giopMinor);

      in.openEncapsulatedArray();
      Any result = in.read_any();

      // not necessary, since stream is never used again
      // in.closeEncapsulation();

      return result;
    } finally {
      in.close();
    }
  }
Esempio n. 4
0
  public Any decode_value(byte[] data, TypeCode tc) throws FormatMismatch, TypeMismatch {
    final CDRInputStream in = new CDRInputStream(orb, data);

    try {
      in.setGIOPMinor(giopMinor);

      in.openEncapsulatedArray();
      Any result = orb.create_any();
      result.read_value(in, tc);

      // not necessary, since stream is never used again
      // in.closeEncasupaltion();

      return result;
    } finally {
      in.close();
    }
  }