+1 I like the interface approach as the flag b/c we can always sense it using instanceof, or use a method typing approach to signal it.
Cheers, Chris On Nov 29, 2012, at 9:34 AM, Martin Desruisseaux wrote: > Hello all > > After a very long while committing accessory stuff, I have been back on > "serious" objects today. I just committed the following interface together > with support classes: > > https://builds.apache.org/job/sis-jdk7/site/apidocs/org/apache/sis/xml/NilObject.html > > In summary, the ISO 19115 standard (the standard which define metadata) > declare some metadata as optional, and some metadata as mandatory. However > the ISO 19139 standard (the standard which specify how to express ISO 19115 > in XML) said that we are allowed to omit a mandatory metadata, provided that > we explain why we omitted it. There is a list of predefined NilReason which > include: INAPPLICABLE, MISSING, TEMPLATE, UNKNOWN, WITHHELD and OTHER. > > In Java, we can not really express "nil value" by null, because "nil value" > are not completely nil... They may still be associated to XLink or the > above-cited NilReason. So the proposed approach, which was implemented in > Geotk, is to still return an instance of the metadata object, but the > instance additionally implements the NilObject marker interface - meaning > "I'm totally empty from an ISO 19115 point of view - but I may still have > some ISO 19139 attributes, in particular a NilReason attribute" (sorry for > the headache... The OGC/ISO standards are very complex...). The above-cited > javadoc contains an example of what it looks like in XML. > > Is there any comment about this approach? > > Martin >
