org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode Java Examples

The following examples show how to use org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode. 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 File: DynAnyBasicImpl.java    From jdk8u60 with 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 File: DynUnionImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example #3
Source File: DynAnyBasicImpl.java    From openjdk-jdk8u with 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 #4
Source File: DynUnionImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example #5
Source File: DynAnyBasicImpl.java    From jdk1.8-source-analysis with Apache License 2.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 #6
Source File: DynAnyBasicImpl.java    From JDKSourceCode1.8 with MIT License 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 #7
Source File: DynUnionImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example #8
Source File: DynUnionImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example #9
Source File: DynAnyBasicImpl.java    From TencentKona-8 with 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 #10
Source File: DynUnionImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example #11
Source File: DynUnionImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected boolean initializeComponentsFromTypeCode() {
    //System.out.println(this + " initializeComponentsFromTypeCode");
    try {
        // We can be sure that memberCount() > 0 according to the IDL language spec
        discriminator = DynAnyUtil.createMostDerivedDynAny(memberLabel(0), orb, false);
        index = 0;
        currentMemberIndex = 0;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(0), orb);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example #12
Source File: DynSequenceImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #13
Source File: DynAnyCollectionImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected void createDefaultComponentAt(int i, TypeCode contentType) {
    try {
        components[i] = DynAnyUtil.createMostDerivedDynAny(contentType, orb);
    } catch (InconsistentTypeCode itc) { // impossible
    }
    // get a hold of the default initialized Any without copying
    anys[i] = getAny(components[i]);
}
 
Example #14
Source File: DynValueBoxImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected boolean initializeComponentsFromTypeCode() {
    try {
        any = DynAnyUtil.createDefaultAnyOfType(any.type(), orb);
        components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
    } catch (InconsistentTypeCode ictc) {
        return false; // impossible
    }
    return true;
}
 
Example #15
Source File: DynValueBoxImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
    } catch (InconsistentTypeCode ictc) {
        return false; // impossible
    }
    return true;
}
 
Example #16
Source File: DynAnyUtil.java    From openjdk-jdk8u with GNU General Public License v2.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 File: DynAnyUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static DynAny convertToNative(DynAny dynAny, ORB orb) {
    if (dynAny instanceof DynAnyImpl) {
        return dynAny;
    } else {
        // if copy flag wasn't true we would be using our DynAny with
        // a foreign Any in it.
        try {
            return createMostDerivedDynAny(dynAny.to_any(), orb, true);
        } catch (InconsistentTypeCode ictc) {
            return null;
        }
    }
}
 
Example #18
Source File: DynUnionImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void set_discriminator (org.omg.DynamicAny.DynAny newDiscriminator)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if ( ! newDiscriminator.type().equal(discriminatorType())) {
        throw new TypeMismatch();
    }
    newDiscriminator = DynAnyUtil.convertToNative(newDiscriminator, orb);
    Any newDiscriminatorAny = getAny(newDiscriminator);
    int newCurrentMemberIndex = currentUnionMemberIndex(newDiscriminatorAny);
    if (newCurrentMemberIndex == NO_INDEX) {
        clearData();
        index = 0;
    } else {
        // _REVISIT_ Could possibly optimize here if we don't need to initialize components
        checkInitComponents();
        if (currentMemberIndex == NO_INDEX || newCurrentMemberIndex != currentMemberIndex) {
            clearData();
            index = 1;
            currentMemberIndex = newCurrentMemberIndex;
            try {
            currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(currentMemberIndex), orb);
            } catch (InconsistentTypeCode ictc) {}
            discriminator = newDiscriminator;
            components = new DynAny[] { discriminator, currentMember };
            representations = REPRESENTATION_COMPONENTS;
        }
    }
}
 
Example #19
Source File: DynUnionImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void set_discriminator (org.omg.DynamicAny.DynAny newDiscriminator)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if ( ! newDiscriminator.type().equal(discriminatorType())) {
        throw new TypeMismatch();
    }
    newDiscriminator = DynAnyUtil.convertToNative(newDiscriminator, orb);
    Any newDiscriminatorAny = getAny(newDiscriminator);
    int newCurrentMemberIndex = currentUnionMemberIndex(newDiscriminatorAny);
    if (newCurrentMemberIndex == NO_INDEX) {
        clearData();
        index = 0;
    } else {
        // _REVISIT_ Could possibly optimize here if we don't need to initialize components
        checkInitComponents();
        if (currentMemberIndex == NO_INDEX || newCurrentMemberIndex != currentMemberIndex) {
            clearData();
            index = 1;
            currentMemberIndex = newCurrentMemberIndex;
            try {
            currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(currentMemberIndex), orb);
            } catch (InconsistentTypeCode ictc) {}
            discriminator = newDiscriminator;
            components = new DynAny[] { discriminator, currentMember };
            representations = REPRESENTATION_COMPONENTS;
        }
    }
}
 
Example #20
Source File: DynUnionImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected boolean initializeComponentsFromTypeCode() {
    //System.out.println(this + " initializeComponentsFromTypeCode");
    try {
        // We can be sure that memberCount() > 0 according to the IDL language spec
        discriminator = DynAnyUtil.createMostDerivedDynAny(memberLabel(0), orb, false);
        index = 0;
        currentMemberIndex = 0;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(0), orb);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example #21
Source File: DynUnionImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        InputStream input = any.create_input_stream();
        Any discriminatorAny = DynAnyUtil.extractAnyFromStream(discriminatorType(), input, orb);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        currentMemberIndex = currentUnionMemberIndex(discriminatorAny);
        Any memberAny = DynAnyUtil.extractAnyFromStream(memberType(currentMemberIndex), input, orb);
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberAny, orb, false);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example #22
Source File: DynArrayImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_array.
    TypeCode typeCode = any.type();
    int length = getBound();
    TypeCode contentType = getContentType();
    InputStream input;

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

    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 #23
Source File: DynAnyConstructedImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public org.omg.DynamicAny.DynAny copy() {
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkInitAny();
    try {
        return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
    } catch (InconsistentTypeCode ictc) {
        return null; // impossible
    }
}
 
Example #24
Source File: DynAnyBasicImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public org.omg.DynamicAny.DynAny copy() {
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    // The flag "true" indicates copying the Any value
    try {
        return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
    } catch (InconsistentTypeCode ictc) {
        return null; // impossible
    }
}
 
Example #25
Source File: DynAnyCollectionImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void createDefaultComponentAt(int i, TypeCode contentType) {
    try {
        components[i] = DynAnyUtil.createMostDerivedDynAny(contentType, orb);
    } catch (InconsistentTypeCode itc) { // impossible
    }
    // get a hold of the default initialized Any without copying
    anys[i] = getAny(components[i]);
}
 
Example #26
Source File: DynAnyBasicImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public org.omg.DynamicAny.DynAny copy() {
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    // The flag "true" indicates copying the Any value
    try {
        return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
    } catch (InconsistentTypeCode ictc) {
        return null; // impossible
    }
}
 
Example #27
Source File: DynAnyUtil.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static DynAny convertToNative(DynAny dynAny, ORB orb) {
    if (dynAny instanceof DynAnyImpl) {
        return dynAny;
    } else {
        // if copy flag wasn't true we would be using our DynAny with
        // a foreign Any in it.
        try {
            return createMostDerivedDynAny(dynAny.to_any(), orb, true);
        } catch (InconsistentTypeCode ictc) {
            return null;
        }
    }
}
 
Example #28
Source File: DynAnyUtil.java    From jdk8u60 with GNU General Public License v2.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 #29
Source File: DynAnyUtil.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static DynAny createMostDerivedDynAny(Any any, ORB orb, boolean copyValue)
    throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
{
    if (any == null || ! DynAnyUtil.isConsistentType(any.type()))
        throw new org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode();

    switch (any.type().kind().value()) {
        case TCKind._tk_sequence:
            return new DynSequenceImpl(orb, any, copyValue);
        case TCKind._tk_struct:
            return new DynStructImpl(orb, any, copyValue);
        case TCKind._tk_array:
            return new DynArrayImpl(orb, any, copyValue);
        case TCKind._tk_union:
            return new DynUnionImpl(orb, any, copyValue);
        case TCKind._tk_enum:
            return new DynEnumImpl(orb, any, copyValue);
        case TCKind._tk_fixed:
            return new DynFixedImpl(orb, any, copyValue);
        case TCKind._tk_value:
            return new DynValueImpl(orb, any, copyValue);
        case TCKind._tk_value_box:
            return new DynValueBoxImpl(orb, any, copyValue);
        default:
            return new DynAnyBasicImpl(orb, any, copyValue);
    }
}
 
Example #30
Source File: DynAnyCollectionImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void set_elements (org.omg.CORBA.Any[] value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkValue(value);

    components = new DynAny[value.length];
    anys = value;

    // 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();
            }
            try {
                // Creates the appropriate subtype without copying the Any
                components[i] = DynAnyUtil.createMostDerivedDynAny(value[i], orb, false);
                //System.out.println(this + " created component " + components[i]);
            } catch (InconsistentTypeCode itc) {
                throw new InvalidValue();
            }
        } 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;
}