This confuses me. See my remarks below.
On 7/7/09, arghman <jmsachs_at_gmail.com> wrote:
>
>
> I am using JAXB to unmarshal an XML file into a Java object model. Works
> great, except for one thing. I've been using parseMethod and printMethod to
> convert simple strings to a type of my choice, e.g.:
>
> <someElement tag='Bismarck' name='Dagwood' />
> <someElement tag='Pierre' name='Herb' />
>
> where the "tag" attribute, instead of being unmarshalled as a string, gets
> unmarshalled as a custom type e.g. a Tag class in java.
>
> This works fine, but it relies on parseMethod and printMethod being static
> methods. I would like to use a marshaller/unmarshaller that is a class
> instance, that I pass into the Unmarshaller or Marshaller.
Pass an (Un)marshaller into itself? Please clarify.
Is there a way to
> do this? (I hope so :-( otherwise I'm stuck) I have read up on XMLAdapter
> and it looks OK, only it seems to require that the type conversion has
> already occurred.
It relies on some conversion JAXB knows about, but this could be from a
string to java.lang.String, and therefore you'd lose nothing.
What I want is for my someElement class in Java to have a method:
>
> Tag getTag()
>
> where Tag is an interface, and I want to install a hook object (an instance
> of class TagManager in this case) so that the hook object gets to do the
> unmarshaling from String to Tag, and marshaling from Tag back into String.
Where should this "hook object" be installed? It can't very well be in a
someElement object, since this is the one being created while the conversion
of its attribute "tag" takes place.
-W
> All the other unmarshaling/marshaling steps are fine as is through the
> default methods.
>
>
> --
> View this message in context:
> http://www.nabble.com/runtime-%28or-per-instance%29-custom-unmarshaling-tp24373874p24373874.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
>
>