Search Results

Search found 44 results on 2 pages for 'xstream'.

Page 1/2 | 1 2  | Next Page >

  • NoSuchMethodError in Java using XStream

    - by Brad Germain
    I'm trying to save a database into a file using XStream and then open it again later using XStream and deserialize it back into the objects it was in previously. The database consists of an arraylist of tables, which consists of an arraylist of a data class where the data class contains an arraylist of objects. I'm basically trying to create an sql compiler. I'm currently getting a java.lang.NoSuchMethodError because of the last line in the load method. Here's what I have: Save Method public void save(Database DB){ File file = new File(DB.getName().toUpperCase() + ".xml"); //Test sample DB.createTable("TBL1(character(a));"); DB.tables.getTable("TBL1").rows.add(new DataList()); DB.tables.getTable("TBL1").rows.getRow(0).add(10); XStream xstream = new XStream(); //Database xstream.alias("Database", Database.class); //Tables xstream.alias("Table", Table.class); //Rows xstream.alias("Row", DataList.class); //Data //xstream.alias("Data", Object.class); //String xml = xstream.toXML(DB); Writer writer = null; try { writer = new FileWriter(file); writer.write(xstream.toXML(DB)); writer.close(); } catch (IOException e) { e.printStackTrace(); } } Load Method public void Load(String dbName){ XStream xstream = new XStream(); BufferedReader br; StringBuffer buff = null; try { br = new BufferedReader(new FileReader(dbName + ".xml")); buff = new StringBuffer(); String line; while((line = br.readLine()) != null){ buff.append(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } database = (Database)xstream.fromXML(buff.toString()); }

    Read the article

  • Basic XStream Annotations

    - by jmcmahon
    Hello, I just started using XStream Annotations, and I am trying to figure out how to associate the annotations with the XStream object. From the documentation, it seems like this is the accepted method: XStream xstream = new XStream(new DomDriver()); xstream.processAnnotations(AnnotatedClass.class); My problem with this is that Eclipse isn't recognizing this as a valid method. Everything seems to be configured correctly in Eclipse because it shows me the rest of the methods that are in the XStream object. It's almost like Eclipse thinks it's an older version of xstream. I've tried running a Project Clean inside of Eclipse but that didn't fix anything. I've also tried downloading the XStream jar again which didn't help either. Versions: XStream 1.3.1, Eclipse 3.4, Java 6 Has anybody seen this strange behavior before, or have any ideas on how to fix it?

    Read the article

  • XStream noclassdeffound error

    - by Jimmy
    I am attempting to run Xstream in a netbeans proof of concept project. I have the following code. XStream xstream = new XStream(); FileOutputStream fis = new FileOutputStream("Test.xml"); xstream.toXML(company, fis); The program is crashing on the first line of code with the following error. Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException at com.thoughtworks.xstream.XStream.<init>(XStream.java:336) at Parser.XParser.Parse(XParser.java:24) at rejaxbtest.REJAXBTest.main(REJAXBTest.java:39) Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 3 more Java Result: 1 I have seen one other thread with this problem, but the answer that was given was put the jar in the project lib directory, but netbeans has already correctly finished that task. Any other possible thing that would cause java not to recognize the Xstream class at runtime even though it is fine at compile time? Thanks Jimmy

    Read the article

  • Array Conversion in Xstream Parser

    - by Avidev9
    Hi am trying to convert the following xml into object using Xstream parser. I tried using the below code to convert the xml but am getting Duplicate field ERRORS ---- Debugging information ---- field : ERRORS class : com.avidev9.Fees.GCSFeesResponse$DebitsWSDS required-type : com.avidev9.Fees.GCSFeesResponse$DebitsWSDS converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter path : /DebitsWSDS/ERRORS[2] line number : 1 version : null The Code I used xstream.alias("DebitsWSDS", GCSFeesResponse.DebitsWSDS.class); xstream.alias("ERRORS", GCSFeesResponse.ERRORS.class); xstream.alias("ERROR_ID", String.class); xstream.alias("TABLE_NAME", String.class); xstream.alias("TABLE_ID", String.class); xstream.alias("ROW_ID", String.class); xstream.alias("ERROR_TEXT", String.class); xstream.alias("ERROR_CODE", String.class); xstream.alias("COLUMN_ID", String.class); xstream.alias("ERROR_TYPE", String.class); GCSFeesResponse.DebitsWSDS gcsFeesResponse =(GCSFeesResponse.DebitsWSDS)xstream.fromXML(result.get_any()[0].getAsString()); XML <DebitsWSDS xmlns=""> <DEBITS> <DEBIT_ID>-1</DEBIT_ID> <ACCOUNT_ID>12321312313</ACCOUNT_ID> <EFFECTIVE_DATE>2012-12-12T00:00:00-06:00</EFFECTIVE_DATE> <DAY_OF_MONTH>12</DAY_OF_MONTH> <DEBIT_TYPE>S</DEBIT_TYPE> <OCCURS_NUM>1</OCCURS_NUM> <DEBIT_AMOUNT>750</DEBIT_AMOUNT> <MEMO>S</MEMO> <ACTIVE_FLAG>Y</ACTIVE_FLAG> <MODIFIED_BY/> <DEBIT_AUTHORIZED/> <DEBIT_AUTHORIZED_BY/> <REMAINING_OCCURRENCES>0</REMAINING_OCCURRENCES> </DEBITS> <ERRORS> <ERROR_ID>1</ERROR_ID> <TABLE_NAME>Debits</TABLE_NAME> <TABLE_ID>-1</TABLE_ID> <ROW_ID>0</ROW_ID> <COLUMN_ID>EXCEPTION</COLUMN_ID> <ERROR_TYPE>E</ERROR_TYPE> <ERROR_CODE>4</ERROR_CODE> <ERROR_TEXT>This debit type is not allowed for this company and policy group</ERROR_TEXT> </ERRORS> <ERRORS> <ERROR_ID>2</ERROR_ID> <TABLE_NAME>Clients</TABLE_NAME> <TABLE_ID/> <ROW_ID>0</ROW_ID> <COLUMN_ID>CLOSE_SCHED_DATE</COLUMN_ID> <ERROR_TYPE>E</ERROR_TYPE> <ERROR_CODE>4</ERROR_CODE> <ERROR_TEXT>Client has been closed. Cannot Authorize Draft.</ERROR_TEXT> </ERRORS> <ERRORS> <ERROR_ID>3</ERROR_ID> <TABLE_NAME>Debits</TABLE_NAME> <TABLE_ID>-1</TABLE_ID> <ROW_ID>0</ROW_ID> <COLUMN_ID>EXCEPTION</COLUMN_ID> <ERROR_TYPE>E</ERROR_TYPE> <ERROR_CODE>4</ERROR_CODE> <ERROR_TEXT>Cannot Schedule a Debit or Draft. Client has been closed.</ERROR_TEXT> </ERRORS> <ERRORS> <ERROR_ID>1</ERROR_ID> <TABLE_NAME>Debits</TABLE_NAME> <TABLE_ID>-1</TABLE_ID> <ROW_ID>0</ROW_ID> <COLUMN_ID>ACTIVE_FLAG</COLUMN_ID> <ERROR_TYPE>W</ERROR_TYPE> <ERROR_CODE>4</ERROR_CODE> <ERROR_TEXT>Creating debit on inactive Client account.</ERROR_TEXT> </ERRORS> </DebitsWSDS> My class structure. package com.avidev9.Fees; import java.util.List; public class GCSFeesResponse { public DebitsWSDS DebitsWSDS; public class DebitsWSDS { public List<ERRORS> ERRORS; public String xmlns; public DEBITS DEBITS; } public class ERRORS { public String TABLE_NAME; public Integer TABLE_ID; public Integer ERROR_ID; public Integer ROW_ID; public String ERROR_TEXT; public Integer ERROR_CODE; public String COLUMN_ID; public String ERROR_TYPE; } public class DEBITS { public String EFFECTIVE_DATE; public String ACTIVE_FLAG; public Long ACCOUNT_ID; public String DEBIT_AUTHORIZED_BY; public Integer DAY_OF_MONTH; public Integer DEBIT_ID; public String MEMO; public Integer REMAINING_OCCURRENCES; public String DEBIT_TYPE; public Integer OCCURS_NUM; public Integer DEBIT_AMOUNT; public String DEBIT_AUTHORIZED; public String MODIFIED_BY; } }

    Read the article

  • Base64 en/decoding between xstream and iPhone SDK

    - by Matt McMinn
    I am passing a byte array from a java server to an iPad client in XML. The server is using xstream to convert the byte array to XML with the EncodedByteArrayConverter, which should convert the array to Base 64. Using xstream, I can decode the xml back to the proper byte array in a java client, but in the iPad client, I'm getting an invalid length error. To do my decoding, I'm using the code at the bottom of this page. The length of the string is indeed not a multiple of 4, so there must be something strange with my string - although since xstream can decode it just fine, I'm guessing there's just something I need to to on the iPad side to get it to decode. I've tried cutting off padding at the end of the string to get it down to the right size, and that does allow the decoder to work, but I end up with JPG's that have invalid headers, and are not displayable. On the server side, I'm using the following code: Object rtrn = getByteArray(); XStream xstream = new XStream(); String xml = xstream.toXML(rtrn); On the client side, I'm calling the above decoder from the XML parsing callback like this: -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { NSLog(@"Converting data; string length: %d", [string length]); //NSLog(@"%@", string); NSData *data = [Base64 decode:string]; NSLog(@"converted data length: %d", [data length]); } Any ideas what could be going wrong?

    Read the article

  • Problem with XStream Marshalling to return xml and json

    - by MiKu
    When i use new XStream().toXml(someObject); it returns following xml... <response> <status>SUCCESS</status> <isOwnershipVerified class="boolean">false</isOwnershipVerified> </response> and, when i use new XStream(new JsonHierarchicalStreamDriver()).toXml(someObject); it returns following json... {"response": { "status": "SUCCESS", "isOwnershipVerified": { "@class": "boolean""false"} }} Now, since i want to get rid of class attribute altogether (read it not to alias it with anything else, but to remove it) i use following code. XStream xStream = new XStream(); StringWriter writer = new StringWriter(); xStream.marshal(this, new PrettyPrintWriter(writer) { @Override public void addAttribute(final String key, final String value) { if (!key.equals("class")) { super.addAttribute(key, value); } } }); return writer.toString(); which gives follwing xml... <response> <status>SUCCESS</status> <isOwnershipVerified>false</isOwnershipVerified> </response> but, when i pass new JsonHierarchicalStreamDriver() while xStream object creation above, it does NOT return json. it returns the same xml shown above. What is wrong going on here? Thanks in advance...

    Read the article

  • xstream and ibm j9 sdk incompatibilities on linux

    - by Yoni
    I encountered an incompatibility with xstream and IBM J9 jdk (the 32bits version). Everything worked fine when I used sun jdk but fails on IBM jdk (on linux only. on windows it's ok with both jdks). When debugging, the error appears to be that xstream uses a java.util.TreeSet internally but the set's iterator returns elements in the wrong order (I know this sounds very strange, but this is the behavior that I saw). Googling for related bugs didn't give any meaningful results I tried upgrading pretty much any component possible but no luck. I tried the following configurations: ibm jdk 1.6 SR 7 (bundled with WebSphere 7.0.0.9), xstream 1.2.2 ibm jdk 1.6 SR 8, xstream 1.2.2 ibm jdk 1.6 SR 8, xstream 1.3.1 (I tried those both with tomcat and with WebSphere server, so actually there are 6 configurations using IBM jdk). The code in question is in class com.thoughtworks.xstream.core.DefaultConverterLookup, around line 44. It uses an iterator from class com.thoughtworks.xstream.core.util.PrioritizedList, which uses a custom comparator, but all the comparator does is compare integers (the priorities). Has anyone seen this before? Any idea what can I do or change?

    Read the article

  • Make XStream ignore one specific private variable

    - by Tigraine
    Hi guys, I have a little problem with a class I am currently writing a save function for. I'm using XStream (com.thoughtworks.xstream) to serialize a class to XML using the DOMDriver. The class looks like this: public class World { private Configuration config; public World(Configuration config) { this.config = config; } } So, the issue here is that I do not want to serialize Configuration when serializing world, rather I'd like to give XStream a preconstructed Configuration instance when calling fromXml(). Problem here is mainly class design, Configuration holds a private reference to the GUI classes and therefore serializing Configuration means serializing the whole application completely with GUI etc.. And that's kind of bad. Is there a way to instruct XStream to not serialize the private field config, and upon load supply XStream with a configuration instance to use? greetings Daniel

    Read the article

  • Intercepting Xstream conversion while parsing XML

    - by Shane Bell
    Suppose I have a simple Java class like this: public class User { String firstName; String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } Now, suppose I want to parse the following XML: <user> <firstName>Homer</firstName> <lastName>Simpson</lastName> </user> I can do this with no problems in XStream like so: User homer = (User) xstream.fromXML(xml); Ok, all good so far, but here's my problem. Suppose I have the following XML that I want to parse: <user> <fullName>Homer Simpson</fullName> </user> How can I convert this XML into the same User object using XStream? I'd like a way to implement some kind of callback so that when XStream parses the fullName field, I can split the string in two and manually set the first name and last name fields on the user object. Is this possible? Note that I'm not asking how to split the string in two (that's the easy part), I want to know how to intercept the XML parsing so XStream doesn't try to reflectively set the fullName field on the User object (which obviously doesn't exist). I looked at the converters that XStream provides but couldn't figure out how to use it for this purpose. Any help would be appreciated.

    Read the article

  • XStream JavaBeanConverter not serializing properties

    - by Steve Foster
    Hello All, Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng something simple, or not understanding XStream's converter handling well enough. @XStreamAlias("test") public class TestObject { private String foo; public String getFoo() { return foo; } public void setFoo(String foo) { this.foo = foo; } } public void test() throws Exception { XStream x = new XStream(new XppDriver()); x.autodetectAnnotations(true); x.processAnnotations(TestObject.class); x.registerConverter(new JavaBeanConverter(x.getMapper())); TestObject o = new TestObject(); o.setFoo("bar"); String xml = x.toXML(o); System.out.println(xml); /* Expecting... <test> <foo>bar</foo> </test> But instead getting... <test> <foo/> </test> */ } I tried adding a trace on the TestObject.getFoo() method and it appears it is being called by XStream, but the data isn't being written to the output stream. After looking at the source for JavaBeanConverter, it looks like my implementation should work, which leads me to believe I haven't configured something correctly during the XStream setup. Am I just missing something simple? Thanks! Edit Also, if it helps, I'm using the following Maven deps for this... <dependency> <groupId>org.apache.servicemix.bundles</groupId> <artifactId>org.apache.servicemix.bundles.xstream</artifactId> <version>1.3_3</version> </dependency> <dependency> <groupId>org.apache.servicemix.bundles</groupId> <artifactId>org.apache.servicemix.bundles.xpp3</artifactId> <version>1.1.4c_3</version> </dependency>

    Read the article

  • XStream <-> Alternative binary formats (e.g. protocol buffers)

    - by sehugg
    We currently use XStream for encoding our web service inputs/outputs in XML. However we are considering switching to a binary format with code generator for multiple languages (protobuf, Thrift, Hessian, etc) to make supporting new clients easier and less reliant on hand-coding (also to better support our message formats which include binary data). However most of our objects on the server are POJOs with XStream handling the serialization via reflection and annotations, and most of these libraries assume they will be generating the POJOs themselves. I can think of a few ways to interface an alternative library: Write an XStream marshaler for the target format. Write custom code to marshal the POJOs to/from the classes generated by the alternative library. Subclass the generated classes to implement the POJO logic. May require some rewriting. (Also did I mention we want to use Terracotta?) Use another library that supports both reflection (like XStream) and code generation. However I'm not sure which serialization library would be best suited to the above techniques.

    Read the article

  • csutom converter in XStream

    - by Raja Chandra Rangineni
    Hi All, I am using XStream to serialize my Objects to XML format. The formatted xml that I get is as below: node1, node2, node 3 are attributes of pojo,DetailDollars 100 25 10 I have requirement where in I have to calucluate a percentage, for example 100/ 25 and add the new node to the existing ones. So, the final output should be : 100 25 10 4 I wrote a custom converter and registered to my xstream object. public void marshal(..){ writer.startNode("node4"); writer.setValue(getNode1()/ getnode2() ); writer.endNode(); } But, the xml stream I get has only the new node: 4 I am not sure which xstream api would get me the desired format. could you please help me with this . Thanks, Raja chandra Rangineni.

    Read the article

  • custom converter in XStream

    - by Raja Chandra Rangineni
    Hi All, I am using XStream to serialize my Objects to XML format. The formatted xml that I get is as below: node1, node2, node 3 are attributes of pojo,DetailDollars DetailDollars node1 100 /node1 node2 25 /node2 node3 10 /node3 /DetailDollars I have requirement where in I have to calucluate a percentage, for example 100/ 25 and add the new node to the existing ones. So, the final output should be : DetailDollars node1 100 /node1 node2 25 /node2 node3 10 /node3 node4 4 /node4 DetailDollars I wrote a custom converter and registered to my xstream object. public void marshal(..){ writer.startNode("node4"); writer.setValue(getNode1()/ getnode2() ); writer.endNode(); } But, the xml stream I get has only the new node: DetailDollars node4 4 /node4 /DetailDollars I am not sure which xstream api would get me the desired format. could you please help me with this . Thanks, Raja chandra Rangineni.

    Read the article

  • XStream or Simple

    - by Adeel Ansari
    I need to decide on which one to use. My case is pretty simple. I need to convert a simple POJO/Bean to XML, and then back. Nothing special. One thing I am looking for is it should include the parent properties as well. Best would be if it can work on super type, which can be just a marker interface. If anyone can compare these two with cons and pros, and which thing is missing in which one. I know that XStream supports JSON too, thats a plus. But Simple looked simpler in a glance, if we set JSON aside. Whats the future of Simple in terms of development and community? XStream is quite popular I believe, even the word, "XStream", hit many threads on SO. Thanks.

    Read the article

  • XStream parse attributes and values at the same time

    - by gurbieta
    Hi, I have the following XML <search ver="3.0"> <loc id="ARBA0009" type="1">Buenos Aires, Argentina</loc> <loc id="BRXX1283" type="1">Buenos Aires, Brazil</loc> <loc id="ARDF0127" type="1">Aeroparque Buenos Aires, Argentina</loc> <loc id="MXJO0669" type="1">Concepcion De Buenos Aires, Mexico</loc> <loc id="MXPA1785" type="1">San Nicolas De Buenos Aires, Mexico</loc> <loc id="ARBA0005" type="1">Balcarce, Argentina</loc> <loc id="ARBA0008" type="1">Bragado, Argentina</loc> <loc id="ARBA0010" type="1">Campana, Argentina</loc> <loc id="ARBA0016" type="1">Chascomus, Argentina</loc> <loc id="ARBA0019" type="1">Chivilcoy, Argentina</loc> </search> And a City class public class City { private String id; private Integer type; private String name; // getters & setters... } I tried the following aliases to parse the XML xStream.alias("search", List.class); xStream.alias("loc", City.class); xStream.useAttributeFor("id", String.class); xStream.useAttributeFor("type", Integer.class); But I can't figure out how to set the value of the "loc" tag, if I try to transform the City object in XML I get <search> <loc id="ARBA0001" type="1"> <name>Buenos Aires</name> </loc> </search> When I really need to get this <search> <loc id="ARBA0001" type="1">Buenos Aires</loc> </search> Then, if I try to parse the XML to a City object I get the field "name" with a null value. Anybody knows how to set te correct aliases to do this? Thanks in advance.

    Read the article

  • XStream serializable objects

    - by Jeff Storey
    I am currently using XStream to serialize some of my objects that don't implement Serializable. Is there a way to tell XStream to use Java's default serialization if the object does implement Serializable and to fall back on XML serialization if it does not? Or would I need to implement a simple layer on top of it to check? thanks, Jeff

    Read the article

  • customising serialisation of java collections using xstream

    - by Will Goring
    I have an object that needs to be serialised as XML, which contains the following field: List<String> tags = new List<String>(); XStream serialises it just fine (after some aliases) like this: <tags> <string>tagOne</string> <string>tagTwo</string> <string>tagThree</string> <string>tagFour</string> </tags> That's OK as far as it goes, but I'd like to be able to rename the <string> elements to, say, <tag>. I can't see an obvious way to do that from the alias documentation on the XStream site. Am I missing something obvious?

    Read the article

  • xstream handles non-english character

    - by Yan Cheng CHEOK
    I have the following code : /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package helloworld; import com.thoughtworks.xstream.XStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import javax.swing.JOptionPane; /** * * @author yccheok */ public class Test { @SuppressWarnings("unchecked") public static <A> A fromXML(Class c, File file) { XStream xStream = new XStream(); InputStream inputStream = null; try { inputStream = new java.io.FileInputStream(file); Object object = xStream.fromXML(inputStream); if (c.isInstance(object)) { return (A)object; } } catch (Exception exp) { exp.printStackTrace(); } finally { if (inputStream != null) { try { inputStream.close(); inputStream = null; } catch (java.io.IOException exp) { exp.printStackTrace(); return null; } } } return null; } @SuppressWarnings("unchecked") public static <A> A fromXML(Class c, String filePath) { return (A)fromXML(c, new File(filePath)); } public static boolean toXML(Object object, File file) { XStream xStream = new XStream(); OutputStream outputStream = null; try { outputStream = new FileOutputStream(file); xStream.toXML(object, outputStream); } catch (Exception exp) { exp.printStackTrace(); return false; } finally { if (outputStream != null) { try { outputStream.close(); outputStream = null; } catch (java.io.IOException exp) { exp.printStackTrace(); return false; } } } return true; } public static boolean toXML(Object object, String filePath) { return toXML(object, new File(filePath)); } public static void main(String args[]) { String s = "\u6210\u4EA4\u91CF"; // print ??? System.out.println(s); // fine! show ??? JOptionPane.showMessageDialog(null, s); toXML(s, "C:\\A.XML"); String o = fromXML(String.class, "C:\\A.XML"); // show ??? JOptionPane.showMessageDialog(null, o); } } I run the following code through command prompt in Windows Vista. 1) May I know why System.out.println unable to print out Chinese Character in console? 2) I open up the xstream file. The saved value is <string>???</string> How can I make xstream save Chinese Character correctly? Thanks.

    Read the article

  • C++ Serialization Clean XML Similar to XSTREAM

    - by disown
    I need to write a linux c++ app which saves it settings in XML format (for easy hand editing) and also communicates with existing apps through XML messages over sockets and HTTP. Problem is that I haven't been able to find any intelligent libs to help me, I don't particular feel like writing DOM or SAX code just to write and read some very simple messages. Boost Serialization was almost a match, but it adds a lot of boost-specific data to the xml it generates. This obviously doesn't work well for interchange formats. I'm wondering if it is possible to make Boost Serialization or some other c++ serialization library generate clean xml. I don't mind if there are some required extra attributes - like a version attribute, but I'd really like to be able to control their naming and also get rid of 'features' that I don't use - tracking_level and class_id for instance. Ideally I would just like to have something similar to xstream in Java. I am aware of the fact that c++ lacks introspection and that it is therefore necessary to do some manual coding - but it would be nice if there was a clean solution to just read and write simple XML without kludges! If this cannot be done I am also interested in tools where the XML schema is the canonical resource (contract first) - a good JAXB alternative to C++. So far I have only found commercial solutions like CodeSynthesis XSD. I would prefer open source solutions. I have tried gSoap - but it generates really ugly code and it is also SOAP-specific. In desperation I also started looking at alternative serialization formats for protobuffers. This exists - but only for Java! It really surprises me that protocol buffers seems to be a better supported data interchange format than XML. I'm going mad just finding libs for this app and I really need some new ideas. Anyone?

    Read the article

  • Is it possible to use XStream with an abstract node?

    - by Dan Watling
    My client application is making calls to a service that returns a common "root" XML, but a different result node. The "root" XML contains possible error codes. Is it possible to use XStream in this scenario? Example: public class RootNode { ErrorInfo errorInfo; BaseResult result; ... } public class ErrorInfo { String message; ... } public abstract BaseResult { } public class SearchResult extends BaseResult { List<Object> searchResults; ... } public class AccountResult extends BaseResult { String name; ... } The XML coming back could be one of two formats: <root> <errorInfo><message>...</message></errorInfo> <result> <searchResults>...</searchResults> </result> </root> OR <root> <errorInfo><message>...</message></errorInfo> <result> <name>...</name> </result> </root> I have set up my XStream object as follows: XStream x = new XStream(); x.alias("root", Root.class); x.alias("errorInfo", ErrorInfo.class); x.alias("result", <SearchResult.class OR AccountResult.class depending on what I am expecting back>); Of course, when I run this I receive an error telling me XStream cannot instantiate the base class (BaseResult). For fun, I also converted the BaseResult into an interface but received a similar error. I've looked through XStream's documentation and it isn't clear to me how to handle a situation like the one I just described. Is it even possible to do using XStream? Thanks, -Dan

    Read the article

  • Using XStream to deserialize an XML response with separate "success" and "failure" forms?

    - by Chris Markle
    I am planning on using XStream with Java to convert between objects and XML requests and XML responses and objects, where the XML is flowing over HTTP/HTTPS. On the response side, I can get a "successful" response, which seems like it would map to one Java class, or a "failure" response, which seems like it would map to another Java class. For example, for a "file list" request, I could get an affirmative response e.g., <?xml version="1.0" encoding="UTF-8"?> <response> <success>true</success> <files> <file>[...]</file> <file>[...]</file> <file>[...]</file> </files> </response> or I could get a negative response e.g., <?xml version="1.0" encoding="UTF-8"?> <response> <success>false</success> <error> <errorCode>-502</errorCode> <systemMessage>[...]AuthenticationException</systemMessage> <userMessage>Not authenticated</userMessage> </error> </response> To handle this, should I include fields in one class for both cases or should I somehow use XStream to "conditionally" create one of the two potential classes? The case with fields from both response cases in the same object would look something like this: Class Response { boolean success; ArrayList<File> files; ResponseError error; [...] } Class File { String name; long size; [...] } Class ResponseError { int errorCode; String systemMessage; String userMessage; [...] } I don't know what the "use XStream and create different objects in case of success or error" looks like. Is it possible to do that somehow? Is it better or worse way to go? Anyway, any advice on how to handle using XStream to deal with this success vs. failure response case would be appreciated. Thanks in advance!

    Read the article

  • How do I use xStream to output Java Objects with List properties?

    - by Zachary Spencer
    Hello, I am trying to output some Java objects as JSON, they have List properties which I want to be formatted as { "People" : [ { "Name" : "Bob" } , { "Name" : "Jim" } ] } However, I cannot figure out how to do this with XStream. It always outputs as { "Person" : { "Name" : "Bob" }, "Person" : { "Name" : "Bob" } Is there a way to fix this? I've put together some sample code with a unit test in github if you need something more concrete to play with: http://gist.github.com/371358 Thanks!

    Read the article

  • How to get and set dynamic or runtime input in XStream

    - by RSR
    i am getting xml tags as input in java web services. i need that to parsed to java objects i had tried everything like XStream,XMLEncoder, JaxB Concepts also. But I don't know what is the problem. i am having pojo class for that input but it is not working. example for xml tags : 1034|Chromepet|Chennai|117.97.24.32 first to extract data : i need only data from .... and then Using Xstream or XmlEncoder i have to parse it like i want only devsrlno:101 signalstrength : 30 devicedatetime:01/24/2010 10:10:23 AM gprsdatetime:01/24/2010 10:10:23 AM debug:yes autoip :1034|Chromepet|Chennai|117.97.24.32. please tell me how to do it

    Read the article

  • how to create a JSON object in action class of JAVA

    - by Jugal
    I want to create a JSON object. I have tried the following myString=new JSONObject().put("JSON", sampleClass).toString(); but mystring gives me {"SampleClass@170f98"}. I also tried the following XStream xsStream=new XStream(new JsonHierarchicalStreamDriver()); SampleClass sampleClass=new SampleClass(userset.getId(),userset.getUsername()); myString=xsStream.toXML(sampleClass); It works but when i use getJSON in javascript to get myString it does not work.

    Read the article

1 2  | Next Page >