EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jaxb
Class MarshallerProperties

java.lang.Object
  extended by org.eclipse.persistence.jaxb.MarshallerProperties

public class MarshallerProperties
extends java.lang.Object

These are properties that may be set on an instance of Marshaller. Below is an example of using the property mechanism to enable MOXy's JSON binding for an instance of Marshaller.

 Marshaller marshaller = jaxbContext.createMarshaller();
 marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json");
 


Field Summary
static java.lang.String CHARACTER_ESCAPE_HANDLER
          The Constant CHARACTER_ESCAPE_HANDLER.
static java.lang.String INDENT_STRING
          The Constant INDENT_STRING.
static java.lang.String JSON_ATTRIBUTE_PREFIX
          The name of the property used to specify a value that will be prepended to all keys that are mapped to an XML attribute.
static java.lang.String JSON_INCLUDE_ROOT
          The name of the property used to specify in the root node should be included in the message (default is true).
static java.lang.String JSON_MARSHAL_EMPTY_COLLECTIONS
          The Constant JSON_MARSHAL_EMPTY_COLLECTIONS.
static java.lang.String JSON_NAMESPACE_SEPARATOR
          The name of the property used to specify the character (default is '.')
static java.lang.String JSON_REDUCE_ANY_ARRAYS
          The Constant JSON_REDUCE_ANY_ARRAYS.
static java.lang.String JSON_VALUE_WRAPPER
          The name of the property used to specify the key that will correspond to the property mapped with @XmlValue.
static java.lang.String JSON_WRAPPER_AS_ARRAY_NAME
          The Constant JSON_WRAPPER_AS_ARRAY_NAME.
static java.lang.String MEDIA_TYPE
          The name of the property used to specify the type of binding to be performed.
static java.lang.String NAMESPACE_PREFIX_MAPPER
          The Constant NAMESPACE_PREFIX_MAPPER.
 
Constructor Summary
MarshallerProperties()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARACTER_ESCAPE_HANDLER

public static final java.lang.String CHARACTER_ESCAPE_HANDLER
The Constant CHARACTER_ESCAPE_HANDLER. Allows for customization of character escaping when marshalling. Value should be an implementation of org.eclipse.persistence.oxm.CharacterEscapeHandler.

See Also:
CharacterEscapeHandler, Constant Field Values
Since:
2.3.3

INDENT_STRING

public static final java.lang.String INDENT_STRING
The Constant INDENT_STRING. Property used to set the string used when indenting formatted marshalled documents. The default for formatted documents is " " (three spaces).

See Also:
Constant Field Values
Since:
2.3.3

JSON_ATTRIBUTE_PREFIX

public static final java.lang.String JSON_ATTRIBUTE_PREFIX
The name of the property used to specify a value that will be prepended to all keys that are mapped to an XML attribute. By default there is no attribute prefix. There is no effect when media type is "application/xml". When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this attribute prefix.

See Also:
org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_ATTRIBUTE_PREFIX, org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX, Constant Field Values
Since:
2.4

JSON_INCLUDE_ROOT

public static final java.lang.String JSON_INCLUDE_ROOT
The name of the property used to specify in the root node should be included in the message (default is true). There is no effect when media type is "application/xml". When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this setting.

See Also:
org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_INCLUDE_ROOT, org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_INCLUDE_ROOT, Constant Field Values
Since:
2.4

JSON_NAMESPACE_SEPARATOR

public static final java.lang.String JSON_NAMESPACE_SEPARATOR
The name of the property used to specify the character (default is '.') that separates the prefix from the key name. It is only used if namespace qualification has been enabled be setting a namespace prefix mapper. When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this setting.

See Also:
org.eclipse.persistence.jaxb.JAXBContextProperties.NAMESPACE_SEPARATOR, org.eclipse.persistence.jaxb.UnmarshallerProperties.NAMESPACE_SEPARATOR, Constant Field Values
Since:
2.4

JSON_VALUE_WRAPPER

public static final java.lang.String JSON_VALUE_WRAPPER
The name of the property used to specify the key that will correspond to the property mapped with @XmlValue. This key will only be used if there are other mapped properties. When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this setting.

See Also:
org.eclipse.persistence.jaxb.JAXBContextPropertes.JSON_VALUE_WRAPPER, org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_VALUE_WRAPPER, Constant Field Values
Since:
2.4

MEDIA_TYPE

public static final java.lang.String MEDIA_TYPE
The name of the property used to specify the type of binding to be performed. When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this media type. Supported values are:

See Also:
org.eclipse.persistence.jaxb.JAXBContextProperties.MEDIA_TYPE, org.eclipse.persistence.jaxb.UnmarshallerProperties.MEDIA_TYPE, MediaType, Constant Field Values
Since:
2.4

NAMESPACE_PREFIX_MAPPER

public static final java.lang.String NAMESPACE_PREFIX_MAPPER
The Constant NAMESPACE_PREFIX_MAPPER. Provides a means to customize the namespace prefixes used while marshalling to XML. Used for both marshal and unmarshal when mediaType is set to "application/json". Value is either a Map of URIs to prefixes, or an implementation of org.eclipse.persistence.oxm.NamespacePrefixMapper.

See Also:
NamespacePrefixMapper, Constant Field Values
Since:
2.3.3

JSON_MARSHAL_EMPTY_COLLECTIONS

public static final java.lang.String JSON_MARSHAL_EMPTY_COLLECTIONS
The Constant JSON_MARSHAL_EMPTY_COLLECTIONS. If true an empty or null collection will be marshalled as null or empty array, if false both will be represented as an absent node.

See Also:
Constant Field Values
Since:
2.4

JSON_REDUCE_ANY_ARRAYS

public static final java.lang.String JSON_REDUCE_ANY_ARRAYS
The Constant JSON_REDUCE_ANY_ARRAYS. If true arrays that have just one item in them will be reduced and marshalled as a single item and not as a collection. ie: no [ ] in the marshalled JSON Default is false so all collections (even size 1) will have the [ ] around them.

See Also:
Constant Field Values
Since:
2.4.2

JSON_WRAPPER_AS_ARRAY_NAME

public static final java.lang.String JSON_WRAPPER_AS_ARRAY_NAME
The Constant JSON_WRAPPER_AS_ARRAY_NAME. If true the grouping element will be used as the JSON key. There is no effect when media type is "application/xml". When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this.

Example

Given the following class:

 @XmlAccessorType(XmlAccessType.FIELD)
 public class Customer {
 
     @XmlElementWrapper(name="phone-numbers")
     @XmlElement(name="phone-number")
     private List phoneNumbers;
 
 }
 

If the property is set to false (the default) the JSON output will be:

 {
     "phone-numbers" : {
         "phone-number" : [ {
             ...
         }, {
             ...
         }]
     }
 }
 

And if the property is set to true, then the JSON output will be:

 {
     "phone-numbers" : [ {
         ...
     }, {
         ...
     }]
 }
 

See Also:
org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME, org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, Constant Field Values
Since:
2.4.2
Constructor Detail

MarshallerProperties

public MarshallerProperties()

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference