Representing a null java.lang.Double in CORBA?
Let's say I have a null java.lang.Double (object) to pass through CORBA. CORBA doesn't accept null for the double primitive type, so I'll have to map it to another double (primitive) value.
What is the b开发者_运维问答est value I should use?
Thanks!
This is a difficult question to answer, especially if all double values are valid for whatever this variable will be representing.
The best bet would be to choose Double.MIN_VALUE or some value that will most likely not be used.
However, you need to make sure this value will also be representable in the other languages/hardware that will be interfacing with CORBA.
CORBA value types support null; see Chapter 9 of the CORBA 3.1 spec part 1 - http://www.omg.org/spec/CORBA/3.1/Interfaces/PDF/
I think that the following IDL syntax will define a boxed value type that can represent a double
or null
.
valuetype Double double;
If you can't change the IDL and the current IDL doesn't allow you to send null
values, then you should treat a null as an error and not try to send it. Stealing a legitimate value (say Double.MAX_VALUE
) from the double
value-set to stand for a null
is asking for problems:
- Some day there could be a need to send a
Double.MAX_VALUE
as data. - Other existing software using this interface is likely to not know about your convention, and may process a
Double.MAX_VALUE
as its literal self.
精彩评论