Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/406697"

Line 119: Line 119:
*in conjunction with adapters?
*in conjunction with adapters?

Revision as of 08:35, 9 May 2013

Document History

  • April 26, 2013 - Initial Draft



public class Root {
	public String name;
	public List<Thing> things;
public class Thing {
	public String thingName;
	public String thingValue;
Root r = new Root();
r.name = "theRootName";
r.things = new ArrayList<Thing>();
Thing thing1 = new Thing();
thing1.thingName = "thinga";
thing1.thingValue = "thingavalue";
Thing thing2 = new Thing();
thing2.thingName = "thingb";
thing2.thingValue = "thingbvalue";
Thing thing3 = new Thing();
thing3.thingName = "thingc";
thing3.thingValue = "thingcvalue";
marshaller.marshal(r, System.out)
marshaller.marshal(r, System.out)


The following annotation will be added

@Target({METHOD, FIELD})
public @interface XmlVariableNode {
    String attributeName();
    Class type() default DEFAULT.class;    
    String getMethod() default "##default";
    String setMethod() default "##default";
    static final class DEFAULT {}

External Bindings


A new mapping will be created XMLVariableXPathMapping and it will extend the AnyCollectionMapping

This mapping will assume that the key names are unique so will never write ['s in JSON

This annotation only makes sense when the referenced type is a complex thing. An exception will be thrown if this annotation is used on a simple object or List of simple things.


Since this makes use of the any logic during unmarshal and MOXy only handles one Any mapping on a class if a class makes use of the XmlVariableNode annotation then that class can not have XmlAnyElement annotations or any other variables that would cause AnyObject or AnyCollection mappings to be created.


  • inheritance
  • List<Object>
  • single case ie:not on a collection XMLVariableXPathObjectMapping XMLVariableXPathCollectionMapping
  • external bindings
  • don`t write out that property itself as nested if it is the variable field - currently need to mark that property as transient.
  • startcollection and endcollection [ ]'s in JSON
  • could specify get/set method instead of attribute
  • namespaces
  • in conjunction with adapters?
  • array
  • elementwrapper