xstream

Serialization problem with Enums at Android

I'm using XStream to serialize some objects to XML, and am facing a problem with Enums. The exception I get when I try to serialize the object: "ObjectAccessException: invalid final field java.lang.Enum.name". Apparently, this is a problem with the reflection API implementation in android: It doesn't treat final fields correctly. This p...

Xstream question and java object

I am looking to build java objects <placement_rules> <section name="news"> <front_order> <article_type name="article1"></article_type> <article_type name="article2"></article_type> </front_order> <back_order> <article_type name="article3"></article_type> </back_order> </section> <section name=...

XML element containing other xml characters replaced using xstream

Hi, I'm using xstream in java 1.4 and I'm having an issue with some embedded xml in the elements. I have the following message: <detail> <SwiftMessage><SWIFT>hi<SWIFT/><SwiftMessage/> <detail/> The element data hi is a string held in the SwiftMessage tags. I can see that Xstream is seeing these and replacing them with &lt;SWIFT&gt;...

Optimize loading speed of xstream

I felt xstream loading speed doesn't up to my requirement when I try to perform loading from the XML file. For an "database" with 10k ++ entries, it will take several minutes. The following is the entire data structure I use to serialize. Size of List (symbols and codes) will be roughly 10k ++ entries. http://jstock.cvs.sourceforge.net...

xstream - correct way to save XML in UTF-8

Previously, to read XML in UTF-8 encoding through xstream, I am using DomDriver as follow : XStream xStream = new XStream(new DomDriver("UTF-8")); However, later I realize this is VERY slow. I use the following way : http://stackoverflow.com/questions/3623546/optimize-loading-speed-of-xstream This works fine at least. However, late...

Mapping mixed content type using XStream

Hi, A question on creating java class for following XML node which contains a error code and description on the same element. My question is about how could I map the error message details in the java class so XStream works for deserializing. XML: Java: @XStreamAlias("response") public class ErrorResponse { @XStreamAlias("co...

XSteream Java Obj to XML Skipping some of the fields

How to skip certain fields of object in serialization of Obj to XML. code is here ...

XStreamMarshaller autodetect annotations -- Cannot flush HierarchicalStreamWriter

My context looks like this: <bean id="xStreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" p:converters-ref="converters" p:autodetectAnnotations="true"/> And if I switch on annotation auto-detection I get org.springframework.oxm.xstream.XStreamMarshaller - Could not flush HierarchicalStreamW...

Customizing XStream output

I have a class that resembles something like this: class foo { List<String> bar; ... } I add four Strings to the list bar: bar.add("1"); bar.add("2"); bar.add("3"); bar.add("4"); Using xstream, I've managed to get output that looks like this: <foo> <bar> <blah>1</blah> <blah>2</blah> <blah>3</blah> <b...

Xstream to map "choice" elements of XML

I need to map an XML, constrained by an XSD to Java object using XStream. The XSD has 4 complex type elements, which are "choice" elements, that is either one of those 4 can be present in the XML under a root tag. I have been looking at XStream but it seems to me that, to map such an XML, I would require 8 classes. How? here it is... S...

Using external Jars on GWT server-side

Hi, Im new to GWT. Im using the eclipse plugin and started tweaking google's 'hello, world!' project: greetServlet. Im trying to build a webapp that will use XML (de)serializing. I chose XStream library for the relative easiness. my classpath includes the xstream.jar. I also manually copied the jar to the WEB-INF/lib folder (Is this...

ERROR errors.GrailsExceptionResolver - Cannot reference implicit element

I am getting the below error when I try to use Xstream to marshal one of my groovy domain classes Employee. Employee hasmany employeDesiredSkills, which belongsTo Skill and Employee Here is the relevant Xstream code employeeInstance = new Employee(); XStream xstream = new XStream(); Xstream.alias("employee", Employee.class); String x...

XML serialization using XStream - Problem with unmarshal

The DTO structure is like below- class VO { Map<String,DTO> values; } class DTO { Map<String,String> details; } I am using XStream to convert the above DTO to XML and back to DTO Without using any user defined converters in XStream, the converted XML looks like below- <VO> <values> <entry> <string>input 123</string> ...

XStream: how to marshal/unmarshal lists in a custom converter?

I have the following class (legacy; not annotatable) that is serialized with a custom converter: class Test { // some other variables List<SomeType> someTypeList; } A properly working converter for SomeType is already available. However I want the list to be serialized as if it was annotated with @XStreamAlias("someTypes")....

Aesthetic question about Xstream XML output

Hi all, When I output an XML file using Xstream with a custom converter, all the nodes are printed out nice and indented etc., however when I print out another object, there is no new line between the end object tag and the new object tag. Take the example below: </macroblock> </frame> </MetadataFrame><MetadataFrame frame="456"> ...

How to access the XStream object inside the Converter

I have an instance of XStream where I've registered some converters and made some configuration the way I want things to work. XStream xstream = new XStream(); xstream.registerConverter(new SomeConverter()); (...) And I have a SomeConverter class that implements Converter. For some reason, I'd like to access the xstream object inside...

how to specify an alias when serializing an enum using Xstream

I am serializing a class that contains an enum as a field, let say : private class DayOfWeekSet { private final EnumSet<DayOfWeek> days; } public enum DayOfWeek implements Serializable { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY; } the Xstream output of the enum is : <days> <...

XStream Alias of List root elements

I want to be able to alias the root list element depending upon what type of objects are contained in the list. For example, this is my current output: <list> <coin>Gold</coin> <coin>Silver</coin> <coin>Bronze</coin> </list> And this is what I want it to look like: <coins> <coin>Gold</coin> <coin>Silver</coin> <coin>Bronze</coin> </...

Demarshalling XStream errors

Hi everyone, I have successfully created an XML file using XStream and a custom converter. The custom converter marshalls an object so it is nicely readable by humans as follows: <Header clip="16:01:02:22 -&gt; 16:01:52:00" match clock="961"> <match filename="MatchName" name="Jets vs Giants" date="2009-11-29 16:00:00.0"/> </Header> ...

Xstream duplicate attribute problem

Hi Everyone, I've been playing about with XStream XML parsing and I have a bit of a problem. In a file I need to parse, I have a node with several arbitrary attributes of the same name. THe node is a football team and the attributes are the names of each player. <team home="Arsenal"> <squad player="Manuel Almunia Rivero" player="Abou...