public void insert_fixed(java.math.BigDecimal value) { typeCode = TypeCodeImpl.convertToNative( orb, orb.create_fixed_tc(TypeCodeImpl.digits(value), TypeCodeImpl.scale(value))); object = value; isInitialized = true; }
/* */ public void insert_fixed(BigDecimal paramBigDecimal) { /* 1175 */ this.typeCode = TypeCodeImpl.convertToNative( this.orb, this.orb.create_fixed_tc( TypeCodeImpl.digits(paramBigDecimal), TypeCodeImpl.scale(paramBigDecimal))); /* */ /* 1177 */ this.object = paramBigDecimal; /* 1178 */ this.isInitialized = true; /* */ }
public void insert_fixed(java.math.BigDecimal value, org.omg.CORBA.TypeCode type) { try { if (TypeCodeImpl.digits(value) > type.fixed_digits() || TypeCodeImpl.scale(value) > type.fixed_scale()) { throw wrapper.fixedNotMatch(); } } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) { // type isn't even of kind fixed throw wrapper.fixedBadTypecode(bk); } typeCode = TypeCodeImpl.convertToNative(orb, type); object = value; isInitialized = true; }
// This method could very well be moved into TypeCodeImpl or a common utility class, // but is has to be in this package. public static Any extractAnyFromStream(TypeCode memberType, InputStream input, ORB orb) { Any returnValue = orb.create_any(); OutputStream out = returnValue.create_output_stream(); TypeCodeImpl.convertToNative(orb, memberType).copy(input, out); returnValue.read_value(out.create_input_stream(), memberType); return returnValue; }
/* */ public void insert_fixed(BigDecimal paramBigDecimal, TypeCode paramTypeCode) /* */ { /* */ try { /* 1184 */ if ((TypeCodeImpl.digits(paramBigDecimal) > paramTypeCode.fixed_digits()) || (TypeCodeImpl.scale(paramBigDecimal) > paramTypeCode.fixed_scale())) /* */ { /* 1187 */ throw this.wrapper.fixedNotMatch(); /* */ } /* */ } /* */ catch (BadKind localBadKind) { /* 1191 */ throw this.wrapper.fixedBadTypecode(localBadKind); /* */ } /* 1193 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, paramTypeCode); /* 1194 */ this.object = paramBigDecimal; /* 1195 */ this.isInitialized = true; /* */ }
/* */ public TypeCode createTypeCodeForClass(Class paramClass, ORB paramORB) /* */ { /* 1212 */ TypeCodeImpl localTypeCodeImpl = paramORB.getTypeCodeForClass(paramClass); /* 1213 */ if (localTypeCodeImpl != null) { /* 1214 */ return localTypeCodeImpl; /* */ } /* */ /* 1220 */ RepositoryIdStrings localRepositoryIdStrings = RepositoryIdFactory.getRepIdStringsFactory(); /* */ java.lang.Object localObject1; /* */ java.lang.Object localObject2; /* 1226 */ if (paramClass.isArray()) /* */ { /* 1228 */ localObject1 = paramClass.getComponentType(); /* */ /* 1230 */ if (((Class) localObject1).isPrimitive()) { /* 1231 */ localObject2 = getPrimitiveTypeCodeForClass((Class) localObject1, paramORB); /* */ } /* */ else { /* 1234 */ localObject2 = createTypeCodeForClass((Class) localObject1, paramORB); /* */ } /* */ /* 1237 */ TypeCode localTypeCode = paramORB.create_sequence_tc(0, (TypeCode) localObject2); /* */ /* 1239 */ String str = localRepositoryIdStrings.createForJavaType(paramClass); /* */ /* 1241 */ return paramORB.create_value_box_tc(str, "Sequence", localTypeCode); /* 1242 */ } if (paramClass == String.class) /* */ { /* 1244 */ localObject1 = paramORB.create_string_tc(0); /* */ /* 1246 */ localObject2 = localRepositoryIdStrings.createForJavaType(paramClass); /* */ /* 1248 */ return paramORB.create_value_box_tc( (String) localObject2, "StringValue", (TypeCode) localObject1); /* */ } /* */ /* 1253 */ localTypeCodeImpl = (TypeCodeImpl) ValueUtility.createTypeCodeForClass( paramORB, paramClass, ORBUtility.createValueHandler()); /* */ /* 1256 */ localTypeCodeImpl.setCaching(true); /* */ /* 1258 */ paramORB.setTypeCodeForClass(paramClass, localTypeCodeImpl); /* 1259 */ return localTypeCodeImpl; /* */ }
/** * Utility method for insert_Value and Util.writeAny. * * <p>The ORB passed in should have the desired ORBVersion. It is used to generate the type codes. */ public TypeCode createTypeCodeForClass(java.lang.Class c, ORB tcORB) { // Look in the cache first TypeCodeImpl classTC = tcORB.getTypeCodeForClass(c); if (classTC != null) return classTC; // All cases need to be able to create repository IDs. // // See bug 4391648 for more info about the tcORB in this // case. RepositoryIdStrings repStrs = RepositoryIdFactory.getRepIdStringsFactory(); // Assertion: c instanceof Serializable? if (c.isArray()) { // Arrays - may recurse for multi-dimensional arrays Class componentClass = c.getComponentType(); TypeCode embeddedType; if (componentClass.isPrimitive()) { embeddedType = getPrimitiveTypeCodeForClass(componentClass, tcORB); } else { embeddedType = createTypeCodeForClass(componentClass, tcORB); } TypeCode t = tcORB.create_sequence_tc(0, embeddedType); String id = repStrs.createForJavaType(c); return tcORB.create_value_box_tc(id, "Sequence", t); } else if (c == java.lang.String.class) { // Strings TypeCode t = tcORB.create_string_tc(0); String id = repStrs.createForJavaType(c); return tcORB.create_value_box_tc(id, "StringValue", t); } // Anything else // We know that this is a TypeCodeImpl since it is our ORB classTC = (TypeCodeImpl) ValueUtility.createTypeCodeForClass(tcORB, c, ORBUtility.createValueHandler()); // Intruct classTC to store its buffer classTC.setCaching(true); // Update the cache tcORB.setTypeCodeForClass(c, classTC); return classTC; }
/** See the description of the <a href="#anyOps">general Any operations.</a> */ public org.omg.CORBA.Object extract_Object() { // debug.log ("extract_Object"); if (!isInitialized) throw wrapper.extractNotInitialized(); // Check if the object contained here is of the type in typeCode org.omg.CORBA.Object obj = null; try { obj = (org.omg.CORBA.Object) object; if (typeCode.id().equals("IDL:omg.org/CORBA/Object:1.0") || obj._is_a(typeCode.id())) { return obj; } else { throw wrapper.extractObjectIncompatible(); } } catch (Exception ex) { throw wrapper.extractObjectFailed(ex); } }
/* */ static AnyImpl convertToNative(ORB paramORB, Any paramAny) /* */ { /* 158 */ if ((paramAny instanceof AnyImpl)) { /* 159 */ return (AnyImpl) paramAny; /* */ } /* 161 */ AnyImpl localAnyImpl = new AnyImpl(paramORB, paramAny); /* 162 */ localAnyImpl.typeCode = TypeCodeImpl.convertToNative(paramORB, localAnyImpl.typeCode); /* 163 */ return localAnyImpl; /* */ }
/* */ public void type(TypeCode paramTypeCode) /* */ { /* 248 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, paramTypeCode); /* */ /* 250 */ this.stream = null; /* 251 */ this.value = 0L; /* 252 */ this.object = null; /* */ /* 254 */ this.isInitialized = (paramTypeCode.kind().value() == 0); /* */ }
// // We could optimize this by noticing whether the target stream // has ever had anything marshaled on it that required an // alignment of greater than 4 (was write_double() ever called on it). // If not, then we can just do a byte array copy without having to // drive the remarshaling through typecode interpretation. // public void write_value(OutputStream out) { // debug.log ("write_value"); if (AnyImpl.isStreamed[realType().kind().value()]) { typeCode.copy(stream.dup(), out); } else { // _REVISIT_ check isInitialized whether all we write is TypeCode! TCUtility.marshalIn(out, realType(), value, object); } }
/* */ public Any extractAny(TypeCode paramTypeCode, ORB paramORB) /* */ { /* 1315 */ Any localAny = paramORB.create_any(); /* 1316 */ org.omg.CORBA.portable.OutputStream localOutputStream = localAny.create_output_stream(); /* 1317 */ TypeCodeImpl.convertToNative(paramORB, paramTypeCode) .copy(this.stream, localOutputStream); /* 1318 */ localAny.read_value(localOutputStream.create_input_stream(), paramTypeCode); /* 1319 */ return localAny; /* */ }
static AnyImpl convertToNative(ORB orb, Any any) { if (any instanceof AnyImpl) { return (AnyImpl) any; } else { AnyImpl anyImpl = new AnyImpl(orb, any); anyImpl.typeCode = TypeCodeImpl.convertToNative(orb, anyImpl.typeCode); return anyImpl; } }
/** * sets the type of the element to be contained in the Any. * * @param tc the TypeCode for the element in the Any */ public void type(TypeCode tc) { // debug.log ("type2"); // set the typecode typeCode = TypeCodeImpl.convertToNative(orb, tc); stream = null; value = 0; object = null; // null is the only legal value this Any can have after resetting the type code isInitialized = (tc.kind().value() == TCKind._tk_null); }
/* */ public static Any extractAnyFromStream( TypeCode paramTypeCode, org.omg.CORBA.portable.InputStream paramInputStream, ORB paramORB) /* */ { /* 1325 */ Any localAny = paramORB.create_any(); /* 1326 */ org.omg.CORBA.portable.OutputStream localOutputStream = localAny.create_output_stream(); /* 1327 */ TypeCodeImpl.convertToNative(paramORB, paramTypeCode) .copy(paramInputStream, localOutputStream); /* 1328 */ localAny.read_value(localOutputStream.create_input_stream(), paramTypeCode); /* 1329 */ return localAny; /* */ }
// // If the InputStream is a CDRInputStream then we can copy the bytes // since it is in our format and does not have alignment issues. // public void read_value(org.omg.CORBA.portable.InputStream in, TypeCode tc) { // debug.log ("read_value"); // // Assume that someone isn't going to think they can keep reading // from this stream after calling us. That would be likely for // an IIOPInputStream but if it is an AnyInputStream then they // presumably obtained it via our create_output_stream() so they could // write the contents of an IDL data type to it and then call // create_input_stream() for us to read it. This is how Helper classes // typically implement the insert() method. // We should probably document this behavior in the 1.1 revision // task force. // typeCode = TypeCodeImpl.convertToNative(orb, tc); int kind = realType().kind().value(); if (kind >= isStreamed.length) { throw wrapper.invalidIsstreamedTckind(CompletionStatus.COMPLETED_MAYBE, new Integer(kind)); } if (AnyImpl.isStreamed[kind]) { if (in instanceof AnyInputStream) { // could only have been created here stream = (CDRInputStream) in; } else { org.omg.CORBA_2_3.portable.OutputStream out = (org.omg.CORBA_2_3.portable.OutputStream) orb.create_output_stream(); typeCode.copy((org.omg.CORBA_2_3.portable.InputStream) in, out); stream = (CDRInputStream) out.create_input_stream(); } } else { java.lang.Object[] objholder = new java.lang.Object[1]; objholder[0] = object; long[] longholder = new long[1]; TCUtility.unmarshalIn(in, realType(), longholder, objholder); value = longholder[0]; object = objholder[0]; stream = null; } isInitialized = true; }
/** See the description of the <a href="#anyOps">general Any operations.</a> */ public void insert_wstring(String s) { // debug.log ("insert_wstring"); // Make sure type code information for bounded strings is not erased if (typeCode.kind() == TCKind.tk_wstring) { int length = 0; try { length = typeCode.length(); } catch (BadKind bad) { throw wrapper.badkindCannotOccur(); } // Check if bounded strings length is not exceeded if (length != 0 && s != null && s.length() > length) { throw wrapper.badStringBounds(new Integer(s.length()), new Integer(length)); } } else { typeCode = orb.get_primitive_tc(TCKind._tk_wstring); } object = s; isInitialized = true; }
/** A variant of the insertion operation that takes a typecode argument as well. */ public void insert_Object(org.omg.CORBA.Object o, TypeCode tc) { // debug.log ("insert_Object2"); try { if (tc.id().equals("IDL:omg.org/CORBA/Object:1.0") || o._is_a(tc.id())) { typeCode = TypeCodeImpl.convertToNative(orb, tc); object = o; } else { throw wrapper.insertObjectIncompatible(); } } catch (Exception ex) { throw wrapper.insertObjectFailed(ex); } isInitialized = true; }
/* */ public void insert_Value(Serializable paramSerializable) /* */ { /* 1143 */ this.object = paramSerializable; /* */ TypeCode localTypeCode; /* 1147 */ if (paramSerializable == null) { /* 1148 */ localTypeCode = this.orb.get_primitive_tc(TCKind.tk_value); /* */ } /* */ else /* */ { /* 1159 */ localTypeCode = createTypeCodeForClass(paramSerializable.getClass(), (ORB) ORB.init()); /* */ } /* */ /* 1162 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, localTypeCode); /* 1163 */ this.isInitialized = true; /* */ }
/* */ public void insert_Object(org.omg.CORBA.Object paramObject, TypeCode paramTypeCode) /* */ { /* */ try /* */ { /* 1047 */ if ((paramTypeCode.id().equals("IDL:omg.org/CORBA/Object:1.0")) || (paramObject._is_a(paramTypeCode.id()))) /* */ { /* 1049 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, paramTypeCode); /* 1050 */ this.object = paramObject; /* */ } /* */ else { /* 1053 */ throw this.wrapper.insertObjectIncompatible(); /* */ } /* */ } catch (Exception localException) { /* 1056 */ throw this.wrapper.insertObjectFailed(localException); /* */ } /* 1058 */ this.isInitialized = true; /* */ }
/* */ public void read_value( org.omg.CORBA.portable.InputStream paramInputStream, TypeCode paramTypeCode) /* */ { /* 554 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, paramTypeCode); /* 555 */ int i = realType().kind().value(); /* 556 */ if (i >= isStreamed.length) /* 557 */ throw this.wrapper.invalidIsstreamedTckind( CompletionStatus.COMPLETED_MAYBE, new Integer(i)); /* */ java.lang.Object localObject; /* 561 */ if (isStreamed[i] != 0) { /* 562 */ if ((paramInputStream instanceof AnyInputStream)) /* */ { /* 564 */ this.stream = ((CDRInputStream) paramInputStream); /* */ } else { /* 566 */ localObject = (org.omg.CORBA_2_3.portable.OutputStream) this.orb.create_output_stream(); /* */ /* 568 */ this.typeCode.copy( (org.omg.CORBA_2_3.portable.InputStream) paramInputStream, (org.omg.CORBA.portable.OutputStream) localObject); /* 569 */ this.stream = ((CDRInputStream) ((org.omg.CORBA_2_3.portable.OutputStream) localObject).create_input_stream()); /* */ } /* */ } else { /* 572 */ localObject = new java.lang.Object[1]; /* 573 */ localObject[0] = this.object; /* 574 */ long[] arrayOfLong = new long[1]; /* 575 */ TCUtility.unmarshalIn( paramInputStream, this.typeCode, arrayOfLong, (java.lang.Object[]) localObject); /* 576 */ this.value = arrayOfLong[0]; /* 577 */ this.object = localObject[0]; /* 578 */ this.stream = null; /* */ } /* 580 */ this.isInitialized = true; /* */ }
public void insert_Value(Serializable v) { // debug.log ("insert_Value"); object = v; TypeCode tc; if (v == null) { tc = orb.get_primitive_tc(TCKind.tk_value); } else { // See note in getPrimitiveTypeCodeForClass. We // have to use the latest type code fixes in this // case since there is no way to know what ORB will // actually send this Any. In RMI-IIOP, when using // Util.writeAny, we can do the versioning correctly, // and use the insert_Value(Serializable, TypeCode) // method. // // The ORB singleton uses the latest version. tc = createTypeCodeForClass(v.getClass(), (ORB) ORB.init()); } typeCode = TypeCodeImpl.convertToNative(orb, tc); isInitialized = true; }
/** * takes a streamable and inserts its reference into the any * * @param s the streamable to insert */ public void insert_Streamable(Streamable s) { // debug.log ("insert_Streamable"); typeCode = TypeCodeImpl.convertToNative(orb, s._type()); object = s; isInitialized = true; }
/* */ private boolean equalMember( TypeCode paramTypeCode, org.omg.CORBA.portable.InputStream paramInputStream1, org.omg.CORBA.portable.InputStream paramInputStream2) /* */ { /* 369 */ TypeCode localTypeCode = realType(paramTypeCode); /* */ try /* */ { /* */ int j; /* */ int m; /* 372 */ switch (localTypeCode.kind().value()) /* */ { /* */ case 0: /* */ case 1: /* 376 */ return true; /* */ case 2: /* 378 */ return paramInputStream1.read_short() == paramInputStream2.read_short(); /* */ case 3: /* 380 */ return paramInputStream1.read_long() == paramInputStream2.read_long(); /* */ case 4: /* 382 */ return paramInputStream1.read_ushort() == paramInputStream2.read_ushort(); /* */ case 5: /* 384 */ return paramInputStream1.read_ulong() == paramInputStream2.read_ulong(); /* */ case 6: /* 386 */ return paramInputStream1.read_float() == paramInputStream2.read_float(); /* */ case 7: /* 388 */ return paramInputStream1.read_double() == paramInputStream2.read_double(); /* */ case 8: /* 390 */ return paramInputStream1.read_boolean() == paramInputStream2.read_boolean(); /* */ case 9: /* 392 */ return paramInputStream1.read_char() == paramInputStream2.read_char(); /* */ case 26: /* 394 */ return paramInputStream1.read_wchar() == paramInputStream2.read_wchar(); /* */ case 10: /* 396 */ return paramInputStream1.read_octet() == paramInputStream2.read_octet(); /* */ case 11: /* 398 */ return paramInputStream1.read_any().equal(paramInputStream2.read_any()); /* */ case 12: /* 400 */ return paramInputStream1 .read_TypeCode() .equal(paramInputStream2.read_TypeCode()); /* */ case 18: /* 402 */ return paramInputStream1.read_string().equals(paramInputStream2.read_string()); /* */ case 27: /* 404 */ return paramInputStream1 .read_wstring() .equals(paramInputStream2.read_wstring()); /* */ case 23: /* 406 */ return paramInputStream1.read_longlong() == paramInputStream2.read_longlong(); /* */ case 24: /* 408 */ return paramInputStream1.read_ulonglong() == paramInputStream2.read_ulonglong(); /* */ case 14: /* 411 */ return paramInputStream1.read_Object().equals(paramInputStream2.read_Object()); /* */ case 13: /* 413 */ return paramInputStream1 .read_Principal() .equals(paramInputStream2.read_Principal()); /* */ case 17: /* 416 */ return paramInputStream1.read_long() == paramInputStream2.read_long(); /* */ case 28: /* 418 */ return paramInputStream1.read_fixed().compareTo(paramInputStream2.read_fixed()) == 0; /* */ case 15: /* */ case 22: /* 421 */ int i = localTypeCode.member_count(); /* 422 */ for (int k = 0; k < i; k++) { /* 423 */ if (!equalMember( localTypeCode.member_type(k), paramInputStream1, paramInputStream2)) { /* 424 */ return false; /* */ } /* */ } /* 427 */ return true; /* */ case 16: /* 430 */ Any localAny1 = this.orb.create_any(); /* 431 */ Any localAny2 = this.orb.create_any(); /* 432 */ localAny1.read_value(paramInputStream1, localTypeCode.discriminator_type()); /* 433 */ localAny2.read_value(paramInputStream2, localTypeCode.discriminator_type()); /* */ /* 435 */ if (!localAny1.equal(localAny2)) { /* 436 */ return false; /* */ } /* 438 */ TypeCodeImpl localTypeCodeImpl = TypeCodeImpl.convertToNative(this.orb, localTypeCode); /* 439 */ int n = localTypeCodeImpl.currentUnionMemberIndex(localAny1); /* 440 */ if (n == -1) { /* 441 */ throw this.wrapper.unionDiscriminatorError(); /* */ } /* 443 */ if (!equalMember( localTypeCode.member_type(n), paramInputStream1, paramInputStream2)) { /* 444 */ return false; /* */ } /* 446 */ return true; /* */ case 19: /* 449 */ j = paramInputStream1.read_long(); /* 450 */ paramInputStream2.read_long(); /* 451 */ for (m = 0; m < j; m++) { /* 452 */ if (!equalMember( localTypeCode.content_type(), paramInputStream1, paramInputStream2)) { /* 453 */ return false; /* */ } /* */ } /* 456 */ return true; /* */ case 20: /* 459 */ j = localTypeCode.member_count(); /* 460 */ for (m = 0; m < j; m++) { /* 461 */ if (!equalMember( localTypeCode.content_type(), paramInputStream1, paramInputStream2)) { /* 462 */ return false; /* */ } /* */ } /* 465 */ return true; /* */ case 29: /* */ case 30: /* 473 */ org.omg.CORBA_2_3.portable.InputStream localInputStream1 = (org.omg.CORBA_2_3.portable.InputStream) paramInputStream1; /* */ /* 475 */ org.omg.CORBA_2_3.portable.InputStream localInputStream2 = (org.omg.CORBA_2_3.portable.InputStream) paramInputStream2; /* */ /* 477 */ return localInputStream1.read_value().equals(localInputStream2.read_value()); /* */ case 21: /* 481 */ throw this.wrapper.errorResolvingAlias(); /* */ case 25: /* 484 */ throw this.wrapper.tkLongDoubleNotSupported(); /* */ } /* */ /* 487 */ throw this.wrapper.typecodeNotSupported(); /* */ } /* */ catch (BadKind localBadKind) { /* 490 */ throw this.wrapper.badkindCannotOccur(); } catch (Bounds localBounds) { /* */ } /* 492 */ throw this.wrapper.boundsCannotOccur(); /* */ }
// Needed for equal() in order to achieve linear performance for complex types. // Uses up (recursively) copies of the InputStream in both Anys that got created in equal(). private boolean equalMember(TypeCode memberType, InputStream myStream, InputStream otherStream) { // Resolve aliases here TypeCode realType = realType(memberType); try { switch (realType.kind().value()) { // handle primitive types case TCKind._tk_null: case TCKind._tk_void: return true; case TCKind._tk_short: return (myStream.read_short() == otherStream.read_short()); case TCKind._tk_long: return (myStream.read_long() == otherStream.read_long()); case TCKind._tk_ushort: return (myStream.read_ushort() == otherStream.read_ushort()); case TCKind._tk_ulong: return (myStream.read_ulong() == otherStream.read_ulong()); case TCKind._tk_float: return (myStream.read_float() == otherStream.read_float()); case TCKind._tk_double: return (myStream.read_double() == otherStream.read_double()); case TCKind._tk_boolean: return (myStream.read_boolean() == otherStream.read_boolean()); case TCKind._tk_char: return (myStream.read_char() == otherStream.read_char()); case TCKind._tk_wchar: return (myStream.read_wchar() == otherStream.read_wchar()); case TCKind._tk_octet: return (myStream.read_octet() == otherStream.read_octet()); case TCKind._tk_any: return myStream.read_any().equal(otherStream.read_any()); case TCKind._tk_TypeCode: return myStream.read_TypeCode().equal(otherStream.read_TypeCode()); case TCKind._tk_string: return myStream.read_string().equals(otherStream.read_string()); case TCKind._tk_wstring: return (myStream.read_wstring().equals(otherStream.read_wstring())); case TCKind._tk_longlong: return (myStream.read_longlong() == otherStream.read_longlong()); case TCKind._tk_ulonglong: return (myStream.read_ulonglong() == otherStream.read_ulonglong()); case TCKind._tk_objref: return (myStream.read_Object().equals(otherStream.read_Object())); case TCKind._tk_Principal: return (myStream.read_Principal().equals(otherStream.read_Principal())); case TCKind._tk_enum: return (myStream.read_long() == otherStream.read_long()); case TCKind._tk_fixed: return (myStream.read_fixed().compareTo(otherStream.read_fixed()) == 0); case TCKind._tk_except: case TCKind._tk_struct: { int length = realType.member_count(); for (int i = 0; i < length; i++) { if (!equalMember(realType.member_type(i), myStream, otherStream)) { return false; } } return true; } case TCKind._tk_union: { Any myDiscriminator = orb.create_any(); Any otherDiscriminator = orb.create_any(); myDiscriminator.read_value(myStream, realType.discriminator_type()); otherDiscriminator.read_value(otherStream, realType.discriminator_type()); if (!myDiscriminator.equal(otherDiscriminator)) { return false; } TypeCodeImpl realTypeCodeImpl = TypeCodeImpl.convertToNative(orb, realType); int memberIndex = realTypeCodeImpl.currentUnionMemberIndex(myDiscriminator); if (memberIndex == -1) throw wrapper.unionDiscriminatorError(); if (!equalMember(realType.member_type(memberIndex), myStream, otherStream)) { return false; } return true; } case TCKind._tk_sequence: { int length = myStream.read_long(); otherStream.read_long(); // just so that the two stream are in sync for (int i = 0; i < length; i++) { if (!equalMember(realType.content_type(), myStream, otherStream)) { return false; } } return true; } case TCKind._tk_array: { int length = realType.member_count(); for (int i = 0; i < length; i++) { if (!equalMember(realType.content_type(), myStream, otherStream)) { return false; } } return true; } // 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: org.omg.CORBA_2_3.portable.InputStream mine = (org.omg.CORBA_2_3.portable.InputStream) myStream; org.omg.CORBA_2_3.portable.InputStream other = (org.omg.CORBA_2_3.portable.InputStream) otherStream; return mine.read_value().equals(other.read_value()); case TCKind._tk_alias: // error resolving alias above throw wrapper.errorResolvingAlias(); case TCKind._tk_longdouble: throw wrapper.tkLongDoubleNotSupported(); default: throw wrapper.typecodeNotSupported(); } } catch (BadKind badKind) { // impossible throw wrapper.badkindCannotOccur(); } catch (Bounds bounds) { // impossible throw wrapper.boundsCannotOccur(); } }
/** * 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(); } }
/* */ public void insert_Streamable(Streamable paramStreamable) /* */ { /* 610 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, paramStreamable._type()); /* 611 */ this.object = paramStreamable; /* 612 */ this.isInitialized = true; /* */ }
public void insert_Value(Serializable v, org.omg.CORBA.TypeCode t) { // debug.log ("insert_Value2"); object = v; typeCode = TypeCodeImpl.convertToNative(orb, t); isInitialized = true; }
/* */ public void insert_Value(Serializable paramSerializable, TypeCode paramTypeCode) /* */ { /* 1169 */ this.object = paramSerializable; /* 1170 */ this.typeCode = TypeCodeImpl.convertToNative(this.orb, paramTypeCode); /* 1171 */ this.isInitialized = true; /* */ }