simple-support Mailing List for Simple (Page 78)
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: Filip P. <fil...@ev...> - 2007-12-11 16:47:05
|
Bug in scattered inlined elements:
When using scattered inlined elements, the set(List list) method is =
called once only containing the first Element that is found. See the =
below test case:
Possible fix: Call the set(List list) method only after alla element in =
the list has been added.
import java.util.LinkedList;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.load.Persister;
@Root(name=3D"t")
public class InlinePrimitiveList {
public static boolean showBug;
=20
@Element String name;
private List<String> data =3D new LinkedList<String>();
=20
@ElementList(inline=3Dtrue)
void setList(List<String> list) {
if(showBug) {
data =3D new LinkedList(list);
} else {
data =3D list;
}
}
=20
@ElementList(inline=3Dtrue)
List<String> getList() {
return data;
}
=20
public String toString() {
return " name: " + name + " " + data;
}
=20
public static void main(String[] args) throws Exception {
showBug =3D false;
test();
showBug =3D true;
test();
}
=20
private static void test() throws Exception {
System.out.println("Object: " + new =
Persister().read(InlinePrimitiveList.class, =
"<t><string>1</string><name>a</name><string>2</string></t>"));
}
=20
}
/Filip Perlhagen
|
|
From: Niall G. <gal...@ya...> - 2007-12-10 22:57:51
|
Hi, Take a look at the following unit test. http://simple.svn.sourceforge.net/viewvc/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/load/SubstituteTest.java This shows the @Replace and @Resolve methods working. The reason you could not get your test to run is because the very root Class within the schema cannot be replaced, only fields of a composite class. For instance if the class schema you defined was a field of some other class then it would replace fine. With respect to you global property suggestion, why not just use the session map to pass information about, it will be passed to the @Persist and @Complete annotated methods. For example: @Persist private void persistMe(Map session) { // use session here before serialization... } @Complete private void completeMe(Map session) { // use the session here after serialization... } This is just one way, there are tonnes of other ways this can be done. Niall --- Ben Wolfe <si...@be...> wrote: > > I can't seem to get the Replace method to work. > I've attached a test > method to demonstrate. Perhaps you can show me what > I'm doing wrong. :-/ > > The @Replace/@Resolve methods have promise, but I > still don't see a way > for the person serializing to trigger it. The > closest solution would be > if "someProperty" in your example below were > actually a global property > set/retrieved via a call to a util class. However, > our code is running > on a server, and it is quite possible that multiple > serializations will > be happening at the same time -- some "primary key > only" and some full. > > >public Object myResolveMethod() { > > if(someProperty) { > > return new SomeOtherObject(myProperty1, > myProperty2); > > } > > return this; // Here I am saying don't read > resolve > >} > > I have coded up the tags possibility. I can submit > a patch if you're > interested. :-) > > Ben > > Niall Gallagher wrote: > > Hi, > > > > Forgot to explain the following code snippit. This > > demonstrates how an @Replace method could be used > > instead of a @Resolve. The @Replace is used in > > writing, it is similar to Java object > serialization > > writeReplace. > > > > @Root > > public class SomeObject { > > > > @Element(required=false) > > private String text; > > > > @Attribute(required=false) > > private int version; > > > > @Attribute > > private String key; > > > > public SomeObject() { > > super(); > > } > > > > public SomeObject(String key) { > > this.key = key; > > } > > > > @Validate > > public void validate() { > > // do some validation here... > > } > > > > @Replace > > private Object writeReplace() { > > return new SomeObject(key); // Here I > provide > > the same type with a subset of the properties > > } > > } > > > > You could also use the @Persist and @Complete, the > > method annotated with @Persist is called just > before > > serialization of the object, and @Complete is > called > > directly after. So you can modify the contents of > the > > object before it is serialized and bring the > object > > back to a known state when you have finished > > serializing it. So you get a chance to modify the > > object for serialization, there is an example in > the > > tutorial. > > > > Niall > > > > --- Niall Gallagher <gal...@ya...> > wrote: > > > >> Hi, > >> > >> This will give you both worlds. Why not do the > >> following: > >> > >> public Object myResolveMethod() { > >> if(someProperty) { > >> return new SomeOtherObject(myProperty1, > >> myProperty2); > >> } > >> return this; // Here I am saying don't read > >> resolve > >> } > >> > >> When you return "this" from the method annotated > >> with > >> @Resolve annotation you are saying not to resolve > to > >> something different. Also, you don't need to > return > >> a > >> different type. > >> > >> > >> @Root > >> public class SomeObject { > >> > >> @Element(required=false) > >> private String text; > >> > >> @Attribute(required=false) > >> private int version; > >> > >> @Attribute > >> private String key; > >> > >> public SomeObject() { > >> super(); > >> } > >> > >> public SomeObject(String key) { > >> this.key = key; > >> } > >> > >> @Validate > >> public void validate() { > >> // do some validation here... > >> } > >> > >> @Replace > >> private Object writeReplace() { > >> return new SomeObject(key); // Here I > provide > >> the same type with a subset of the properties > >> } > >> } > >> > >> Hope this helps. > >> > >> Niall > >> > >> > >> --- Ben Wolfe <si...@be...> wrote: > >> > >>> I'm not sure this will work for me. I want to > >> have > >>> both worlds. I want > >>> to be able to serialize our objects to just > their > >>> primary keys sometimes > >>> and at others be able to serialize all > >> @Attributes, > >>> @Elements, etc on > >>> the object to xml. > >>> > >>> Ben > >>> > >>> Niall Gallagher wrote: > >>>> Hi, > >>>> > >>>> There is a way you could do this, don't know > how > >>> well > >>>> it would suit you. But the @Resolve and > @Replace > >>>> annotations are used in situations like this. > >>> Anything > >>>> you can do with the readResolve and > writeReplace > >>> for > >>>> conventional object serialization can be done > >> with > >>>> these annotations. Here is an example of what > >> you > >>>> might do. > >>>> > >>>> > >>>> @Root > >>>> public class CompleteObject { > >>>> > >>>> @Attribute > >>>> private String name; > >>>> > >>>> @Element > === message truncated ===> package org.simpleframework.xml.load; > > import java.io.StringWriter; > > import org.simpleframework.xml.Attribute; > import org.simpleframework.xml.Element; > import org.simpleframework.xml.Root; > import org.simpleframework.xml.ValidationTestCase; > > /** > * > */ > public class ReplaceTest extends ValidationTestCase > { > > private static final String exampleReplaceMethod > = "<example exampleId=\"123\"/>"; > > @Root > private static class Example { > > public Example(Integer exampleId) { > this.exampleId = exampleId; > } > > @Element(required=false) > private String exampleMessage; > > @Attribute(required=false) > private Integer exampleId; > > @Replace > private Object exampleReplaceMethod() { > return new Example(exampleId); > } > } > > /** > * This method tests the replace method > * > * @throws Exception > */ > public void testReplaceExample() throws Exception { > > Persister persister = new Persister(); > Example ex = new Example(123); > ex.exampleMessage = "test"; > > StringWriter buffer = new StringWriter(); > persister.write(ex, buffer); > > assertEquals("The serialization is not > right.", exampleReplaceMethod, buffer.toString()); > > validate(ex, persister); > > } > > } > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php> _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
|
From: Ben W. <si...@be...> - 2007-12-10 22:34:39
|
I can't seem to get the Replace method to work. I've attached a test
method to demonstrate. Perhaps you can show me what I'm doing wrong. :-/
The @Replace/@Resolve methods have promise, but I still don't see a way
for the person serializing to trigger it. The closest solution would be
if "someProperty" in your example below were actually a global property
set/retrieved via a call to a util class. However, our code is running
on a server, and it is quite possible that multiple serializations will
be happening at the same time -- some "primary key only" and some full.
>public Object myResolveMethod() {
> if(someProperty) {
> return new SomeOtherObject(myProperty1, myProperty2);
> }
> return this; // Here I am saying don't read resolve
>}
I have coded up the tags possibility. I can submit a patch if you're
interested. :-)
Ben
Niall Gallagher wrote:
> Hi,
>
> Forgot to explain the following code snippit. This
> demonstrates how an @Replace method could be used
> instead of a @Resolve. The @Replace is used in
> writing, it is similar to Java object serialization
> writeReplace.
>
> @Root
> public class SomeObject {
>
> @Element(required=false)
> private String text;
>
> @Attribute(required=false)
> private int version;
>
> @Attribute
> private String key;
>
> public SomeObject() {
> super();
> }
>
> public SomeObject(String key) {
> this.key = key;
> }
>
> @Validate
> public void validate() {
> // do some validation here...
> }
>
> @Replace
> private Object writeReplace() {
> return new SomeObject(key); // Here I provide
> the same type with a subset of the properties
> }
> }
>
> You could also use the @Persist and @Complete, the
> method annotated with @Persist is called just before
> serialization of the object, and @Complete is called
> directly after. So you can modify the contents of the
> object before it is serialized and bring the object
> back to a known state when you have finished
> serializing it. So you get a chance to modify the
> object for serialization, there is an example in the
> tutorial.
>
> Niall
>
> --- Niall Gallagher <gal...@ya...> wrote:
>
>> Hi,
>>
>> This will give you both worlds. Why not do the
>> following:
>>
>> public Object myResolveMethod() {
>> if(someProperty) {
>> return new SomeOtherObject(myProperty1,
>> myProperty2);
>> }
>> return this; // Here I am saying don't read
>> resolve
>> }
>>
>> When you return "this" from the method annotated
>> with
>> @Resolve annotation you are saying not to resolve to
>> something different. Also, you don't need to return
>> a
>> different type.
>>
>>
>> @Root
>> public class SomeObject {
>>
>> @Element(required=false)
>> private String text;
>>
>> @Attribute(required=false)
>> private int version;
>>
>> @Attribute
>> private String key;
>>
>> public SomeObject() {
>> super();
>> }
>>
>> public SomeObject(String key) {
>> this.key = key;
>> }
>>
>> @Validate
>> public void validate() {
>> // do some validation here...
>> }
>>
>> @Replace
>> private Object writeReplace() {
>> return new SomeObject(key); // Here I provide
>> the same type with a subset of the properties
>> }
>> }
>>
>> Hope this helps.
>>
>> Niall
>>
>>
>> --- Ben Wolfe <si...@be...> wrote:
>>
>>> I'm not sure this will work for me. I want to
>> have
>>> both worlds. I want
>>> to be able to serialize our objects to just their
>>> primary keys sometimes
>>> and at others be able to serialize all
>> @Attributes,
>>> @Elements, etc on
>>> the object to xml.
>>>
>>> Ben
>>>
>>> Niall Gallagher wrote:
>>>> Hi,
>>>>
>>>> There is a way you could do this, don't know how
>>> well
>>>> it would suit you. But the @Resolve and @Replace
>>>> annotations are used in situations like this.
>>> Anything
>>>> you can do with the readResolve and writeReplace
>>> for
>>>> conventional object serialization can be done
>> with
>>>> these annotations. Here is an example of what
>> you
>>>> might do.
>>>>
>>>>
>>>> @Root
>>>> public class CompleteObject {
>>>>
>>>> @Attribute
>>>> private String name;
>>>>
>>>> @Element
>>>> private String id;
>>>>
>>>> @Element
>>>> private Stirng address;
>>>>
>>>> public CompleteObject() {
>>>> super();
>>>> }
>>>>
>>>> public CompleteObject(String name, String id)
>> {
>>>> this.name = name;
>>>> this.id = id;
>>>> }
>>>>
>>>> @Replace
>>>> private Object getPrimaryKey() {
>>>> return new PrimaryKey(name, id);
>>>> }
>>>>
>>>> @Root
>>>> private static class PrimaryKey {
>>>>
>>>> @Attribute
>>>> private String name;
>>>>
>>>> @Element
>>>> private String id;
>>>>
>>>> public PrimaryKey() {
>>>> super();
>>>> }
>>>>
>>>> public PrimaryKey(String name, String id)
>> {
>>>> this.name = name;
>>>> this.id = id;
>>>> }
>>>>
>>>> @Resolve
>>>> private Object getCompleteObject() {
>>>> return new CompleteObject(name, id);
>>
>>>
>>>>
>>>> }
>>>> }
>>>> }
>>>>
>>>> If you pair this with a custom Strategy
>>> implementation
>>>> then you can ensure the class="" attributes can
>> be
>>>> replaced with other tokens to indicate what
>>> objects to
>>>> use. This above example is obviously not very
>>> useful,
>>>> but when used properly @Replace and @Resolve can
>>> be
>>>> quite powerful.
>>>>
>>>> Niall
>>>>
>>>> --- Ben Wolfe <si...@be...> wrote:
>>>>
>>>>> We have several places in our code where we
>> could
>>>>> benefit from a shorter
>>>>> serialization. We don't need to serialize the
>>>>> entire object, just the
>>>>> primary keys of the object.
>>>>>
>>>>> I haven't been able to find a way to do this
>> yet.
>>>>> Did I miss something?
>>>>> Is there a way to do it currently?
>>>>>
>>>>> My thoughts on how to implement it:
>>>>>
>>>>> The primary key attributes/elements would need
>> to
>>> be
>>>>> annotated. The
>>>>> most general way to do it would be to add a
>>> String
>>>>> "tag" option to the
>>>>> "Attribute" and "Element" annotations. The tag
>>>>> would be a string that
>>>>> groups certain attributes together and can be
>>> used
>>>>> later.
>>>>> I don't know why it would be necessary right
>> now,
>>>>> but we could have any
>>>>> number of "sets of serializations" with any
>> named
>>>>> tag we want: A "Short"
>>>>> one that would (de)derialize to just the
>> primary
>>>>> keys, a "medium" one
>>>>> that would (de)serialize to only certain
>>> attributes,
> === message truncated ===
>
>
>
> ____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
|
|
From: Niall G. <gal...@ya...> - 2007-12-10 19:49:28
|
Hi,
Forgot to explain the following code snippit. This
demonstrates how an @Replace method could be used
instead of a @Resolve. The @Replace is used in
writing, it is similar to Java object serialization
writeReplace.
@Root
public class SomeObject {
@Element(required=false)
private String text;
@Attribute(required=false)
private int version;
@Attribute
private String key;
public SomeObject() {
super();
}
public SomeObject(String key) {
this.key = key;
}
@Validate
public void validate() {
// do some validation here...
}
@Replace
private Object writeReplace() {
return new SomeObject(key); // Here I provide
the same type with a subset of the properties
}
}
You could also use the @Persist and @Complete, the
method annotated with @Persist is called just before
serialization of the object, and @Complete is called
directly after. So you can modify the contents of the
object before it is serialized and bring the object
back to a known state when you have finished
serializing it. So you get a chance to modify the
object for serialization, there is an example in the
tutorial.
Niall
--- Niall Gallagher <gal...@ya...> wrote:
> Hi,
>
> This will give you both worlds. Why not do the
> following:
>
> public Object myResolveMethod() {
> if(someProperty) {
> return new SomeOtherObject(myProperty1,
> myProperty2);
> }
> return this; // Here I am saying don't read
> resolve
> }
>
> When you return "this" from the method annotated
> with
> @Resolve annotation you are saying not to resolve to
> something different. Also, you don't need to return
> a
> different type.
>
>
> @Root
> public class SomeObject {
>
> @Element(required=false)
> private String text;
>
> @Attribute(required=false)
> private int version;
>
> @Attribute
> private String key;
>
> public SomeObject() {
> super();
> }
>
> public SomeObject(String key) {
> this.key = key;
> }
>
> @Validate
> public void validate() {
> // do some validation here...
> }
>
> @Replace
> private Object writeReplace() {
> return new SomeObject(key); // Here I provide
> the same type with a subset of the properties
> }
> }
>
> Hope this helps.
>
> Niall
>
>
> --- Ben Wolfe <si...@be...> wrote:
>
> >
> > I'm not sure this will work for me. I want to
> have
> > both worlds. I want
> > to be able to serialize our objects to just their
> > primary keys sometimes
> > and at others be able to serialize all
> @Attributes,
> > @Elements, etc on
> > the object to xml.
> >
> > Ben
> >
> > Niall Gallagher wrote:
> > > Hi,
> > >
> > > There is a way you could do this, don't know how
> > well
> > > it would suit you. But the @Resolve and @Replace
> > > annotations are used in situations like this.
> > Anything
> > > you can do with the readResolve and writeReplace
> > for
> > > conventional object serialization can be done
> with
> > > these annotations. Here is an example of what
> you
> > > might do.
> > >
> > >
> > > @Root
> > > public class CompleteObject {
> > >
> > > @Attribute
> > > private String name;
> > >
> > > @Element
> > > private String id;
> > >
> > > @Element
> > > private Stirng address;
> > >
> > > public CompleteObject() {
> > > super();
> > > }
> > >
> > > public CompleteObject(String name, String id)
> {
> > > this.name = name;
> > > this.id = id;
> > > }
> > >
> > > @Replace
> > > private Object getPrimaryKey() {
> > > return new PrimaryKey(name, id);
> > > }
> > >
> > > @Root
> > > private static class PrimaryKey {
> > >
> > > @Attribute
> > > private String name;
> > >
> > > @Element
> > > private String id;
> > >
> > > public PrimaryKey() {
> > > super();
> > > }
> > >
> > > public PrimaryKey(String name, String id)
> {
> > > this.name = name;
> > > this.id = id;
> > > }
> > >
> > > @Resolve
> > > private Object getCompleteObject() {
> > > return new CompleteObject(name, id);
>
> >
> > >
> > > }
> > > }
> > > }
> > >
> > > If you pair this with a custom Strategy
> > implementation
> > > then you can ensure the class="" attributes can
> be
> > > replaced with other tokens to indicate what
> > objects to
> > > use. This above example is obviously not very
> > useful,
> > > but when used properly @Replace and @Resolve can
> > be
> > > quite powerful.
> > >
> > > Niall
> > >
> > > --- Ben Wolfe <si...@be...> wrote:
> > >
> > >> We have several places in our code where we
> could
> > >> benefit from a shorter
> > >> serialization. We don't need to serialize the
> > >> entire object, just the
> > >> primary keys of the object.
> > >>
> > >> I haven't been able to find a way to do this
> yet.
> >
> > >> Did I miss something?
> > >> Is there a way to do it currently?
> > >>
> > >> My thoughts on how to implement it:
> > >>
> > >> The primary key attributes/elements would need
> to
> > be
> > >> annotated. The
> > >> most general way to do it would be to add a
> > String
> > >> "tag" option to the
> > >> "Attribute" and "Element" annotations. The tag
> > >> would be a string that
> > >> groups certain attributes together and can be
> > used
> > >> later.
> > >> I don't know why it would be necessary right
> now,
> > >> but we could have any
> > >> number of "sets of serializations" with any
> named
> > >> tag we want: A "Short"
> > >> one that would (de)derialize to just the
> primary
> > >> keys, a "medium" one
> > >> that would (de)serialize to only certain
> > attributes,
>
=== message truncated ===
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
|
|
From: Niall G. <gal...@ya...> - 2007-12-10 19:43:05
|
Hi,
This will give you both worlds. Why not do the
following:
public Object myResolveMethod() {
if(someProperty) {
return new SomeOtherObject(myProperty1,
myProperty2);
}
return this; // Here I am saying don't read resolve
}
When you return "this" from the method annotated with
@Resolve annotation you are saying not to resolve to
something different. Also, you don't need to return a
different type.
@Root
public class SomeObject {
@Element(required=false)
private String text;
@Attribute(required=false)
private int version;
@Attribute
private String key;
public SomeObject() {
super();
}
public SomeObject(String key) {
this.key = key;
}
@Validate
public void validate() {
// do some validation here...
}
@Replace
private Object writeReplace() {
return new SomeObject(key); // Here I provide
the same type with a subset of the properties
}
}
Hope this helps.
Niall
--- Ben Wolfe <si...@be...> wrote:
>
> I'm not sure this will work for me. I want to have
> both worlds. I want
> to be able to serialize our objects to just their
> primary keys sometimes
> and at others be able to serialize all @Attributes,
> @Elements, etc on
> the object to xml.
>
> Ben
>
> Niall Gallagher wrote:
> > Hi,
> >
> > There is a way you could do this, don't know how
> well
> > it would suit you. But the @Resolve and @Replace
> > annotations are used in situations like this.
> Anything
> > you can do with the readResolve and writeReplace
> for
> > conventional object serialization can be done with
> > these annotations. Here is an example of what you
> > might do.
> >
> >
> > @Root
> > public class CompleteObject {
> >
> > @Attribute
> > private String name;
> >
> > @Element
> > private String id;
> >
> > @Element
> > private Stirng address;
> >
> > public CompleteObject() {
> > super();
> > }
> >
> > public CompleteObject(String name, String id) {
> > this.name = name;
> > this.id = id;
> > }
> >
> > @Replace
> > private Object getPrimaryKey() {
> > return new PrimaryKey(name, id);
> > }
> >
> > @Root
> > private static class PrimaryKey {
> >
> > @Attribute
> > private String name;
> >
> > @Element
> > private String id;
> >
> > public PrimaryKey() {
> > super();
> > }
> >
> > public PrimaryKey(String name, String id) {
> > this.name = name;
> > this.id = id;
> > }
> >
> > @Resolve
> > private Object getCompleteObject() {
> > return new CompleteObject(name, id);
>
> >
> > }
> > }
> > }
> >
> > If you pair this with a custom Strategy
> implementation
> > then you can ensure the class="" attributes can be
> > replaced with other tokens to indicate what
> objects to
> > use. This above example is obviously not very
> useful,
> > but when used properly @Replace and @Resolve can
> be
> > quite powerful.
> >
> > Niall
> >
> > --- Ben Wolfe <si...@be...> wrote:
> >
> >> We have several places in our code where we could
> >> benefit from a shorter
> >> serialization. We don't need to serialize the
> >> entire object, just the
> >> primary keys of the object.
> >>
> >> I haven't been able to find a way to do this yet.
>
> >> Did I miss something?
> >> Is there a way to do it currently?
> >>
> >> My thoughts on how to implement it:
> >>
> >> The primary key attributes/elements would need to
> be
> >> annotated. The
> >> most general way to do it would be to add a
> String
> >> "tag" option to the
> >> "Attribute" and "Element" annotations. The tag
> >> would be a string that
> >> groups certain attributes together and can be
> used
> >> later.
> >> I don't know why it would be necessary right now,
> >> but we could have any
> >> number of "sets of serializations" with any named
> >> tag we want: A "Short"
> >> one that would (de)derialize to just the primary
> >> keys, a "medium" one
> >> that would (de)serialize to only certain
> attributes,
> >> and then the
> >> default that would work normally using all
> >> annotations (as it does now).
> >>
> >> 1) It could be done with a custom Strategy, but
> >> alas, "Strategy"s are
> >> only notified about elements (via
> setElement(...)).
> >> If there were a
> >> setAttribute(...) method that was called on
> >> strategies, the custom
> >> strategy could look up the Object's annoations,
> find
> >> the right ones, and
> >> only let certain attributes and elements be
> written
> >> out to the DOM.
> >> This has the benefit of the least about of core
> >> simpleframework code
> >> changes.
> >>
> >> 2) The Source object could have a "List<String>
> >> tags" object that holds
> >> the current tags to serialize on. The Source can
> >> tell the scanner what
> >> tags to look for. Only the matching tags are
> >> included as attributes and
> >> elements for objects. The Persister/Serializer
> will
> >> need to have a
> >> setTags() method that it can pass on to the
> Source.
> >> The downside of this approach is that more code
> >> would have to be
> >> changed. The benefit is that not all of the
> >> attributes/elements would be
> >> looped over unnecessarily if there is only a
> "short"
> >> serialization going on.
> >>
> >> I am happy to code this up and submit a patch.
> >> However, I am not sure
> >> which you would prefer. There might be a third
> >> option that I'm missing.
> >> Please point me in the right direction if that
> is
> >> the case.
> >>
> >> Thanks,
> >> Ben
> >>
> >>
> >
>
-------------------------------------------------------------------------
> >> SF.Net email is sponsored by:
> >> Check out the new SourceForge.net Marketplace.
> >> It's the best place to buy or sell services for
> >> just about anything Open Source.
> >> http://sourceforge.net/services/buy/index.php
> >> _______________________________________________
> >> Simple-support mailing list
> >> Sim...@li...
> >>
> >
>
https://lists.sourceforge.net/lists/listinfo/simple-support
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Looking for last minute shopping deals?
> > Find them fast with Yahoo! Search.
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> >
> >
>
-------------------------------------------------------------------------
>
=== message truncated ===
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
|
|
From: Niall G. <gal...@ya...> - 2007-12-08 13:50:32
|
Hi,
There is a way you could do this, don't know how well
it would suit you. But the @Resolve and @Replace
annotations are used in situations like this. Anything
you can do with the readResolve and writeReplace for
conventional object serialization can be done with
these annotations. Here is an example of what you
might do.
@Root
public class CompleteObject {
@Attribute
private String name;
@Element
private String id;
@Element
private Stirng address;
public CompleteObject() {
super();
}
public CompleteObject(String name, String id) {
this.name = name;
this.id = id;
}
@Replace
private Object getPrimaryKey() {
return new PrimaryKey(name, id);
}
@Root
private static class PrimaryKey {
@Attribute
private String name;
@Element
private String id;
public PrimaryKey() {
super();
}
public PrimaryKey(String name, String id) {
this.name = name;
this.id = id;
}
@Resolve
private Object getCompleteObject() {
return new CompleteObject(name, id);
}
}
}
If you pair this with a custom Strategy implementation
then you can ensure the class="" attributes can be
replaced with other tokens to indicate what objects to
use. This above example is obviously not very useful,
but when used properly @Replace and @Resolve can be
quite powerful.
Niall
--- Ben Wolfe <si...@be...> wrote:
>
> We have several places in our code where we could
> benefit from a shorter
> serialization. We don't need to serialize the
> entire object, just the
> primary keys of the object.
>
> I haven't been able to find a way to do this yet.
> Did I miss something?
> Is there a way to do it currently?
>
> My thoughts on how to implement it:
>
> The primary key attributes/elements would need to be
> annotated. The
> most general way to do it would be to add a String
> "tag" option to the
> "Attribute" and "Element" annotations. The tag
> would be a string that
> groups certain attributes together and can be used
> later.
> I don't know why it would be necessary right now,
> but we could have any
> number of "sets of serializations" with any named
> tag we want: A "Short"
> one that would (de)derialize to just the primary
> keys, a "medium" one
> that would (de)serialize to only certain attributes,
> and then the
> default that would work normally using all
> annotations (as it does now).
>
> 1) It could be done with a custom Strategy, but
> alas, "Strategy"s are
> only notified about elements (via setElement(...)).
> If there were a
> setAttribute(...) method that was called on
> strategies, the custom
> strategy could look up the Object's annoations, find
> the right ones, and
> only let certain attributes and elements be written
> out to the DOM.
> This has the benefit of the least about of core
> simpleframework code
> changes.
>
> 2) The Source object could have a "List<String>
> tags" object that holds
> the current tags to serialize on. The Source can
> tell the scanner what
> tags to look for. Only the matching tags are
> included as attributes and
> elements for objects. The Persister/Serializer will
> need to have a
> setTags() method that it can pass on to the Source.
> The downside of this approach is that more code
> would have to be
> changed. The benefit is that not all of the
> attributes/elements would be
> looped over unnecessarily if there is only a "short"
> serialization going on.
>
> I am happy to code this up and submit a patch.
> However, I am not sure
> which you would prefer. There might be a third
> option that I'm missing.
> Please point me in the right direction if that is
> the case.
>
> Thanks,
> Ben
>
>
-------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
|
|
From: Ben W. <si...@be...> - 2007-12-07 20:33:57
|
We have several places in our code where we could benefit from a shorter serialization. We don't need to serialize the entire object, just the primary keys of the object. I haven't been able to find a way to do this yet. Did I miss something? Is there a way to do it currently? My thoughts on how to implement it: The primary key attributes/elements would need to be annotated. The most general way to do it would be to add a String "tag" option to the "Attribute" and "Element" annotations. The tag would be a string that groups certain attributes together and can be used later. I don't know why it would be necessary right now, but we could have any number of "sets of serializations" with any named tag we want: A "Short" one that would (de)derialize to just the primary keys, a "medium" one that would (de)serialize to only certain attributes, and then the default that would work normally using all annotations (as it does now). 1) It could be done with a custom Strategy, but alas, "Strategy"s are only notified about elements (via setElement(...)). If there were a setAttribute(...) method that was called on strategies, the custom strategy could look up the Object's annoations, find the right ones, and only let certain attributes and elements be written out to the DOM. This has the benefit of the least about of core simpleframework code changes. 2) The Source object could have a "List<String> tags" object that holds the current tags to serialize on. The Source can tell the scanner what tags to look for. Only the matching tags are included as attributes and elements for objects. The Persister/Serializer will need to have a setTags() method that it can pass on to the Source. The downside of this approach is that more code would have to be changed. The benefit is that not all of the attributes/elements would be looped over unnecessarily if there is only a "short" serialization going on. I am happy to code this up and submit a patch. However, I am not sure which you would prefer. There might be a third option that I'm missing. Please point me in the right direction if that is the case. Thanks, Ben |
|
From: Niall G. <gal...@ya...> - 2007-12-06 19:17:20
|
Hi,
There are several ways to do this. One is to use the
inline=true attribute in @ElementList. This will
select an ArrayList from the Java collections
framework. For example
@ElementList(inline=true)
private List<String> list;
Or you can implement a Strategy, which is used to
resolve and instantiate all classes. Take a look at
DefaultStrategy.
Niall
--- Ealden Escañan <ea...@gm...> wrote:
> Hi, all
>
> I'm trying to convert a List<String> into XML. I
> used @ElementList as
> mentioned in the tutorial which works but the
> attribute "class" is
> added to my XML:
>
> @Root
> public class Table {
> @ElementList
> private List<String> list;
>
> ....
> }
>
> <table>
> <list class="java.util.ArrayList">
> ...
> </list>
> </table>
>
> XML conversion works correctly if I used a concrete
> implementation
> such as an ArrayList. Is there a way to still make
> use of List
> without Simple adding the "class" attribute?
>
> Thanks
>
> --
> Ealden Esto E. Escañan
> http://ealden.net
>
>
-------------------------------------------------------------------------
> SF.Net email is sponsored by: The Future of Linux
> Business White Paper
> from Novell. From the desktop to the data center,
> Linux is going
> mainstream. Let it simplify your IT future.
>
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
|
|
From: Frank C. <fra...@gm...> - 2007-12-06 13:10:04
|
Is there a way to read an XML file and get the DOM tree associated with it before it populates XML schema classes? Thanks Frank |
|
From: <ea...@gm...> - 2007-12-05 03:13:03
|
Hi, all
I'm trying to convert a List<String> into XML. I used @ElementList as
mentioned in the tutorial which works but the attribute "class" is
added to my XML:
@Root
public class Table {
@ElementList
private List<String> list;
....
}
<table>
<list class=3D"java.util.ArrayList">
...
</list>
</table>
XML conversion works correctly if I used a concrete implementation
such as an ArrayList. Is there a way to still make use of List
without Simple adding the "class" attribute?
Thanks
--=20
Ealden Esto E. Esca=F1an
http://ealden.net
|
|
From: Niall G. <gal...@ya...> - 2007-12-02 16:35:22
|
Hi,
It should be "public static class" for Item, rather
than "public class", currently I have not implemented
not-static innerclass instantiation as it requires
instantiation of the outer class.
Niall
--- Frank Castellucci <fra...@gm...> wrote:
> ===========
> Here is the xml:
> ===========
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <navtree name="AddCustomer">
> <items>
> <item name="General"
> content="/customer/ccw/general.zul"/>
> <item name="ISY Setup"
> content="/customer/ccw/isysetup.zul"/>
> <item name="Floorplan"
> content="/customer/ccw/floorplan.zul"/>
> <item name="Complete"
> content="/customer/ccw/completed.zul"/>
> </items>
> </navtree>
>
> ================
> Here is the java class:
> ================
>
> package org.fvjc.udservice.ui;
>
> import java.util.List;
> import java.util.ArrayList;
> import org.simpleframework.xml.*;
> /**
> * @author frank
> *
> */
>
> @Root(name="navtree")
> public class WizardItems
> {
> @Attribute(name="name")
> private String name;
>
> @ElementList(name="items")
> private List<Item> list;
>
>
> @Root(name="item")
> public class Item
> {
> @Attribute
> private String name;
> @Attribute
> private String content;
>
> public Item()
> {
>
> }
>
> public Item(String name, String content)
> {
> this.name = name;
> this.content = content;
> }
> /**
> * @return the name
> */
> public String getName()
> {
> return name;
> }
> /**
> * @return the content
> */
> public String getContent()
> {
> return content;
> }
>
> }
>
> public WizardItems()
> {
>
> }
>
> public WizardItems(String name)
> {
> super();
> this.name = name;
> }
> /**
> * @param name
> * @param list
> */
> public WizardItems(String name, List<Item> list)
> {
> super();
> this.name = name;
> this.list = list;
> }
>
> public String getName()
> {
> return name;
> }
>
> public List<Item> getItems()
> {
> return list;
> }
>
> }
>
> ================
> Here is the invocation:
> ================
> Persister ser = new Persister();
> File example = new File(Sessions.getCurrent
> ().getWebApp().getRealPath(arg0));
> try
> {
> final WizardItems wizItems =
> ser.read(WizardItems.class,
> example);
> if(wizItems != null)
> {
>
> }
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
>
> ===================
> And here is the exception
> ===================
> java.lang.NoSuchMethodException:
> org.fvjc.udservice.ui.WizardItems$Item
> .<init>()
> at java.lang.Class.getConstructor0(Unknown
> Source)
> at
> java.lang.Class.getDeclaredConstructor(Unknown
> Source)
> at
>
org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88)
> at
>
org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72)
> at
>
org.simpleframework.xml.load.Composite.read(Composite.java:113)
> at
>
org.simpleframework.xml.load.Traverser.read(Traverser.java:72)
> at
>
org.simpleframework.xml.load.CompositeList.read(CompositeList.java
> :134)
> at
>
org.simpleframework.xml.load.CompositeList.read(CompositeList.java
> :108)
> at
>
org.simpleframework.xml.load.Composite.read(Composite.java:355)
> at
>
org.simpleframework.xml.load.Composite.readElement(Composite.java
> :334)
> at
>
org.simpleframework.xml.load.Composite.readElements(Composite.java
> :250)
> at
>
org.simpleframework.xml.load.Composite.read(Composite.java:194)
> at
>
org.simpleframework.xml.load.Composite.read(Composite.java:140)
> at
>
org.simpleframework.xml.load.Composite.read(Composite.java:116)
> at
>
org.simpleframework.xml.load.Traverser.read(Traverser.java:72)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:392)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:374)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:355)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:337)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:319)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:300)
> at
>
org.simpleframework.xml.load.Persister.read(Persister.java:279)
> at
>
org.fvjc.udservice.ui.Wizard.setConfig(Wizard.java:169)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> at java.lang.reflect.Method.invoke(Unknown
> Source)
> at
>
org.zkoss.zk.ui.metainfo.Property.assign(Property.java:187)
>
=== message truncated ===>
-------------------------------------------------------------------------
> SF.Net email is sponsored by: The Future of Linux
> Business White Paper
> from Novell. From the desktop to the data center,
> Linux is going
> mainstream. Let it simplify your IT future.
>
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4>
_______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs
|
|
From: Frank C. <fra...@gm...> - 2007-12-02 04:30:48
|
===========
Here is the xml:
===========
<?xml version="1.0" encoding="UTF-8"?>
<navtree name="AddCustomer">
<items>
<item name="General" content="/customer/ccw/general.zul"/>
<item name="ISY Setup" content="/customer/ccw/isysetup.zul"/>
<item name="Floorplan" content="/customer/ccw/floorplan.zul"/>
<item name="Complete" content="/customer/ccw/completed.zul"/>
</items>
</navtree>
================
Here is the java class:
================
package org.fvjc.udservice.ui;
import java.util.List;
import java.util.ArrayList;
import org.simpleframework.xml.*;
/**
* @author frank
*
*/
@Root(name="navtree")
public class WizardItems
{
@Attribute(name="name")
private String name;
@ElementList(name="items")
private List<Item> list;
@Root(name="item")
public class Item
{
@Attribute
private String name;
@Attribute
private String content;
public Item()
{
}
public Item(String name, String content)
{
this.name = name;
this.content = content;
}
/**
* @return the name
*/
public String getName()
{
return name;
}
/**
* @return the content
*/
public String getContent()
{
return content;
}
}
public WizardItems()
{
}
public WizardItems(String name)
{
super();
this.name = name;
}
/**
* @param name
* @param list
*/
public WizardItems(String name, List<Item> list)
{
super();
this.name = name;
this.list = list;
}
public String getName()
{
return name;
}
public List<Item> getItems()
{
return list;
}
}
================
Here is the invocation:
================
Persister ser = new Persister();
File example = new File(Sessions.getCurrent
().getWebApp().getRealPath(arg0));
try
{
final WizardItems wizItems = ser.read(WizardItems.class,
example);
if(wizItems != null)
{
}
}
catch (Exception e)
{
e.printStackTrace();
}
===================
And here is the exception
===================
java.lang.NoSuchMethodException: org.fvjc.udservice.ui.WizardItems$Item
.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88)
at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72)
at org.simpleframework.xml.load.Composite.read(Composite.java:113)
at org.simpleframework.xml.load.Traverser.read(Traverser.java:72)
at org.simpleframework.xml.load.CompositeList.read(CompositeList.java
:134)
at org.simpleframework.xml.load.CompositeList.read(CompositeList.java
:108)
at org.simpleframework.xml.load.Composite.read(Composite.java:355)
at org.simpleframework.xml.load.Composite.readElement(Composite.java
:334)
at org.simpleframework.xml.load.Composite.readElements(Composite.java
:250)
at org.simpleframework.xml.load.Composite.read(Composite.java:194)
at org.simpleframework.xml.load.Composite.read(Composite.java:140)
at org.simpleframework.xml.load.Composite.read(Composite.java:116)
at org.simpleframework.xml.load.Traverser.read(Traverser.java:72)
at org.simpleframework.xml.load.Persister.read(Persister.java:392)
at org.simpleframework.xml.load.Persister.read(Persister.java:374)
at org.simpleframework.xml.load.Persister.read(Persister.java:355)
at org.simpleframework.xml.load.Persister.read(Persister.java:337)
at org.simpleframework.xml.load.Persister.read(Persister.java:319)
at org.simpleframework.xml.load.Persister.read(Persister.java:300)
at org.simpleframework.xml.load.Persister.read(Persister.java:279)
at org.fvjc.udservice.ui.Wizard.setConfig(Wizard.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.zkoss.zk.ui.metainfo.Property.assign(Property.java:187)
at org.zkoss.zk.ui.metainfo.ComponentInfo.applyProperties(
ComponentInfo.java:490)
at org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(
AbstractUiFactory.java:94)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java
:492)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java
:474)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:434)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:417)
at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:317)
at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:260)
at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(
DHtmlLayoutServlet.java:200)
at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java
:140)
at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doPost(
DHtmlLayoutServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(
ApplicationDispatcher.java:557)
at org.apache.catalina.core.ApplicationDispatcher.include(
ApplicationDispatcher.java:481)
at org.zkoss.web.servlet.Servlets.include(Servlets.java:480)
at org.zkoss.zk.ui.http.ExecutionImpl.include(ExecutionImpl.java:222)
at org.zkoss.zul.Include.include(Include.java:135)
at org.zkoss.zul.Include.redraw(Include.java:123)
at org.zkoss.zk.ui.impl.UiVisualizer.redraw(UiVisualizer.java:818)
at org.zkoss.zk.ui.impl.UiVisualizer.getResponses(UiVisualizer.java:550)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:748)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(
DHtmlUpdateServlet.java:257)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java
:142)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(
DHtmlUpdateServlet.java:150)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java
:447)
at java.lang.Thread.run(Unknown Source)
Please help !!!
|
|
From: Wessam A. R. <wes...@gm...> - 2007-11-29 20:56:33
|
Hi Niall, The XML file is not generated by my code. I don't write the prolog to the file. This file is generated from a live java Derby database using an external library called apache ddlutils. I think that there are no spaces in the prolog. So, i don't know what could be causing this exactly. A more interesting point is that i managed to manipulate the code of this library such that no prolog gets generated with the file. so the file now starts as follows: <database name="dd"> Still i get the same exception: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog. at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:563) How come it's still complaining about prolog while the file does not contain one? Thanks, Wessam On Nov 29, 2007 8:56 PM, Niall Gallagher <gal...@ya...> wrote: > Hi Wessam, > > The first character of a prolog must be the "<" before > the "?xml" so there can be no spaces. Maybe you have > added the prolog as " <?xml version='1.0' > encoding='UTF-8'?>". If not then I would recommend you > try to write the XML to a file and parse that if you > still get the error then compare the generated XML the > working XML to figure out the issue. > > With respect to Simple XML validation, I have many > tests validating the generated XML against W3C DOM, so > my guess is that you have a bad prolog. > > Niall > > --- Wessam Abd Rabo <wes...@gm...> wrote: > > > Hi, > > I use Apache DDLutils library to generate XML file > > from live databases then > > feed this file to Simple to deserialize. I get an > > exception as Simple starts > > to parse the XML file prolog. the following is the > > exception's stack trace: > > > > javax.xml.stream.XMLStreamException: ParseError at > > [row,col]:[1,1] > > Message: Content is not allowed in prolog. > > at > > > com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:563) > > at > > > com.sun.xml.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java > > :86) > > at > > > org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java > > :117) > > at > > > org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74) > > at > > > org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74) > > at > > > org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61) > > at > > > org.simpleframework.xml.load.Persister.read(Persister.java:337) > > at > > > org.simpleframework.xml.load.Persister.read(Persister.java:258) > > > > This is the prolog of the generated XML file: > > > > <?xml version="1.0" encoding="UTF-8"?> > > > > What is the not allowed content in prolog? and how > > can i overcome this > > problem? > > > > Thanks in advance, > > Wessam > > > > > > > ____________________________________________________________________________________ > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs > |
|
From: Wessam A. R. <wes...@gm...> - 2007-11-29 18:47:40
|
Hi, I use Apache DDLutils library to generate XML file from live databases then feed this file to Simple to deserialize. I get an exception as Simple starts to parse the XML file prolog. the following is the exception's stack trace: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog. at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:563) at com.sun.xml.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java :86) at org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java :117) at org.simpleframework.xml.stream.NodeReader.readRoot(NodeReader.java:74) at org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:74) at org.simpleframework.xml.stream.NodeBuilder.read(NodeBuilder.java:61) at org.simpleframework.xml.load.Persister.read(Persister.java:337) at org.simpleframework.xml.load.Persister.read(Persister.java:258) This is the prolog of the generated XML file: <?xml version="1.0" encoding="UTF-8"?> What is the not allowed content in prolog? and how can i overcome this problem? Thanks in advance, Wessam |
|
From: Karthik K. <ka...@on...> - 2007-11-13 18:33:02
|
Hi,
I am having trouble with serialization of an inner element of an object.
Here is some example code to show what is not working:
@Root
public class SerializationWrapper <T>
{
@Element
private T _wrapped;
public SerializationWrapper(T object) {
_wrapped = object;
}
public T getInner() {
return _wrapped;
}
}
public abstract class Packet
{
// basic Packet methods
}
@Root
public class MessagePacket extends Packet
{
@Element(name="message")
private String _message;
public MessagePacket(String message)
{
_message = message;
}
public String getMessage() {
return _message;
}
}
Packet p = new MessagePacket("test");
SerializationWrapper<Packet> wrapper = new SerializationWrapper<Packet>(p);
*Serialization of p itself gives valid XML:*
<messagePacket>
<message>test</message>
</messagePacket>
*However, trying to serialize wrapper produces the following
exception/stack trace:*
org.simpleframework.xml.transform.TransformException: Transform of class
com.vandul.messaging.packets.MessagePacket not supported
at
org.simpleframework.xml.transform.PackageMatcher.match(PackageMatcher.java:91)
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)
...
This occurs even if I remove the abstraction and make
SerializationWrapper's generic type a MessagePacket:
SerializationWrapper<MessagePacket> wrapper2 = new
SerializationWrapper<MessagePacket>((MessagePacket) p);
Any help with this would be greatly appreciated. Thanks,
Karthik
|
|
From: Stan C. <sta...@mo...> - 2007-11-13 17:30:04
|
Is there a way to ensure the ordering of the serialized XML elements
when using subclasses?
Simplified example.
@Root(name = "response")
public class ClassA {
@Element(name = "code", required = true)
private Integer code;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getXmlResponse() throws Exception {
Serializer serializer = new Persister(new Format(4, "<?xml
version=\"1.0\" encoding=\"UTF-8\"?>"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
serializer.write(this, out);
out.flush();
return out.toString();
}
}
@Root(name = "response")
public class ClassB extends ClassA {
@Element(name = "status", required = false)
private String status;
@Element(name = "transactionCode", required = false)
private String transactionCode;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTransactionCode() {
return transactionCode;
}
public void setTransactionCode(String transactionCode) {
this.transactionCode = transactionCode;
}
}
In the Simple example above I'm trying to get this:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<code>200</code>
<status>Completed</status>
<transactionCode>101</transactionCode>
</response>
but I get this:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>Completed</status>
<transactionCode>101</transactionCode>
<code>200</code>
</response>
Thanks,
Stan
|
|
From: Niall G. <gal...@ya...> - 2007-11-11 23:38:25
|
Hi Wessam, Yes, the object you are trying to instantiate is either a non-static inner class or you have not declared the default no argument constructor. Niall --- Wessam Abd Rabo <wes...@gm...> wrote: > Hi, > I get the following exception when i try to > deserialize: > > java.lang.NoSuchMethodException: > org.netbeans.erdcore.datamodel.database.<init>() > at java.lang.Class.getConstructor0(Class.java:2706) > at > java.lang.Class.getDeclaredConstructor(Class.java:1985) > at > org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88) > at > org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72) > at > org.simpleframework.xml.load.Composite.read(Composite.java:107) > at > org.simpleframework.xml.load.Traverser.read(Traverser.java:72) > at > org.simpleframework.xml.load.Persister.read(Persister.java:392) > at > org.simpleframework.xml.load.Persister.read(Persister.java:374) > at > org.simpleframework.xml.load.Persister.read(Persister.java:355) > at > org.simpleframework.xml.load.Persister.read(Persister.java:337) > at > org.simpleframework.xml.load.Persister.read(Persister.java:319) > at > org.simpleframework.xml.load.Persister.read(Persister.java:300) > at > org.simpleframework.xml.load.Persister.read(Persister.java:279) > at > org.netbeans.erdcore.GraphSceneImpl.Deserialize(GraphSceneImpl.java:248) > > any idea what could be causing it not to see the > constructor? > > Thanks in advance, > Wessam > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
|
From: Wessam A. R. <wes...@gm...> - 2007-11-11 00:08:13
|
Hi, I get the following exception when i try to deserialize: java.lang.NoSuchMethodException: org.netbeans.erdcore.datamodel.database.<init>() at java.lang.Class.getConstructor0(Class.java:2706) at java.lang.Class.getDeclaredConstructor(Class.java:1985) at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88) at org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72) at org.simpleframework.xml.load.Composite.read(Composite.java:107) at org.simpleframework.xml.load.Traverser.read(Traverser.java:72) at org.simpleframework.xml.load.Persister.read(Persister.java:392) at org.simpleframework.xml.load.Persister.read(Persister.java:374) at org.simpleframework.xml.load.Persister.read(Persister.java:355) at org.simpleframework.xml.load.Persister.read(Persister.java:337) at org.simpleframework.xml.load.Persister.read(Persister.java:319) at org.simpleframework.xml.load.Persister.read(Persister.java:300) at org.simpleframework.xml.load.Persister.read(Persister.java:279) at org.netbeans.erdcore.GraphSceneImpl.Deserialize(GraphSceneImpl.java:248) any idea what could be causing it not to see the constructor? Thanks in advance, Wessam |
|
From: Niall G. <gal...@ya...> - 2007-09-20 11:03:49
|
Hi, Look in the jar/ directory of the extracted tar and you will see the simple JAR. If you are using Java 1.5 or lower you will also need the StAX and StAX API jars which are in the lib/ directory. Place them on your classpath and your ready to go. Niall --- manjus <ah...@ya...> wrote: > > > HI > > I downloaded the tar file...How do I go from > there > > -- > View this message in context: > http://www.nabble.com/How-to-download-and-get-to-work-with-simple-framework%2C-tf4477916.html#a12768528 > Sent from the Simple XML Serialization mailing list > archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. http://farechase.yahoo.com/ |
|
From: manjus <ah...@ya...> - 2007-09-19 00:08:59
|
HI I downloaded the tar file...How do I go from there -- View this message in context: http://www.nabble.com/How-to-download-and-get-to-work-with-simple-framework%2C-tf4477916.html#a12768528 Sent from the Simple XML Serialization mailing list archive at Nabble.com. |
|
From: manjus <ah...@ya...> - 2007-09-18 18:45:30
|
Hi,
I am new to simple framework. I could understand the concept . I
wrote a JavaBean class. I want to serialize this bean object. Please advise
me on where to write the code for serialization, is in the same java bean
class or is in a main class that I have to write....Please let me know...
Where to put this code....
Serializer s = new Persister();
--------
serializer.write(JavaBEanobject,outputxmlfile)
Thanks,
--
View this message in context: http://www.nabble.com/Where-do-we-write-the-code-for-xml-serialization-tf4476212.html#a12763358
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: Niall G. <gal...@ya...> - 2007-09-16 11:28:41
|
Hi, Yes, if you want to add this at the beginning, you can do this. String text = "<?xml version=\"1.0\"?>" + "<!DOCTYPE database SYSTEM \"http://db.apache.org/torque/dtd/database.dtd\">"; Format format = new Format(text); Persister persister = new Persister(format); The heading will then appear at the start of the generated XML document. Niall --- Wessam Abd Rabo <wes...@gm...> wrote: > Thanks, it worked. I have another question. Is there > a way to generate the > following 2 lines at the beginning of XML file? > <?xml version="1.0"?> > <!DOCTYPE database SYSTEM > "http://db.apache.org/torque/dtd/database.dtd"> > > Thanks again > > Wessam > > > On 9/14/07, Wessam Abd Rabo > <wes...@gm...> wrote: > > > > Hi, > > Am experiencing a problem on trying to use > ElementList inside my code. Am > > trying to produce XML in the following format: > > > > <database name="Company"> > > > > <table name="Employee"> > > <column name="ssn" primary key="true"/> > > <column name="sname" /> > > </table> > > > > <table name="Department"> > > <column name="dcode" primary key="true"/> > > <column name="dname" /> > > </table> > > > > </database> > > > > > > However the one produced looks as follows: > > > > <database name="Company"> > > <table> > > > > <table name="Employee"> > > <column> > > <column name="ssn" primary key="true"/> > > <column name="sname" /> > > </column> > > </table> > > > > <table name="Department"> > > <column> > > <column name="dcode" primary key="true"/> > > <column name="dname" /> > > </column> > > </table> > > > > </table> > > </database> > > > > I think i have a problem with using ElementList. > In my code, i > > declare class database in which i declare the > following Arraylist to get the > > tables list: > > > > @ElementList(name="table") > > ArrayList <table> list; > > > > Class Table looks as follows: > > > > @Root(name="table") > > > > class table{ > > > > @Attribute(name="name") > > private String name; > > > > @ElementList(name="Column") > > private ArrayList<Entry> list; > > > > ......} > > > > I declare inside table another arraylist for the > columns. Class Column: > > > > > > @Root(name="column") > > public class column { > > > > @Attribute(name="name") > > private String name; > > > > @Attribute(name="primary key") > > private boolean value; > > ........} > > > > i'm not sure if the format i want can still be > generated if i use > > elementlist in the same way. > > > > i need help with this > > > > Thanks in advance > > > > Wessam > > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/> _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Yahoo! oneSearch: Finally, mobile search that gives answers, not web links. http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC |
|
From: Wessam A. R. <wes...@gm...> - 2007-09-15 11:05:18
|
Thanks, it worked. I have another question. Is there a way to generate the following 2 lines at the beginning of XML file? <?xml version="1.0"?> <!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database.dtd"> Thanks again Wessam On 9/14/07, Wessam Abd Rabo <wes...@gm...> wrote: > > Hi, > Am experiencing a problem on trying to use ElementList inside my code. Am > trying to produce XML in the following format: > > <database name="Company"> > > <table name="Employee"> > <column name="ssn" primary key="true"/> > <column name="sname" /> > </table> > > <table name="Department"> > <column name="dcode" primary key="true"/> > <column name="dname" /> > </table> > > </database> > > > However the one produced looks as follows: > > <database name="Company"> > <table> > > <table name="Employee"> > <column> > <column name="ssn" primary key="true"/> > <column name="sname" /> > </column> > </table> > > <table name="Department"> > <column> > <column name="dcode" primary key="true"/> > <column name="dname" /> > </column> > </table> > > </table> > </database> > > I think i have a problem with using ElementList. In my code, i > declare class database in which i declare the following Arraylist to get the > tables list: > > @ElementList(name="table") > ArrayList <table> list; > > Class Table looks as follows: > > @Root(name="table") > > class table{ > > @Attribute(name="name") > private String name; > > @ElementList(name="Column") > private ArrayList<Entry> list; > > ......} > > I declare inside table another arraylist for the columns. Class Column: > > > @Root(name="column") > public class column { > > @Attribute(name="name") > private String name; > > @Attribute(name="primary key") > private boolean value; > ........} > > i'm not sure if the format i want can still be generated if i use > elementlist in the same way. > > i need help with this > > Thanks in advance > > Wessam > > > |
|
From: Niall G. <gal...@ya...> - 2007-09-14 15:10:53
|
Hi Wessam,
You need to make the ElementList inline. So the
following should be used:
@ElementList(name="table", inline=true)
ArrayList <table> list;
This will ensure there is no enclosing <table>
representing the list object. Same goes for the
column. Hope this helps.
Niall
--- Wessam Abd Rabo <wes...@gm...> wrote:
> Hi,
> Am experiencing a problem on trying to use
> ElementList inside my code. Am
> trying to produce XML in the following format:
>
> <database name="Company">
>
> <table name="Employee">
> <column name="ssn" primary key="true"/>
> <column name="sname" />
> </table>
>
> <table name="Department">
> <column name="dcode" primary key="true"/>
> <column name="dname" />
> </table>
>
> </database>
>
>
> However the one produced looks as follows:
>
> <database name="Company">
> <table>
>
> <table name="Employee">
> <column>
> <column name="ssn" primary key="true"/>
> <column name="sname" />
> </column>
> </table>
>
> <table name="Department">
> <column>
> <column name="dcode" primary key="true"/>
> <column name="dname" />
> </column>
> </table>
>
> </table>
> </database>
>
> I think i have a problem with using ElementList. In
> my code, i declare class
> database in which i declare the following Arraylist
> to get the tables list:
>
> @ElementList(name="table")
> ArrayList <table> list;
>
> Class Table looks as follows:
>
> @Root(name="table")
>
> class table{
>
> @Attribute(name="name")
> private String name;
>
> @ElementList(name="Column")
> private ArrayList<Entry> list;
>
> ......}
>
> I declare inside table another arraylist for the
> columns. Class Column:
>
>
> @Root(name="column")
> public class column {
>
> @Attribute(name="name")
> private String name;
>
> @Attribute(name="primary key")
> private boolean value;
> ........}
>
> i'm not sure if the format i want can still be
> generated if i use
> elementlist in the same way.
>
> i need help with this
>
> Thanks in advance
>
> Wessam
> >
-------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio
> 2005.
>
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/>
_______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
|
|
From: Wessam A. R. <wes...@gm...> - 2007-09-14 13:01:35
|
Hi,
Am experiencing a problem on trying to use ElementList inside my code. Am
trying to produce XML in the following format:
<database name="Company">
<table name="Employee">
<column name="ssn" primary key="true"/>
<column name="sname" />
</table>
<table name="Department">
<column name="dcode" primary key="true"/>
<column name="dname" />
</table>
</database>
However the one produced looks as follows:
<database name="Company">
<table>
<table name="Employee">
<column>
<column name="ssn" primary key="true"/>
<column name="sname" />
</column>
</table>
<table name="Department">
<column>
<column name="dcode" primary key="true"/>
<column name="dname" />
</column>
</table>
</table>
</database>
I think i have a problem with using ElementList. In my code, i declare class
database in which i declare the following Arraylist to get the tables list:
@ElementList(name="table")
ArrayList <table> list;
Class Table looks as follows:
@Root(name="table")
class table{
@Attribute(name="name")
private String name;
@ElementList(name="Column")
private ArrayList<Entry> list;
......}
I declare inside table another arraylist for the columns. Class Column:
@Root(name="column")
public class column {
@Attribute(name="name")
private String name;
@Attribute(name="primary key")
private boolean value;
........}
i'm not sure if the format i want can still be generated if i use
elementlist in the same way.
i need help with this
Thanks in advance
Wessam
|