Java Code Examples for org.omg.CORBA.TypeCode

The following are top voted examples for showing how to use org.omg.CORBA.TypeCode. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: AnyImpl.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Project: OpenJSharp   File: AnyImpl.java   View source code 6 votes vote down vote up
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;
}
 
Example 3
Project: openjdk-jdk10   File: AnyImpl.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Project: OpenJSharp   File: TypeCodeImpl.java   View source code 6 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    String id,
                    String name,
                    TypeCode original_type)
                    // for aliases and value boxes
{
    this(orb) ;

    if ( creationKind == TCKind._tk_alias || creationKind == TCKind._tk_value_box )
        {
            _kind           = creationKind;
            setId(id);
            _name           = name;
            _contentType    = convertToNative(_orb, original_type);
        }
    // else initializes to null

}
 
Example 5
Project: openjdk-jdk10   File: AnyImpl.java   View source code 6 votes vote down vote up
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;
}
 
Example 6
Project: openjdk-jdk10   File: TypeCodeImpl.java   View source code 6 votes vote down vote up
public TypeCode member_type(int index)
    throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds
{
    switch (_kind) {
    case tk_indirect:
        return indirectType().member_type(index);
    case TCKind._tk_except:
    case TCKind._tk_struct:
    case TCKind._tk_union:
    case TCKind._tk_value:
        try {
            return _memberTypes[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new org.omg.CORBA.TypeCodePackage.Bounds();
        }
    default:
        throw new BadKind();
    }
}
 
Example 7
Project: openjdk-jdk10   File: ValueUtility.java   View source code 6 votes vote down vote up
private static TypeCode createTypeCodeForClassInternal (ORB orb,
                                                        java.lang.Class c,
                                                        ValueHandler vh,
                                                        IdentityKeyValueStack createdIDs)
{
    // This wrapper method is the protection against infinite recursion.
    TypeCode tc = null;
    String id = (String)createdIDs.get(c);
    if (id != null) {
        return orb.create_recursive_tc(id);
    } else {
        id = vh.getRMIRepositoryID(c);
        if (id == null) id = "";
        // cache the rep id BEFORE creating a new typecode.
        // so that recursive tc can look up the rep id.
        createdIDs.push(c, id);
        tc = createTypeCodeInternal(orb, c, vh, id, createdIDs);
        createdIDs.pop();
        return tc;
    }
}
 
Example 8
Project: OpenJSharp   File: Util.java   View source code 6 votes vote down vote up
/**
 * When using our own ORB and Any implementations, we need to get
 * the ORB version and create the type code appropriately.  This is
 * to overcome a bug in which the JDK 1.3.x ORBs used a tk_char
 * rather than a tk_wchar to describe a Java char field.
 *
 * This only works in RMI-IIOP with Util.writeAny since we actually
 * know what ORB and stream we're writing with when we insert
 * the value.
 *
 * Returns null if it wasn't possible to create the TypeCode (means
 * it wasn't our ORB or Any implementation).
 *
 * This does not handle null objs.
 */
private TypeCode createTypeCode(Serializable obj,
                                org.omg.CORBA.Any any,
                                org.omg.CORBA.ORB orb) {

    if (any instanceof com.sun.corba.se.impl.corba.AnyImpl &&
        orb instanceof ORB) {

        com.sun.corba.se.impl.corba.AnyImpl anyImpl
            = (com.sun.corba.se.impl.corba.AnyImpl)any;

        ORB ourORB = (ORB)orb;

        return anyImpl.createTypeCodeForClass(obj.getClass(), ourORB);

    } else
        return null;
}
 
Example 9
Project: OpenJSharp   File: Util.java   View source code 6 votes vote down vote up
/**
 * This is used to create the TypeCode for a null reference.
 * It also handles backwards compatibility with JDK 1.3.x.
 *
 * This method will not return null.
 */
private TypeCode createTypeCodeForNull(org.omg.CORBA.ORB orb)
{
    if (orb instanceof ORB) {

        ORB ourORB = (ORB)orb;

        // Preserve backwards compatibility with Kestrel and Ladybird
        // by not fully implementing interop issue resolution 3857,
        // and returning a null TypeCode with a tk_value TCKind.
        // If we're not talking to Kestrel or Ladybird, fall through
        // to the abstract interface case (also used for foreign ORBs).
        if (!ORBVersionFactory.getFOREIGN().equals(ourORB.getORBVersion()) &&
            ORBVersionFactory.getNEWER().compareTo(ourORB.getORBVersion()) > 0) {

            return orb.get_primitive_tc(TCKind.tk_value);
        }
    }

    // Use tk_abstract_interface as detailed in the resolution

    // REVISIT: Define this in IDL and get the ID in generated code
    String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0";

    return orb.create_abstract_interface_tc(abstractBaseID, "");
}
 
Example 10
Project: openjdk-jdk10   File: TypeCodeImpl.java   View source code 6 votes vote down vote up
public TypeCode content_type()
    throws BadKind
{
    switch (_kind) {
    case tk_indirect:
        return indirectType().content_type();
    case TCKind._tk_sequence:
        return lazy_content_type();
    case TCKind._tk_array:
    case TCKind._tk_alias:
    case TCKind._tk_value_box:
        return _contentType;
    default:
        throw new BadKind();
    }
}
 
Example 11
Project: openjdk-jdk10   File: ValueUtility.java   View source code 6 votes vote down vote up
public static TypeCode getPrimitiveTypeCodeForClass (ORB orb,
                                                     Class c,
                                                     ValueHandler vh) {

    if (c == Integer.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_long);
    } else if (c == Byte.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_octet);
    } else if (c == Long.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_longlong);
    } else if (c == Float.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_float);
    } else if (c == Double.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_double);
    } else if (c == Short.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_short);
    } else if (c == Character.TYPE) {
        return orb.get_primitive_tc (((ValueHandlerImpl)vh).getJavaCharTCKind());
    } else if (c == Boolean.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_boolean);
    } else {
        // _REVISIT_ Not sure if this is right.
        return orb.get_primitive_tc (TCKind.tk_any);
    }
}
 
Example 12
Project: OpenJSharp   File: AnyImpl.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Project: OpenJSharp   File: AnyImpl.java   View source code 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_TypeCode(TypeCode tc)
{
    //debug.log ("insert_TypeCode");
    typeCode = orb.get_primitive_tc(TCKind._tk_TypeCode);
    object = tc;
    isInitialized = true;
}
 
Example 14
Project: OpenJSharp   File: AnyImpl.java   View source code 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public TypeCode extract_TypeCode()
{
    //debug.log ("extract_TypeCode");
    checkExtractBadOperation( TCKind._tk_TypeCode ) ;
    return (TypeCode)object;
}
 
Example 15
Project: OpenJSharp   File: TypeCodeImpl.java   View source code 5 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    String id,
                    String name,
                    TypeCode discriminator_type,
                    UnionMember[] members)
                    // for unions
{
    this(orb) ;

    if (creationKind == TCKind._tk_union) {
        _kind               = creationKind;
        setId(id);
        _name               = name;
        _memberCount        = members.length;
        _discriminator      = convertToNative(_orb, discriminator_type);

        _memberNames = new String[_memberCount];
        _memberTypes = new TypeCodeImpl[_memberCount];
        _unionLabels = new AnyImpl[_memberCount];

        for (int i = 0 ; i < _memberCount ; i++) {
            _memberNames[i] = members[i].name;
            _memberTypes[i] = convertToNative(_orb, members[i].type);
            _memberTypes[i].setParent(this);
            _unionLabels[i] = new AnyImpl(_orb, members[i].label);
            // check whether this is the default branch.
            if (_unionLabels[i].type().kind() == TCKind.tk_octet) {
                if (_unionLabels[i].extract_octet() == (byte)0) {
                    _defaultIndex = i;
                }
            }
        }
    } // else initializes to null
}
 
Example 16
Project: OpenJSharp   File: TypeCodeImpl.java   View source code 5 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    String id,
                    String name,
                    short type_modifier,
                    TypeCode concrete_base,
                    ValueMember[] members)
                    // for value types
{
    this(orb) ;

    if (creationKind == TCKind._tk_value) {
        _kind               = creationKind;
        setId(id);
        _name               = name;
        _type_modifier      = type_modifier;
        if (concrete_base != null) {
            _concrete_base = convertToNative(_orb, concrete_base);
        }
        _memberCount        = members.length;

        _memberNames = new String[_memberCount];
        _memberTypes = new TypeCodeImpl[_memberCount];
        _memberAccess = new short[_memberCount];

        for (int i = 0 ; i < _memberCount ; i++) {
            _memberNames[i] = members[i].name;
            _memberTypes[i] = convertToNative(_orb, members[i].type);
            _memberTypes[i].setParent(this);
            _memberAccess[i] = members[i].access;
        }
    } // else initializes to null
}
 
Example 17
Project: openjdk-jdk10   File: ValueUtility.java   View source code 5 votes vote down vote up
public static TypeCode createTypeCodeForClass (ORB orb, java.lang.Class c, ValueHandler vh) {
    // Maps classes to repositoryIDs strings. This is used to detect recursive types.
    IdentityKeyValueStack createdIDs = new IdentityKeyValueStack();
    // Stores all types created for resolving indirect types at the end.
    TypeCode tc = createTypeCodeForClassInternal(orb, c, vh, createdIDs);
    return tc;
}
 
Example 18
Project: openjdk-jdk10   File: ExceptionListImpl.java   View source code 5 votes vote down vote up
public TypeCode item(int index)
    throws Bounds
{
    try {
        return (TypeCode) _exceptions.elementAt(index);
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new Bounds();
    }
}
 
Example 19
Project: OpenJSharp   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
protected boolean isRecursive() {
    if (isRecursive == RECURSIVE_UNDEF) {
        TypeCode typeCode = any.type();
        if (typeCode instanceof TypeCodeImpl) {
            if (((TypeCodeImpl)typeCode).is_recursive())
                isRecursive = RECURSIVE_YES;
            else
                isRecursive = RECURSIVE_NO;
        } else {
            // No way to find out unless the TypeCode spec changes.
            isRecursive = RECURSIVE_NO;
        }
    }
    return (isRecursive == RECURSIVE_YES);
}
 
Example 20
Project: OpenJSharp   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
public void insert_typecode(org.omg.CORBA.TypeCode value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (index == NO_INDEX)
        throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
    DynAny currentComponent = current_component();
    if (DynAnyUtil.isConstructedDynAny(currentComponent))
        throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
    currentComponent.insert_typecode(value);
}
 
Example 21
Project: openjdk-jdk10   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
protected boolean isRecursive() {
    if (isRecursive == RECURSIVE_UNDEF) {
        TypeCode typeCode = any.type();
        if (typeCode instanceof TypeCodeImpl) {
            if (((TypeCodeImpl)typeCode).is_recursive())
                isRecursive = RECURSIVE_YES;
            else
                isRecursive = RECURSIVE_NO;
        } else {
            // No way to find out unless the TypeCode spec changes.
            isRecursive = RECURSIVE_NO;
        }
    }
    return (isRecursive == RECURSIVE_YES);
}
 
Example 22
Project: openjdk-jdk10   File: AnyImpl.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 23
Project: OpenJSharp   File: ORBSingleton.java   View source code 5 votes vote down vote up
public TypeCode create_union_tc(String id,
                                String name,
                                TypeCode discriminator_type,
                                UnionMember[] members)
{
    return new TypeCodeImpl(this,
                            TCKind._tk_union,
                            id,
                            name,
                            discriminator_type,
                            members);
}
 
Example 24
Project: openjdk-jdk10   File: ServerRequestInfoImpl.java   View source code 5 votes vote down vote up
/**
 * See ServerRequestInfo for javadocs.
 */
public TypeCode[] exceptions (){
    checkAccess( MID_EXCEPTIONS );

    // _REVISIT_ PI RTF Issue: No exception list on server side.

    throw stdWrapper.piOperationNotSupported2() ;
}
 
Example 25
Project: OpenJSharp   File: DynAnyCollectionImpl.java   View source code 5 votes vote down vote up
protected TypeCode getContentType() {
    try {
        return any.type().content_type();
    } catch (BadKind badKind) { // impossible
        return null;
    }
}
 
Example 26
Project: OpenJSharp   File: DynAnyCollectionImpl.java   View source code 5 votes vote down vote up
public void set_elements_as_dyn_any (org.omg.DynamicAny.DynAny[] value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkValue(value);

    components = (value == null ? emptyComponents : value);
    anys = new Any[value.length];

    // We know that this is of kind tk_sequence or tk_array
    TypeCode expectedTypeCode = getContentType();
    for (int i=0; i<value.length; i++) {
        if (value[i] != null) {
            if (! value[i].type().equal(expectedTypeCode)) {
                clearData();
                // _REVISIT_ More info
                throw new TypeMismatch();
            }
            anys[i] = getAny(value[i]);
        } else {
            clearData();
            // _REVISIT_ More info
            throw new InvalidValue();
        }
    }
    index = (value.length == 0 ? NO_INDEX : 0);
    // Other representations are invalidated by this operation
    representations = REPRESENTATION_COMPONENTS;
}
 
Example 27
Project: OpenJSharp   File: DynStructImpl.java   View source code 5 votes vote down vote up
protected DynStructImpl(ORB orb, TypeCode typeCode) {
    // We can be sure that typeCode is of kind tk_struct
    super(orb, typeCode);
    // For DynStruct, the operation sets the current position to -1
    // for empty exceptions and to zero for all other TypeCodes.
    // The members (if any) are (recursively) initialized to their default values.
    index = 0;
}
 
Example 28
Project: OpenJSharp   File: DynSequenceImpl.java   View source code 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    length = input.read_long();
    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example 29
Project: openjdk-jdk10   File: DynAnyBasicImpl.java   View source code 5 votes vote down vote up
public org.omg.CORBA.TypeCode get_typecode()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_TypeCode)
        throw new TypeMismatch();
    return any.extract_TypeCode();
}
 
Example 30
Project: openjdk-jdk10   File: ServerRequestImpl.java   View source code 5 votes vote down vote up
/** This is called from the ORB after the DynamicImplementation.invoke
 *  returns. Here we set the result if result() has not already been called.
 *  @return the exception if there is one (then ORB will not call
 *  marshalReplyParams()) otherwise return null.
 */
public Any checkResultCalled()
{
    // Two things to be checked (CORBA 2.2 spec, section 6.3):
    // 1. Unless it calls set_exception(), the DIR must call arguments()
    //    exactly once, even if the operation signature contains
    //    no parameters.
    // 2. Unless set_exception() is called, if the invoked operation has a
    //    non-void result type, set_result() must be called exactly once
    //    before the DIR returns.

    if ( _paramsCalled && _resultSet ) // normal invocation return
        return null;
    else if ( _paramsCalled && !_resultSet && !_exceptionSet ) {
        try {
            // Neither a result nor an exception has been set.
            // Assume that the return type is void. If this is not so,
            // the client will throw a MARSHAL exception while
            // unmarshaling the return value.
            TypeCode result_tc = _orb.get_primitive_tc(
                org.omg.CORBA.TCKind.tk_void);
            _resultAny = _orb.create_any();
            _resultAny.type(result_tc);
            _resultSet = true;

            return null;
        } catch ( Exception ex ) {
            throw _wrapper.dsiResultException(
                CompletionStatus.COMPLETED_MAYBE, ex ) ;
        }
    } else if ( _exceptionSet )
        return _exception;
    else {
        throw _wrapper.dsimethodNotcalled(
            CompletionStatus.COMPLETED_MAYBE ) ;
    }
}
 
Example 31
Project: openjdk-jdk10   File: ORBImpl.java   View source code 5 votes vote down vote up
public synchronized org.omg.CORBA.TypeCode create_abstract_interface_tc(
                                                           String id,
                                                           String name)
{
    checkShutdownState();
    return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name);
}
 
Example 32
Project: OpenJSharp   File: Util.java   View source code 5 votes vote down vote up
/**
 * Writes any java.lang.Object as a CORBA any.
 * @param out the stream in which to write the any.
 * @param obj the object to write as an any.
 */
public void writeAny( org.omg.CORBA.portable.OutputStream out,
                     java.lang.Object obj)
{
    org.omg.CORBA.ORB orb = out.orb();

    // Create Any
    Any any = orb.create_any();

    // Make sure we have a connected object...
    java.lang.Object newObj = Utility.autoConnect(obj,orb,false);

    if (newObj instanceof org.omg.CORBA.Object) {
        any.insert_Object((org.omg.CORBA.Object)newObj);
    } else {
        if (newObj == null) {
            // Handle the null case, including backwards
            // compatibility issues
            any.insert_Value(null, createTypeCodeForNull(orb));
        } else {
            if (newObj instanceof Serializable) {
                // If they're our Any and ORB implementations,
                // we may want to do type code related versioning.
                TypeCode tc = createTypeCode((Serializable)newObj, any, orb);
                if (tc == null)
                    any.insert_Value((Serializable)newObj);
                else
                    any.insert_Value((Serializable)newObj, tc);
            } else if (newObj instanceof Remote) {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            } else {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            }
        }
    }

    out.write_any(any);
}
 
Example 33
Project: openjdk-jdk10   File: DynSequenceImpl.java   View source code 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    length = input.read_long();
    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example 34
Project: openjdk-jdk10   File: Util.java   View source code 5 votes vote down vote up
/**
 * Writes any java.lang.Object as a CORBA any.
 * @param out the stream in which to write the any.
 * @param obj the object to write as an any.
 */
public void writeAny( org.omg.CORBA.portable.OutputStream out,
                     java.lang.Object obj)
{
    org.omg.CORBA.ORB orb = out.orb();

    // Create Any
    Any any = orb.create_any();

    // Make sure we have a connected object...
    java.lang.Object newObj = Utility.autoConnect(obj,orb,false);

    if (newObj instanceof org.omg.CORBA.Object) {
        any.insert_Object((org.omg.CORBA.Object)newObj);
    } else {
        if (newObj == null) {
            // Handle the null case, including backwards
            // compatibility issues
            any.insert_Value(null, createTypeCodeForNull(orb));
        } else {
            if (newObj instanceof Serializable) {
                // If they're our Any and ORB implementations,
                // we may want to do type code related versioning.
                TypeCode tc = createTypeCode((Serializable)newObj, any, orb);
                if (tc == null)
                    any.insert_Value((Serializable)newObj);
                else
                    any.insert_Value((Serializable)newObj, tc);
            } else if (newObj instanceof Remote) {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            } else {
                ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
            }
        }
    }

    out.write_any(any);
}
 
Example 35
Project: OpenJSharp   File: CDRInputStream_1_0.java   View source code 5 votes vote down vote up
private boolean isCustomType(ValueHelper helper) {
    try{
        TypeCode tc = helper.get_type();
        int kind = tc.kind().value();
        if (kind == TCKind._tk_value) {
            return (tc.type_modifier() == org.omg.CORBA.VM_CUSTOM.value);
        }
    } catch(BadKind ex) {
        throw wrapper.badKind(ex) ;
    }

    return false;
}
 
Example 36
Project: openjdk-jdk10   File: DynAnyBasicImpl.java   View source code 5 votes vote down vote up
public void insert_typecode(org.omg.CORBA.TypeCode value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_TypeCode)
        throw new TypeMismatch();
    any.insert_TypeCode(value);
}
 
Example 37
Project: OpenJSharp   File: CDREncapsCodec.java   View source code 5 votes vote down vote up
/**
 * Decode the given octet sequence into an any based on a CDR
 * encapsulated octet sequence.  The type code is expected not to appear
 * in the octet sequence, and the given type code is used instead.
 */
public Any decode_value( byte[] data, TypeCode tc )
    throws FormatMismatch, TypeMismatch
{
    if( data == null )
        throw wrapper.nullParam() ;
    if( tc == null )
        throw  wrapper.nullParam() ;
    return decodeImpl( data, tc );
}
 
Example 38
Project: OpenJSharp   File: ClientRequestInfoImpl.java   View source code 5 votes vote down vote up
/**
 * See RequestInfoImpl for javadoc.
 */
public TypeCode[] exceptions (){
    checkAccess( MID_EXCEPTIONS );

    if( cachedExceptions == null ) {
        if( request == null ) {
           throw stdWrapper.piOperationNotSupported2() ;
        }

        // Get the list of exceptions from DII request data, If there are
        // no exceptions raised then this method will return null.
        ExceptionList excList = request.exceptions( );
        int count = excList.count();
        TypeCode[] excTCList = new TypeCode[count];
        try {
            for( int i = 0; i < count; i++ ) {
                excTCList[i] = excList.item( i );
            }
        } catch( Exception e ) {
            throw wrapper.exceptionInExceptions( e ) ;
        }

        cachedExceptions = excTCList;
    }

    // Good citizen: In the interest of efficiency, we assume
    // interceptors will be "good citizens" in that they will not
    // modify the contents of the TypeCode[] array.  We also assume
    // they will not change the values of the containing TypeCodes.

    return cachedExceptions;
}
 
Example 39
Project: openjdk-jdk10   File: CDREncapsCodec.java   View source code 5 votes vote down vote up
/**
 * Decode the given octet sequence into an any based on a CDR
 * encapsulated octet sequence.  The type code is expected not to appear
 * in the octet sequence, and the given type code is used instead.
 */
public Any decode_value( byte[] data, TypeCode tc )
    throws FormatMismatch, TypeMismatch
{
    if( data == null )
        throw wrapper.nullParam() ;
    if( tc == null )
        throw  wrapper.nullParam() ;
    return decodeImpl( data, tc );
}
 
Example 40
Project: openjdk-jdk10   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
protected DynAnyConstructedImpl(ORB orb, TypeCode typeCode) {
    // assertion: typeCode has been checked to be valid for this particular subclass.
    // note: We don't copy TypeCodes since they are considered immutable.
    super(orb, typeCode);
    if (typeCode != null) {
        representations = REPRESENTATION_TYPECODE;
    }
    // set the current position to 0 if any has components, otherwise to -1.
    index = NO_INDEX;

    // _REVISIT_ Would need REPRESENTATION_TYPECODE for lazy initialization
    //if ( ! isRecursive()) {
    //    initializeComponentsFromTypeCode();
    //}
}