Package org.eclipse.persistence.jaxb
Class UnmarshallerProperties
- java.lang.Object
-
- org.eclipse.persistence.jaxb.UnmarshallerProperties
-
public class UnmarshallerProperties extends java.lang.Object
These are properties that may be set on an instance of Unmarshaller. Below is an example of using the property mechanism to enable MOXy's JSON binding for an instance of Unmarshaller.Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTO_DETECT_MEDIA_TYPE
The name of the property used to specify if the media type should be auto detected (default is false).static java.lang.String
BEAN_VALIDATION_FACTORY
Property for setting preferred or custom validator factory.static java.lang.String
BEAN_VALIDATION_GROUPS
Property for setting bean validation target groups.static java.lang.String
BEAN_VALIDATION_MODE
Property for setting bean validation mode.static java.lang.String
BEAN_VALIDATION_NO_OPTIMISATION
Property for disabling Bean Validation optimisations.static java.lang.String
DISABLE_SECURE_PROCESSING
static java.lang.String
ID_RESOLVER
The name of the property used to specify a custom IDResolver class, to allow customization of ID/IDREF processing.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_NAMESPACE_PREFIX_MAPPER
The Constant JSON_NAMESPACE_PREFIX_MAPPER.static java.lang.String
JSON_NAMESPACE_SEPARATOR
The name of the property used to specify the character (default is '.')static java.lang.String
JSON_TYPE_ATTRIBUTE_NAME
Override default type property name for JSON as MOXy type discriminator.static java.lang.String
JSON_TYPE_COMPATIBILITY
If we should treat unqualified type property in JSON as MOXy type discriminator.static java.lang.String
JSON_USE_XSD_TYPES_WITH_PREFIX
If there should be xsd prefix when using simple types, e.g. xsd.int.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
MOXY_LOG_PAYLOAD
Property for logging Entities content during marshalling/unmarshalling operation in MOXy.static java.lang.String
MOXY_LOGGING_LEVEL
Property for MOXy logging level.static java.lang.String
OBJECT_GRAPH
static java.lang.String
UNMARSHALLING_CASE_INSENSITIVE
If set to Boolean.TRUE,JAXBUnmarshaller
will match XML Elements and XML Attributes to Java fields case insensitively.
-
Constructor Summary
Constructors Constructor Description UnmarshallerProperties()
-
-
-
Field Detail
-
ID_RESOLVER
public static final java.lang.String ID_RESOLVER
The name of the property used to specify a custom IDResolver class, to allow customization of ID/IDREF processing.- See Also:
IDResolver
, 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.
-
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:
JAXBContextProperties.JSON_INCLUDE_ROOT
,MarshallerProperties.JSON_INCLUDE_ROOT
, Constant Field Values- Since:
- 2.4
-
JSON_NAMESPACE_PREFIX_MAPPER
public static final java.lang.String JSON_NAMESPACE_PREFIX_MAPPER
The Constant JSON_NAMESPACE_PREFIX_MAPPER. Provides a means to set a a Map of namespace URIs to prefixes. Alternatively can be an implementation of NamespacePrefixMapper.- See Also:
NamespacePrefixMapper
, 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.
-
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:
JAXBContextProperties.JSON_VALUE_WRAPPER
,MarshallerProperties.JSON_VALUE_WRAPPER
, Constant Field Values- Since:
- 2.4
-
JSON_USE_XSD_TYPES_WITH_PREFIX
public static final java.lang.String JSON_USE_XSD_TYPES_WITH_PREFIX
If there should be xsd prefix when using simple types, e.g. xsd.int.
-
JSON_TYPE_COMPATIBILITY
public static final java.lang.String JSON_TYPE_COMPATIBILITY
If we should treat unqualified type property in JSON as MOXy type discriminator.
-
JSON_TYPE_ATTRIBUTE_NAME
public static final java.lang.String JSON_TYPE_ATTRIBUTE_NAME
Override default type property name for JSON as MOXy type discriminator. Settings from binding file have higher priority.Example
Given the following property
unmarshaller.setProperty(UnmarshallerProperties.JSON_TYPE_ATTRIBUTE_NAME, "mytype");
If the property is set the valid JSON input will be:
... { "mytype": "phone", "contactId": 3, "number": "987654321" } ...
for following object model
@XmlSeeAlso({Address.class, Phone.class}) public class Contact { public int contactId; ...
public class Phone extends Contact{ public String number; ...
If the property is not set (default value) the valid JSON input will be:
... { "type": "phone", "contactId": 3, "number": "987654321" } ...
Unmarshaller will use it as type discriminator to select right child class.
-
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:- MediaType.APPLICATION_XML (default)
- MediaType.APPLICATION_JSON
- "application/xml"
- "application/json"
- See Also:
JAXBContextProperties.MEDIA_TYPE
,MarshallerProperties.MEDIA_TYPE
,MediaType
, Constant Field Values- Since:
- 2.4
-
AUTO_DETECT_MEDIA_TYPE
public static final java.lang.String AUTO_DETECT_MEDIA_TYPE
The name of the property used to specify if the media type should be auto detected (default is false). Only set to true when the media type is unknown. Otherwise set the MEDIA_TYPE property. If the type can not be auto-detected an unmarshal with the MEDIA_TYPE value will be performed.- See Also:
MEDIA_TYPE
,MediaType
, Constant Field Values- Since:
- 2.4
-
OBJECT_GRAPH
public static final java.lang.String OBJECT_GRAPH
- See Also:
- Constant Field Values
-
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<PhoneNumber> 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" : [ { ... }, { ... }] }
-
UNMARSHALLING_CASE_INSENSITIVE
public static final java.lang.String UNMARSHALLING_CASE_INSENSITIVE
If set to Boolean.TRUE,JAXBUnmarshaller
will match XML Elements and XML Attributes to Java fields case insensitively.Example
Given the following class:
@XmlAccessorType(XmlAccessType.FIELD) public class Customer { @XmlElement private String name; @XmlAttribute private int id; }
If the property is set to true, the following XML object will match the class and will be unmarshalled.
<customer iD="007"> <nAMe>cafeBabe</nAMe> </customer>
By default, case-insensitive unmarshalling is turned off.
The property can be set through
JAXBUnmarshaller.setProperty(String, Object)
.
-
BEAN_VALIDATION_MODE
public static final java.lang.String BEAN_VALIDATION_MODE
Property for setting bean validation mode. Valid valuesBeanValidationMode.AUTO
(default),BeanValidationMode.CALLBACK
,BeanValidationMode.NONE
.
-
BEAN_VALIDATION_FACTORY
public static final java.lang.String BEAN_VALIDATION_FACTORY
Property for setting preferred or custom validator factory. Mapped value must be instance ofValidatorFactory
.
-
BEAN_VALIDATION_GROUPS
public static final java.lang.String BEAN_VALIDATION_GROUPS
Property for setting bean validation target groups. Mapped value must be of type Class[].
-
BEAN_VALIDATION_NO_OPTIMISATION
public static final java.lang.String BEAN_VALIDATION_NO_OPTIMISATION
Property for disabling Bean Validation optimisations. Bean Validation in MOXy features optimisations, which are used to skip BV processes on non-constrained objects. This is to make maintenance easier and to allow for debugging in case that some object is not validated, but should be. Usage: set toBoolean.TRUE
to disable optimisations, set toBoolean.FALSE
to re-enable them again.
-
DISABLE_SECURE_PROCESSING
public static final java.lang.String DISABLE_SECURE_PROCESSING
- See Also:
- Constant Field Values
-
MOXY_LOGGING_LEVEL
public static final java.lang.String MOXY_LOGGING_LEVEL
Property for MOXy logging level. This is to make maintenance easier and to allow MOXy generate more diagnostic log messages. Allowed values are specified inLogLevel
Default value isLogLevel.INFO
- See Also:
JAXBContextProperties.MOXY_LOGGING_LEVEL
,MarshallerProperties.MOXY_LOGGING_LEVEL
,LogLevel
, Constant Field Values- Since:
- 3.0
-
MOXY_LOG_PAYLOAD
public static final java.lang.String MOXY_LOG_PAYLOAD
Property for logging Entities content during marshalling/unmarshalling operation in MOXy. It calls toString() method from entity. This is to make maintenance easier and to allow for debugging to check marshalled/unmarshalled content. Use it carefully. It can produce high amount of data in the log files. Usage: set toBoolean.TRUE
to enable payload logging, set toBoolean.FALSE
to disable it. It can be set via system property with name "eclipselink.logging.payload.moxy" too. By default it is disabled.- See Also:
JAXBContextProperties.MOXY_LOG_PAYLOAD
,MarshallerProperties.MOXY_LOG_PAYLOAD
, Constant Field Values- Since:
- 3.0
-
-