XStream不支持自定义转换器交叉委托?
在我看来,Java XStream 库不支持交叉委托。我的这个信念正确吗?
因此,我可以解释我的意思,请考虑以下示例:
<node-type-x>
<node-type-y>
<a/>
<b/>
</node-type-y>
<node-type-y>
<c/>
<d/>
假设我们有一个用于“node-type-x”节点的转换器和另一个用于“node-type-y”节点的转换器。我希望在 XStream 中看到的功能是某种类型的 delegate() 方法,我可以在 node-type-x 转换器中调用该方法来识别嵌套节点类型-y 节点并将解组委托给此类节点的转换器并返回结果,以便节点类型 x 转换器可以根据需要处理结果。就目前情况而言,XStream 似乎要求“node-type-x”转换器处理此类节点的所有子节点。
It appears to me that the Java XStream library does not support cross-delegation. Am I correct in this belief?
So, I can explain what I mean, consider the following example:
<node-type-x>
<node-type-y>
<a/>
<b/>
</node-type-y>
<node-type-y>
<c/>
<d/>
Let's say we have a converter for "node-type-x" nodes and another converter for "node-type-y" nodes. The functionality I would like to see in XStream would be sometype of delegate() method which I could call within the node-type-x converter that would identify nested node-type-y nodes and delegate unmarshalling to the converter for such nodes and return the result so that the node-type-x converter can process the result as needed. As it stands, XStream seems to require that the converter for "node-type-x" handle processing of all children of such nodes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两种简单的方法可以做到这一点:
Two simple ways to do this: