Package org.omg.CORBA

Examples of org.omg.CORBA.TypeCode


    }
   
    public void testGetSetValueData() {
        QName anyName = new QName("TestAny");
        QName anyIdlType = CorbaConstants.NT_CORBA_ANY;
        TypeCode anyTC = orb.get_primitive_tc(TCKind.tk_any);
        CorbaAnyHandler anyHandler = new CorbaAnyHandler(anyName, anyIdlType, anyTC, null);

        String value = null;
        String resultValue = null;
        String schemaType = null;
View Full Code Here


    private TypeCode realType() {
        return realType(typeCode);
    }

    private TypeCode realType(TypeCode aType) {
        TypeCode realType = aType;
        try {
            // Note: Indirect types are handled in kind() method
            while (realType.kind().value() == TCKind._tk_alias) {
                realType = realType.content_type();
            }
        } catch (BadKind bad) { // impossible
      throw wrapper.badkindCannotOccur( bad ) ;
        }
        return realType;
View Full Code Here

  // 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:
View Full Code Here

    // 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;
    }
View Full Code Here

    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
View Full Code Here

  // 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);
  }
View Full Code Here

    private TypeCode getConstantTypeCode(Class cls)
            throws IRConstructionException {
        if (cls == null)
            throw JacORBMessages.MESSAGES.invalidNullClass();

        TypeCode ret = constantTypeCodeMap.get(cls);

        if (ret == null)
            throw JacORBMessages.MESSAGES.badClassForConstant(cls.getName());
        return ret;
    }
View Full Code Here

    private TypeCode getTypeCode(Class cls)
            throws IRConstructionException, RMIIIOPViolationException {
        if (cls == null)
            throw JacORBMessages.MESSAGES.invalidNullClass();

        TypeCode ret = (TypeCode) typeCodeMap.get(cls);

        if (ret == null) {
            if (cls == java.lang.String.class)
                ret = getJavaLangString().type();
            else if (cls == java.lang.Object.class)
View Full Code Here

    private void addTypeCode(Class cls, TypeCode typeCode)
            throws IRConstructionException {
        if (cls == null)
            throw JacORBMessages.MESSAGES.invalidNullClass();

        TypeCode tc = (TypeCode) typeCodeMap.get(cls);

        if (tc != null)
            throw JacORBMessages.MESSAGES.duplicateTypeCodeForClass(cls.getName());

        typeCodeMap.put(cls, typeCode);
View Full Code Here

            final String version = "1.0";

            // Get module to add typedef to.
            ModuleDefImpl m = ensurePackageExists("java.io");

            TypeCode typeCode = orb.create_alias_tc(id, name,
                    orb.get_primitive_tc(TCKind.tk_any));
//         TypeCode typeCode = new TypeCodeImpl(TCKind._tk_alias, id, name,
//                                            new TypeCodeImpl(TCKind.tk_any));

            javaIoSerializable = new AliasDefImpl(id, name, version, m,
View Full Code Here

TOP

Related Classes of org.omg.CORBA.TypeCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.