Re: [Simple-support] Support for almost-primitive types, Converters in attributes and Arrays in att
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-05-20 08:55:24
|
Hi, These capabilities are all ready there, take a look at the Matcher/Transform for transforming custom types and attributes. Also, @Elementon an array produces a comma separated list, all read and written via the Transform objects resolve to the types. Niall --- On Thu, 19/5/11, Raphael Jolivet <rap...@gm...> wrote: From: Raphael Jolivet <rap...@gm...> Subject: [Simple-support] Support for almost-primitive types, Converters in attributes and Arrays in attributes To: sim...@li... Received: Thursday, 19 May, 2011, 6:10 AM Hello there, I am using the Simple XML framework extensively for all my XML parsing / generating tasks and I am very happy with it.However, I would like to propose some enhancements that would enable me to serialize / deserialize almost all my classes without the need of further work, except for some annotations. = Almost-primitive types First, I would like to ask for the support of "almost-primitive" types. In the Jersey REST Servlet (based on JAX-RS API), there is a convention that states : Any class providing a "public Constructor(String)" or a static method "static public fromString(String)" can be considered as a native type and is parsed, serialized without having to write a custom Converter / Mapper. The toString() method is using for serialization. This is very handy, as writing a single static method for a class is less work than writing a Converter and having to register it, or to annotate every occurrence of attributes of its type. = Only primitive types supported for attributes ? Also, I have experienced that custom converters (either registered in a strategy, or specified as annotations with the AnnotationStrategy) are not supported for attributes. It seems that attributes explicitly require the use of Java primitive types. Therefore, I had to write custom getters / setters with Strings to overcome this limitation. = Unique annotation to parse Lists and Arrays, and new annotation to parse arrays of attributes (with a separator) I think that the distinction between ElementArray and ElementList is not necessary, as it is semantically the same structure of objects ( a sequence of objects) : The framework should handle transparently Arrays and List without having to specify it in the annotation. let's have a unique "ElementSequence" annotation. Also, this is a very common situation to have several values wrapped into a unique attributes, as comma separated values.<task times="2 s, 3 h, 4m" > I would like to be able to write something like AttributeSequence(name="times", separator=",")Duration[] durations; Duration being a class that provides a static "fromString(String)" method, to parse Strings. With that, the framework should be able to serialize / parse this code without the need of any other information / code. What do you think about those requests ?Some of them may be already supported : Please tell me if I missed something. Thanks again for your great work,Best regards, Raphael JOLIVET -----Inline Attachment Follows----- ------------------------------------------------------------------------------ What Every C/C++ and Fortran developer Should Know! Read this article and learn how Intel has extended the reach of its next-generation tools to help Windows* and Linux* C/C++ and Fortran developers boost performance applications - including clusters. http://p.sf.net/sfu/intel-dev2devmay -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |