Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] MOXy: example of XmlIsSetNullPolicy use

Hello Martin,

Below are answers to some of your questions.  There a few items I need to dig into further:

1) is MOXy able to satisfy all my specified features?

a) entities are marshaled from/to XML and JSON

Yes, MOXy supports converting objects to/from both XML and JSON.  For an example see:
Another example is MOXy's external mapping document.  We use the same model and mappings to support both XML and JSON formats:
b) null values are represented as <field xsi:nil="true"/>

Yes, MOXy (and all JAXB implementations) are able to leverage the xsi:nil attribute to represent null:
c) unchanged default field values has not to be marshaled
d) changed field values (even changed to default values) has to be marshaled
e) server is able to identify which fields are changed (i.e. changed during unmarshaling) for partial updates

Let me dig into these further and send a separate email answering these.


2) are there any examples for use of XmlIsSetNullPolicy?

I have attached an example of using @XmlIsSetNullPolicy.  Note that due to bug 389092 (http://bugs.eclipse.org/389092) you need to have an @XmlElement annotation whenever you use @XmlIsSetNullPolicy.



3) can I specify null policy in one place for ale fields in entity class (or classes in package), say by parameterized "isSet" method?
Currently the null policy must be set per field/property.  If you have an idea for a global configuration option, please enter an enhancement request for it at the following link:

-Blaise

On 12-09-07 5:48 AM, Martin Schayna wrote:
Hi all,

I plan to use MOXy in Jersey server for marshaling annotated entities with
this features:

a) entities are marshaled from/to XML and JSON
b) null values are represented as <field xsi:nil="true"/>
c) unchanged default field values has not to be marshaled
d) changed field values (even changed to default values) has to be marshaled
e) server is able to identify which fields are changed (i.e. changed during
unmarshaling) for partial updates

I am pretty sure that this is for what MOXy specific annotation
XmlIsSetNullPolicy is, but I didn't found any example. It looks like my
entities have to implement "isSet" method for each field and set the
appropriate flag in setter. Something like that (completely based on MOXy
Javadoc):

public class Entity {

  private String field = null;  // default value
  private boolean changed = false;

  public String getField() {
    return field;
  }

  @XmlIsSetNullPolicy( isSetMethodName = "isChanged", xsiNilRepresentsNull =
true)
  public String setField(String field) {
    this.field = field;
    this.changed = true;
  }

  public boolean isChanged() {
    return changed;
  }
}

Questions:

1) is MOXy able to satisfy all my specified features?
2) are there any examples for use of XmlIsSetNullPolicy?
3) can I specify null policy in one place for ale fields in entity class (or
classes in package), say by parameterized "isSet" method?

Blaise Doughan?

Thanks,

Martin Schayna



--
View this message in context: http://eclipse.1072660.n5.nabble.com/MOXy-example-of-XmlIsSetNullPolicy-use-tp154296.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Attachment: isset.zip
Description: Zip archive


Back to the top