Re: [Simple-support] Possible enhancements
Brought to you by:
niallg
|
From: Mike Q. <mik...@su...> - 2007-05-01 17:40:29
|
Hi Niall,
=20
Glad to hear some of these features are already planned.
=20
I have another one :)
=20
Add some basic validation to multiple annotations.
=20
e.g. @ElementList( min =3D "1", max =3D "10" )
=20
which adds a constraint on the number of elements this list may contain.
=20
Cheers.
=20
Mike.
________________________________
From: sim...@li...
[mailto:sim...@li...] On Behalf Of Niall
Gallagher
Sent: 01 May 2007 18:23
To: sim...@li...
Subject: Re: [Simple-support] Possible enhancements
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,
=20
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.
=20
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.
=20
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 :)
=20
=20
1) Default the element/attribute name to the field/method it is on (not
sure if the annotations are supported on methods)
=20
e.g.
=20
@Attribute( name =3D "path" )
private String path;
The name =3D "path" seems pretty redundant to me in this case. Could =
just
be
=20
@Attribute
private String path;
=20
=20
2) Derive types from generics/array types where possible.
=20
=20
@ElementList( name =3D "schemas", type =3D Schema.class)
private List< Schema > schemas;
OR
=20
@ElementArray( name =3D "schemas", type =3D Schema.class)
private Schema[] schemas;
I believe the type/class can be derived from the generic type of the
array type.
=20
field.getType().getComponentType().
=20
Generics you can use
=20
((ParameterizedType)field.getGenericType()).getActualTypeArguments()[ 0
].
=20
=20
Combined with 1) above makes the above examples
=20
=20
@ElementList
private List< Schema > schemas;
OR
=20
@ElementArray
private Schema[] schemas;
=20
=20
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.
=20
@Target( FIELD, METHOD )
@Retention(RetentionPolicy.RUNTIME)
public @interface Attribute {
=20
=20
=20
Cheers.
=20
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
________________________________
Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.
<http://us.rd.yahoo.com/evt=3D48245/*http://autos.yahoo.com/new_cars.html=
;
_ylc=3DX3oDMTE1YW1jcXJ2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3LWNhcn=
M
-> =20
This e-mail is bound by the terms and conditions described at http://www=
=2Esubexazure.com/mail-disclaimer.html
=0D |