/**
   * entry method to the TypeCode reader logic
   *
   * @param logger used to log informational/debug information
   * @param in the InputStream from which should be read from
   * @param recursiveTCMap Map that should be used to store the buffer positions of not completely
   *     read in TypeCodes
   * @param repeatedTCMap Map that should be used to store the buffer positions of completely read
   *     in TypeCodes
   */
  public TypeCode readTypeCode(
      Logger logger, CDRInputStream in, Map recursiveTCMap, Map repeatedTCMap) {
    in.mark(0);

    final int kind = in.read_long();
    final int start_pos = in.get_pos() - 4;

    try {
      in.reset();
    } catch (IOException e) {
      assert false;
      throw new RuntimeException("should not happen");
    }

    if (logger.isDebugEnabled()) {
      logger.debug(
          in.getIndentString() + "read TypeCode kind " + kind + " at startposition " + start_pos);
    }

    final TypeCode result = doReadTypeCode(in, recursiveTCMap, repeatedTCMap, kind);

    if (logger.isDebugEnabled()) {
      logger.debug(
          in.getIndentString()
              + "return "
              + result
              + " ("
              + result.getClass().getName()
              + "@"
              + System.identityHashCode(result)
              + ")");
    }

    return result;
  }
Esempio n. 2
0
 /**
  * check that a type is a legal member type (cf. CORBA 2.4 chapter 10, section 7.3
  *
  * @throws org.omg.CORBA.BAD_PARAM
  */
 private void checkTCMemberType(TypeCode typeCode) throws BAD_TYPECODE {
   if (!org.jacorb.orb.TypeCode.isRecursive(typeCode)
       && (typeCode == null
           || typeCode.kind().value() == TCKind._tk_null
           || typeCode.kind().value() == TCKind._tk_void
           || typeCode.kind().value() == TCKind._tk_except)) {
     throw new BAD_TYPECODE("Illegal member TypeCode", 2, CompletionStatus.COMPLETED_NO);
   }
 }
Esempio n. 3
0
 /*      */ private TypeCode realType(TypeCode paramTypeCode) {
   /*  227 */ TypeCode localTypeCode = paramTypeCode;
   /*      */ try
   /*      */ {
     /*  230 */ while (localTypeCode.kind().value() == 21)
       /*  231 */ localTypeCode = localTypeCode.content_type();
     /*      */ }
   /*      */ catch (BadKind localBadKind) {
     /*  234 */ throw this.wrapper.badkindCannotOccur(localBadKind);
     /*      */ }
   /*  236 */ return localTypeCode;
   /*      */ }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
  /**
   * Dumps the description of a given wstring TypeCode.
   *
   * @param type the <code>TypeCode</code>
   * @param output the output stream where the TypeCode will be dumped
   * @pre <code>type</code> must be an wstring type.
   */
  public static void dump(TypeCode type, java.io.PrintWriter output) throws java.io.IOException {
    output.print("[TYPECODE]{wstring");
    try {
      if (type.length() != 0) {
        output.print('<');
        output.print(type.length());
        output.print('>');
      }
    } catch (BadKind bk) {
      throw new BAD_TYPECODE("Fault in length() operation:" + bk.toString());
    }

    output.print('}');
  }
Esempio n. 6
0
 /** 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;
 }
 private static boolean isSystemExceptionTypeCode(TypeCode type, ORB orb) {
   StructMember[] systemExceptionMembers = systemExceptionMembers(orb);
   try {
     return (type.kind().value() == TCKind._tk_except
         && type.member_count() == 3
         && type.member_type(0).equal(systemExceptionMembers[0].type)
         && type.member_type(1).equal(systemExceptionMembers[1].type)
         && type.member_type(2).equal(systemExceptionMembers[2].type));
   } catch (BadKind ex) {
     return false;
   } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) {
     return false;
   }
 }
Esempio n. 8
0
 /*      */ 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;
   /*      */ }
Esempio n. 9
0
  // This is used by the Any type when trying to re-construct the type stored inside a
  // CORBA Any.
  public QName getIdlType(TypeCode tc) {
    String repId = null;
    try {
      repId = tc.id();
    } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
      // No id has been set.
      return null;
    }

    if (repId == null) {
      return null;
    }

    Set<Map.Entry<String, CorbaTypeImpl>> mapSet = typeMap.entrySet();
    for (Iterator<Map.Entry<String, CorbaTypeImpl>> i = mapSet.iterator(); i.hasNext(); ) {
      Map.Entry<String, CorbaTypeImpl> entry = i.next();
      if (entry.getValue() instanceof NamedType) {
        NamedType n = (NamedType) entry.getValue();
        if (n.getRepositoryID().equals(repId)) {
          return new QName(getTargetNamespace(), entry.getKey());
        }
      }
    }

    return null;
  }
Esempio n. 10
0
  /**
   * Dumps the description of a the marshaled value of a given TypeCode.
   *
   * @param type the <code>TypeCode</code>
   * @param input the input stream where the value is marshaled
   * @param output the output stream where the value will be dumped
   * @pre the typecode must be a wstring type
   * @return <code>true</code> if if has been possible dump the value.
   */
  public static boolean dumpValue(TypeCode type, InputStream input, java.io.PrintWriter output)
      throws java.io.IOException {
    output.print("[VALUE]{wstring");

    try {
      if (type.length() != 0) {
        output.print('<');
        output.print(type.length());
        output.print('>');
      }
    } catch (BadKind bk) {
      throw new BAD_TYPECODE("Fault in length() operation:" + bk.toString());
    }
    output.print(": \"");
    output.print(input.read_wstring());
    output.print("\"}");
    return true;
  }
Esempio n. 11
0
 /*      */ 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;
   /*      */ }
Esempio n. 12
0
 /*      */ 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);
   /*      */ }
Esempio n. 13
0
  /**
   * 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);
  }
Esempio n. 14
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();
   /*      */ }
Esempio n. 15
0
  // 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();
    }
  }
Esempio n. 16
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();
    }
  }
Esempio n. 17
0
  public void testCreateDynamicTypeCode() throws Exception {
    TypeCode typeCode = org.jacorb.orb.TypeCode.create_tc(MyClass.class);

    assertEquals(2, typeCode.member_count());
    assertEquals(typeCode.member_type(0).type_modifier(), typeCode.member_type(1).type_modifier());
  }
Esempio n. 18
0
 public void testEquals() {
   TypeCode tc = orb.create_string_tc(10);
   assertFalse(tc.equals("bla"));
 }
  private void testArgs(ServerRequestInfo ri, boolean resultAvail) {
    String op = ri.operation();
    org.omg.Dynamic.Parameter[] args = ri.arguments();
    if (op.startsWith("_set_") || op.startsWith("_get_")) {
      boolean isstr; // struct or string?
      isstr = (op.indexOf("string") != -1);
      if (op.startsWith("_get_")) {
        TEST(args.length == 0);
        if (resultAvail) {
          //
          // Test: result
          //
          Any result = ri.result();
          if (isstr) {
            String str = result.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(result);
            TEST(sp.sval.startsWith("TEST"));
          }
        }
      } else {
        TEST(args.length == 1);
        TEST(args[0].mode == org.omg.CORBA.ParameterMode.PARAM_IN);
        if (resultAvail) {
          if (isstr) {
            String str = args[0].argument.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(args[0].argument);
            TEST(sp.sval.startsWith("TEST"));
          }
        }
      }
    } else if (op.startsWith("one_")) {
      String which = op.substring(4); // Which operation?
      boolean isstr; // struct or string?
      ParameterMode mode; // The parameter mode

      if (which.startsWith("string")) isstr = true;
      else
        // if which.startsWith("struct"))
        isstr = false;

      which = which.substring(7); // Skip <string|struct>_

      if (which.equals("return")) {
        TEST(args.length == 0);
        if (resultAvail) {
          //
          // Test: result
          //
          Any result = ri.result();
          if (isstr) {
            String str = result.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(result);
            TEST(sp.sval.startsWith("TEST"));
          }
        }
      } else {
        TEST(args.length == 1);
        if (which.equals("in")) mode = org.omg.CORBA.ParameterMode.PARAM_IN;
        else if (which.equals("inout")) mode = org.omg.CORBA.ParameterMode.PARAM_INOUT;
        else
          // if(which.equals("out"))
          mode = org.omg.CORBA.ParameterMode.PARAM_OUT;

        TEST(mode == args[0].mode);

        if (mode != org.omg.CORBA.ParameterMode.PARAM_OUT || resultAvail) {
          if (isstr) {
            String str = args[0].argument.extract_string();
            TEST(str.startsWith("TEST"));
          } else {
            s sp = sHelper.extract(args[0].argument);
            TEST(sp.sval.startsWith("TEST"));
          }

          if (resultAvail) {
            //
            // Test: result
            //
            Any result = ri.result();
            TypeCode tc = result.type();
            TEST(tc.kind() == TCKind.tk_void);
          }
        }
      }
    } else {
      TEST(args.length == 0);
    }

    if (!resultAvail) {
      //
      // Test: result is not available
      //
      try {
        Any result = ri.result();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }
    }
  }
Esempio n. 20
0
  static void marshalIn(
      org.omg.CORBA.portable.OutputStream s, TypeCode typeCode, long l, Object o) {
    switch (typeCode.kind().value()) {
      case TCKind._tk_null:
      case TCKind._tk_void:
      case TCKind._tk_native:
        // nothing to write
        break;

      case TCKind._tk_short:
        s.write_short((short) (l & 0xFFFFL));
        break;

      case TCKind._tk_ushort:
        s.write_ushort((short) (l & 0xFFFFL));
        break;

      case TCKind._tk_enum:
      case TCKind._tk_long:
        s.write_long((int) (l & 0xFFFFFFFFL));
        break;

      case TCKind._tk_ulong:
        s.write_ulong((int) (l & 0xFFFFFFFFL));
        break;

      case TCKind._tk_float:
        s.write_float(Float.intBitsToFloat((int) (l & 0xFFFFFFFFL)));
        break;

      case TCKind._tk_double:
        s.write_double(Double.longBitsToDouble(l));
        break;

      case TCKind._tk_boolean:
        if (l == 0) s.write_boolean(false);
        else s.write_boolean(true);
        break;

      case TCKind._tk_char:
        s.write_char((char) (l & 0xFFFFL));
        break;

      case TCKind._tk_octet:
        s.write_octet((byte) (l & 0xFFL));
        break;

      case TCKind._tk_any:
        s.write_any((Any) o);
        break;

      case TCKind._tk_TypeCode:
        s.write_TypeCode((TypeCode) o);
        break;

      case TCKind._tk_Principal:
        s.write_Principal((Principal) o);
        break;

      case TCKind._tk_objref:
        s.write_Object((org.omg.CORBA.Object) o);
        break;

      case TCKind._tk_longlong:
        s.write_longlong(l);
        break;

      case TCKind._tk_ulonglong:
        s.write_ulonglong(l);
        break;

      case TCKind._tk_wchar:
        s.write_wchar((char) (l & 0xFFFFL));
        break;

      case TCKind._tk_string:
        s.write_string((String) o);
        break;

      case TCKind._tk_wstring:
        s.write_wstring((String) o);
        break;

      case TCKind._tk_value:
      case TCKind._tk_value_box:
        ((org.omg.CORBA_2_3.portable.OutputStream) s).write_value((Serializable) o);
        break;

      case TCKind._tk_fixed:
        // _REVISIT_ As soon as the java-rtf adds digits and scale parameters to
        // OutputStream, this check will be unnecessary
        if (s instanceof CDROutputStream) {
          try {
            ((CDROutputStream) s)
                .write_fixed((BigDecimal) o, typeCode.fixed_digits(), typeCode.fixed_scale());
          } catch (BadKind badKind) { // impossible
          }
        } else {
          s.write_fixed((BigDecimal) o);
        }
        break;

      case TCKind._tk_struct:
      case TCKind._tk_union:
      case TCKind._tk_sequence:
      case TCKind._tk_array:
      case TCKind._tk_alias:
      case TCKind._tk_except:
        ((Streamable) o)._write(s);
        break;

      case TCKind._tk_abstract_interface:
        ((org.omg.CORBA_2_3.portable.OutputStream) s).write_abstract_interface(o);
        break;

      case TCKind._tk_longdouble:
        // Unspecified for Java
      default:
        ORBUtilSystemException wrapper =
            ORBUtilSystemException.get(
                (com.sun.corba.se.spi.orb.ORB) s.orb(), CORBALogDomains.RPC_PRESENTATION);
        throw wrapper.typecodeNotSupported();
    }
  }
Esempio n. 21
0
  static void unmarshalIn(
      org.omg.CORBA.portable.InputStream s, TypeCode typeCode, long[] la, Object[] oa) {
    int type = typeCode.kind().value();
    long l = 0;
    Object o = oa[0];

    switch (type) {
      case TCKind._tk_null:
      case TCKind._tk_void:
      case TCKind._tk_native:
        // Nothing to read
        break;

      case TCKind._tk_short:
        l = s.read_short() & 0xFFFFL;
        break;

      case TCKind._tk_ushort:
        l = s.read_ushort() & 0xFFFFL;
        break;

      case TCKind._tk_enum:
      case TCKind._tk_long:
        l = s.read_long() & 0xFFFFFFFFL;
        break;

      case TCKind._tk_ulong:
        l = s.read_ulong() & 0xFFFFFFFFL;
        break;

      case TCKind._tk_float:
        l = Float.floatToIntBits(s.read_float()) & 0xFFFFFFFFL;
        break;

      case TCKind._tk_double:
        l = Double.doubleToLongBits(s.read_double());
        break;

      case TCKind._tk_char:
        l = s.read_char() & 0xFFFFL;
        break;

      case TCKind._tk_octet:
        l = s.read_octet() & 0xFFL;
        break;

      case TCKind._tk_boolean:
        if (s.read_boolean()) l = 1;
        else l = 0;
        break;

      case TCKind._tk_any:
        o = s.read_any();
        break;

      case TCKind._tk_TypeCode:
        o = s.read_TypeCode();
        break;

      case TCKind._tk_Principal:
        o = s.read_Principal();
        break;

      case TCKind._tk_objref:
        if (o instanceof Streamable) ((Streamable) o)._read(s);
        else o = s.read_Object();
        break;

      case TCKind._tk_longlong:
        l = s.read_longlong();
        break;

      case TCKind._tk_ulonglong:
        l = s.read_ulonglong();
        break;

      case TCKind._tk_wchar:
        l = s.read_wchar() & 0xFFFFL;
        break;

      case TCKind._tk_string:
        o = s.read_string();
        break;

      case TCKind._tk_wstring:
        o = s.read_wstring();
        break;

      case TCKind._tk_value:
      case TCKind._tk_value_box:
        o = ((org.omg.CORBA_2_3.portable.InputStream) s).read_value();
        break;

      case TCKind._tk_fixed:
        try {
          // _REVISIT_ As soon as the java-rtf adds digits and scale parameters to
          // InputStream, this check will be unnecessary
          if (s instanceof CDRInputStream) {
            o = ((CDRInputStream) s).read_fixed(typeCode.fixed_digits(), typeCode.fixed_scale());
          } else {
            BigDecimal bigDecimal = s.read_fixed();
            o = bigDecimal.movePointLeft((int) typeCode.fixed_scale());
          }
        } catch (BadKind badKind) { // impossible
        }
        break;

      case TCKind._tk_struct:
      case TCKind._tk_union:
      case TCKind._tk_sequence:
      case TCKind._tk_array:
      case TCKind._tk_alias:
      case TCKind._tk_except:
        ((Streamable) o)._read(s);
        break;

      case TCKind._tk_abstract_interface:
        o = ((org.omg.CORBA_2_3.portable.InputStream) s).read_abstract_interface();
        break;

      case TCKind._tk_longdouble:
        // Unspecified for Java
      default:
        ORBUtilSystemException wrapper =
            ORBUtilSystemException.get(
                (com.sun.corba.se.spi.orb.ORB) s.orb(), CORBALogDomains.RPC_PRESENTATION);
        throw wrapper.typecodeNotSupported();
    }

    oa[0] = o;
    la[0] = l;
  }
Esempio n. 22
0
  /**
   * Allows the possibility of not checking the name when creating this typecode. This is to cater
   * for compact typecodes where the name may not be set. Checking of the name will always be true
   * for user driven requests
   *
   * @param id the id
   * @param name the name
   * @param discriminator_type the discriminator_type
   * @param members the members
   * @param checkName the check name
   * @return the type code
   */
  public TypeCode create_union_tc(
      String id,
      String name,
      TypeCode discriminator_type,
      org.omg.CORBA.UnionMember[] members,
      boolean checkName) {
    checkTCRepositoryId(id);
    checkTCName(name, true);

    // check discriminator type

    TypeCode disc_tc = org.jacorb.orb.TypeCode.originalType(discriminator_type);

    if (disc_tc == null
        || !(disc_tc.kind().value() == TCKind._tk_short
            || disc_tc.kind().value() == TCKind._tk_long
            || disc_tc.kind().value() == TCKind._tk_longlong
            || disc_tc.kind().value() == TCKind._tk_ushort
            || disc_tc.kind().value() == TCKind._tk_ulong
            || disc_tc.kind().value() == TCKind._tk_ulonglong
            || disc_tc.kind().value() == TCKind._tk_char
            || disc_tc.kind().value() == TCKind._tk_boolean
            || disc_tc.kind().value() == TCKind._tk_enum)) {
      throw new BAD_PARAM("Illegal union discriminator type", 20, CompletionStatus.COMPLETED_NO);
    }

    // check that member names are legal (they do not need to be unique)

    for (int i = 0; i < members.length; i++) {
      checkTCMemberType(members[i].type);

      if (checkName) {
        try {
          checkTCName(members[i].name);
        } catch (BAD_PARAM e) {
          logger.debug("Typecode name check failed", e);
          throw new BAD_PARAM(
              "Illegal union member name: " + members[i].name, 17, CompletionStatus.COMPLETED_NO);
        }
      }

      // check that member type matches discriminator type or is default

      org.omg.CORBA.Any label = members[i].label;
      if (!discriminator_type.equivalent(label.type())
          && !(label.type().kind().value() == TCKind._tk_octet
              && label.extract_octet() == (byte) 0)) {
        throw new BAD_PARAM(
            "Label type does not match discriminator type", 19, CompletionStatus.COMPLETED_NO);
      }

      // check that member labels are unique

      for (int j = 0; j < i; j++) {
        if (label.equal(members[j].label)) {
          throw new BAD_PARAM("Duplicate union case label", 18, CompletionStatus.COMPLETED_NO);
        }
      }
    }

    org.jacorb.orb.TypeCode typeCode =
        new org.jacorb.orb.TypeCode(id, name, discriminator_type, members);

    // resolve any recursive references to this TypeCode in its members

    return typeCode;
  }
Esempio n. 23
0
 /*      */ 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();
   /*      */ }