Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/370574"

Line 7: Line 7:
 
In the current JAXB RI, developed by Sun, there are a series of "proprietary" JAXB extensions that are available to provide advanced JAXB functionality outside of the JAXB spec.
 
In the current JAXB RI, developed by Sun, there are a series of "proprietary" JAXB extensions that are available to provide advanced JAXB functionality outside of the JAXB spec.
  
The '''Marshaller''' property '''com.sun.xml.bind.indentString''' provided in the Sun JAXB implementation allows users to override the indent string that is used when marshalling objects.
+
The '''Marshaller''' property '''com.sun.xml.bind.indentString''' provided in the Sun JAXB implementation allows users to override the indent string that is used when marshalling objects.  EclipseLink's default indent string is "  " (three spaces).
  
 
This document will outline the design for an EclipseLink equivalent to this extension.
 
This document will outline the design for an EclipseLink equivalent to this extension.
Line 21: Line 21:
  
 
If a custom indent string has been set on the '''Marshaller''', then an element of depth ''k'' will be indented by printing this string ''k'' times.  Custom indenting is only applicable if the '''Marshaller''' property '''Marshaller.JAXB_FORMATTED_OUTPUT''' / '''"jaxb.formatted.output"''' is enabled.
 
If a custom indent string has been set on the '''Marshaller''', then an element of depth ''k'' will be indented by printing this string ''k'' times.  Custom indenting is only applicable if the '''Marshaller''' property '''Marshaller.JAXB_FORMATTED_OUTPUT''' / '''"jaxb.formatted.output"''' is enabled.
 +
 +
 +
= Configuration =
 +
 +
A custom indent string can be specified on a '''Marshaller''' using the <tt>addProperty()</tt> method:
 +
 +
<div style="width:800px">
 +
<source lang="java">
 +
...
 +
JAXBContext ctx = ...
 +
Marshaller u = ctx.createMarshaller();
 +
u.setProperty(IDResolver.class.getName(), new MyIDResolver());
 +
...
 +
</source>
 +
</div>

Revision as of 11:58, 7 February 2012

Design Documentation: IndentString

ER 370574

In the current JAXB RI, developed by Sun, there are a series of "proprietary" JAXB extensions that are available to provide advanced JAXB functionality outside of the JAXB spec.

The Marshaller property com.sun.xml.bind.indentString provided in the Sun JAXB implementation allows users to override the indent string that is used when marshalling objects. EclipseLink's default indent string is " " (three spaces).

This document will outline the design for an EclipseLink equivalent to this extension.


Requirements

  • Provide support in EclipseLink's JAXBMarshaller to customize the indent string used.
  • Allow the usage of Sun JAXB property names to set this feature, so that no code changes are required for users migrating from Sun to EclipseLink JAXB.


Behaviour

If a custom indent string has been set on the Marshaller, then an element of depth k will be indented by printing this string k times. Custom indenting is only applicable if the Marshaller property Marshaller.JAXB_FORMATTED_OUTPUT / "jaxb.formatted.output" is enabled.


Configuration

A custom indent string can be specified on a Marshaller using the addProperty() method:

...
JAXBContext ctx = ...
Marshaller u = ctx.createMarshaller();
u.setProperty(IDResolver.class.getName(), new MyIDResolver());
...

Back to the top