[Simple-support] Loaded element used in Converter for next element
Brought to you by:
niallg
|
From: Przemysław K. <pk....@gm...> - 2011-07-07 21:53:44
|
Hello,
I have the following problem: assume we have a class:
class Profile {
@Element
ComplexType first;
@Element
DIfferentComplexType second;
}
Now, we have a Converter for DifferentComplexType. However, for
deserialization process, this converter needs an object of class
ComplexType, and it should be the one loaded for Profile object instance:
public class DIfferentComplexTypeConverter implements
Converter<DIfferentComplexType> {
private ComplexType complexType;
public DIfferentComplexTypeConverter(ComplexType complexType) {
this.complexType= complexType;
}
public DIfferentComplexType read(InputNode inputNode) throws Exception {
// some operations which need a ComplexType object to be done
}
public void write(OutputNode outputNode, Texture texture) throws
Exception {
// some operations
}
}
Does any of you has any idea how something like this could be achieved? I.
e. how to pass just deserialized "first" field of type ComplexType to
converter that will be used to deserialize the next field (named "second")?
The problem is, that the Registry object is created before deserializing,
and so adding DIfferentComplexTypeConverter to it is impossible, because we
don't have the ComplexType object yet. I'm starting wondering if this is
even possible, and if this is a good idea.
I know I could load these fields separately - have separate serializers, and
create each when I have the needed objects for converters. However, I would
have to store object's definitions in different XML files and serializing
process would not be as nice as with the above approach. Anyways, any ideas?
Take care,
Iskar
|