users@jaxb.java.net

Re: Mapping Heterogenous Hashmap to JAXB

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 12 Jan 2010 17:05:59 +0100

You won't be able to marshal java.awt.Rectangle.

The classes in java.awt are designed for representing graphic objects in a
dynamic rendering environement. JAXB may handle unannotated classes, but
only if they are well-behaved, i.e., written as Java Beans.

You might consider using SVG.

-W


On Mon, Jan 11, 2010 at 10:43 PM, srinivasan_pavan <
srinivasan_pavan_at_yahoo.com> wrote:

>
> 1: yes, the Rectangle does represents java.awt.Rectangle, I am basically
> saving layout information of the component in xml.
> the map might look like this
> key="componentIndex" value=1
> key="bounds" value=new Rectangle(1,1,110,10)
> key="insets" value=new Insets(1,1,1,1)
> key="borderColor" value="Color.Red"
>
> ..basically depending on the container in which the components are
> placed..the placement properties might differ...(eg :
> BorderLayout,FlowLayout,GridLayout ...Container).
>
> 2: so basically my Map looks like <String,Object>. I could write a XMLJava
> adapter for the map
> Class ValueAdapter extends XMLAdapter{
> public <...>marshal(...){
> if(obj instanceof Integer){
> //delegate to jaxb for marshalling
> }
> else if (obj instance of Rectangle){
> //perform marshalling myself
> }
> }
>
> Is..is there any way i could check whethere jaxb has marshalling support
> for
> a class ..before performing it myself...as in the code above ?
>
> Regards,
> Pavan
>
> Wolfgang Laun-2 wrote:
> >
> > The XML you've shown isn't likely to be a Map's straightforward mapping
> to
> > XML,
> > where each entry would normally contain a <key> and a <value> element.
> > Marshalling of arbitrary elements with arbitrary content is possible but
> > it
> > requires
> > complex processing. Please provide more details about your problem.
> >
> > Also, I'm somewhat suspicious with respect to the contents of your
> > <bounds>
> > element: Is this meant to represent a java.awt.Rectangle object?
> >
> > -W
> >
> > On Sun, Jan 10, 2010 at 6:52 AM, srinivasan_pavan <
> > srinivasan_pavan_at_yahoo.com> wrote:
> >
> >>
> >> Hi,
> >> I have a Map with entries of type Object ie(Hetrogenous)
> >> <bounds> Rectangle(0,0,1,1)</bounds>
> >> <type>1</type>
> >> <...>
> >>
> >> How can i map them in JAXB.
> >>
> >> Thanks,
> >> Pavan
> >>
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/Mapping-Heterogenous-Hashmap-to-JAXB-tp27095849p27095849.html
> >> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Mapping-Heterogenous-Hashmap-to-XML-in-JAXB-tp27095849p27118299.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>