KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > dynamicany > DynValueCommonImpl


1 /*
2  * @(#)DynValueCommonImpl.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.dynamicany;
9
10 import org.omg.CORBA.TypeCode JavaDoc;
11 import org.omg.CORBA.TCKind JavaDoc;
12 import org.omg.CORBA.Any JavaDoc;
13 import org.omg.CORBA.TypeCodePackage.BadKind JavaDoc;
14 import org.omg.CORBA.TypeCodePackage.Bounds JavaDoc;
15 import org.omg.DynamicAny.*;
16 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc;
17 import org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc;
18 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode JavaDoc;
19
20 import com.sun.corba.se.spi.orb.ORB ;
21 import com.sun.corba.se.spi.logging.CORBALogDomains ;
22 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
23
24 abstract class DynValueCommonImpl extends DynAnyComplexImpl implements DynValueCommon
25 {
26     //
27
// Constructors
28
//
29

30     protected boolean isNull;
31
32     private DynValueCommonImpl() {
33         this(null, (Any JavaDoc)null, false);
34         isNull = true;
35     }
36
37     protected DynValueCommonImpl(ORB orb, Any JavaDoc any, boolean copyValue) {
38         super(orb, any, copyValue);
39         isNull = checkInitComponents();
40     }
41
42     protected DynValueCommonImpl(ORB orb, TypeCode JavaDoc typeCode) {
43         super(orb, typeCode);
44         isNull = true;
45     }
46
47     //
48
// DynValueCommon methods
49
//
50

51     // Returns TRUE if this object represents a null valuetype
52
public boolean is_null() {
53         return isNull;
54     }
55
56     // Changes the representation to a null valuetype.
57
public void set_to_null() {
58         isNull = true;
59         clearData();
60     }
61
62     // If this object represents a null valuetype then this operation
63
// replaces it with a newly constructed value with its components
64
// initialized to default values as in DynAnyFactory::create_dyn_any_from_type_code.
65
// If this object represents a non-null valuetype, then this operation has no effect.
66
public void set_to_value() {
67         if (isNull) {
68             isNull = false;
69             // the rest is done lazily
70
}
71         // else: there is nothing to do
72
}
73
74     //
75
// Methods differing from DynStruct
76
//
77

78     // Required to raise InvalidValue if this is a null value type.
79
public org.omg.DynamicAny.NameValuePair JavaDoc[] get_members ()
80         throws org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc
81     {
82         if (status == STATUS_DESTROYED) {
83         throw wrapper.dynAnyDestroyed() ;
84         }
85         if (isNull) {
86             throw new InvalidValue JavaDoc();
87         }
88         checkInitComponents();
89         return nameValuePairs;
90     }
91
92     // Required to raise InvalidValue if this is a null value type.
93
public org.omg.DynamicAny.NameDynAnyPair JavaDoc[] get_members_as_dyn_any ()
94         throws org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc
95     {
96         if (status == STATUS_DESTROYED) {
97         throw wrapper.dynAnyDestroyed() ;
98         }
99         if (isNull) {
100             throw new InvalidValue JavaDoc();
101         }
102         checkInitComponents();
103         return nameDynAnyPairs;
104     }
105
106     //
107
// Overridden methods
108
//
109

110     // Overridden to change to non-null status.
111
public void set_members (org.omg.DynamicAny.NameValuePair JavaDoc[] value)
112         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc,
113                org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc
114     {
115         super.set_members(value);
116         // If we didn't get an exception then this must be a valid non-null value
117
isNull = false;
118     }
119
120     // Overridden to change to non-null status.
121
public void set_members_as_dyn_any (org.omg.DynamicAny.NameDynAnyPair JavaDoc[] value)
122         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc,
123                org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc
124     {
125         super.set_members_as_dyn_any(value);
126         // If we didn't get an exception then this must be a valid non-null value
127
isNull = false;
128     }
129 }
130
Popular Tags