Re: [Simple-support] Possible enhancements
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2007-05-01 17:22:44
|
Hi Mike,
Thanks for the feedback regarding your mails on the tutorial. With regards to the improvements suggested:
1) Default the element/attribute name to the method or field name
I have already started on this and it should be in the next release.
2) Use the generic parameter type for collections and the component type for arrays
This is something I will investigate further for collections. With regard to arrays this is already done
3) Add in the targets for the annotations
Yes, I initially held off on this as only fields were supported in earlier releases. I think I will also make @Root inherited.
Thanks,
Niall
----- Original Message ----
From: Mike Quilleash <mik...@su...>
To: sim...@li...
Sent: Tuesday, May 1, 2007 11:26:20 AM
Subject: [Simple-support] Possible enhancements
Hi
all,
First off, nice
project! I've finally got fed up at navigating around dom4j nodes so was
looking around for xml binding stuff. Started looking at JAXB but I'm not
sure I've ever seen a more complicated way of doing something that should be so
simple. My next stop was google search "xml binding simple" which brought
me here.
I really like the
annotation approach to doing this as it's quick and easy to understand.
The tutorial was also excellent as I could actually start coding in
<5 minutes, bit of a novelty after spending an hour poring over JAXB
APIs.
I have some
suggestions to maybe enhance/simplify some areas regarding the
annotations. Please don't take this as any form of criticism, just some
ideas :)
1) Default the
element/attribute name to the field/method it is on (not sure if the annotations
are supported on methods)
e.g.
@Attribute( name = "path" )
private String
path;
The name = "path"
seems pretty redundant to me in this case. Could just
be
@Attribute
private String
path;
2) Derive types from
generics/array types where possible.
@ElementList( name = "schemas", type
= Schema.class)
private List< Schema >
schemas;
OR
@ElementArray( name = "schemas",
type = Schema.class)
private Schema[]
schemas;
I believe the type/class can be derived from the
generic type of the array type.
field.getType().getComponentType().
Generics you can use
((ParameterizedType)field.getGenericType()).getActualTypeArguments()[
0 ].
Combined with 1) above makes the above
examples
@ElementList
private List< Schema > schemas;
OR
@ElementArray
private Schema[]
schemas;
3) Make the annotations limited
on what they can be applied to. Minor point, but at the moment I can
use @Attribute on a class if I really want to. I imagine nothing would go
wrong, it would just be ignored, but it adds another piece of implicit
documentation.
@Target( FIELD, METHOD
)
@Retention(RetentionPolicy.RUNTIME)
public @interface Attribute
{
Cheers.
Mike.
This e-mail is bound by the terms and conditions described at http://www.subexazure.com/mail-disclaimer.html
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com |