/**
   * Write the structure to the CDR output stream. Writes the integer identifier of the tag, then
   * the size of the tag data and then the specified number of bytes, representing the data of the
   * tag.
   *
   * @param output a org.omg.CORBA.portable stream stream to write into.
   * @param value a value to write.
   */
  public static void write(OutputStream output, TaggedComponent value) {
    output.write_long(value.tag);
    output.write_long(value.component_data.length);

    try {
      output.write(value.component_data);
    } catch (IOException e) {
      MARSHAL m = new MARSHAL();
      m.minor = Minor.Encapsulation;
      m.initCause(e);
      throw m;
    }
  }
 /**
  * Read the structure from the CDR intput stream. Expects the integer identifier of the tag, then
  * the size of the tag data and then the specified number of bytes, representing the data of the
  * tag.
  *
  * @param input a org.omg.CORBA.portable stream to read from.
  */
 public static TaggedComponent read(InputStream input) {
   TaggedComponent value = new TaggedComponent();
   value.tag = input.read_long();
   value.component_data = new byte[input.read_long()];
   try {
     input.read(value.component_data);
   } catch (IOException e) {
     MARSHAL m = new MARSHAL();
     m.minor = Minor.Encapsulation;
     m.initCause(e);
     throw m;
   }
   return value;
 }
Exemplo n.º 3
0
Arquivo: IOR.java Projeto: Blueash/gcc
    /** Write the internet profile (except the heading tag. */
    public void write(AbstractCdrOutput out) {
      try {
        // Need to write the Internet profile into the separate
        // stream as we must know the size in advance.
        AbstractCdrOutput b = out.createEncapsulation();

        version.write(b);
        b.write_string(host);

        b.write_ushort((short) (port & 0xFFFF));

        // Write the object key.
        b.write_long(key.length);
        b.write(key);

        // Number of the tagged components.
        b.write_long(1 + components.size());

        b.write_long(CodeSets_profile.TAG_CODE_SETS);
        CodeSets.write(b);

        TaggedComponent t;

        for (int i = 0; i < components.size(); i++) {
          t = (TaggedComponent) components.get(i);
          TaggedComponentHelper.write(b, t);
        }

        b.close();
      } catch (Exception e) {
        MARSHAL m = new MARSHAL("Unable to write Internet profile.");
        m.minor = Minor.IOR;
        m.initCause(e);
        throw m;
      }
    }