Hi Abhi,

Abhiram Panyam wrote:

> I would like to know if I can serialize methods in addition to fields. For
> instance, I have the following class
> 
> public class offerVO {
> 
>         private Long offerId;
> private String offer;
> 
>         public OfferVO() {
> 
>         }
> 
>         public Long getOfferId() {
> return offerId;
> }
> 
> public void setOfferId(Long offerId) {
> this.offerId = offerId;
> }
> 
> public String getOffer() {
> return offer;
> }
> 
> public void setOffer(String offer) {
> this.offer = offer;
> }
> 
>         public Date getExpirationDate() {
>            return Calendar.getInstance().getDate();
>         }
> }
> 
> Notice that there is no field called expirationDate in the class, but I
> would like to have it appear in the XML as an attribute called
> 'expirationDate' for the OfferVO element. Please advise.

You can register a JavaBeanConverter to handle OfferVO:

JavaBeanProvider beanProvider = new JavaBeanProvider();
xstream.registerConverter(new JavaBeanConverter(xstream.getMapper(), 
beanProvider, OfferVO.class));

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to