static public boolean equivalent()

in yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/Util.java [278:373]


    static public boolean equivalent(IOR ior1, IOR ior2) {
        int p1, p2, b1, b2;
        int cnt1 = 0, cnt2 = 0;
        ProfileBody_1_0[] bodies1;
        ProfileBody_1_0[] bodies2;

        //
        // Calculate number of IIOP profiles in ior1
        //
        for (p1 = 0; p1 < ior1.profiles.length; p1++)
            if (ior1.profiles[p1].tag == TAG_INTERNET_IOP.value)
                cnt1++;

        //
        // Calculate number of IIOP profiles in ior2
        //
        for (p2 = 0; p2 < ior2.profiles.length; p2++)
            if (ior2.profiles[p2].tag == TAG_INTERNET_IOP.value)
                cnt2++;

        //
        // Return false now if the number of IIOP profile bodies do not
        // match
        //
        if (cnt1 != cnt2)
            return false;

        //
        // Create an array with all IIOP profile bodies of ior1
        //
        bodies1 = new ProfileBody_1_0[cnt1];
        for (p1 = 0, b1 = 0; p1 < ior1.profiles.length; p1++)
            if (ior1.profiles[p1].tag == TAG_INTERNET_IOP.value) {
                byte[] data = ior1.profiles[p1].profile_data;
                Buffer buf = new Buffer(
                        data, data.length);
                InputStream in = new InputStream(buf, 0, false, null, null);
                in._OB_readEndian();
                bodies1[b1++] = ProfileBody_1_0Helper.read(in);
            }

        if (b1 != cnt1)
            throw new InternalError();

        //
        // Create an array with all IIOP profile bodies of ior2
        //
        bodies2 = new ProfileBody_1_0[cnt2];
        for (p2 = 0, b2 = 0; p2 < ior2.profiles.length; p2++)
            if (ior2.profiles[p2].tag == TAG_INTERNET_IOP.value) {
                byte[] data = ior2.profiles[p2].profile_data;
                Buffer buf = new Buffer(
                        data, data.length);
                InputStream in = new InputStream(buf, 0, false, null, null);
                in._OB_readEndian();
                bodies2[b2++] = ProfileBody_1_0Helper.read(in);
            }

        if (b2 != cnt2)
            throw new InternalError();

        //
        // Check for profile body matches
        //
        for (b1 = 0; b1 < cnt1; b1++) {
            for (b2 = 0; b2 < cnt2; b2++) {
                if (bodies2[b2] == null)
                    continue;

                //
                // Compare profile bodies
                //
                if (compareBodies(bodies1[b1], bodies2[b2])) {
                    //
                    // OK, found a match
                    //
                    bodies1[b1] = null;
                    bodies2[b2] = null;
                    break;
                }
            }
        }

        //
        // Check whether there are any unmatched IIOP profile bodies
        //
        for (b1 = 0; b1 < cnt1; b1++)
            if (bodies1[b1] != null)
                return false;

        for (b2 = 0; b2 < cnt2; b2++)
            if (bodies2[b2] != null)
                return false;

        return true;
    }