commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: How does using Interface for mapping object-to-xml works in Betwixt?
Date Tue, 27 Jan 2004 22:23:09 GMT
hi

i've set up some tests using the source provided but i'm afraid to say 
that i don't seem to be able to reproduce your problem.

i suspect that your using some .betwixt files and maybe there's a 
problem somewhere there.

could you either post you .betwixt files or (even better) a unit test 
that i can run and demonstrates the problem.

- robert

On 27 Jan 2004, at 16:04, cheongco@netscape.net wrote:

> I seems to have different result when i map an object-to-xml  using an 
> object instance as compared to that of an interface.
>
> The scenario is as such:
> I have a Person class which implements an interface PersonIntf and 
> when this object is mapped into xml using the Person instance, i have 
> the following result
>   <person age="21" name="John Smith">
>       <address street1="Street1" postalcode="12345"/>
>   </person>
>
> but when i used the same Person object instance but now using the 
> PersonIntf via the XMLInspector.setClassNormalizer() i have the 
> following result - the <address> element info are all missing
>   <person age="21" name="John Smith">
>       <address street1="" postalcode=""/>  <!-- street1 & postalcode 
> not being mapped -->
>   </person>
>
> Did i missed something here? I suspect that the XMLIntrospector did 
> not include the super interface of PersonIntf => AddressIntf, am i 
> right?
>
> I have all my classes listed below, i am using the nightly build 
> downloaded last night.
>
> Any help will be greatly appreciated. Thanks in advance
>
> ===Address Interface Class ===
> public interface AddressIntf {
>     public String getStreet1();
>     public int getPostalcode();
>     public void setStreet1(String st);
>     public void setPostalcode(int pc);
>
>     //convenience method
>     public void setAddress(String st, int pc);
>
> }
>
> ===Person Interface Class===
> public interface PersonIntf extends AddressIntf{
>     public String getName();
>     public int getAge();
>     public void setName(String name);
>     public void setAge(int age);
>
>     //derive attr
>     public AddressIntf getAddress();
> }
>
> ===Person Class===
> public class Person implements PersonIntf {
>     private String name;
>     private int age;
>     private Address address;
>
>     public Person() {address = new Address();}
>
>     public Person(String name, int age) {
>        this(name, age, null, 0);
>     }
>
>     public Person(String name, int age, String street1, int 
> postalcode){
>         this.name = name;
>         this.age = age;
>         this.address = new Address(street1, postalcode);
>     }
>
>     public String getName() { return name;}
>     public void setName(String name) {this.name = name;}
>
>     public int getAge() {return age;}
>     public void setAge(int age) {this.age = age;}
>
>     public AddressIntf getAddress() {return address;}
>     public void setAddress(Address address) {this.address=address;}
>     public void setAddress(String st, int pc) {address.setAddress(st, 
> pc);}
>
>     public String getStreet1(){ return address.getStreet1();}
>     public void setStreet1(String st){ address.setStreet1(st);}
>
>     public int getPostalcode(){ return address.getPostalcode();}
>     public void setPostalcode(int pc){address.setPostalcode(pc);}
>
>     public String toString() {return "PersonBean[name='" + name + 
> "',age='" + age + ", address[" + address +"']";}
>
>     private class Address implements AddressIntf {
>         private String street1;
>         private int postalcode;
>
>         /** Creates a new instance of Name */
>         public Address() {}
>
>         public Address(String street1, int postalcode){
>             this.street1=street1;
>             this.postalcode=postalcode;
>         }
>
>         public String getStreet1() {return street1;}
>         public void setStreet1(String street1) {this.street1 = 
> street1;}
>
>         public int getPostalcode() {return postalcode;}
>
>         public void setPostalcode(int postalcode) {this.postalcode = 
> postalcode;}
>
>         public void setAddress(String street1, int postalcode){
>             this.street1=street1;
>             this.postalcode=postalcode;
>         }
>
>         public String toString(){return "street1="+street1+", 
> postalcode="+postalcode;}
>
>     }
> }
>
>
>
> __________________________________________________________________
> New! Unlimited Netscape Internet Service.
> Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
> Act now to get a personalized email address!
>
> Netscape. Just the Net You Need.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message