org.omg.CORBA.TCKind Java Examples

The following examples show how to use org.omg.CORBA.TCKind. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: DynAnyBasicImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    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_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example #2
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: AnyImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_string(String s)
{
    //debug.log ("insert_string");
    // Make sure type code information for bounded strings is not erased
    if (typeCode.kind() == TCKind.tk_string) {
        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_string);
    }
    object = s;
    isInitialized = true;
}
 
Example #3
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: TypeCodeImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
void read_value_kind(InputStream is) {
    // unmarshal the kind
    _kind = is.read_long();

    // check validity of kind
    if ((_kind < 0 || _kind > typeTable.length) && _kind != tk_indirect) {
        throw wrapper.cannotMarshalBadTckind() ;
    }
    // Don't do any work if this is native
    if (_kind == TCKind._tk_native)
        throw wrapper.cannotMarshalNative() ;

    if (_kind == tk_indirect) {
        throw wrapper.recursiveTypecodeError() ;
    }
}
 
Example #4
Source Project: hottub   Author: dsrg-uoft   File: AnyImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_string(String s)
{
    //debug.log ("insert_string");
    // Make sure type code information for bounded strings is not erased
    if (typeCode.kind() == TCKind.tk_string) {
        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_string);
    }
    object = s;
    isInitialized = true;
}
 
Example #5
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ValueUtility.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static String getSignature(ValueMember member)
    throws ClassNotFoundException {

    // REVISIT.  Can the type be something that is
    // non-primitive yet not a value_box, value, or objref?
    // If so, should use ObjectStreamClass or throw
    // exception.

    if (member.type.kind().value() == TCKind._tk_value_box ||
        member.type.kind().value() == TCKind._tk_value ||
        member.type.kind().value() == TCKind._tk_objref) {
        Class c = RepositoryId.cache.getId(member.id).getClassFromType();
        return ObjectStreamClass.getSignature(c);

    } else {

        return primitiveConstants[member.type.kind().value()];
    }

}
 
Example #6
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: AnyImpl.java    License: GNU General Public License v2.0 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 #7
Source Project: cxf   Author: apache   File: CorbaUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static TypeCode getPrimitiveTypeCode(ORB orb, QName type) {
    TCKind kind = PRIMITIVE_TYPECODES.get(type);
    if (kind != null) {
        return orb.get_primitive_tc(kind);
    }

    // There is a possiblitity that the idl type will not have its namespace URI set if it has
    // been read directly from the WSDL file as a string. Try with the standard corba namespace URI.
    if (type.getNamespaceURI() == null) {
        QName uriIdltype = new QName(CorbaConstants.NU_WSDL_CORBA, type.getLocalPart(), type.getPrefix());

        kind = PRIMITIVE_TYPECODES.get(uriIdltype);
        if (kind != null) {
            return orb.get_primitive_tc(kind);
        }
    }
    return null;
}
 
Example #8
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: TypeCodeImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public String name()
    throws BadKind
{
    switch (_kind) {
    case tk_indirect:
        return indirectType().name();
    case TCKind._tk_except:
    case TCKind._tk_objref:
    case TCKind._tk_struct:
    case TCKind._tk_union:
    case TCKind._tk_enum:
    case TCKind._tk_alias:
    case TCKind._tk_value:
    case TCKind._tk_value_box:
    case TCKind._tk_native:
    case TCKind._tk_abstract_interface:
        return _name;
    default:
        throw new BadKind();
    }
}
 
Example #9
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: TypeCodeImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
void read_value_kind(InputStream is) {
    // unmarshal the kind
    _kind = is.read_long();

    // check validity of kind
    if ((_kind < 0 || _kind > typeTable.length) && _kind != tk_indirect) {
        throw wrapper.cannotMarshalBadTckind() ;
    }
    // Don't do any work if this is native
    if (_kind == TCKind._tk_native)
        throw wrapper.cannotMarshalNative() ;

    if (_kind == tk_indirect) {
        throw wrapper.recursiveTypecodeError() ;
    }
}
 
Example #10
Source Project: openjdk-8   Author: bpupadhyaya   File: ValueUtility.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static String getSignature(ValueMember member)
    throws ClassNotFoundException {

    // REVISIT.  Can the type be something that is
    // non-primitive yet not a value_box, value, or objref?
    // If so, should use ObjectStreamClass or throw
    // exception.

    if (member.type.kind().value() == TCKind._tk_value_box ||
        member.type.kind().value() == TCKind._tk_value ||
        member.type.kind().value() == TCKind._tk_objref) {
        Class c = RepositoryId.cache.getId(member.id).getClassFromType();
        return ObjectStreamClass.getSignature(c);

    } else {

        return primitiveConstants[member.type.kind().value()];
    }

}
 
Example #11
Source Project: openjdk-8   Author: bpupadhyaya   File: TypeCodeImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    short digits,
                    short scale)
                    // for fixed
{
    this(orb) ;

    //if (digits < 1 || digits > 31)
    //throw new BAD_TYPECODE();

    if (creationKind == TCKind._tk_fixed) {
        _kind               = creationKind;
        _digits             = digits;
        _scale              = scale;
    } // else initializes to null
}
 
Example #12
Source Project: openjdk-8-source   Author: keerath   File: AnyImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_Object(org.omg.CORBA.Object o)
{
    //debug.log ("insert_Object");
    if ( o == null ) {
        typeCode = orb.get_primitive_tc(TCKind._tk_objref);
    } else {
        if (StubAdapter.isStub(o)) {
            String[] ids = StubAdapter.getTypeIds( o ) ;
            typeCode = new TypeCodeImpl(orb, TCKind._tk_objref, ids[0], "");
        } else {
            throw wrapper.badInsertobjParam(
                CompletionStatus.COMPLETED_MAYBE, o.getClass().getName() ) ;
        }
    }

    object = o;
    isInitialized = true;
}
 
Example #13
Source Project: openjdk-8-source   Author: keerath   File: DynAnyBasicImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void insert_string(String 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_string)
        throw new TypeMismatch();
    if (value == null)
        throw new InvalidValue();
    // Throw InvalidValue if this is a bounded string and the length is exceeded
    try {
        if (any.type().length() > 0 && any.type().length() < value.length())
            throw new InvalidValue();
    } catch (BadKind bad) { // impossible
    }
    any.insert_string(value);
}
 
Example #14
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: Util.java    License: MIT License 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 #15
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: TypeCodeImpl.java    License: Apache License 2.0 6 votes vote down vote up
int currentUnionMemberIndex(Any discriminatorValue) throws BadKind {
    if (_kind != TCKind._tk_union)
        throw new BadKind();

    try {
        for (int i=0; i<member_count(); i++) {
            if (member_label(i).equal(discriminatorValue)) {
                return i;
            }
        }
        if (_defaultIndex != -1) {
            return _defaultIndex;
        }
    } catch (BadKind bad) {
    } catch (org.omg.CORBA.TypeCodePackage.Bounds bounds) {
    }
    return -1;
}
 
Example #16
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: DynAnyUtil.java    License: Apache License 2.0 5 votes vote down vote up
static DynAny createMostDerivedDynAny(TypeCode typeCode, ORB orb)
    throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
{
    if (typeCode == null || ! DynAnyUtil.isConsistentType(typeCode))
        throw new org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode();

    switch (typeCode.kind().value()) {
        case TCKind._tk_sequence:
            return new DynSequenceImpl(orb, typeCode);
        case TCKind._tk_struct:
            return new DynStructImpl(orb, typeCode);
        case TCKind._tk_array:
            return new DynArrayImpl(orb, typeCode);
        case TCKind._tk_union:
            return new DynUnionImpl(orb, typeCode);
        case TCKind._tk_enum:
            return new DynEnumImpl(orb, typeCode);
        case TCKind._tk_fixed:
            return new DynFixedImpl(orb, typeCode);
        case TCKind._tk_value:
            return new DynValueImpl(orb, typeCode);
        case TCKind._tk_value_box:
            return new DynValueBoxImpl(orb, typeCode);
        default:
            return new DynAnyBasicImpl(orb, typeCode);
    }
}
 
Example #17
Source Project: openjdk-8-source   Author: keerath   File: DynAnyBasicImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public org.omg.CORBA.Any get_any()
    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_any)
        throw new TypeMismatch();
    return any.extract_any();
}
 
Example #18
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: AnyImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_short(short s)
{
    //debug.log ("insert_short");
    typeCode = orb.get_primitive_tc(TCKind._tk_short);
    value = s;
    isInitialized = true;
}
 
Example #19
Source Project: jdk8u60   Author: chenghanpeng   File: AnyImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_short(short s)
{
    //debug.log ("insert_short");
    typeCode = orb.get_primitive_tc(TCKind._tk_short);
    value = s;
    isInitialized = true;
}
 
Example #20
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: AnyImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public int extract_long()
{
    //debug.log ("extract_long");
    checkExtractBadOperationList( new int[] { TCKind._tk_long, TCKind._tk_enum } ) ;
    return (int)value;
}
 
Example #21
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: DynAnyBasicImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void insert_float(float 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_float)
        throw new TypeMismatch();
    any.insert_float(value);
}
 
Example #22
Source Project: jdk8u60   Author: chenghanpeng   File: DynAnyBasicImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public int get_ulong()
    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_ulong)
        throw new TypeMismatch();
    return any.extract_ulong();
}
 
Example #23
Source Project: openjdk-8-source   Author: keerath   File: AnyImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public long extract_longlong()
{
    //debug.log ("extract_longlong");
    checkExtractBadOperation( TCKind._tk_longlong ) ;
    return value;
}
 
Example #24
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: DynAnyBasicImpl.java    License: Apache License 2.0 5 votes vote down vote up
public long get_longlong()
    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_longlong)
        throw new TypeMismatch();
    return any.extract_longlong();
}
 
Example #25
Source Project: jdk8u60   Author: chenghanpeng   File: AnyImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Note that the Serializable really should be an IDLEntity of
 * some kind.  It shouldn't just be an RMI-IIOP type.  Currently,
 * we accept and will produce RMI repIds with the latest
 * calculations if given a non-IDLEntity Serializable.
 */
public Serializable extract_Value()
{
    //debug.log ("extract_Value");
    checkExtractBadOperationList( new int[] { TCKind._tk_value,
        TCKind._tk_value_box, TCKind._tk_abstract_interface } ) ;
    return (Serializable)object;
}
 
Example #26
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: AnyImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public int extract_ulong()
{
    //debug.log ("extract_ulong");
    checkExtractBadOperation( TCKind._tk_ulong ) ;
    return (int)value;
}
 
Example #27
Source Project: openjdk-8   Author: bpupadhyaya   File: DynAnyBasicImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public String get_string()
    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_string)
        throw new TypeMismatch();
    return any.extract_string();
}
 
Example #28
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: AnyImpl.java    License: GNU General Public License v2.0 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 #29
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: TypeCodeImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    int bound)
                    // for strings
{
    this(orb) ;

    if (bound < 0)
        throw wrapper.negativeBounds() ;

    if ((creationKind == TCKind._tk_string) || (creationKind == TCKind._tk_wstring)) {
        _kind               = creationKind;
        _length             = bound;
    } // else initializes to null
}
 
Example #30
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: TypeCodeImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    int bound,
                    TypeCode element_type)
                    // for sequences and arrays
{
    this(orb) ;

    if ( creationKind == TCKind._tk_sequence || creationKind == TCKind._tk_array ) {
        _kind               = creationKind;
        _length             = bound;
        _contentType        = convertToNative(_orb, element_type);
    } // else initializes to null
}