如何使用 com.ericsson.otp.erlang 确定 erlang 术语是否为空
在我们的 Java 程序中,我们收到一个 Erlang 元组并将其提取到 OtpErlangTuple
中。元组的元素之一应该是字符串,但可以为空。当它为空时,它的值为 []
- Erlang 表示空列表的方式。
我的问题是如何检查元素是否为空以便将其转换为 OtpErlangString ?
由于现在是 (OtpErlangString)messageData.elementAt(2)
,因此会引发以下异常:
class java.lang.ClassCastException , 'com.ericsson.otp.erlang.OtpErlangList 无法转换为 com.ericsson.otp.erla ng.OtpErlangString'
谢谢,
马丁
In our Java program we receive an Erlang tuple and extract it in OtpErlangTuple
. One of the elements of the tuple should be a string but can be empty. When it is empty, its value is []
- the Erlang way of representing an empty list.
My question is how to check if the element is empty so to cast it to a OtpErlangString
?
As it is now (OtpErlangString)messageData.elementAt(2)
, the following exception is raised:
class java.lang.ClassCastException
, 'com.ericsson.otp.erlang.OtpErlangList cannot be cast to com.ericsson.otp.erla
ng.OtpErlangString'
Thanks,
Martin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查它是否等于
[]
,如果是,则执行特定操作:您可以按照您想要的方式处理这种情况,具体取决于您如何管理这些
OtpErlangString
Check if it is equal to
[]
and do a specific operation if so:You can handle this case the way you want depending on how you then manage those
OtpErlangString