Difference between revisions of "Sed and mismatches"

(Fixing mismatch with data)
Line 2: Line 2:
  
 
==Fixing type name mismatches==
 
==Fixing type name mismatches==
The first kind of mismatches that can occur is when a type was renamed or a generic parameters was either added or removed. If you know the old name and the new name, you can pass to <e>{SED_INDEPENDENT_DESERIALIZER}.set_class_type_translator</e> an agent that will return the new type name given the old type name. This agent will be called each time we cannot find the name in the retrieving system.
+
The first kind of mismatches that can occur is when a type was renamed or a generic parameters was either added or removed. If you know the old name and the new name, you can pass to <e>{SED_RECOVERABLE_DESERIALIZER}.set_class_type_translator</e> an agent that will return the new type name given the old type name. This agent will be called each time we cannot find the name in the retrieving system.
  
 
When all types have found their corresponding type name, we can continue and solve attribute type/name mismatches.
 
When all types have found their corresponding type name, we can continue and solve attribute type/name mismatches.
Line 9: Line 9:
 
There are various kind of mismatches:
 
There are various kind of mismatches:
 
*The type of the attribute was changed from X to Z. There are different scenarios:
 
*The type of the attribute was changed from X to Z. There are different scenarios:
*#The old type conforms to the new type: if <e>{SED_INDEPENDENT_DESERIALIZER}.is_conforming_mismatch_allowed</e> is true, then no mismatch is reported, otherwise we report one which will be handled when retrieving the object data.
+
*#The old type conforms to the new type: if <e>{SED_RECOVERABLE_DESERIALIZER}.is_conforming_mismatch_allowed</e> is true, then no mismatch is reported, otherwise we report one which will be handled when retrieving the object data.
 
*#The types differ only by their attachment mark: if the new type is attached while the other is not, then we will only trigger a mismatch when retrieving the object data when we get Void; otherwise no mismatch is being raised.
 
*#The types differ only by their attachment mark: if the new type is attached while the other is not, then we will only trigger a mismatch when retrieving the object data when we get Void; otherwise no mismatch is being raised.
 
*#If the old type without attachment mark conforms to the new type without attachment mark, we apply first #1 and if True we apply #2 above.
 
*#If the old type without attachment mark conforms to the new type without attachment mark, we apply first #1 and if True we apply #2 above.
 
*#The types are completely unrelated: we trigger a mismatch when retrieving the object data.
 
*#The types are completely unrelated: we trigger a mismatch when retrieving the object data.
  
*The name of some attributes have changed: if an attribute name translator has been provided via <e>{SED_INDEPENDENT_DESERIALIZER}.set_attribute_name_translator</e>, we use this to find out the new name of the attribute and then apply the above in case the type has also changed. If no translator was provided, we simply trigger a mismatch when retrieving the object data.
+
*The name of some attributes have changed: if an attribute name translator has been provided via <e>{SED_RECOVERABLE_DESERIALIZER}.set_attribute_name_translator</e>, we use this to find out the new name of the attribute and then apply the above in case the type has also changed. If no translator was provided, we simply trigger a mismatch when retrieving the object data.
  
*Some attributes have been removed: if <e>{SED_INDEPENDENT_DESERIALIZER}.is_attribute_removal_allowed</e> is true, then no mismatch is reported, otherwise we report one which will be handled when retrieving the object data.
+
*Some attributes have been removed: if <e>{SED_RECOVERABLE_DESERIALIZER}.is_attribute_removal_allowed</e> is true, then no mismatch is reported, otherwise we report one which will be handled when retrieving the object data.
  
 
==Fixing mismatch with data==
 
==Fixing mismatch with data==
Line 23: Line 23:
 
This is done by calling the <e>correct_mismatch</e> routine from the type which has the mismatch. From that routine, you can have access to an instance of <e>SED_TYPE_MISMATCH</e> and <e>MISMATCH_INFORMATION</e> holding all the information you need to know what is mismatched and all the object data you need to reconnect the attributes.
 
This is done by calling the <e>correct_mismatch</e> routine from the type which has the mismatch. From that routine, you can have access to an instance of <e>SED_TYPE_MISMATCH</e> and <e>MISMATCH_INFORMATION</e> holding all the information you need to know what is mismatched and all the object data you need to reconnect the attributes.
  
If you are unable to fix, then you should raise an exception which will be internally understood as not being able to retrieve the storable. At this stage, you can either choose to continue retrieving the rest of the data or stop right there by setting <e>{SED_INDEPENDENT_DESERIALIZER}.is_stopping_on_data_retrieval_error</e>.
+
If you are unable to fix, then you should raise an exception which will be internally understood as not being able to retrieve the storable. At this stage, you can either choose to continue retrieving the rest of the data or stop right there by setting <e>{SED_RECOVERABLE_DESERIALIZER}.is_stopping_on_data_retrieval_error</e>.

Revision as of 10:49, 2 March 2010

Let's find out how to fix mismatches when retrieving a serialized objects.

Fixing type name mismatches

The first kind of mismatches that can occur is when a type was renamed or a generic parameters was either added or removed. If you know the old name and the new name, you can pass to {SED_RECOVERABLE_DESERIALIZER}.set_class_type_translator an agent that will return the new type name given the old type name. This agent will be called each time we cannot find the name in the retrieving system.

When all types have found their corresponding type name, we can continue and solve attribute type/name mismatches.

Fixing attribute type/name mismatches

There are various kind of mismatches:

  • The type of the attribute was changed from X to Z. There are different scenarios:
    1. The old type conforms to the new type: if {SED_RECOVERABLE_DESERIALIZER}.is_conforming_mismatch_allowed is true, then no mismatch is reported, otherwise we report one which will be handled when retrieving the object data.
    2. The types differ only by their attachment mark: if the new type is attached while the other is not, then we will only trigger a mismatch when retrieving the object data when we get Void; otherwise no mismatch is being raised.
    3. If the old type without attachment mark conforms to the new type without attachment mark, we apply first #1 and if True we apply #2 above.
    4. The types are completely unrelated: we trigger a mismatch when retrieving the object data.
  • The name of some attributes have changed: if an attribute name translator has been provided via {SED_RECOVERABLE_DESERIALIZER}.set_attribute_name_translator, we use this to find out the new name of the attribute and then apply the above in case the type has also changed. If no translator was provided, we simply trigger a mismatch when retrieving the object data.
  • Some attributes have been removed: if {SED_RECOVERABLE_DESERIALIZER}.is_attribute_removal_allowed is true, then no mismatch is reported, otherwise we report one which will be handled when retrieving the object data.

Fixing mismatch with data

When none of the above was able to automatically address the various mismatches, we trigger a mismatch whenever we are done retrieving an object which has a mismatch.

This is done by calling the correct_mismatch routine from the type which has the mismatch. From that routine, you can have access to an instance of SED_TYPE_MISMATCH and MISMATCH_INFORMATION holding all the information you need to know what is mismatched and all the object data you need to reconnect the attributes.

If you are unable to fix, then you should raise an exception which will be internally understood as not being able to retrieve the storable. At this stage, you can either choose to continue retrieving the rest of the data or stop right there by setting {SED_RECOVERABLE_DESERIALIZER}.is_stopping_on_data_retrieval_error.