simple-support Mailing List for Simple (Page 79)
Brought to you by:
niallg
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(13) |
May
(13) |
Jun
(27) |
Jul
(4) |
Aug
(14) |
Sep
(7) |
Oct
|
Nov
(6) |
Dec
(24) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
(21) |
Mar
(10) |
Apr
(15) |
May
(24) |
Jun
(24) |
Jul
(30) |
Aug
(5) |
Sep
(19) |
Oct
(27) |
Nov
(16) |
Dec
(24) |
| 2009 |
Jan
(34) |
Feb
(24) |
Mar
(35) |
Apr
(26) |
May
(8) |
Jun
(17) |
Jul
(28) |
Aug
(31) |
Sep
(36) |
Oct
(35) |
Nov
(20) |
Dec
(16) |
| 2010 |
Jan
(40) |
Feb
(21) |
Mar
(47) |
Apr
(45) |
May
(34) |
Jun
(68) |
Jul
(46) |
Aug
(39) |
Sep
(47) |
Oct
(20) |
Nov
(42) |
Dec
(13) |
| 2011 |
Jan
(41) |
Feb
(16) |
Mar
(32) |
Apr
(44) |
May
(28) |
Jun
(35) |
Jul
(37) |
Aug
(33) |
Sep
(60) |
Oct
(20) |
Nov
(35) |
Dec
(23) |
| 2012 |
Jan
(34) |
Feb
(23) |
Mar
(34) |
Apr
(21) |
May
(48) |
Jun
(24) |
Jul
(31) |
Aug
(39) |
Sep
(25) |
Oct
(10) |
Nov
(27) |
Dec
(28) |
| 2013 |
Jan
(32) |
Feb
(24) |
Mar
(24) |
Apr
(9) |
May
(4) |
Jun
(6) |
Jul
(2) |
Aug
(5) |
Sep
|
Oct
(5) |
Nov
(1) |
Dec
(12) |
| 2014 |
Jan
(14) |
Feb
(16) |
Mar
(5) |
Apr
(3) |
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
|
Sep
(6) |
Oct
|
Nov
(6) |
Dec
|
| 2015 |
Jan
(3) |
Feb
(15) |
Mar
(7) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
| 2016 |
Jan
|
Feb
(6) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Niall G. <gal...@ya...> - 2007-08-21 07:49:05
|
Hi Wessam, I suspect you are loading from two different class loaders here. So although the ZephyrParserFactory is an implementation of the XMLInputFactory they are both loaded from different class loaders (perhaps the ZephyrParserFactory is bundled with a separate StAX API JAR). If two identical classes are loaded from different class loaders they are NOT the same class, so you will get a class cast exception. Why don't you just download Woodstox, bundle this with the Simple XML JAR and set the system property: -Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory Niall --- Wessam Abd Rabo <wes...@gm...> wrote: > hey david, > > Thanks for the note. I did what you suggested but > still i get this same > error: > > java.lang.ClassCastException: > com.sun.xml.stream.ZephyrParserFactory cannot > be cast to javax.xml.stream.XMLInputFactory > at > javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136) > at > org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48) > Caused: *java.lang.ExceptionInInitializerError > * at > org.simpleframework.xml.load.Persister.write(Persister.java:687) > at > org.simpleframework.xml.load.Persister.write(Persister.java:669) > at > org.simpleframework.xml.load.Persister.write(Persister.java:650) > at > org.simpleframework.xml.load.Persister.write(Persister.java:629) > at > org.netbeans.shapesample.GraphSceneImpl.generateXML(GraphSceneImpl.java > :152 > > > Let me tell you what i'm trying to do here. I'm > using an external library > called Simple Framework > http://simple.sourceforge.net/ for generating the > XML file from the diagram. I created a moudle suite > and added to it this > library as a library wrapper and also added a module > which contains my > appliction that will use the library. This > application is just topcomponent > and graphscene implementation. inside dragndrop > accept method, i call a > function that generates xml using this piece of code > which i got from a > tutorial on the website of this library : > > > java.io.File result = new > java.io.File("example.xml"); > > Example example=new Example("Example Message",123); > > org.simpleframework.xml.Serializer serializer = new > org.simpleframework.xml.load.Persister(); > > serializer.write(example, result); > > it doesn't work at all inside a module project while > it works perfectly and > generates the xml file in a standard java project. > > i asked the help of the developer who wrote this > library and that was his > reply: > > > Your NoClassDefFoundError is caused by a failure to > > load a suitable StAX implementation from the static > > initializer. If you are using Java 5 then you need > the > > StAX API and a StAX implementation. Both come with > the > > download in the lib directory. > so what i did is that i wrapped the stax api and > implementation inside the > library wrapper i have together with the rest of the > library jar file. i > then added this library as a dependency to my > application module. > > I'm really stuck with this for 3 days and i dunno > what else i can do to fix > it. can you help me with it? > > Thanks in advance > > Wessam > > > > > On 8/20/07, David Van Couvering > <da...@va...> wrote: > > > > You have to make sure that the package you want to > have accessible are > > exported as friends. You do this through the > project's > > Properties->API Versioning, then click on [Add...] > under "Public > > Packages" > > > > Then in the module that uses the package, you have > to add your module > > as a Library. You do this thorugh the project's > > Properties->Libraries. Click on [Add...]. Make > sure you click on > > "Show Non-API modules", and then you can type in > the name of your > > module to search for it. > > > > David > > > > On 8/20/07, Wessam Abd Rabo > <wes...@gm...> wrote: > > > hi toni, i still get the ClassDefNotFoundError > exception even after > > creating > > > the library wrapper for my external library. the > strange thing is that > > when > > > i add this same library in a java application > and not a module project > > it > > > works perefectly. once i try it out in a module, > it craches. I call it > > > inside a class implementation of a GraphScene, > can this be contributing > > to > > > the problem? > > > > > > thanks again > > > wessam > > > > > > > > > > > > > > > > > > > > > > > > On 8/20/07, Anton Epple <ep...@ge... > > wrote: > > > > > Hi Wessam, > > > > > > > > > > create a library wrapper module for your > xml serialization library: > > > > > > > > > http://wiki.netbeans.info/wiki/view/DevFaqWrapperModules > > > > > > > > > > then you can find it in the modules list. > > > > > > > > > > best, > > > > > Toni > > > > > > > > > > Wessam Abd Rabo wrote: > > > > > > > > > > > Hi, > > > > > > > > > > > > I'm developing a module in netbeans in > which i use an external > > library > > > > > > called simple framework for XML > serialization. I just call a > > function > > > > > > inside a class that extends GraphScene > class. on exectuting this > > code, > > > > > > a ClassDefNotFountError exception is > thrown. I don't include this > > > > > > library in the module dependency cause i > don't know how to do this > > if > > > > > > the library is not added to the list of > modules of nb. I tried > > putting > > > > > > the jar file of this library in all nb > folders but still i cant > > find > > > > > > it in the modules list. so i just added > the packages of this > > library > > > > > > to the source packages of my module. I > don't know if this > > contibutes > > > > > > to the problem or have nothing to do with > it. also a null pointer > > > > > > exception is thrown the 2nd time the > function is called. the > > strange > > > > > > thing is when i use this same piece of > code in a java application, > > not > > > > > > a module application, it runs perfectly. > can anyone help me with > > this? > > > > > > > > > > > > Thanks in advance, > > > > > > > > > > > > Wessam > > > > > > === message truncated === ____________________________________________________________________________________ Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 |
|
From: Frank B. <f_b...@ya...> - 2007-08-21 07:03:41
|
Hi Niall,=0A=0ATried it with the @Root annotation in both classes and am st=
ill getting the same error?=0A(btw when i tried to test it with the classes=
as shown in the tutorial (Task, Example, DividerTask ...)=0Ai also got tha=
t message.=0AHas something gone wrong in the last version???=0A=0Athanks=0A=
=0AFrank=0A=0A----- Original Message ----=0AFrom: Niall Gallagher <gallaghe=
r_...@ya...>=0ATo: Frank Beullens <f_b...@ya...>; simple-supp=
or...@li...=0ASent: Monday, August 20, 2007 3:11:06 PM=0ASubj=
ect: Re: [Simple-support] Problem serialzing object with lists=0A=0A=0AHi,=
=0A=0AYou are missing a @Root annotation on the TestPref1=0Aand TestPref2 c=
lasses. The general rule is, if there=0Ais no @Root annotation then a trans=
formation is=0Aattempted as a last resort. However, typically=0Atransformat=
ions will be reserved for simple types,=0Asuch as integers, booleans, strin=
gs, dates, and so on.=0A=0ANiall=0A=0A--- Frank Beullens <f_beullens@yahoo.=
com> wrote:=0A=0A> Hi,=0A> =0A> i have created the following objects:=0A> =
=0A> public interface IPreference {=0A> =0A> }=0A> =0A> public class Te=
stPref1 implements IPreference {=0A> @Element(name=3D"id")=0A> priv=
ate long id =3D 0;=0A> =0A> @Element(name=3D"pref1name")=0A> pr=
ivate String name =3D "";=0A> =0A> /** Creates a new instance of Te=
stPref1 */=0A> public TestPref1() {=0A> }=0A> public long getId=
() {=0A> return id;=0A> }=0A> public void setId(long id) {=
=0A> this.id =3D id;=0A> }=0A> public String getName() {=0A=
> return name;=0A> }=0A> public void setName(String name) {=
=0A> this.name =3D name;=0A> }=0A> =0A> }=0A> =0A> public c=
lass TestPref2 implements IPreference {=0A> @Element(name=3D"pref2code"=
)=0A> private String code =3D "";=0A> =0A> /** Creates a new in=
stance of TestPref2 */=0A> public TestPref2() {=0A> }=0A> publi=
c String getCode() {=0A> return code;=0A> }=0A> public void=
setCode(String code) {=0A> this.code =3D code;=0A> }=0A> =
=0A> }=0A> =0A> @Root(name=3D"preferencegroup")=0A> public class Preference=
Group implements IPreference=0A> {=0A> @ElementList(name=3D"preferences=
")=0A> private List<IPreference> preferences =3D null;=0A> =0A> =
@Attribute(name=3D"groupcode")=0A> private String groupCode =3D "";=0A=
> =0A> public List<IPreference> getPreferences() {=0A> retu=
rn this.preferences;=0A> }=0A> =0A> public void setPreferences(=
List<IPreference>=0A> preferences) {=0A> this.preferences =3D prefe=
rences;=0A> }=0A> public String getGroupCode() {=0A> return=
groupCode;=0A> }=0A> public void setGroupCode(String groupCode) {=
=0A> this.groupCode =3D groupCode;=0A> }=0A> }=0A> =0A> =0A> wh=
en trying to do the following:=0A> =0A> PreferenceGroup group =3D n=
ew=0A> PreferenceGroup();=0A> group.setGroupCode("TESTGROUP");=0A> =
List<IPreference> preferences =3D new=0A> ArrayList<IPreference>();=
=0A> TestPref1 pref1 =3D new TestPref1();=0A> pref1.setId(1=
);=0A> pref1.setName("test preference 1");=0A> preferences.=
add(pref1);=0A> TestPref2 pref2 =3D new TestPref2();=0A> pr=
ef2.setCode("TSTPRF2");=0A> preferences.add(pref2);=0A> gro=
up.setPreferences(preferences);=0A> Serializer serializer =3D new P=
ersister();=0A> File result =3D new File("preferences.xml");=0A> =
try {=0A> serializer.write(group, result);=0A> } =
catch (Exception ex) {=0A> ex.printStackTrace();=0A> }=
=0A> =0A> I get the error:=0A> =0A>=0Aorg.simpleframework.xml.transform.Tra=
nsformException:=0A> Transform of class=0A> com.libesoft.rcp.preferences.te=
st.TestPref1 not=0A> supported=0A> at=0A>=0Aorg.simpleframework.xml=
.transform.PackageMatcher.match(PackageMatcher.java:88)=0A> at=0A>=
=0Aorg.simpleframework.xml.transform.DefaultMatcher.matchType(DefaultMatche=
r.java:111)=0A> at=0A>=0Aorg.simpleframework.xml.transform.DefaultM=
atcher.match(DefaultMatcher.java:90)=0A> at=0A>=0Aorg.simpleframewo=
rk.xml.transform.Transformer.write(Transformer.java:129)=0A> at=0A>=
=0Aorg.simpleframework.xml.load.PrimitiveFactory.getText(PrimitiveFactory.j=
ava:128)=0A> at=0A>=0Aorg.simpleframework.xml.load.Primitive.write(=
Primitive.java:200)=0A> at=0A>=0Aorg.simpleframework.xml.load.Primi=
tiveList.write(PrimitiveList.java:157)=0A> at=0A>=0Aorg.simpleframe=
work.xml.load.Composite.writeElement(Composite.java:589)=0A> at=0A>=
=0Aorg.simpleframework.xml.load.Composite.writeElements(Composite.java:485)=
=0A> at=0A>=0Aorg.simpleframework.xml.load.Composite.write(Composit=
e.java:423)=0A> at=0A>=0Aorg.simpleframework.xml.load.Composite.wri=
te(Composite.java:401)=0A> at=0A>=0Aorg.simpleframework.xml.load.Tr=
averser.write(Traverser.java:186)=0A> at=0A>=0Aorg.simpleframework.=
xml.load.Traverser.write(Traverser.java:165)=0A> at=0A>=0Aorg.simpl=
eframework.xml.load.Traverser.write(Traverser.java:143)=0A> at=0A>=
=0Aorg.simpleframework.xml.load.Persister.write(Persister.java:608)=0A> =
at=0A>=0Aorg.simpleframework.xml.load.Persister.write(Persister.java:5=
90)=0A> at=0A>=0Aorg.simpleframework.xml.load.Persister.write(Persi=
ster.java:571)=0A> at=0A>=0Aorg.simpleframework.xml.load.Persister.=
write(Persister.java:687)=0A> at=0A>=0Aorg.simpleframework.xml.load=
.Persister.write(Persister.java:669)=0A> at=0A>=0Aorg.simpleframewo=
rk.xml.load.Persister.write(Persister.java:650)=0A> at=0A>=0Aorg.si=
mpleframework.xml.load.Persister.write(Persister.java:629)=0A> =0A> =0A> An=
y ideas what i am doing wrong????=0A> =0A> Thanks=0A> =0A> Frank=0A> =0A>=
=0A------------------------------------------------------------------------=
-=0A> This SF.net email is sponsored by: Splunk Inc.=0A> Still grepping thr=
ough log files to find problems? =0A> Stop.=0A> Now Search log events and c=
onfiguration files using=0A> AJAX and a browser.=0A> Download your FREE cop=
y of Splunk now >> =0A> http://get.splunk.com/=0A> ________________________=
_______________________=0A> Simple-support mailing list=0A> Simple-support@=
lists.sourceforge.net=0A>=0Ahttps://lists.sourceforge.net/lists/listinfo/si=
mple-support=0A> =0A=0A=0A=0A =0A____________________________________=
________________________________________________=0ABoardwalk for $500? In 2=
007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Y=
ahoo! Games.=0Ahttp://get.games.yahoo.com/proddesc?gamekey=3Dmonopolyhereno=
w
|
|
From: Wessam A. R. <wes...@gm...> - 2007-08-21 01:27:22
|
Hi, I keep getting this error on running the tutorial example code inside a module project in netbeans IDE. *java.lang.ClassCastException: com.sun.xml.stream.ZephyrParserFactory cannot be cast to javax.xml.stream.XMLInputFactory at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136) at org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48) * I was initially getting a ClassDefNotFounfError exception. Then when i added the stax API and implementation to my module i get this exception. It can't possibly be anything i add to the code, cause i'm just using the tutorial example. It has to be something with the library itself. Could anyone help me fix this error? Please it's urgent Thanks in advance Wessam |
|
From: Wessam A. R. <wes...@gm...> - 2007-08-20 23:40:09
|
Hi Niall, after working around, i get this exception instead of the ClassDefNotFoundException. I still think it's caused by the same reason. something that has to do with initializing XMLInputFactory or something. I added the stax API and implementation to my module as dependencies and i still ge the same error. can you please help with this error? java.lang.ClassCastException: com.sun.xml.stream.ZephyrParserFactory cannot be cast to javax.xml.stream.XMLInputFactory at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136) at org.simpleframework.xml.stream.NodeBuilder .<clinit>(NodeBuilder.java :48) Caused: *java.lang.ExceptionInInitializerError * at org.simpleframework.xml.load.Persister.write(Persister.java:687) at org.simpleframework.xml.load.Persister.write (Persister.java:669) at org.simpleframework.xml.load.Persister.write(Persister.java:650) at org.simpleframework.xml.load.Persister.write(Persister.java:629) at org.netbeans.shapesample.GraphSceneImpl.generateXML (GraphSceneImpl.java :152 Wessam |
|
From: Wessam A. R. <wes...@gm...> - 2007-08-20 23:36:05
|
hey david, Thanks for the note. I did what you suggested but still i get this same error: java.lang.ClassCastException: com.sun.xml.stream.ZephyrParserFactory cannot be cast to javax.xml.stream.XMLInputFactory at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136) at org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48) Caused: *java.lang.ExceptionInInitializerError * at org.simpleframework.xml.load.Persister.write(Persister.java:687) at org.simpleframework.xml.load.Persister.write(Persister.java:669) at org.simpleframework.xml.load.Persister.write(Persister.java:650) at org.simpleframework.xml.load.Persister.write(Persister.java:629) at org.netbeans.shapesample.GraphSceneImpl.generateXML(GraphSceneImpl.java :152 Let me tell you what i'm trying to do here. I'm using an external library called Simple Framework http://simple.sourceforge.net/ for generating the XML file from the diagram. I created a moudle suite and added to it this library as a library wrapper and also added a module which contains my appliction that will use the library. This application is just topcomponent and graphscene implementation. inside dragndrop accept method, i call a function that generates xml using this piece of code which i got from a tutorial on the website of this library : java.io.File result = new java.io.File("example.xml"); Example example=new Example("Example Message",123); org.simpleframework.xml.Serializer serializer = new org.simpleframework.xml.load.Persister(); serializer.write(example, result); it doesn't work at all inside a module project while it works perfectly and generates the xml file in a standard java project. i asked the help of the developer who wrote this library and that was his reply: Your NoClassDefFoundError is caused by a failure to load a suitable StAX implementation from the static initializer. If you are using Java 5 then you need the StAX API and a StAX implementation. Both come with the download in the lib directory. so what i did is that i wrapped the stax api and implementation inside the library wrapper i have together with the rest of the library jar file. i then added this library as a dependency to my application module. I'm really stuck with this for 3 days and i dunno what else i can do to fix it. can you help me with it? Thanks in advance Wessam On 8/20/07, David Van Couvering <da...@va...> wrote: > > You have to make sure that the package you want to have accessible are > exported as friends. You do this through the project's > Properties->API Versioning, then click on [Add...] under "Public > Packages" > > Then in the module that uses the package, you have to add your module > as a Library. You do this thorugh the project's > Properties->Libraries. Click on [Add...]. Make sure you click on > "Show Non-API modules", and then you can type in the name of your > module to search for it. > > David > > On 8/20/07, Wessam Abd Rabo <wes...@gm...> wrote: > > hi toni, i still get the ClassDefNotFoundError exception even after > creating > > the library wrapper for my external library. the strange thing is that > when > > i add this same library in a java application and not a module project > it > > works perefectly. once i try it out in a module, it craches. I call it > > inside a class implementation of a GraphScene, can this be contributing > to > > the problem? > > > > thanks again > > wessam > > > > > > > > > > > > > > > > > On 8/20/07, Anton Epple <ep...@ge... > wrote: > > > > Hi Wessam, > > > > > > > > create a library wrapper module for your xml serialization library: > > > > > > http://wiki.netbeans.info/wiki/view/DevFaqWrapperModules > > > > > > > > then you can find it in the modules list. > > > > > > > > best, > > > > Toni > > > > > > > > Wessam Abd Rabo wrote: > > > > > > > > > Hi, > > > > > > > > > > I'm developing a module in netbeans in which i use an external > library > > > > > called simple framework for XML serialization. I just call a > function > > > > > inside a class that extends GraphScene class. on exectuting this > code, > > > > > a ClassDefNotFountError exception is thrown. I don't include this > > > > > library in the module dependency cause i don't know how to do this > if > > > > > the library is not added to the list of modules of nb. I tried > putting > > > > > the jar file of this library in all nb folders but still i cant > find > > > > > it in the modules list. so i just added the packages of this > library > > > > > to the source packages of my module. I don't know if this > contibutes > > > > > to the problem or have nothing to do with it. also a null pointer > > > > > exception is thrown the 2nd time the function is called. the > strange > > > > > thing is when i use this same piece of code in a java application, > not > > > > > a module application, it runs perfectly. can anyone help me with > this? > > > > > > > > > > Thanks in advance, > > > > > > > > > > Wessam > > > > > > > > > > > > > > > > > > > |
|
From: Niall G. <gal...@ya...> - 2007-08-20 13:11:16
|
Hi,
You are missing a @Root annotation on the TestPref1
and TestPref2 classes. The general rule is, if there
is no @Root annotation then a transformation is
attempted as a last resort. However, typically
transformations will be reserved for simple types,
such as integers, booleans, strings, dates, and so on.
Niall
--- Frank Beullens <f_b...@ya...> wrote:
> Hi,
>
> i have created the following objects:
>
> public interface IPreference {
>
> }
>
> public class TestPref1 implements IPreference {
> @Element(name="id")
> private long id = 0;
>
> @Element(name="pref1name")
> private String name = "";
>
> /** Creates a new instance of TestPref1 */
> public TestPref1() {
> }
> public long getId() {
> return id;
> }
> public void setId(long id) {
> this.id = id;
> }
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
>
> }
>
> public class TestPref2 implements IPreference {
> @Element(name="pref2code")
> private String code = "";
>
> /** Creates a new instance of TestPref2 */
> public TestPref2() {
> }
> public String getCode() {
> return code;
> }
> public void setCode(String code) {
> this.code = code;
> }
>
> }
>
> @Root(name="preferencegroup")
> public class PreferenceGroup implements IPreference
> {
> @ElementList(name="preferences")
> private List<IPreference> preferences = null;
>
> @Attribute(name="groupcode")
> private String groupCode = "";
>
> public List<IPreference> getPreferences() {
> return this.preferences;
> }
>
> public void setPreferences(List<IPreference>
> preferences) {
> this.preferences = preferences;
> }
> public String getGroupCode() {
> return groupCode;
> }
> public void setGroupCode(String groupCode) {
> this.groupCode = groupCode;
> }
> }
>
>
> when trying to do the following:
>
> PreferenceGroup group = new
> PreferenceGroup();
> group.setGroupCode("TESTGROUP");
> List<IPreference> preferences = new
> ArrayList<IPreference>();
> TestPref1 pref1 = new TestPref1();
> pref1.setId(1);
> pref1.setName("test preference 1");
> preferences.add(pref1);
> TestPref2 pref2 = new TestPref2();
> pref2.setCode("TSTPRF2");
> preferences.add(pref2);
> group.setPreferences(preferences);
> Serializer serializer = new Persister();
> File result = new File("preferences.xml");
> try {
> serializer.write(group, result);
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> I get the error:
>
>
org.simpleframework.xml.transform.TransformException:
> Transform of class
> com.libesoft.rcp.preferences.test.TestPref1 not
> supported
> at
>
org.simpleframework.xml.transform.PackageMatcher.match(PackageMatcher.java:88)
> at
>
org.simpleframework.xml.transform.DefaultMatcher.matchType(DefaultMatcher.java:111)
> at
>
org.simpleframework.xml.transform.DefaultMatcher.match(DefaultMatcher.java:90)
> at
>
org.simpleframework.xml.transform.Transformer.write(Transformer.java:129)
> at
>
org.simpleframework.xml.load.PrimitiveFactory.getText(PrimitiveFactory.java:128)
> at
>
org.simpleframework.xml.load.Primitive.write(Primitive.java:200)
> at
>
org.simpleframework.xml.load.PrimitiveList.write(PrimitiveList.java:157)
> at
>
org.simpleframework.xml.load.Composite.writeElement(Composite.java:589)
> at
>
org.simpleframework.xml.load.Composite.writeElements(Composite.java:485)
> at
>
org.simpleframework.xml.load.Composite.write(Composite.java:423)
> at
>
org.simpleframework.xml.load.Composite.write(Composite.java:401)
> at
>
org.simpleframework.xml.load.Traverser.write(Traverser.java:186)
> at
>
org.simpleframework.xml.load.Traverser.write(Traverser.java:165)
> at
>
org.simpleframework.xml.load.Traverser.write(Traverser.java:143)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:608)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:590)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:571)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:687)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:669)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:650)
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:629)
>
>
> Any ideas what i am doing wrong????
>
> Thanks
>
> Frank
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?
> Stop.
> Now Search log events and configuration files using
> AJAX and a browser.
> Download your FREE copy of Splunk now >>
> http://get.splunk.com/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
|
|
From: Frank B. <f_b...@ya...> - 2007-08-20 12:46:12
|
Hi,=0A=0Ai have created the following objects:=0A=0Apublic interface IPrefe=
rence {=0A =0A}=0A=0Apublic class TestPref1 implements IPreference {=0A =
@Element(name=3D"id")=0A private long id =3D 0;=0A =0A @Element=
(name=3D"pref1name")=0A private String name =3D "";=0A =0A /** Cre=
ates a new instance of TestPref1 */=0A public TestPref1() {=0A }=0A =
public long getId() {=0A return id;=0A }=0A public void setI=
d(long id) {=0A this.id =3D id;=0A }=0A public String getName(=
) {=0A return name;=0A }=0A public void setName(String name) {=
=0A this.name =3D name;=0A }=0A =0A}=0A=0Apublic class TestPre=
f2 implements IPreference {=0A @Element(name=3D"pref2code")=0A privat=
e String code =3D "";=0A =0A /** Creates a new instance of TestPref2 =
*/=0A public TestPref2() {=0A }=0A public String getCode() {=0A =
return code;=0A }=0A public void setCode(String code) {=0A =
this.code =3D code;=0A }=0A =0A}=0A=0A@Root(name=3D"preferencegroup=
")=0Apublic class PreferenceGroup implements IPreference {=0A @ElementLi=
st(name=3D"preferences")=0A private List<IPreference> preferences =3D nu=
ll;=0A =0A @Attribute(name=3D"groupcode")=0A private String groupC=
ode =3D "";=0A =0A public List<IPreference> getPreferences() {=0A =
return this.preferences;=0A }=0A =0A public void setPreference=
s(List<IPreference> preferences) {=0A this.preferences =3D preferenc=
es;=0A }=0A public String getGroupCode() {=0A return groupCode=
;=0A }=0A public void setGroupCode(String groupCode) {=0A this=
.groupCode =3D groupCode;=0A }=0A}=0A=0A=0Awhen trying to do the followi=
ng:=0A=0A PreferenceGroup group =3D new PreferenceGroup();=0A =
group.setGroupCode("TESTGROUP");=0A List<IPreference> preferences =
=3D new ArrayList<IPreference>();=0A TestPref1 pref1 =3D new TestPre=
f1();=0A pref1.setId(1);=0A pref1.setName("test preference 1"=
);=0A preferences.add(pref1);=0A TestPref2 pref2 =3D new Test=
Pref2();=0A pref2.setCode("TSTPRF2");=0A preferences.add(pref=
2);=0A group.setPreferences(preferences);=0A Serializer seria=
lizer =3D new Persister();=0A File result =3D new File("preferences.=
xml");=0A try {=0A serializer.write(group, result);=0A =
} catch (Exception ex) {=0A ex.printStackTrace();=0A =
}=0A=0AI get the error:=0A=0Aorg.simpleframework.xml.transform.TransformEx=
ception: Transform of class com.libesoft.rcp.preferences.test.TestPref1 not=
supported=0A at org.simpleframework.xml.transform.PackageMatcher.ma=
tch(PackageMatcher.java:88)=0A at org.simpleframework.xml.transform.=
DefaultMatcher.matchType(DefaultMatcher.java:111)=0A at org.simplefr=
amework.xml.transform.DefaultMatcher.match(DefaultMatcher.java:90)=0A =
at org.simpleframework.xml.transform.Transformer.write(Transformer.java:1=
29)=0A at org.simpleframework.xml.load.PrimitiveFactory.getText(Prim=
itiveFactory.java:128)=0A at org.simpleframework.xml.load.Primitive.=
write(Primitive.java:200)=0A at org.simpleframework.xml.load.Primiti=
veList.write(PrimitiveList.java:157)=0A at org.simpleframework.xml.l=
oad.Composite.writeElement(Composite.java:589)=0A at org.simpleframe=
work.xml.load.Composite.writeElements(Composite.java:485)=0A at org.=
simpleframework.xml.load.Composite.write(Composite.java:423)=0A at o=
rg.simpleframework.xml.load.Composite.write(Composite.java:401)=0A a=
t org.simpleframework.xml.load.Traverser.write(Traverser.java:186)=0A =
at org.simpleframework.xml.load.Traverser.write(Traverser.java:165)=0A =
at org.simpleframework.xml.load.Traverser.write(Traverser.java:143)=0A=
at org.simpleframework.xml.load.Persister.write(Persister.java:608)=
=0A at org.simpleframework.xml.load.Persister.write(Persister.java:5=
90)=0A at org.simpleframework.xml.load.Persister.write(Persister.jav=
a:571)=0A at org.simpleframework.xml.load.Persister.write(Persister.=
java:687)=0A at org.simpleframework.xml.load.Persister.write(Persist=
er.java:669)=0A at org.simpleframework.xml.load.Persister.write(Pers=
ister.java:650)=0A at org.simpleframework.xml.load.Persister.write(P=
ersister.java:629)=0A=0A=0AAny ideas what i am doing wrong????=0A=0AThanks=
=0A=0AFrank
|
|
From: Wessam A. R. <wes...@gm...> - 2007-08-18 23:58:45
|
Hi, I'm just trying to run the tutorial code inside a module am develping in netbeans. it keeps giving me this error on running. *java.lang.NoClassDefFoundError: Could not initialize class org.simpleframework.xml.stream.NodeBuilder* ** do i need to add any specific dependency for this module? Thanks in advance Wessam |
|
From: Wessam A. R. <wes...@gm...> - 2007-08-17 17:20:35
|
Hi,
I just started using this library in a module am developing for Netbeans
IDE. I was just trying out the tutorial example but it keeps giving me a
Java.lang.NoClassDefFoundError exception. in the details of this error this
is written beside the exception name "javax/xml/stream/XMLInputFactory".
This is the code i wrote:
*try {
org.simpleframework.xml.Serializer serializer = new Persister();
Example example = new Example("Example message", 123);
File result = new File("H:\\example.xml");
serializer.write(example, result);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}*
and this is the class i have:
*@Root
public class Example {*
* @Element
private String text;*
* @Attribute
private int index;*
* public Example() {
super();
} *
* public Example(String text, int index) {
this.text = text;
this.index = index;
}*
* public String getMessage() {
return text;
}*
* public int getId() {
return index;
}
}*
Please i need help with this.
Thanks in advance
Wessam
|
|
From: Wessam A. R. <wes...@gm...> - 2007-08-16 21:42:27
|
hi i want to subscribe to this list |
|
From: Niall G. <gal...@ya...> - 2007-08-07 11:43:37
|
Hi, In relation to your comments: 1) Yes I am aware that the Class.forName is not going to offer a suitable solution to the problem you mention. At the same time there are issues with the class loading strategies available. Ill make sure that a better class loading strategy is used in the next release. 2) Ya, this is true. I typically tend not to expose default compontents in this way, however it may be a good idea to allow extension. 3) Mmm.. I thought this was working, I am sure I have a test case for it. Perhaps I have only supported abstract classes? Certainly an addition that should be there. 4) The Persister is fully thread safe and can be shared without concerns, I will mention it in the javadocs. Thank you for your feedback, Niall --- "A. Rothman" <ami...@am...> wrote: > > Hi, and once again thanx for this great package! > > I've come across a few issues when using the > package: > > 1. When using Simple's jar file in an extension > directory while the > application is in the regular classpath, this > results in a > ClassDefNotFoundException when attempting > deserialization. When > researching the problem, I came across the article > at > http://www.javageeks.com/Papers/ClassForName/ClassForName.pdf > (somewhat > old but still relevant) that explains the problem in > detail and provides > two possible solutions. In a nutshell, calling > Class.forName(name) in > DefaultStrategy uses the classloader that was used > to load the library, > which is the ext classloader, which doesn't see the > classpath. I've > tried replacing this call with both suggested > alternatives, and they > both worked properly: > > type = Class.forName(name, true, > Thread.currentThread().getContextClassLoader()); > > type = Class.forName(name, true, > ClassLoader.getSystemClassLoader()); > > It sounds like the former is the better one, since > it gives the caller > the ability to set a custom classloader as well, but > I'm not sure if > there are other consequences of using one or the > other. In any case, > both worked in my case and allowed deserialization > to complete successfully. > > 2. As a side note, if the DefaultStrategy were > publicly extendable, > making such a fix locally (until it is integrated > into the Simple > distribution) would be quite simple. However, with > the existing > DefaultStrategy, the only way to do this is to copy > the entire class > into a custom strategy with a single-line fix, or, > as I did when testing > the solutions, change the original package and > recompile it. I think > making DefaultStrategy easily extendable would be > the best solution for > making such small tweaks to the default strategy. > > 3. When attempting to serialize an interface or > abstract class (as the > root element), and exception is thrown. However, > making a simple wrapper > class with a single field holding this > interface/abstract class works > correctly by serializing the "class" attribute for > correct > deserialization of the original concrete class. It > would be great if > this were fixed so it worked also on the top level > class without > requiring this redundant wrapper. Note that this > would also enable > deserializing an arbitrary object without knowing > it's type in advance! > > 4. The Persister class javadocs don't specify how it > relates to thread > safety - it can be helpful to specify explicitly > whether a single static > instance can be used from many threads, or each > thread needs its own > Persister instance, etc. > > Thanks again! > > Amichai > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? > Stop. > Now Search log events and configuration files using > AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/> _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=list&sid=396545433 |
|
From: A. R. <ami...@am...> - 2007-08-05 12:19:16
|
Hi, and once again thanx for this great package! I've come across a few issues when using the package: 1. When using Simple's jar file in an extension directory while the application is in the regular classpath, this results in a ClassDefNotFoundException when attempting deserialization. When researching the problem, I came across the article at http://www.javageeks.com/Papers/ClassForName/ClassForName.pdf (somewhat old but still relevant) that explains the problem in detail and provides two possible solutions. In a nutshell, calling Class.forName(name) in DefaultStrategy uses the classloader that was used to load the library, which is the ext classloader, which doesn't see the classpath. I've tried replacing this call with both suggested alternatives, and they both worked properly: type = Class.forName(name, true, Thread.currentThread().getContextClassLoader()); type = Class.forName(name, true, ClassLoader.getSystemClassLoader()); It sounds like the former is the better one, since it gives the caller the ability to set a custom classloader as well, but I'm not sure if there are other consequences of using one or the other. In any case, both worked in my case and allowed deserialization to complete successfully. 2. As a side note, if the DefaultStrategy were publicly extendable, making such a fix locally (until it is integrated into the Simple distribution) would be quite simple. However, with the existing DefaultStrategy, the only way to do this is to copy the entire class into a custom strategy with a single-line fix, or, as I did when testing the solutions, change the original package and recompile it. I think making DefaultStrategy easily extendable would be the best solution for making such small tweaks to the default strategy. 3. When attempting to serialize an interface or abstract class (as the root element), and exception is thrown. However, making a simple wrapper class with a single field holding this interface/abstract class works correctly by serializing the "class" attribute for correct deserialization of the original concrete class. It would be great if this were fixed so it worked also on the top level class without requiring this redundant wrapper. Note that this would also enable deserializing an arbitrary object without knowing it's type in advance! 4. The Persister class javadocs don't specify how it relates to thread safety - it can be helpful to specify explicitly whether a single static instance can be used from many threads, or each thread needs its own Persister instance, etc. Thanks again! Amichai |
|
From: A. R. <am...@am...> - 2007-08-05 12:04:13
|
Hi, and once again thanx for this great package! I've come across a few issues when using the package: 1. When using Simple's jar file in an extension directory while the application is in the regular classpath, this results in a ClassDefNotFoundException when attempting deserialization. When researching the problem, I came across the article at http://www.javageeks.com/Papers/ClassForName/ClassForName.pdf (somewhat old but still relevant) that explains the problem in detail and provides two possible solutions. In a nutshell, calling Class.forName(name) in DefaultStrategy uses the classloader that was used to load the library, which is the ext classloader, which doesn't see the classpath. I've tried replacing this call with both suggested alternatives, and they both worked properly: type = Class.forName(name, true, Thread.currentThread().getContextClassLoader()); type = Class.forName(name, true, ClassLoader.getSystemClassLoader()); It sounds like the former is the better one, since it gives the caller the ability to set a custom classloader as well, but I'm not sure if there are other consequences of using one or the other. In any case, both worked in my case and allowed deserialization to complete successfully. 2. As a side note, if the DefaultStrategy were publicly extendable, making such a fix locally (until it is integrated into the Simple distribution) would be quite simple. However, with the existing DefaultStrategy, the only way to do this is to copy the entire class into a custom strategy with a single-line fix, or, as I did when testing the solutions, change the original package and recompile it. I think making DefaultStrategy easily extendable would be the best solution for making such small tweaks to the default strategy. 3. When attempting to serialize an interface or abstract class (as the root element), and exception is thrown. However, making a simple wrapper class with a single field holding this interface/abstract class works correctly by serializing the "class" attribute for correct deserialization of the original concrete class. It would be great if this were fixed so it worked also on the top level class without requiring this redundant wrapper. Note that this would also enable deserializing an arbitrary object without knowing it's type in advance! 4. The Persister class javadocs don't specify how it relates to thread safety - it can be helpful to specify explicitly whether a single static instance can be used from many threads, or each thread needs its own Persister instance, etc. Thanks again! Amichai |
|
From: Nuno F. <nfa...@is...> - 2007-08-04 18:03:50
|
Hello,
I think Simple framework was an excelent idea. For some years now I have
been trying to find such an easy way to work with XML in Java, and
finally, here it is.
One thing that is missing tough, is the possibility of directly
serializing and deserializing java.util.Map implementing classes
(HashMap, TreeMap, etc), the same way you do with java.util.Collection
classes (ArrayList, HashSet...). There is the Dictionary class, but it's
to limited to my needs, and not exactly what I'm searching for. It is
also possible to use two collection structures and then perform the
necessary binding with Commit, but it's missing the point.
In my case, I have need several complex Map structures, like this for
example:
HashMap<AISSubstance, Double> supSubCon;
The class AISSubstance is annotated with @Root, and several fields are
serializable (with @Element or @Attribute); the Double class is
serialized via Transform. The XML could look something like:
<supSubCon>
<AISSubstance name="whatever">
<BitString>001010001000101</BitString>
<kDif>0.123</kDif>
<kDeg>-0.000234</kDeg>
</AISSubstance>
<double>
1295.1254354
</double>
<AISSubstance name="whatever2">
<BitString>11001010001111101</BitString>
<kDif>0.8231</kDif>
<kDeg>-0.0452486</kDeg>
</AISSubstance>
<double>
99.4336547
</double>
</supSubCon>
I think this could be a very helpful addition to your (already great)
project.
Nuno
|
|
From: Niall G. <gal...@ya...> - 2007-07-30 14:32:19
|
Hi Wolfgang,=0A=0AYou can already use inner classes with simple XML. If you=
are talking about non static inner classes then I will add that to the nex=
t release if you can supply the code to perform this.=0A=0ANiall=0A=0A-----=
Original Message ----=0AFrom: Wolfgang St=F6ttinger (gmx) <w.stoettinger@g=
mx.at>=0ATo: sim...@li...=0ASent: Monday, July 30, =
2007 3:13:51 PM=0ASubject: [Simple-support] Use inner class instead of top =
level class=0A=0A=0A=0A=0A =0A =0A=0A<!--=0A _filtered {font-family:"Cambri=
a Math";panose-1:2 4 5 3 5 4 6 3 2 4;}=0A _filtered {font-family:Calibri;pa=
nose-1:2 15 5 2 2 2 4 3 2 4;}=0A/* Style Definitions */=0A p.MsoNormal, li.=
MsoNormal, div.MsoNormal=0A=09{margin:0cm;margin-bottom:.0001pt;font-size:1=
1.0pt;font-family:"Calibri", "sans-serif";}=0Aa:link, span.MsoHyperlink=0A=
=09{color:blue;text-decoration:underline;}=0Aa:visited, span.MsoHyperlinkFo=
llowed=0A=09{color:purple;text-decoration:underline;}=0Aspan.E-MailFormatvo=
rlage17=0A=09{font-family:"Calibri", "sans-serif";color:windowtext;}=0A.Mso=
ChpDefault=0A=09{}=0A _filtered {margin:70.85pt 70.85pt 2.0cm 70.85pt;}=0Ad=
iv.Section1=0A=09{}=0A-->=0A=0A=0A=0A=0A=0A=0ADear Developers!=0A =0A=0A =
=0A =0A=0AIt would be nice to have inner classes avaliable with simple=0Axm=
l.=0A =0A=0AI need this because i=92d like to keep the number of=0Aclasses =
down.=0A =0A=0A =0A =0A=0AI=92ve allready done it with my version, but it =
would be=0Anice to have it in future versions.=0A =0A=0A =0A =0A=0AKind re=
gards=0A =0A=0A =0A =0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A =0A___________=
_________________________________________________________________________=
=0AGot a little couch potato? =0ACheck out fun summer activities for kids.=
=0Ahttp://search.yahoo.com/search?fr=3Doni_on_mail&p=3Dsummer+activities+fo=
r+kids&cs=3Dbz |
|
From: <w.s...@gm...> - 2007-07-30 14:13:58
|
Dear Developers! =20 It would be nice to have inner classes avaliable with simple xml. I need this because i=92d like to keep the number of classes down. =20 I=92ve allready done it with my version, but it would be nice to have it = in future versions. =20 Kind regards =20 |
|
From: Niall G. <gal...@ya...> - 2007-07-15 01:57:41
|
Hi,
The code you have sketched out would need reified generics, however
Java generics are not reified. As a result the object type parameters
are erased at runtime and you code ends up looking like:
class A {
@ElementList // LINE (1)
List elements; // LINE (2)
A(){
elements = new ArrayList(); // LINE(3)
}
void add(Object t) {
elements.add(t);
}
}
As you can see there is no schema information available here. The only
way to capture generic information is to give it a non template type.
For instance:
class A<T extends Foo> {
@ElementList // LINE (1)
List<Foo> elements; // LINE (2)
A(){
elements = new ArrayList<T>(); // LINE(3)
}
void add(T t) {
elements.add(t);
}
}
Here you can make use of the known type Foo. Of course there are other
ways around this. But unfortunately because of the lack of runtime
generic information it is impossible to acquire T.class.
You may ask why bother finding the class statically, you don't I just
implement it to get Object.getClass() at runtime. This would be great
for serialization, but for deserialization there would be problems as
the resulting XML would not match any available schema definition in
you oject definition.
For info on reified generics and why they suck, look here.
http://gafter.blogspot.com/2006/11/reified-generics-for-java.html
Also, if you have any suggestions on how you think this could be
improved I'd welcome suggestions.
Niall
----- Original Message ----
From: Paulo Fonseca <pau...@gm...>
To: sim...@li...
Sent: Saturday, July 14, 2007 12:00:53 PM
Subject: [Simple-support] problem with generic list
hello,
i'm trying to use simple and so far it's been helpful. however, i'm
facing some difficulty with the problem sketched below:
@Root
class C {
@Element
String data;
C(String data){
this.data=data;
}
}
class A<T> {
@ElementList // LINE (1)
List<T> elements; // LINE (2)
A(){
elements = new ArrayList<T>(); // LINE(3)
}
void add(T t) {
elements.add(t);
}
}
@Root
class B {
@Element
A<C> aC;
B() {
aC = new A<C>();
}
}
public void test() {
B b = new B();
b.aC.add(new C("hello"));
b.aC.add(new C("world"));
Serializer serializer = new Persister();
File dest = new File("test.xml");
try {
serializer.write(b,dest);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
with this code, it throws
org.simpleframework.xml.load.ElementException: Unable to determine
type for @org.simpleframework.xml.ElementList(inline=false, type=void,
required=true, data=false, name=, parent=)
i think i must add some type attribute to LINE (1), but don't know
exactly how to do it.
i also tryed to replace LINE(2) and LINE (3) by
List<Object> elements; // LINE (2*)
elements = new ArrayList<Object>(); // LINE(3*)
but then it gives
org.simpleframework.xml.transform.TransformRequiredException:
Transform memex.common.test.MapSerialisationAdaptorTest$CTransform is
required for class memex.common.test.MapSerialisationAdaptorTest$C
i might be missing something very elementary and i'd really appreciate
if anyone could help me.
thanks in advance,
paulo
-------------------------------------------------------------------------
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
____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
|
|
From: Paulo F. <pau...@gm...> - 2007-07-14 11:00:56
|
hello,
i'm trying to use simple and so far it's been helpful. however, i'm
facing some difficulty with the problem sketched below:
@Root
class C {
@Element
String data;
C(String data){
this.data=data;
}
}
class A<T> {
@ElementList // LINE (1)
List<T> elements; // LINE (2)
A(){
elements = new ArrayList<T>(); // LINE(3)
}
void add(T t) {
elements.add(t);
}
}
@Root
class B {
@Element
A<C> aC;
B() {
aC = new A<C>();
}
}
public void test() {
B b = new B();
b.aC.add(new C("hello"));
b.aC.add(new C("world"));
Serializer serializer = new Persister();
File dest = new File("test.xml");
try {
serializer.write(b,dest);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
with this code, it throws
org.simpleframework.xml.load.ElementException: Unable to determine
type for @org.simpleframework.xml.ElementList(inline=false, type=void,
required=true, data=false, name=, parent=)
i think i must add some type attribute to LINE (1), but don't know
exactly how to do it.
i also tryed to replace LINE(2) and LINE (3) by
List<Object> elements; // LINE (2*)
elements = new ArrayList<Object>(); // LINE(3*)
but then it gives
org.simpleframework.xml.transform.TransformRequiredException:
Transform memex.common.test.MapSerialisationAdaptorTest$CTransform is
required for class memex.common.test.MapSerialisationAdaptorTest$C
i might be missing something very elementary and i'd really appreciate
if anyone could help me.
thanks in advance,
paulo
|
|
From: Niall G. <gal...@ya...> - 2007-06-28 17:13:29
|
Hi, For anyone interested I have released 1.4, this can be downloaded at: http://simple.sourceforge.net/download.php Of from maven using <dependency> <groupId>org.simpleframework</groupId> <artifactId>simple-xml</artifactId> <version>1.4</version> <scope>compile</scope> </dependency> One thing to note is that the package naming has changed from simple.xml to org.simpleframework.xml. Niall ____________________________________________________________________________________ Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool. http://autos.yahoo.com/carfinder/ |
|
From: Serge R. <ser...@gm...> - 2007-06-19 15:08:55
|
> > Hi Nial, It works as a standalone application or a NetBeans plugin. It would be nic= e if someone can write an Eclipse plugin.... And you=B4re correct. I forgot to say that Atabaque DTDtoBean tool is available at http://dtdtobean.sourceforge.net. Serge ------------------------------ > > Message: 3 > Date: Tue, 19 Jun 2007 05:27:26 -0700 (PDT) > From: Niall Gallagher <gal...@ya...> > Subject: Re: [Simple-support] Atabaque DTDtoBean Tool > To: Serge Rehem < ser...@gm...>, > sim...@li... > Message-ID: <265...@we... > > Content-Type: text/plain; charset=3D"iso-8859-1" > > Hi, > > I tried to find it at http://sf.net/projects/atabaque but later realized > that it was located at http://sourceforge.net/projects/dtdtobean/, can it > work with Eclipse? > > Niall > > ----- Original Message ---- > From: Serge Rehem < ser...@gm...> > To: sim...@li... > Sent: Monday, June 18, 2007 10:03:37 PM > Subject: [Simple-support] Atabaque DTDtoBean Tool > > Hi Everybody!!! > > Tired to write Java Beans by hand? > > See the first beta version of Atabaque DTDtoBean, that generates JavaBean= s > from an specified DTD > file. You can choose generate standard Java Beans or using Annotations > for Simple or XStream. It?s available as a > command line, Swing application or NetBeans plugin. > > > > > This project was started from a necessity of Atabaque > project, so that?s the reason for using Atabaque DTDtoBean name. > > > Hope you enjoy and contribute to it! > > []?s > Serge Rehem > > |
|
From: Niall G. <gal...@ya...> - 2007-06-19 12:27:39
|
Hi,=0A=0AI tried to find it at http://sf.net/projects/atabaque but later re= alized that it was located at http://sourceforge.net/projects/dtdtobean/, c= an it work with Eclipse?=0A=0ANiall=0A=0A----- Original Message ----=0AFrom= : Serge Rehem <ser...@gm...>=0ATo: sim...@li...= e.net=0ASent: Monday, June 18, 2007 10:03:37 PM=0ASubject: [Simple-support]= Atabaque DTDtoBean Tool=0A=0AHi Everybody!!!=0A=0ATired to write Java Bean= s by hand? =0A=0ASee the first beta version of Atabaque DTDtoBean, that gen= erates JavaBeans from an specified DTD=0Afile. You can choose generate stan= dard Java Beans or using Annotations=0Afor Simple or XStream. It=B4s availa= ble as a=0Acommand line, Swing application or NetBeans plugin.=0A=0A=0A=0A= =0AThis project was started from a necessity of Atabaque=0Aproject, so that= =B4s the reason for using Atabaque DTDtoBean name. =0A=0A=0AHope you enjoy = and contribute to it!=0A=0A[]=B4s=0ASerge Rehem=0A=0A2007/6/14, simple-supp= ort...@li...=0A <sim...@li...= rge.net>:=0ASend Simple-support mailing list submissions to=0A simpl= e-s...@li...=0A=0ATo subscribe or unsubscribe via the Wo= rld Wide Web, visit=0A=0A https://lists.sourceforge.net/lists/listin= fo/simple-support=0Aor, via email, send a message with subject or body 'hel= p' to=0A =0As...@li...=0A=0AYou ca= n reach the person managing the list at=0A =0Asimple-support-owner@l= ists.sourceforge.net=0A=0AWhen replying, please edit your Subject line so i= t is more specific=0Athan "Re: Contents of Simple-support digest..."=0A=0A= =0AToday's Topics:=0A=0A=0A 1. Re: Element/Attribute Default Values (Nial= l Gallagher)=0A 2. Re: Element/Attribute Default Values (Keith Byrne)=0A= =0A=0A---------------------------------------------------------------------= -=0A=0AMessage: 1=0A=0ADate: Wed, 13 Jun 2007 12:44:05 -0700 (PDT)=0AFrom: = Niall Gallagher <gal...@ya...>=0ASubject: Re: [Simple-support]= Element/Attribute Default Values=0ATo: Niall Gallagher <=0Agallagher_niall= @yahoo.com>, Keith Byrne=0A <ka...@gm...>, =0Asimple-su= pp...@li...=0AMessage-ID: <327...@we...= d.yahoo.com>=0AContent-Type: text/plain; charset=3D"us-ascii"=0A=0A=0AHi,= =0A=0ASimple 1.3.1 has been release with support for null @Attribute and @T= ext 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 ta= ke the following:=0A=0A=0A@Root=0Apublic class Example {=0A=0A @Attribute= (empty=3D"NULL")=0A private String name;=0A=0A @Text(empty=3D"NO TEXT H= ERE")=0A private String value;=0A=0A public Example() {=0A super()= ;=0A=0A }=0A=0A public Example(String name, String value) {=0A thi= s.name =3D name;=0A this.value =3D value;=0A }=0A}=0A=0ASo if Persis= ter.write was used on various instances of the Example class the output wou= ld look like follows:=0A=0A=0A1) new Example(null, null)=0A=0A<example name= =3D"NULL>NO TEXT HERE</example>=0A=0A2) new Example("Some Name", null)=0A= =0A<example name=3D"Some Name">NO TEXT HERE</example>=0A=0A=0A3) new Exampl= e("Some Name", "Some Description")=0A=0A<example name=3D"Some Name">Some De= scription</example>=0A=0ADeserialization will ensure that fields with the n= ull text value will be assigned null. I have not yet had time to add suppor= t for null @Element, @ElementArray, or @ElementList.=0A=0A=0ANiall=0A=0A---= -- Original Message ----=0AFrom: Niall Gallagher <gal...@ya...= >=0ATo: Niall Gallagher <=0Ag...@ya...>; Keith Byrne <kabyrn= e...@gm...>; sim...@li...=0ASent: Tuesday, June 12= , 2007 10:36:56 AM=0A=0ASubject: Re: [Simple-support] Element/Attribute Def= ault Values=0A=0AHi,=0A=0AIn future I hope to add an "empty" attribute to a= ll of the annotations such that empty values can be inserted without having= to bend over backwards to cope with null values. Ill be implementing somet= hing like=0A=0A=0A@Root=0Apublic class MyClass {=0A=0A @Attribute(empty= =3D"NULL")=0A private String example;=0A}=0A=0ASuch that if the field "ex= ample" had a null value it would be written as follows:=0A=0A=0A<myClass ex= ample=3D"NULL"/>=0A=0AThe deserialization process will know to substitute t= he specified value with null when reconstituting the object. For the @Eleme= nt, @ElementList, and @ElementArray annotations the field will be a boolean= like so:=0A=0A=0A@Root=0Apublic class MyOtherClass=0A {=0A=0A @ElementLi= st(empty=3Dtrue)=0A private Collection<String> list;=0A}=0A=0AThe above a= nnotation tells the persister to serialize the empty value such that the re= sult of having a null list would be:=0A=0A=0A<myOtherClass>=0A <list/>=0A= </myOtherClass>=0A=0AWhere as if the annotation was set not to write an emp= ty value the resulting XML would be:=0A=0A<myOtherClass/>=0A=0AThis require= s only very minor changes, so will probably make it in soon enough.=0A=0A= =0ANiall=0A=0A----- Original Message ----=0AFrom: Niall Gallagher <gallaghe= r_...@ya...>=0ATo: Keith Byrne <ka...@gm...=0A>; simple-support= @lists.sourceforge.net=0ASent: Monday, June 11, 2007 10:38:52 PM=0ASubject:= Re: [Simple-support] Element/Attribute Default Values=0A=0A=0AHi,=0A=0AYes= there is a way to intercept, for example:=0A=0Apublic class MyExample {=0A= =0A private static final DEFAULT_VALUE =3D "[[NULL]]";=0A @Element=0A priv= ate String webAddress=0A=0A @Commit=0A private void resolveMyDefault() {= =0A=0A if(webAddress.equals(DEFAULT_VALUE)) {=0A webAddress =3D = null;=0A }=0A }=0A=0A @Persist=0A private void fixMyObject() {=0A = if(webAddress =3D=3D null){=0A webAddress =3D DEFAULT_VALUE:=0A= =0A }=0A }=0A=0A @Complete=0A=0A private void backToNormal() {=0A = resolveMyDefault();=0A }=0A}=0A=0AThis should do the trick, as @Pers= ist gets called just before the object is persisted, and @Complete gets cal= led when its been serialized to the XML document. The @Commit gets called a= fter deserialization so the object values will be reverted to a proper work= ing runtime value.=0A=0A=0AHope this helps.=0ANiall=0A=0A----- Original Mes= sage ----=0AFrom: Keith Byrne <ka...@gm...>=0ATo: simple-support@list= s.sourceforge.net=0A=0ASent: Monday, June 11, 2007 10:33:16 AM=0ASubject: [= Simple-support] Element/Attribute Default Values=0A=0A=0AI have a situation= where a field isn't required, but when it's null and is serialized, the ta= g still needs to show up empty. Specifically, there is a String field (web= Address) that has an Attribute annotation, that went it's null=0A=0A 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?=0A=0A=0A----------------------------------= ---------------------------------------=0A=0AThis SF.net email is sponsored= by DB2 Express=0ADownload DB2 Express C - the FREE version of DB2 express = and take=0Acontrol of your XML. No limits. Just data. Click to get it now.= =0A=0Ahttp://sourceforge.net/powerbar/db2/=0A______________________________= _________________=0ASimple-support mailing lis...@li...= ceforge.net=0A=0Ahttps://lists.sourceforge.net/lists/listinfo/simple-suppor= t=0A=0A=0A=0A=0A=0A=0A=0A Shape Yahoo! in your own image.=0AJoin our N= etwork Research Panel today!=0A=0A-----------------------------------------= --------------------------------=0AThis SF.net email is sponsored by DB2 Ex= press=0ADownload DB2 Express C - the FREE version of DB2 express and take= =0Acontrol of your XML. No limits. Just data. Click to get it now.=0A=0Ahtt= p://sourceforge.net/powerbar/db2/=0A_______________________________________= ________=0ASimple-support mailing lis...@li...= e.net=0Ahttps://lists.sourceforge.net/lists/listinfo/simple-support=0A=0A= =0A=0A=0A=0A=0A=0A Got a little couch potato?=0A=0A=0ACheck out fun su= mmer activities for kids.=0A=0A=0A=0A=0A=0A=0A_____________________________= _______________________________________________________=0ALooking for a dea= l? Find great prices on flights and hotels with Yahoo! FareChase.=0A=0Ahttp= ://farechase.yahoo.com/=0A-------------- next part --------------=0AAn HTML= attachment was scrubbed...=0A=0A------------------------------=0A=0AMessag= e: 2=0ADate: Thu, 14 Jun 2007 12:16:06 -0400=0A=0AFrom: "Keith Byrne" <kaby= rn...@gm...>=0ASubject: Re: [Simple-support] Element/Attribute Default Va= lues=0ATo: "Niall Gallagher" <=0Ag...@ya...>=0ACc: simple-su= pp...@li...=0AMessage-ID:=0A <=0A5336fd4d0706140916w= 558...@ma...>=0AContent-Type: text/plain; chars= et=3D"iso-8859-1"=0A=0AThanks, this is great. I look forward to the suppor= t the @Element=0Aannotations.=0A=0A=0AOn 6/13/07, Niall Gallagher <gallaghe= r_...@ya...> wrote:=0A>=0A> Hi,=0A>=0A> Simple 1.3.1 has been release= with support for null @Attribute and @Text=0A=0A> values. This means that = within the XML document the Java null value can be=0A> represented in a tex= tual manner within the XML document. For example take=0A> the following:=0A= >=0A> @Root=0A> public class Example {=0A=0A>=0A> @Attribute(empty=3D"NU= LL")=0A> private String name;=0A>=0A> @Text(empty=3D"NO TEXT HERE")= =0A> private String value;=0A>=0A> public Example() {=0A> super= ();=0A=0A> }=0A>=0A> public Example(String name, String value) {=0A> = this.name =3D name;=0A> this.value =3D value;=0A> }=0A> }=0A= >=0A> So if Persister.write=0A was used on various instances of the Example= class=0A> the output would look like follows:=0A>=0A> 1) new Example(null,= null)=0A>=0A> <example name=3D"NULL>NO TEXT HERE</example>=0A>=0A=0A> 2) n= ew Example("Some Name", null)=0A>=0A> <example name=3D"Some Name">NO TEXT H= ERE</example>=0A>=0A> 3) new Example("Some Name", "Some Description")=0A=0A= >=0A> <example name=3D"Some Name">Some Description</example>=0A>=0A> Deseri= alization will ensure that fields with the null text value will be=0A> assi= gned null. I have not yet had time to add support for null @Element,=0A=0A>= @ElementArray, or @ElementList.=0A>=0A> Niall=0A>=0A> ----- Original Messa= ge ----=0A> From: Niall Gallagher <gal...@ya...>=0A=0A> To: Ni= all Gallagher <gal...@ya...>; Keith Byrne <=0A> kabyrne@gmail.= com>; =0As...@li...=0A> Sent: Tuesday, June 12, 2= 007 10:36:56 AM=0A> Subject: Re: [Simple-support] Element/Attribute Default= Values=0A>=0A> Hi,=0A>=0A> In future I hope to add an "empty" attribute to= all of the annotations=0A=0A> such that empty values can be inserted witho= ut having to bend over backwards=0A> to cope with null values. Ill be imple= menting something like=0A>=0A> @Root=0A> public class MyClass {=0A>=0A> = @Attribute(empty=3D"NULL")=0A=0A> private String example;=0A> }=0A>=0A> = Such that if the field "example" had a null value it would be written as=0A= > follows:=0A>=0A> <myClass example=3D"NULL"/>=0A=0A>=0A> The deserializati= on process will know to substitute the specified value=0A> with null when r= econstituting the object. For the @Element, @ElementList,=0A> and @ElementA= rray annotations the field will be a boolean like so:=0A=0A>=0A> @Root=0A> = public class MyOtherClass {=0A>=0A> @ElementList(empty=3Dtrue)=0A> pr= ivate Collection<String> list;=0A> }=0A>=0A> The above annotation tells the= persister to serialize the empty value such=0A=0A> that the result of havi= ng a null list would be:=0A>=0A> <myOtherClass>=0A> <list/>=0A> </myOthe= rClass>=0A>=0A> Where as if the annotation was set not to write an empty va= lue the=0A=0A> resulting XML would be:=0A>=0A> <myOtherClass/>=0A>=0A> This= requires only very minor changes, so will probably make it in soon=0A> eno= ugh.=0A>=0A> Niall=0A>=0A> ----- Original Message ----=0A=0A> From: Niall G= allagher <gal...@ya...>=0A> To: Keith Byrne <ka...@gm...= >; =0As...@li...=0A> Sent: Monday, June 11, 2007 = 10:38:52 PM=0A> Subject: Re: [Simple-support] Element/Attribute Default Val= ues=0A>=0A> Hi,=0A>=0A> Yes there is a way to intercept, for example:=0A=0A= >=0A> public class MyExample {=0A>=0A> private static final DEFAULT_VALUE = =3D "[[NULL]]";=0A> @Element=0A> private String webAddress=0A>=0A> @Co= mmit=0A> private void resolveMyDefault() {=0A=0A> if(webAddress.equa= ls(DEFAULT_VALUE)) {=0A> webAddress =3D null;=0A> }=0A> }=0A>= =0A> @Persist=0A> private void fixMyObject() {=0A> if(webAddress= =3D=3D null){=0A=0A> webAddress =3D DEFAULT_VALUE:=0A> }=0A= > }=0A>=0A> @Complete=0A> private void backToNormal() {=0A> = resolveMyDefault();=0A> }=0A> }=0A>=0A> This should do the trick, as @Pe= rsist gets called just before the object=0A=0A> is persisted, and @Complete= gets called when its been serialized to the XML=0A> document. The @Commit = gets called after deserialization so the object values=0A> will be reverted= to a proper working runtime value.=0A=0A>=0A> Hope this helps.=0A> Niall= =0A>=0A> ----- Original Message ----=0A> From: Keith Byrne <kabyrne@gmail.c= om>=0A> To: =0As...@li...=0A> Sent: Monday, June = 11, 2007 10:33:16 AM=0A> Subject: [Simple-support] Element/Attribute Defaul= t Values=0A>=0A>=0A> I have a situation where a field isn't required, but w= hen it's null and is=0A=0A> serialized, the tag still needs to show up empt= y. Specifically, there is a=0A> String field (webAddress) that has an Attr= ibute annotation, that went it's=0A> null should be serialized to <webAddre= ss/>, instead of not showing up. Is=0A=0A> there a way to intercept the se= rializing of an Element/Attribute, and based=0A> upon it's type, serialize = a default value?=0A> ------------------------------------------------------= -------------------=0A=0A> This SF.net email is sponsored by DB2 Express=0A= > Download DB2 Express C - the FREE version of DB2 express and take=0A> con= trol of your XML. No limits. Just data. Click to get it now.=0A> =0Ahttp://= sourceforge.net/powerbar/db2/=0A> _________________________________________= ______=0A> Simple-support mailing list=0A> Sim...@li...= .net=0A=0A> https://lists.sourceforge.net/lists/listinfo/simple-support=0A>= =0A>=0A> ------------------------------=0A> Shape Yahoo! in your own image.= Join our Network Research Panel today!<=0Ahttp://us.rd.yahoo.com/evt=3D485= 17/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=3D7>=0A> ----= ---------------------------------------------------------------------=0A=0A= > This SF.net email is sponsored by DB2 Express=0A> Download DB2 Express C = - the FREE version of DB2 express and take=0A> control of your XML. No limi= ts. Just data. Click to get it now.=0A> =0Ahttp://sourceforge.net/powerbar/= db2/=0A> _______________________________________________=0A> Simple-support= mailing list=0A> Sim...@li...=0A=0A> https://lists= .sourceforge.net/lists/listinfo/simple-support=0A>=0A>=0A> ----------------= --------------=0A> Got a little couch potato?=0A=0A> Check out fun summer a= ctivities for kids.<http://us.rd.yahoo.com/evt=3D48248/*http://search.yahoo= .com/search?fr=3Doni_on_mail&p=3Dsummer+activities+for+kids&cs=3Dbz=0A>=0A>= =0A>=0A> ------------------------------=0A> Sick sense of humor? Visit Yaho= o! TV's Comedy with an Edge=0A> <=0Ahttp://us.rd.yahoo.com/evt=3D47093/*htt= p://tv.yahoo.com/collections/222>to=0A> see what's on, when.=0A>=0A--------= ------ next part --------------=0AAn HTML attachment was scrubbed...=0A=0A-= -----------------------------=0A=0A=0A-------------------------------------= ------------------------------------=0AThis SF.net email is sponsored by DB= 2 Express=0ADownload DB2 Express C - the FREE version of DB2 express and ta= ke=0Acontrol of your XML. No limits. Just data. Click to get it now.=0A=0Ah= ttp://sourceforge.net/powerbar/db2/=0A=0A------------------------------=0A= =0A_______________________________________________=0ASimple-support mailing= lis...@li...=0Ahttps://lists.sourceforge= .net/lists/listinfo/simple-support=0A=0A=0AEnd of Simple-support Digest, Vo= l 3, Issue 5=0A=0A********************************************=0A=0A=0A=0A-= ------------------------------------------------------------------------=0A= This SF.net email is sponsored by DB2 Express=0ADownload DB2 Express C - th= e FREE version of DB2 express and take=0Acontrol of your XML. No limits. Ju= st data. Click to get it now.=0Ahttp://sourceforge.net/powerbar/db2/=0A____= ___________________________________________=0ASimple-support mailing list= =0AS...@li...=0Ahttps://lists.sourceforge.net/lis= ts/listinfo/simple-support=0A=0A=0A=0A=0A=0A=0A=0A ___________________= _________________________________________________________________=0ALuggage= ? GPS? Comic books? =0ACheck out fitting gifts for grads at Yahoo! Search= =0Ahttp://search.yahoo.com/search?fr=3Doni_on_mail&p=3Dgraduation+gifts&cs= =3Dbz |
|
From: Niall G. <gal...@ya...> - 2007-06-19 07:44:08
|
Hi,
With regard to the @Root annotation it is currently an optional annotation. What it does is tell the serialization process what the root element name of the object should be. For example take the following objects:
@
public class First {
}
public class Second extends First {
}
@Root
public class Third extends Second {
}
If I serialize these objects the following is created:
1) new First()
<first/>
2) new Second()
<first/>
3) new Third()
<third/>
So here the @Root annotation tells the persistence engine what the root element will be. Also, it is used to specify overrides if required:
@Root(name="myRoot")
public class SomeLongNameNotToBeUsedAsAnElementName {
}
This results in:
<myRoot/>
Finally, you can specify the parsing mode for the object using the strict attribute:
@Root(name="myName", strict=true)
public class LooseMatchObject {
}
This allows the object to match only certain parts of the XML document, meaning that you do not need to write a complete object representation of the XML.
With regard to the requirement for an annotation on serializable fields and methods this was taken because I believe for all but the most trivial of objects, you are going to need to specify meta data. For example an @Element annotation may be optional, or require CDATA externalization, I think it would be more confusing to see an object with @Element and @Attribute annotations on some fields and nothing on others, it is not immediately obvious to the reader of your code what the external representation of your object is.
Also, I feel that the @ElementList is one of the most common annotations used, the @Element annotation serializes in a different manner, again I feel that seeing an object with a mixture of annotated and unannotated fields would make the XML schema of the class less obvious.
Although I can fully appreciate your comments, it is obviously an attractive option to have your POJOs serializable without modification, I feel annotations are nessecary. One of the primary goals of this project from the outset is that there was a single entity representing everything, the annotated object represents the XML schema. So there are no external mapping files to maintain and refactor, no mapping classes etc. Just a single object and a single point of refactoring, I have found that this helped me develop quickly.
Thanks for the feedback, any suggestions on how the framework could be modified/improved are appreciated.
Niall
----- Original Message ----
From: Travis Reeder <tr...@gm...>
To: sim...@li...
Sent: Tuesday, June 19, 2007 7:35:01 AM
Subject: [Simple-support] Beginner Questions
Hi,
I just came across your project and it looks very interesting indeed. A few questions/comments:
- Why is the @Root required? It looks like you have to always use it which means that it's not really useful. Unless I'm missing something.
- I also noticed that if you don't use the @Attribute or @Element, then the field is not serialized. It would be a lot more user friendly to include all fields, probably defaulting to @Element, and the use the annotations to exclude the ones you don't want with something similar to JPA's @Transient or change the way it's serialized with @Attribute.
I have to admit that as soon as I saw that you must have all these annotations, my interest decreased. It seems to me the default could work out of the box with no annotations like XStream and you only add annotations to modify that default behaviour. Rather than the current behaviour of doing nothing unless you add annotations.
Just my 2 cents.
Travis
-------------------------------------------------------------------------
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
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html |
|
From: Travis R. <tr...@gm...> - 2007-06-19 06:35:03
|
Hi, I just came across your project and it looks very interesting indeed. A few questions/comments: - Why is the @Root required? It looks like you have to always use it which means that it's not really useful. Unless I'm missing something. - I also noticed that if you don't use the @Attribute or @Element, then the field is not serialized. It would be a lot more user friendly to include all fields, probably defaulting to @Element, and the use the annotations to exclude the ones you don't want with something similar to JPA's @Transient or change the way it's serialized with @Attribute. I have to admit that as soon as I saw that you must have all these annotations, my interest decreased. It seems to me the default could work out of the box with no annotations like XStream and you only add annotations to modify that default behaviour. Rather than the current behaviour of doing nothing unless you add annotations. Just my 2 cents. Travis |
|
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 > ******************************************** > |
|
From: Keith B. <ka...@gm...> - 2007-06-14 16:16:09
|
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 @Text
> 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="NULL")
> private String name;
>
> @Text(empty="NO TEXT HERE")
> private String value;
>
> public Example() {
> super();
> }
>
> public Example(String name, String value) {
> this.name = name;
> this.value = 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="NULL>NO TEXT HERE</example>
>
> 2) new Example("Some Name", null)
>
> <example name="Some Name">NO TEXT HERE</example>
>
> 3) new Example("Some Name", "Some Description")
>
> <example name="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 backwards
> to cope with null values. Ill be implementing something like
>
> @Root
> public class MyClass {
>
> @Attribute(empty="NULL")
> private String example;
> }
>
> Such that if the field "example" had a null value it would be written as
> follows:
>
> <myClass example="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=true)
> 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 = "[[NULL]]";
> @Element
> private String webAddress
>
> @Commit
> private void resolveMyDefault() {
> if(webAddress.equals(DEFAULT_VALUE)) {
> webAddress = null;
> }
> }
>
> @Persist
> private void fixMyObject() {
> if(webAddress == null){
> webAddress = 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 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=48517/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7>
> -------------------------------------------------------------------------
> 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=48248/*http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz>
>
>
> ------------------------------
> Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge
> <http://us.rd.yahoo.com/evt=47093/*http://tv.yahoo.com/collections/222>to
> see what's on, when.
>
|