public synchronized boolean equal()

in yoko-core/src/main/java/org/apache/yoko/orb/CORBA/Any.java [369:491]


    public synchronized boolean equal(org.omg.CORBA.Any a) {
        if (a == null)
            return false;

        if (this == a)
            return true;

        if (!type_.equal(a.type()))
            return false;

        Any any = null;
        try {
            any = (Any) a;
        } catch (ClassCastException ex) {
            //
            // Argument may have been created by a foreign singleton ORB,
            // so we'll use a temporary.
            //
            any = new Any(a);
        }

        if (value_ == any.value_)
            return true;

        if (value_ == null || any.value_ == null)
            return false;

        if (value_ instanceof org.omg.CORBA.portable.Streamable
                && any.value_ instanceof org.omg.CORBA.portable.Streamable) {
            OutputStream os1 = (OutputStream) create_output_stream();
            ((org.omg.CORBA.portable.Streamable) value_)._write(os1);
            OutputStream os2 = (OutputStream) create_output_stream();
            ((org.omg.CORBA.portable.Streamable) any.value_)._write(os2);
            return compare(os1._OB_buffer(), os2._OB_buffer());
        }

        int kind = origType_.kind().value();
        switch (kind) {
        case org.omg.CORBA.TCKind._tk_null:
        case org.omg.CORBA.TCKind._tk_void:
            return true;

        case org.omg.CORBA.TCKind._tk_short:
        case org.omg.CORBA.TCKind._tk_long:
        case org.omg.CORBA.TCKind._tk_longlong:
        case org.omg.CORBA.TCKind._tk_ushort:
        case org.omg.CORBA.TCKind._tk_ulong:
        case org.omg.CORBA.TCKind._tk_ulonglong:
        case org.omg.CORBA.TCKind._tk_float:
        case org.omg.CORBA.TCKind._tk_double:
        case org.omg.CORBA.TCKind._tk_boolean:
        case org.omg.CORBA.TCKind._tk_char:
        case org.omg.CORBA.TCKind._tk_wchar:
        case org.omg.CORBA.TCKind._tk_octet:
        case org.omg.CORBA.TCKind._tk_enum:
        case org.omg.CORBA.TCKind._tk_string:
        case org.omg.CORBA.TCKind._tk_wstring:
        case org.omg.CORBA.TCKind._tk_fixed:
            return value_.equals(any.value_);

        case org.omg.CORBA.TCKind._tk_any:
            return extract_any().equal(any.extract_any());

        case org.omg.CORBA.TCKind._tk_TypeCode:
            return extract_TypeCode().equal(any.extract_TypeCode());

        case org.omg.CORBA.TCKind._tk_Principal:
            return extract_Principal().equals(any.extract_Principal());

        case org.omg.CORBA.TCKind._tk_objref:
        case org.omg.CORBA_2_4.TCKind._tk_local_interface:
            return extract_Object()._is_equivalent(any.extract_Object());

        case org.omg.CORBA.TCKind._tk_struct:
        case org.omg.CORBA.TCKind._tk_except:
        case org.omg.CORBA.TCKind._tk_union:
        case org.omg.CORBA.TCKind._tk_sequence:
        case org.omg.CORBA.TCKind._tk_array: {
            org.apache.yoko.orb.OCI.Buffer buf1 = ((InputStream) value_)
                    ._OB_buffer();
            org.apache.yoko.orb.OCI.Buffer buf2 = ((InputStream) any.value_)
                    ._OB_buffer();
            return compare(buf1, buf2);
        }

        case org.omg.CORBA.TCKind._tk_value:
        case org.omg.CORBA.TCKind._tk_value_box: {
            if (value_ instanceof InputStream
                    && any.value_ instanceof InputStream) {
                org.apache.yoko.orb.OCI.Buffer buf1 = ((InputStream) value_)
                        ._OB_buffer();
                org.apache.yoko.orb.OCI.Buffer buf2 = ((InputStream) any.value_)
                        ._OB_buffer();
                return compare(buf1, buf2);
            } else
                return false;
        }

        case org.omg.CORBA.TCKind._tk_abstract_interface: {
            if (value_ instanceof org.omg.CORBA.Object
                    && any.value_ instanceof org.omg.CORBA.Object) {
                return extract_Object()._is_equivalent(any.extract_Object());
            } else if (value_ instanceof InputStream
                    && any.value_ instanceof InputStream) {
                org.apache.yoko.orb.OCI.Buffer buf1 = ((InputStream) value_)
                        ._OB_buffer();
                org.apache.yoko.orb.OCI.Buffer buf2 = ((InputStream) any.value_)
                        ._OB_buffer();
                return compare(buf1, buf2);
            }
            return false;
        }

        case org.omg.CORBA.TCKind._tk_native:
            return (value_ == any.value_);

        case org.omg.CORBA.TCKind._tk_alias:
        default:
            org.apache.yoko.orb.OB.Assert._OB_assert("tk_alias not supported for comparison");
        }

        return false; // The compiler needs this
    }