简体   繁体   English

在CORBA中代表一个空的java.lang.Double吗?

[英]Representing a null java.lang.Double in CORBA?

Let's say I have a null java.lang.Double (object) to pass through CORBA. 假设我有一个空的java.lang.Double(对象)要通过CORBA传递。 CORBA doesn't accept null for the double primitive type, so I'll have to map it to another double (primitive) value. CORBA不接受双基本类型的null,因此我必须将其映射到另一个双(基本)值。

What is the best 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. 最好的选择是选择Double.MIN_VALUE或一些很可能不会使用的值。

However, you need to make sure this value will also be representable in the other languages/hardware that will be interfacing with CORBA. 但是,您需要确保此值在与CORBA交互的其他语言/硬件中也可以表示。

CORBA value types support null; CORBA值类型支持null; see Chapter 9 of the CORBA 3.1 spec part 1 - http://www.omg.org/spec/CORBA/3.1/Interfaces/PDF/ 看到CORBA 3.1规范部分的第9章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 . 我认为以下IDL语法将定义一个可以表示doublenull的装箱值类型。

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. 如果您不能更改IDL并且当前的IDL不允许您发送null值,那么您应该将空值视为错误,而不要尝试发送它。 Stealing a legitimate value (say Double.MAX_VALUE ) from the double value-set to stand for a null is asking for problems: double Double.MAX_VALUE值集中窃取合法值(例如Double.MAX_VALUE )以表示null表示问题:

  • Some day there could be a need to send a Double.MAX_VALUE as data. 有一天可能需要发送Double.MAX_VALUE作为数据。
  • 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. 使用此接口的其他现有软件可能不了解您的约定,并且可能将Double.MAX_VALUE作为其字面本身进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM