Exemplo n.º 1
0
  /**
   * checks for equality between Anys.
   *
   * @param otherAny the Any to be compared with.
   * @result true if the Anys are equal, false otherwise.
   */
  public boolean equal(Any otherAny) {
    // debug.log ("equal");

    if (otherAny == this) return true;

    // first check for typecode equality.
    // note that this will take aliases into account
    if (!typeCode.equal(otherAny.type())) return false;

    // Resolve aliases here
    TypeCode realType = realType();

    // _REVISIT_ Possible optimization for the case where
    // otherAny is a AnyImpl and the endianesses match.
    // Need implementation of CDRInputStream.equals()
    // For now we disable this to encourage testing the generic,
    // unoptimized code below.
    // Unfortunately this generic code needs to copy the whole stream
    // at least once.
    //    if (AnyImpl.isStreamed[realType.kind().value()]) {
    //        if (otherAny instanceof AnyImpl) {
    //            return ((AnyImpl)otherAny).stream.equals(stream);
    //        }
    //    }
    switch (realType.kind().value()) {
        // handle primitive types
      case TCKind._tk_null:
      case TCKind._tk_void:
        return true;
      case TCKind._tk_short:
        return (extract_short() == otherAny.extract_short());
      case TCKind._tk_long:
        return (extract_long() == otherAny.extract_long());
      case TCKind._tk_ushort:
        return (extract_ushort() == otherAny.extract_ushort());
      case TCKind._tk_ulong:
        return (extract_ulong() == otherAny.extract_ulong());
      case TCKind._tk_float:
        return (extract_float() == otherAny.extract_float());
      case TCKind._tk_double:
        return (extract_double() == otherAny.extract_double());
      case TCKind._tk_boolean:
        return (extract_boolean() == otherAny.extract_boolean());
      case TCKind._tk_char:
        return (extract_char() == otherAny.extract_char());
      case TCKind._tk_wchar:
        return (extract_wchar() == otherAny.extract_wchar());
      case TCKind._tk_octet:
        return (extract_octet() == otherAny.extract_octet());
      case TCKind._tk_any:
        return extract_any().equal(otherAny.extract_any());
      case TCKind._tk_TypeCode:
        return extract_TypeCode().equal(otherAny.extract_TypeCode());
      case TCKind._tk_string:
        return extract_string().equals(otherAny.extract_string());
      case TCKind._tk_wstring:
        return (extract_wstring().equals(otherAny.extract_wstring()));
      case TCKind._tk_longlong:
        return (extract_longlong() == otherAny.extract_longlong());
      case TCKind._tk_ulonglong:
        return (extract_ulonglong() == otherAny.extract_ulonglong());

      case TCKind._tk_objref:
        return (extract_Object().equals(otherAny.extract_Object()));
      case TCKind._tk_Principal:
        return (extract_Principal().equals(otherAny.extract_Principal()));

      case TCKind._tk_enum:
        return (extract_long() == otherAny.extract_long());
      case TCKind._tk_fixed:
        return (extract_fixed().compareTo(otherAny.extract_fixed()) == 0);
      case TCKind._tk_except:
      case TCKind._tk_struct:
      case TCKind._tk_union:
      case TCKind._tk_sequence:
      case TCKind._tk_array:
        InputStream copyOfMyStream = this.create_input_stream();
        InputStream copyOfOtherStream = otherAny.create_input_stream();
        return equalMember(realType, copyOfMyStream, copyOfOtherStream);

        // Too complicated to handle value types the way we handle
        // other complex types above. Don't try to decompose it here
        // for faster comparison, just use Object.equals().
      case TCKind._tk_value:
      case TCKind._tk_value_box:
        return extract_Value().equals(otherAny.extract_Value());

      case TCKind._tk_alias:
        throw wrapper.errorResolvingAlias();

      case TCKind._tk_longdouble:
        // Unspecified for Java
        throw wrapper.tkLongDoubleNotSupported();

      default:
        throw wrapper.typecodeNotSupported();
    }
  }
Exemplo n.º 2
0
 /*      */ public boolean equal(Any paramAny) /*      */ {
   /*  267 */ if (paramAny == this) {
     /*  268 */ return true;
     /*      */ }
   /*      */
   /*  272 */ if (!this.typeCode.equal(paramAny.type())) {
     /*  273 */ return false;
     /*      */ }
   /*      */
   /*  276 */ TypeCode localTypeCode = realType();
   /*      */
   /*  290 */ switch (localTypeCode.kind().value())
   /*      */ {
       /*      */ case 0:
       /*      */ case 1:
       /*  294 */ return true;
       /*      */ case 2:
       /*  296 */ return extract_short() == paramAny.extract_short();
       /*      */ case 3:
       /*  298 */ return extract_long() == paramAny.extract_long();
       /*      */ case 4:
       /*  300 */ return extract_ushort() == paramAny.extract_ushort();
       /*      */ case 5:
       /*  302 */ return extract_ulong() == paramAny.extract_ulong();
       /*      */ case 6:
       /*  304 */ return extract_float() == paramAny.extract_float();
       /*      */ case 7:
       /*  306 */ return extract_double() == paramAny.extract_double();
       /*      */ case 8:
       /*  308 */ return extract_boolean() == paramAny.extract_boolean();
       /*      */ case 9:
       /*  310 */ return extract_char() == paramAny.extract_char();
       /*      */ case 26:
       /*  312 */ return extract_wchar() == paramAny.extract_wchar();
       /*      */ case 10:
       /*  314 */ return extract_octet() == paramAny.extract_octet();
       /*      */ case 11:
       /*  316 */ return extract_any().equal(paramAny.extract_any());
       /*      */ case 12:
       /*  318 */ return extract_TypeCode().equal(paramAny.extract_TypeCode());
       /*      */ case 18:
       /*  320 */ return extract_string().equals(paramAny.extract_string());
       /*      */ case 27:
       /*  322 */ return extract_wstring().equals(paramAny.extract_wstring());
       /*      */ case 23:
       /*  324 */ return extract_longlong() == paramAny.extract_longlong();
       /*      */ case 24:
       /*  326 */ return extract_ulonglong() == paramAny.extract_ulonglong();
       /*      */ case 14:
       /*  329 */ return extract_Object().equals(paramAny.extract_Object());
       /*      */ case 13:
       /*  331 */ return extract_Principal().equals(paramAny.extract_Principal());
       /*      */ case 17:
       /*  334 */ return extract_long() == paramAny.extract_long();
       /*      */ case 28:
       /*  336 */ return extract_fixed().compareTo(paramAny.extract_fixed()) == 0;
       /*      */ case 15:
       /*      */ case 16:
       /*      */ case 19:
       /*      */ case 20:
       /*      */ case 22:
       /*  342 */ org.omg.CORBA.portable.InputStream localInputStream1 = create_input_stream();
       /*  343 */ org.omg.CORBA.portable.InputStream localInputStream2 =
           paramAny.create_input_stream();
       /*  344 */ return equalMember(localTypeCode, localInputStream1, localInputStream2);
       /*      */ case 29:
       /*      */ case 30:
       /*  351 */ return extract_Value().equals(paramAny.extract_Value());
       /*      */ case 21:
       /*  354 */ throw this.wrapper.errorResolvingAlias();
       /*      */ case 25:
       /*  358 */ throw this.wrapper.tkLongDoubleNotSupported();
       /*      */ }
   /*      */
   /*  361 */ throw this.wrapper.typecodeNotSupported();
   /*      */ }