xstream

How to disable pretty-printing(white space/newline) in XStream?

送分小仙女□ 提交于 2019-12-02 17:35:38
This is how I create XStream instance for XML: XStream xstream = new XStream(); This is for JSON: private final XStream xstream = new XStream(new JsonHierarchicalStreamDriver() { public HierarchicalStreamWriter createWriter(Writer writer) { return new JsonWriter(writer, JsonWriter.DROP_ROOT_MODE); } }); Both of them are pretty-printing (indenting) the output. How can I ask the XStream to disable the pretty printing? noclayto Thanks, your posts helped!!! Here is what I use to convert to a String. String strXML = ""; XStream xs = new XStream(); StringWriter sw = new StringWriter(); xs.marshal

xstream flatten an object

我们两清 提交于 2019-12-02 09:05:46
I am trying to flatten the xml output of xstream using a converter/marshaling with no luck. For example, public class A{ public B b; public int F; public String G; } public class B{ public String C; public String D; public int E; } is output as <A> <B> <C></C> <D></D> <E></E> </B> <F></F> <G></G> </A> but I need <A> <C></C> <D></D> <E></E> <F></F> <G></G> </A> is this possible? How to get rid of B? (C, D, E are uniquely named). Thanks. My attempt thus far has been ... public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { B b = (B) value; writer

Converting XML into Java Map<String, Integer>

假装没事ソ 提交于 2019-12-02 07:35:32
I'm trying to convert XML into Java code. This XML is in a different file; it matches words with numbers (a probability distribution) and looks like this: <?xml version="1.0" encoding="UTF-8" ?> <root> <Durapipe type="int">1</Durapipe> <EXPLAIN type="int">2</EXPLAIN> <woods type="int">2</woods> <hanging type="int">3</hanging> <hastily type="int">2</hastily> <localized type="int">1</localized> <Schuster type="int">5</Schuster> <regularize type="int">1</regularize> <LASR type="int">1</LASR> <LAST type="int">22</LAST> <Gelch type="int">2</Gelch> <Gelco type="int">26</Gelco> ....... </root> I'm

XStream : node with attributes and text node in xstream 1.3.1?

懵懂的女人 提交于 2019-12-02 07:34:19
I would like to serialize an object to an XML of this form with XStream. <node att="value">text</node> There already is a solution for this in StackOverflow here: XStream : node with attributes and text node? but it won't work for me since I am restricted to XStream 1.3.1. I found @XStreamConverter(value=ToAttributedValueConverter.class, strings={"content"}) which does exactly what I want in a simple way but it is not available in XStream 1.3.1. Is there a nicer way to solve this issue with 1.3.1 version of XStream? It's possible with some hacks. The main idia is to use a modified

Libgdx, Transitive dependencies Android,Java library project, Jar

情到浓时终转凉″ 提交于 2019-12-02 06:00:33
问题 I have just created template Libgdx project (Core,Android,Windows). Core is regular Java project library. There is a dependency in Core to XStream.jar library. Core contains file input-output via Xml. Android project has dependency to java core project. Now XStraem is working for Windows but not for Android. For Android i got this: 01-22 13:03:24.141: E/AndroidRuntime(25074): FATAL EXCEPTION: GLThread 5187 01-22 13:03:24.141: E/AndroidRuntime(25074): Process: com.barsoft.drag, PID: 25074 01

How can I use JAXB from an unsigned applet (without signing it)?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 05:42:27
问题 I would like to marshall Java objects into XML and vice-versa from within an Unsigned Applet and I can't change any of the security permission/policy files, or sign the application. I seem to get a Security exception, because JAXB is attempting to access fields or constructors that it can't in the applet sandbox. The browser is running JRE 1.6.0_17 I'm also open to solutions based on some other XML (or JSON) library but have tried the following and pretty much run into a similar problem; -

com.thoughtworks.xstream.converters.ConversionException

点点圈 提交于 2019-12-02 05:40:37
[EDITED] The project i'm working on is a 3 folder project in Java J2EE with servlets and Hibernate for the persistance. The structure is as follow: - Admin -> the main program with the beans and HTML/CSS - Jar -> with the jars, Hibernate tools and classes - War -> with the Servlets Between them, I use Xstream to share the classes and important info. I'm using Eclipse and Tomcat 7. Hope that with this all of you get the global idea. This what the Xstream debugger said: Caused by: com.thoughtworks.xstream.converters.ConversionException: satdata.musicoterapia.hibernate.Terapeuta0 : satdata

Single element array bug in XStream

China☆狼群 提交于 2019-12-02 05:06:46
问题 If you have a function like this: List<User> getUsers() {} If getUsers returns a List with just one element the resulting JSON is just a JSON Object rather than a JSON array. Is there a workaround to make XStream return JSON array regardless if the function returns single array List? 回答1: The solution is to downgrade to Jettison 1.2 <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet.ext.xstream</artifactId> <version>${version.restlet}</version> <exclusions> <exclusion>

How can I use JAXB from an unsigned applet (without signing it)?

十年热恋 提交于 2019-12-02 02:52:55
I would like to marshall Java objects into XML and vice-versa from within an Unsigned Applet and I can't change any of the security permission/policy files, or sign the application. I seem to get a Security exception, because JAXB is attempting to access fields or constructors that it can't in the applet sandbox. The browser is running JRE 1.6.0_17 I'm also open to solutions based on some other XML (or JSON) library but have tried the following and pretty much run into a similar problem; - XStream - Gson Given (something like) the following object: @XmlType @XmlRootElement public class

Libgdx, Transitive dependencies Android,Java library project, Jar

老子叫甜甜 提交于 2019-12-02 01:53:12
I have just created template Libgdx project (Core,Android,Windows). Core is regular Java project library. There is a dependency in Core to XStream.jar library. Core contains file input-output via Xml. Android project has dependency to java core project. Now XStraem is working for Windows but not for Android. For Android i got this: 01-22 13:03:24.141: E/AndroidRuntime(25074): FATAL EXCEPTION: GLThread 5187 01-22 13:03:24.141: E/AndroidRuntime(25074): Process: com.barsoft.drag, PID: 25074 01-22 13:03:24.141: E/AndroidRuntime(25074): java.lang.NoClassDefFoundError: com.thoughtworks.xstream