simple-framework

How to serialize a Map<String, String> using Simple XML?

旧时模样 提交于 2019-12-01 18:31:59
问题 How would you go about serialising a Map using simple XML so that it looks something like: <elem foo="value">key</elem> Instead of the normal <elem foo="key">value</elem> (The map is one to many, and since this will be edited by humans, I wanted it to be clearer.) [EDIT]: Doesn't Fix. 回答1: Have you tried something like: @ElementMap(entry="property", value="value", attribute=true, inline=true) private Map<String, String> map; or some combination, i.e. to use the other attributes of the

SimpleXml framework - embedded collections

泪湿孤枕 提交于 2019-12-01 15:14:07
问题 I try to serialize embedded collection using simple. For example : Map<String, List<MyClass>> I already added necessary annotations in MyClass, i tried with @ElementMap but it doesn't work: Exception in thread "main" org.simpleframework.xml.transform.TransformException: Transform of class java.util.ArrayList not supported If its just @ElementMap Map<String, MyClass> it works fine. I don't know ho to deal with embedded collection. I know about @ElementList annotation but don't know how to use

Simple Xml - Element Declared Twice Error

拈花ヽ惹草 提交于 2019-12-01 04:53:21
I have been trying to wrap a set of classes based on Simple XML (Java Serializer) around a RSS Feed. The sample feed is <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>Coding Horror</title> <link>http://www.codinghorror.com/blog/</link> <description>programming and human factors - Jeff Atwood</description> <language>en-us</language> <lastBuildDate>Wed, 04 May 2011 20:34:18 -0700</lastBuildDate> <pubDate>Wed, 04 May 2011 20:34:18 -0700</pubDate> <generator>http://www.typepad.com/<

Android, org.simpleframework.xml Persistence Exception, Element 'foo' is already used

落花浮王杯 提交于 2019-12-01 03:17:52
I am using the org.simpleframework.xml to handle some xml tasks for an android application and am running into the following error which I cannot figure out. org.simpleframework.xml.core.PersistenceException: Element 'album' is already used with @org.simpleframework.xml.ElementList(inline=false, name=album, entry=, data=false, empty=true, required=true, type=void) on field 'albums' private java.util.List us.blah.sonar.xsd.simple.AlbumList.albums at line 5 at org.simpleframework.xml.core.Variable$Adapter.read(Variable.java:484) at org.simpleframework.xml.core.Composite.readVariable(Composite

Simple Xml - Element Declared Twice Error

无人久伴 提交于 2019-12-01 02:44:15
问题 I have been trying to wrap a set of classes based on Simple XML (Java Serializer) around a RSS Feed. The sample feed is <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>Coding Horror</title> <link>http://www.codinghorror.com/blog/</link> <description>programming and human factors - Jeff Atwood</description> <language>en-us</language> <lastBuildDate>Wed, 04 May 2011 20:34:18 -0700<

Android, org.simpleframework.xml Persistence Exception, Element 'foo' is already used

两盒软妹~` 提交于 2019-11-30 23:32:30
问题 I am using the org.simpleframework.xml to handle some xml tasks for an android application and am running into the following error which I cannot figure out. org.simpleframework.xml.core.PersistenceException: Element 'album' is already used with @org.simpleframework.xml.ElementList(inline=false, name=album, entry=, data=false, empty=true, required=true, type=void) on field 'albums' private java.util.List us.blah.sonar.xsd.simple.AlbumList.albums at line 5 at org.simpleframework.xml.core

How to ignore unused XML elements while deserializing a document?

大兔子大兔子 提交于 2019-11-30 10:46:13
I'm using SimpleXml to (de)serialize POJOs. Now, I have a big XML which has some elements which are not needed. For instance, with this XML: <Root> <Element>Used</Element> <Another>Not used</Another> <Root> I want to create a POJO which looks like: @Root class Root{ @Element private String element; } Problem is that I'm getting this Exception: simpleframework.xml.core.ElementException: Element 'Another' does not have a match in class blah.blah.Blah at line 1 So... how should I configure the POJO so that I can parse the XML correctly? Set strict to false within the Root annotation to ignore any

How to solve the XML parsing performance issue on Android

≯℡__Kan透↙ 提交于 2019-11-30 00:26:04
I have to read a XML file with about ~4000 lines on Android. First I tried the SimpleXML library because it's the easiest and it took about 2 minutes on my HTC Desire. So I thought maybe SimpleXML is so slow because of reflection and all the other magic that this library uses. I rewrote my parser and used the built-in DOM parsing method with some special attention for performance. That helped a bit but it still took about 60 seconds which is still totally unacceptable. After a bit of research I found this article on developer.com . There are some graphs that show that the other two available

Android, simple-xml, how to declare a list of elements?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 17:34:59
问题 I have this data structure: <estates version="0.1"> <provider name="Foo"> <estate id="12345678"> <description>aaa</description> <size>300</size> </estate> <estate id="12345679"> <description>bbb</description> <size>450</size> </estate> </provider> <provider name="Bar"> <estate id="987654321"> <description>yyy</description> <size>100</size> </estate> <estate id="987654320"> <description>zzz</description> <size>240</size> </estate> </provider> </estates> which I get from a web service of mine.

Is it possible to apply a single annotation to multiple use-site targets in Kotlin?

依然范特西╮ 提交于 2019-11-29 13:58:55
According to the documentation: https://kotlinlang.org/docs/reference/annotations.html You can apply multiple annotations to a single site-use target, but is there a way to apply the same annotation to multiple site-use targets? My use-case is decorating classes with annotations for SimpleXML. To use an immutable data class , you have to annotate both the field and the constructor parameter: data class Data( @field:Element(name = "ID") @param:Element(name = "ID") val id: Int, @param:Element(name = "TEXT") @field:Element(name = "TEXT") val text: String) For data classes with many fields, you