[英]Serialize an external object
I am programming towards the Bloomberg Desktop Java API where I subscribe to and recieve market data in Message
objects, containing different fields and corresponding values of different types, through the API. 我正在编写Bloomberg Desktop Java API,我订阅并接收
Message
对象中的市场数据,包含不同的字段和不同类型的相应值,通过API。 I want to 'record' a sequence of messages so that I can conduct testing of my code that processes these objects by replaying a known sequence of messages. 我想“记录”一系列消息,以便我可以通过重放已知的消息序列来测试处理这些对象的代码。 Ideally, I would like to subscribe to a number of messages during a day and put them into an
ArrayList
(or similar) and then serialize the list of objects. 理想情况下,我想在一天内订阅一些消息并将它们放入
ArrayList
(或类似的)中,然后序列化对象列表。 However, the Message
object does NOT implement the Serializable
interface so this does not appear to work the way I want it to. 但是,
Message
对象没有实现Serializable
接口,所以这看起来不像我想要的那样工作。
Is it possible, or is there any workaround, to serialize external objects that do not implement Serializable
. 序列化不实现
Serializable
外部对象是否可行,或者是否有任何解决方法。 Thanks. 谢谢。
您可以包装Message
对象并实现Externalizable接口,从而可以在readExternal/writeExternal
方法中编写序列化/反序列化逻辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.