xstream

XStream doesn't support custom converter cross-delegation?

非 Y 不嫁゛ 提交于 2019-12-24 09:56:46
问题 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

Deserializing xml with duplicate entries using xstream

蹲街弑〆低调 提交于 2019-12-24 08:46:45
问题 I am trying to read in an xml file and store its contents as an object for later use. I can reproduce a similar object using the toXML() method and providing sample data however when I call fromXML() on the same object I get an error. The problem is I have multiple instances of fiels. The xml looks something like this... <House> <Address> <Number>1234</Number> <Street>Sample St.</Street> <City>Sample City</City> </Address> <Resident> <Name>Joe</Name> <Age>38</Age> <Profession> <Title>Engineer

XStream deserialization when variable type changed

时光总嘲笑我的痴心妄想 提交于 2019-12-24 06:48:00
问题 I have a java class that looks like public class MyClass { private final String str; private Polygon polygon; // this polygon is a custom type of mine } I have an xml file that has an instance of MyClass written to it using XStream. Now MyClass has changed and polygon has been replaced with List<Polygon> and the field has been renamed to polygons , and I'm trying not to break deserialization. I want to change the deserialization of the polygon field to basically read the polygon and then just

Formatting decimal values for XML

自作多情 提交于 2019-12-23 20:51:54
问题 I have a problem currently where a system we are connecting to expects to receive XML which contains, among other things, three double fields formatted to one decimal place. Personally I feel that our system should just be able to send values in default format and then it's up to other systems to format their own representation as they please, but alas this doesn't seem to be an option. My Java-based system is currently converting objects to XML through the use of XStream. We have an XSD

How to use Mule's XML-to-Object transformer?

戏子无情 提交于 2019-12-23 05:09:15
问题 What are the steps which should be done? What should be present in the driver class? How should I create the POJO with which to map the XML to? How should I configure the transformer? 回答1: you can use a driver class like Xpp3driver eg. the flow would look something like <flow name="mulexmlvalFlow2" doc:name="mulexmlvalFlow2"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP" path="XmlToObj"/> <mulexml:xml-to-object-transformer doc:name=

XStream won't call readObject()

安稳与你 提交于 2019-12-22 18:44:11
问题 I have code that is modeled as such: class A { private transient Foo foo = new Foo(); private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); foo = new Foo(); } } class B extends A {} I added readObject() to A so that during deserialization, the transient foo will be initialized. However, I stuck breakpoints in my code and could see that XStream is not calling readObject() at all. I also tried sticking readObject() in class B that

How to annotation order field when using XStream on Android?

元气小坏坏 提交于 2019-12-22 18:24:25
问题 I need to generate XML from java objects on Android. XML nodes must be in definite sequence. Here is what I got(These fields as according to alphabetical order): <soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <cwmp:Inform> <CurrentTime>2013-06-07 07:11:20.561 UTC<

How to annotation order field when using XStream on Android?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 18:23:25
问题 I need to generate XML from java objects on Android. XML nodes must be in definite sequence. Here is what I got(These fields as according to alphabetical order): <soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <cwmp:Inform> <CurrentTime>2013-06-07 07:11:20.561 UTC<

Java Reading XML with XStream

帅比萌擦擦* 提交于 2019-12-22 09:45:48
问题 I'm trying to deserialize this XML file using XStream and I'm getting this error Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Authors : Authors ---- Debugging information ---- message : Authors cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException cause-message : Authors class : java.util.ArrayList required-type : java.util.ArrayList converter-type : com.thoughtworks.xstream.converters.collections.CollectionConverter path :

xstream errors for serializing & deserializing

岁酱吖の 提交于 2019-12-22 07:02:30
问题 I am using xStream in Java to serialize a java object from a java library and deserializing it at the customer's side. I have several problems: If I do it like this: XStream xstream = new XStream(); xstream.setMode(XStream.ID_REFERENCES); xstream.autodetectAnnotations(true); Writer writer = new FileWriter(xmlFile); writer.write(xstream.toXML(myObject)); writer.close(); => serializing is OK but deserializing: Exception in thread "main" com.thoughtworks.xstream.io.StreamException: : only