[Simple-support] Atabaque DTDtoBean Tool
Brought to you by:
niallg
|
From: Serge R. <ser...@gm...> - 2007-06-18 21:03:42
|
Hi Everybody!!! Tired to write Java Beans by hand? See the first beta version of Atabaque DTDtoBean, that generates JavaBeans from an specified DTD file. You can choose generate standard Java Beans or using Annotations for Simple or XStream. It=B4s available as a command line= , Swing application or NetBeans plugin. This project was started from a necessity of Atabaque<http://atabaque.sourceforge.net/>project, so that=B4s the reason for using Atabaque DTDtoBean name. Hope you enjoy and contribute to it! []=B4s Serge Rehem 2007/6/14, sim...@li... < sim...@li...>: > > Send Simple-support mailing list submissions to > sim...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/simple-support > or, via email, send a message with subject or body 'help' to > sim...@li... > > You can reach the person managing the list at > sim...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Simple-support digest..." > > > Today's Topics: > > 1. Re: Element/Attribute Default Values (Niall Gallagher) > 2. Re: Element/Attribute Default Values (Keith Byrne) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 13 Jun 2007 12:44:05 -0700 (PDT) > From: Niall Gallagher <gal...@ya...> > Subject: Re: [Simple-support] Element/Attribute Default Values > To: Niall Gallagher <gal...@ya...>, Keith Byrne > <ka...@gm...>, sim...@li... > Message-ID: <327...@we...> > Content-Type: text/plain; charset=3D"us-ascii" > > Hi, > > Simple 1.3.1 has been release with support for null @Attribute and @Text > values. This means that within the XML document the Java null value can b= e > represented in a textual manner within the XML document. For example take > the following: > > @Root > public class Example { > > @Attribute(empty=3D"NULL") > private String name; > > @Text(empty=3D"NO TEXT HERE") > private String value; > > public Example() { > super(); > } > > public Example(String name, String value) { > this.name =3D name; > this.value =3D value; > } > } > > So if Persister.write was used on various instances of the Example class > the output would look like follows: > > 1) new Example(null, null) > > <example name=3D"NULL>NO TEXT HERE</example> > > 2) new Example("Some Name", null) > > <example name=3D"Some Name">NO TEXT HERE</example> > > 3) new Example("Some Name", "Some Description") > > <example name=3D"Some Name">Some Description</example> > > Deserialization will ensure that fields with the null text value will be > assigned null. I have not yet had time to add support for null @Element, > @ElementArray, or @ElementList. > > Niall > > ----- Original Message ---- > From: Niall Gallagher <gal...@ya...> > To: Niall Gallagher <gal...@ya...>; Keith Byrne < > ka...@gm...>; sim...@li... > Sent: Tuesday, June 12, 2007 10:36:56 AM > Subject: Re: [Simple-support] Element/Attribute Default Values > > Hi, > > In future I hope to add an "empty" attribute to all of the annotations > such that empty values can be inserted without having to bend over backwa= rds > to cope with null values. Ill be implementing something like > > @Root > public class MyClass { > > @Attribute(empty=3D"NULL") > private String example; > } > > Such that if the field "example" had a null value it would be written as > follows: > > <myClass example=3D"NULL"/> > > The deserialization process will know to substitute the specified value > with null when reconstituting the object. For the @Element, @ElementList, > and @ElementArray annotations the field will be a boolean like so: > > @Root > public class MyOtherClass > { > > @ElementList(empty=3Dtrue) > private Collection<String> list; > } > > The above annotation tells the persister to serialize the empty value suc= h > that the result of having a null list would be: > > <myOtherClass> > <list/> > </myOtherClass> > > Where as if the annotation was set not to write an empty value the > resulting XML would be: > > <myOtherClass/> > > This requires only very minor changes, so will probably make it in soon > enough. > > Niall > > ----- Original Message ---- > From: Niall Gallagher <gal...@ya...> > To: Keith Byrne <ka...@gm...>; sim...@li... > Sent: Monday, June 11, 2007 10:38:52 PM > Subject: Re: [Simple-support] Element/Attribute Default Values > > Hi, > > Yes there is a way to intercept, for example: > > public class MyExample { > > private static final DEFAULT_VALUE =3D "[[NULL]]"; > @Element > private String webAddress > > @Commit > private void resolveMyDefault() { > if(webAddress.equals(DEFAULT_VALUE)) { > webAddress =3D null; > } > } > > @Persist > private void fixMyObject() { > if(webAddress =3D=3D null){ > webAddress =3D DEFAULT_VALUE: > } > } > > @Complete > > private void backToNormal() { > resolveMyDefault(); > } > } > > This should do the trick, as @Persist gets called just before the object > is persisted, and @Complete gets called when its been serialized to the X= ML > document. The @Commit gets called after deserialization so the object val= ues > will be reverted to a proper working runtime value. > > Hope this helps. > Niall > > ----- Original Message ---- > From: Keith Byrne <ka...@gm...> > To: sim...@li... > Sent: Monday, June 11, 2007 10:33:16 AM > Subject: [Simple-support] Element/Attribute Default Values > > > I have a situation where a field isn't required, but when it's null and i= s > serialized, the tag still needs to show up empty. Specifically, there is= a > String field (webAddress) that has an Attribute annotation, that went it'= s > null > should be serialized to <webAddress/>, instead of not showing up. Is > there a way to intercept the serializing of an Element/Attribute, and bas= ed > upon it's type, serialize a default value? > > > ------------------------------------------------------------------------- > 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 > > > > > > > > Shape Yahoo! in your own image. > Join our Network Research Panel today! > ------------------------------------------------------------------------- > 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 > > > > > > > > Got a little couch potato? > > Check out fun summer activities for kids. > > > > > > > > _________________________________________________________________________= ___________ > Looking for a deal? Find great prices on flights and hotels with Yahoo! > FareChase. > http://farechase.yahoo.com/ > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > Message: 2 > Date: Thu, 14 Jun 2007 12:16:06 -0400 > From: "Keith Byrne" <ka...@gm...> > Subject: Re: [Simple-support] Element/Attribute Default Values > To: "Niall Gallagher" <gal...@ya...> > Cc: sim...@li... > Message-ID: > <533...@ma...> > Content-Type: text/plain; charset=3D"iso-8859-1" > > Thanks, this is great. I look forward to the support the @Element > annotations. > > On 6/13/07, Niall Gallagher <gal...@ya...> wrote: > > > > Hi, > > > > Simple 1.3.1 has been release with support for null @Attribute and @Tex= t > > values. This means that within the XML document the Java null value can > be > > represented in a textual manner within the XML document. For example > take > > the following: > > > > @Root > > public class Example { > > > > @Attribute(empty=3D"NULL") > > private String name; > > > > @Text(empty=3D"NO TEXT HERE") > > private String value; > > > > public Example() { > > super(); > > } > > > > public Example(String name, String value) { > > this.name =3D name; > > this.value =3D value; > > } > > } > > > > So if Persister.write was used on various instances of the Example clas= s > > the output would look like follows: > > > > 1) new Example(null, null) > > > > <example name=3D"NULL>NO TEXT HERE</example> > > > > 2) new Example("Some Name", null) > > > > <example name=3D"Some Name">NO TEXT HERE</example> > > > > 3) new Example("Some Name", "Some Description") > > > > <example name=3D"Some Name">Some Description</example> > > > > Deserialization will ensure that fields with the null text value will b= e > > assigned null. I have not yet had time to add support for null @Element= , > > @ElementArray, or @ElementList. > > > > Niall > > > > ----- Original Message ---- > > From: Niall Gallagher <gal...@ya...> > > To: Niall Gallagher <gal...@ya...>; Keith Byrne < > > ka...@gm...>; sim...@li... > > Sent: Tuesday, June 12, 2007 10:36:56 AM > > Subject: Re: [Simple-support] Element/Attribute Default Values > > > > Hi, > > > > In future I hope to add an "empty" attribute to all of the annotations > > such that empty values can be inserted without having to bend over > backwards > > to cope with null values. Ill be implementing something like > > > > @Root > > public class MyClass { > > > > @Attribute(empty=3D"NULL") > > private String example; > > } > > > > Such that if the field "example" had a null value it would be written a= s > > follows: > > > > <myClass example=3D"NULL"/> > > > > The deserialization process will know to substitute the specified value > > with null when reconstituting the object. For the @Element, > @ElementList, > > and @ElementArray annotations the field will be a boolean like so: > > > > @Root > > public class MyOtherClass { > > > > @ElementList(empty=3Dtrue) > > private Collection<String> list; > > } > > > > The above annotation tells the persister to serialize the empty value > such > > that the result of having a null list would be: > > > > <myOtherClass> > > <list/> > > </myOtherClass> > > > > Where as if the annotation was set not to write an empty value the > > resulting XML would be: > > > > <myOtherClass/> > > > > This requires only very minor changes, so will probably make it in soon > > enough. > > > > Niall > > > > ----- Original Message ---- > > From: Niall Gallagher <gal...@ya...> > > To: Keith Byrne <ka...@gm...>; > sim...@li... > > Sent: Monday, June 11, 2007 10:38:52 PM > > Subject: Re: [Simple-support] Element/Attribute Default Values > > > > Hi, > > > > Yes there is a way to intercept, for example: > > > > public class MyExample { > > > > private static final DEFAULT_VALUE =3D "[[NULL]]"; > > @Element > > private String webAddress > > > > @Commit > > private void resolveMyDefault() { > > if(webAddress.equals(DEFAULT_VALUE)) { > > webAddress =3D null; > > } > > } > > > > @Persist > > private void fixMyObject() { > > if(webAddress =3D=3D null){ > > webAddress =3D DEFAULT_VALUE: > > } > > } > > > > @Complete > > private void backToNormal() { > > resolveMyDefault(); > > } > > } > > > > This should do the trick, as @Persist gets called just before the objec= t > > is persisted, and @Complete gets called when its been serialized to the > XML > > document. The @Commit gets called after deserialization so the object > values > > will be reverted to a proper working runtime value. > > > > Hope this helps. > > Niall > > > > ----- Original Message ---- > > From: Keith Byrne <ka...@gm...> > > To: sim...@li... > > Sent: Monday, June 11, 2007 10:33:16 AM > > Subject: [Simple-support] Element/Attribute Default Values > > > > > > I have a situation where a field isn't required, but when it's null and > is > > serialized, the tag still needs to show up empty. Specifically, there > is a > > String field (webAddress) that has an Attribute annotation, that went > it's > > null should be serialized to <webAddress/>, instead of not showing > up. Is > > there a way to intercept the serializing of an Element/Attribute, and > based > > upon it's type, serialize a default value? > > > ------------------------------------------------------------------------- > > 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 > > > > > > ------------------------------ > > Shape Yahoo! in your own image. Join our Network Research Panel today!< > http://us.rd.yahoo.com/evt=3D48517/*http://surveylink.yahoo.com/gmrs/yaho= o_panel_invite.asp?a=3D7 > > > > > ------------------------------------------------------------------------- > > 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 > > > > > > ------------------------------ > > Got a little couch potato? > > Check out fun summer activities for kids.< > http://us.rd.yahoo.com/evt=3D48248/*http://search.yahoo.com/search?fr=3Do= ni_on_mail&p=3Dsummer+activities+for+kids&cs=3Dbz > > > > > > > > ------------------------------ > > Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge > > <http://us.rd.yahoo.com/evt=3D47093/*http://tv.yahoo.com/collections/22= 2 > >to > > see what's on, when. > > > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > ------------------------------------------------------------------------- > 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 > > > End of Simple-support Digest, Vol 3, Issue 5 > ******************************************** > |