예제 #1
0
파일: IOR.java 프로젝트: Blueash/gcc
  /**
   * Read the IOR from the provided input stream, not reading the endian data at the beginning of
   * the stream. The IOR is thansferred in this form in {@link write_Object(org.omg.CORBA.Object)}.
   *
   * <p>If the stream contains a null value, the Id and Internet fields become equal to null.
   * Otherwise Id contains some string (possibly empty).
   *
   * <p>Id is checked for null in AbstractCdrInput that then returns null instead of object.
   *
   * @param c a stream to read from.
   * @throws IOException if the stream throws it.
   */
  public void _read_no_endian(AbstractCdrInput c) throws IOException, BAD_PARAM {
    Id = c.read_string();

    int n_profiles = c.read_long();

    if (n_profiles == 0) {
      Id = null;
      Internet = null;
      return;
    }

    for (int i = 0; i < n_profiles; i++) {
      int tag = c.read_long();
      BufferredCdrInput profile = c.read_encapsulation();

      if (tag == Internet_profile.TAG_INTERNET_IOP) {
        Internet = new Internet_profile();
        Internet.version = Version.read_version(profile);
        Internet.host = profile.read_string();
        Internet.port = profile.gnu_read_ushort();

        key = profile.read_sequence();

        // Read tagged components.
        int n_components = 0;

        try {
          if (Internet.version.since_inclusive(1, 1)) n_components = profile.read_long();

          for (int t = 0; t < n_components; t++) {
            int ctag = profile.read_long();

            if (ctag == CodeSets_profile.TAG_CODE_SETS) {
              Internet.CodeSets.read(profile);
            } else {
              // Construct a generic component for codesets
              // profile.
              TaggedComponent pc = new TaggedComponent();
              pc.tag = ctag;
              pc.component_data = profile.read_sequence();
              Internet.components.add(pc);
            }
          }
        } catch (Unexpected ex) {
          ex.printStackTrace();
        }
      } else {
        // Construct a generic profile.
        TaggedProfile p = new TaggedProfile();
        p.tag = tag;
        p.profile_data = profile.buffer.getBuffer();

        profiles.add(p);
      }
    }
  }
예제 #2
0
파일: IOR.java 프로젝트: Blueash/gcc
  /**
   * Add given component to the given profile that is NOT an Internet profile.
   *
   * @param profile the profile, where the component should be added.
   * @param component the component to add.
   */
  private static void addComponentTo(TaggedProfile profile, TaggedComponent component) {
    if (profile.tag == TAG_MULTIPLE_COMPONENTS.value) {
      TaggedComponent[] present;
      if (profile.profile_data.length > 0) {
        BufferredCdrInput in = new BufferredCdrInput(profile.profile_data);

        present = new TaggedComponent[in.read_long()];

        for (int i = 0; i < present.length; i++) {
          present[i] = TaggedComponentHelper.read(in);
        }
      } else present = new TaggedComponent[0];

      BufferedCdrOutput out =
          new BufferedCdrOutput(profile.profile_data.length + component.component_data.length + 8);

      // Write new amount of components.
      out.write_long(present.length + 1);

      // Write other components.
      for (int i = 0; i < present.length; i++) TaggedComponentHelper.write(out, present[i]);

      // Write the passed component.
      TaggedComponentHelper.write(out, component);

      try {
        out.close();
      } catch (IOException e) {
        throw new Unexpected(e);
      }
      profile.profile_data = out.buffer.toByteArray();
    } else
      // The future supported tagged profiles should be added here.
      throw new BAD_PARAM("Unsupported profile type " + profile.tag);
  }