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: Betwixt : flavours for complex objects
Date Wed, 02 Nov 2005 23:06:21 GMT
On Tue, 2005-11-01 at 07:58 -0600, Ryan McGuinness wrote:
> > I have an issue with objects and flavours, and need to know where to
> > look. I have read the docs, and the source, at this point it still is
> > unclear.
> >
> > I have two objects
> >
> > public Object1 {
> > 	private String name;
> > 	Object2 property1 = new Object2();
> > 	...
> > }
> >
> > public Object2 {
> > 	private String attr1;
> > 	private String attr2;
> > }
> >
> > in my .betwixt file, I have a definition:
> >
> > object1.betwixt
> > <info>
> > 	<element name='my-first-object'>
> > 		<element name='my-name' property='name'>
> > 			<option>
> > 				<name>value</name>
> > 				<value>myValue</value>
> > 			</option>
> > 		</element>
> > 		<element name='my-object' property='property1'>
> > 			<option>
> > 				<name>value</name>
> > 				<value>mySecondValue</value>
> > 			</option>
> > 		</element>
> > 	</element>
> > </info>
> >
> > I have written a custom StringConverter, and I can see which flavours
> > are being passed, and which are not.
> > basically, I do not get a flavour when I am calling the complex type
> > (property1).

as the code stands now, this is expected.

> > Do I have to create a ClassConverter? or do I have to modify some base
> > class? or is there a plugable approach that I can take for this.

not ATM. probably need to add some kind of option inheritance for this
use case.

options are posted onto a stack. ATM only access to the top of the stack
is possible. probably need to be able to access options down the stack.
it would be easy (and backwards compatible) to add a method to context
that searched the stack and returned the first option value matching a
particular name. 

opinions?

> > I need a flavour for this custom object because in one output I have to
> > create:
> >
> > <my-object attr1='somevalue' />
> >
> > and in another
> >
> > <my-object>
> > 	<attr1>value1</attr1>
> > 	<attr2>value2</attr1>
> > </my-object>

this is a structural change

i think that the quickest way to get this working would be to use
multi-mappings
(http://jakarta.apache.org//commons/betwixt/guide/binding.html#Multi%
20Mapping). for each output type, define the mappings for object one and
object two within the same multi-mapping.

if you are caching XmlBeanInfo's then you'll need to maintain a separate
registry for each mapping.

- robert


---------------------------------------------------------------------
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