Support anydata and anyxml statements in Binding V1 (MDSAL-10)

[MDSAL-428] Add anydata/anyxml Binding Spec interfaces Created: 27/Mar/19  Updated: 29/Mar/19  Resolved: 29/Mar/19

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: None
Fix Version/s: 4.0.0

Type: Sub-task Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In order to support generation of code for anydata and anyxml statements, we need to have an anchor point in the binding specification interfaces on top of which generated code can graft onto.

 



 Comments   
Comment by Robert Varga [ 27/Mar/19 ]

As the data model underlying anydata/anyxml is not available at compile-time, whatever we generate will only be a read-only type capture of the data. Furthermore the underlying object model may be dynamic and subject to run-time constraints. For example if anydata comes from XML it will look differently than if it comes from JSON – it may even be NormalizedNode data with or without the corresponding schema.

This means we can only generate tagging interface to hold a reference to the data and expose some minimal information about it, the rest will need to go through some runtime service – both in terms of unpacking to binding world (i.e. "interpret this anydata in terms of global schemacontext rooted here") and packing back ("convert this binding structure into an anydata instance living here").

To support these operations, such generated instance really needs to bind only to an opaque object model, so the baseline interfaces are very simple:

interface AnyxmlObject<T extends AnyxmlObject<T>> extends BindingObject, DataContainer {
    @NonNull Class<T> implementedInterface();

    @NonNull OpaqueData<?> getValue();
}

where OpaqueData is a type-capture interface:

interface OpaqueData<T> {
    @NonNull Class<T> getObjectModel();
    @NonNull T getData();
}
Generated at Wed Feb 07 20:09:47 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.