views:

12

answers:

1

In POF-serialized .NET objects, I have Class A containing Class B, and Class B has an Attribute X which I want to extract and use in a filter.

I can use a SimplePofPath to navigate through the POF stream from A to B and grab X. This works well, except when A.B == null.

When A does not have an instance of B where expected, the SimplePofPath fails with message

getChild() method cannot be invoked on the SimplePofValue instance.

Instead of this, I would like an IPofNavigator that does something more graceful than throw an exception when it can't traverse its path because I serialized null in a field. This could be, say, returning a user-supplied "fallback" value.

Does such an implementation exist? If not, how would I get started extending AbstractPofPath on my own? I have taken a look at this custom navigator dealing with contained collections, but can't wrap my head around how to get started implementing navigate().

A: 

I was able to do this by extending AbstractPofPath and implementing a recursive navigate(PofValue, int) method much like the one linked. I also stubbed it in C# and provided matching user-type configurations in the .NET client and cluster config files.

Before the recursive call, the method checks to see if its parameter has a typeID equal to PofConstants.V_REFERENCE_NULL, and if so, it simply returns its parameter instead of recursing.

Past few minutes of testing show that this approach maintains behavior acceptable to Filter and Extractor objects.

mmsmatt