예제 #1
0
  protected TypeCode doReadTypeCodeInternal(
      CDRInputStream in,
      Map recursiveTCMap,
      Map repeatedTCMap,
      Integer startPosition,
      int kind,
      String repositoryID) {
    final String name = validateName(in.read_string());
    final int member_count = in.read_long();

    StructMember[] members = new StructMember[member_count];
    for (int i = 0; i < member_count; i++) {
      members[i] =
          new StructMember(in.read_string(), in.read_TypeCode(recursiveTCMap, repeatedTCMap), null);
    }
    return orb.create_exception_tc(repositoryID, name, members, false);
  }
예제 #2
0
파일: PrintIOR.java 프로젝트: 2pirad/jacorb
  private static void printJavaCodebaseComponent(TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream in = new CDRInputStream(taggedComponent.component_data);

    try {
      in.openEncapsulatedArray();
      String codebase = in.read_string();

      out.println("\t\tCodebase: " + codebase);
    } finally {
      in.close();
    }
  }
예제 #3
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();
 }
예제 #4
0
  /**
   * Verifies that the default encoding (ISO8859_1) works for char, char arrays, and strings.
   * Reading the string forces alignment of the 4-byte length, and ignores any null terminator.
   */
  @Test
  public void testDefaultEncodingChar() throws Exception {
    byte[] codedText = {'a', 's', 'd', 'f', 'x', 'y', 'z', '*', 0, 0, 0, 5, 'C', 'A', 'F', 'E', 0};
    CDRInputStream stream = new CDRInputStream(orb, codedText);
    assertEquals("char 1", 'a', stream.read_char());
    assertEquals("char 2", 's', stream.read_char());
    assertEquals("char 3", 'd', stream.read_char());
    assertEquals("char 4", 'f', stream.read_char());

    char[] buffer = new char[4];
    buffer[0] = 'w';
    stream.read_char_array(buffer, 1, 3);
    assertEquals("char array", "wxyz", new String(buffer));
    assertEquals("string value", "CAFE", stream.read_string());
    stream.close();
  }
예제 #5
0
 @Test
 public void testFailOnNullEncodedString() throws Exception {
   byte[] codedText = {0, 0, 0, 0};
   CDRInputStream stream = new CDRInputStream(orb, codedText);
   try {
     stream.read_string();
     fail("Null encoded string should have failed with an exception");
   } catch (MARSHAL e) {
     assertNotNull(e.getMessage());
     assertTrue(
         "Not a MARSHALL exception: " + e.getMessage(),
         e.getMessage().matches("^.*invalid string size: 0.*$"));
   } finally {
     stream.close();
   }
 }
예제 #6
0
파일: PrintIOR.java 프로젝트: 2pirad/jacorb
  private static void printAlternateAddress(
      ORB orb, TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is = new CDRInputStream(taggedComponent.component_data);

    try {
      is.openEncapsulatedArray();
      String hostname = is.read_string();
      short port = is.read_ushort();

      IIOPAddress result = new IIOPAddress(hostname, port);
      try {
        result.configure(((org.jacorb.orb.ORB) orb).getConfiguration());
      } catch (ConfigurationException ce) {
        ((org.jacorb.orb.ORB) orb)
            .getConfiguration()
            .getLogger("PrintIOR")
            .warn("ConfigurationException", ce);
      }

      out.println("\t\tAddress: " + result.toString());
    } finally {
      is.close();
    }
  }