Beispiel #1
0
  /**
   * Test that jacorb handles some self-constructed broken typecodes well. The constructed typecode
   * is in principal recursive, but not flagged as such.
   */
  public void testBrokenRecursiveTypecode() {
    Any innerAny = orb.create_any();
    innerAny.insert_long(4711);

    StructMember[] members = {new StructMember("myAny", innerAny.type(), null)};

    TypeCode innerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            members);

    TypeCode outerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            new StructMember[] {new StructMember("foo", innerTc, null)});

    org.jacorb.orb.CDROutputStream out = new org.jacorb.orb.CDROutputStream(orb);
    out.write_TypeCode(outerTc);
    org.jacorb.orb.CDRInputStream in = new org.jacorb.orb.CDRInputStream(orb, out.getBufferCopy());

    out = new org.jacorb.orb.CDROutputStream(orb);

    // need to write out typecode, to check it's consistency completely
    out.write_TypeCode(in.read_TypeCode());
  }
Beispiel #2
0
  public byte[] encode_value(Any data) throws InvalidTypeForEncoding {
    final CDROutputStream out = new CDROutputStream(orb);

    try {
      out.setGIOPMinor(giopMinor);

      out.beginEncapsulatedArray();
      data.write_value(out);

      /*
      closing must not be done, since it will patch the
      array with a size!

      try
      {
      out.endEncapsulation();
      }
      catch (java.io.IOException e)
      {
      }
      */

      /*
       * We have to copy anyway since we need an exact-sized array.
       * Closing afterwards, to return buffer to BufferManager.
       */
      byte[] result = out.getBufferCopy();

      return result;
    } finally {
      out.close();
    }
  }
Beispiel #3
0
 /** Returns a CDR encapsulation of the given UtcT. */
 public static byte[] toCDR(UtcT time) {
   final CDROutputStream out = new CDROutputStream();
   try {
     out.beginEncapsulatedArray();
     UtcTHelper.write(out, time);
     return out.getBufferCopy();
   } finally {
     out.close();
   }
 }
Beispiel #4
0
 public byte[] toCDR() {
   CDROutputStream out = new CDROutputStream();
   try {
     out.beginEncapsulatedArray();
     this.write(out);
     return out.getBufferCopy();
   } finally {
     out.close();
   }
 }