From: <ale...@jb...> - 2005-05-12 13:09:23
|
"ad...@jb..." wrote : Essentially, the problem is that to get the polymorphism to work, | I have to introduce a type binding, in this case | key -> valueType | value -> valueType | where valueType can be collection/array/list/ANY/etc. | | But this then requires an extra object to be constructed to model the polymorphic behaviour: | | | | // value binding | | TypeBinding valueType = schemaBinding.getType(valueTypeQName); | | | | configureValueBindings(valueType); // <------ subelements | | | | valueType.setHandler(new DefaultElementHandler() | | { | | public Object startElement(Object parent, QName name, TypeBinding type) | | { | | return new AbstractValueMetaData(new StringValueMetaData()); | | } | | etc. | | | | Then later I have to unwrap the extra AbstractValueMetaData | | | AbstractMapMetaData map = (AbstractMapMetaData) parent; | | MapEntry entry = (MapEntry) child; | | AbstractValueMetaData entryKey = (AbstractValueMetaData) entry.key; | | if (entryKey == null) | | throw new IllegalArgumentException("No key in map entry"); | | AbstractValueMetaData entryValue = (AbstractValueMetaData) entry.value; | | if (entryValue == null) | | throw new IllegalArgumentException("No value in map entry"); | | map.put(entryKey.getValue(), entryValue.getValue()); | | You want to get rid of constructing an instance of AbstractValueMetaData, right? I think, you could just use the DefaultElementHandler as is, w/o overwritting the startElement. Which will just propagate the MapEntry further and you will be able to add the actual key and value to it. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877461#3877461 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877461 |