Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Development/370574

< EclipseLink‎ | Development
Revision as of 12:20, 22 February 2012 by Rick.barkhouse.oracle.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

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.

EclipseLink's default indent string is "   " (three spaces).


Configuration

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

...
JAXBContext ctx = ...
Marshaller m = ctx.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(org.eclipse.persistence.jaxb.JAXBMarshaller.INDENT_STRING, " "); // one space
...

Note: EclipseLink also supports Sun's indentString property names:

m.setProperty("com.sun.xml.bind.indentString", " ");
m.setProperty("com.sun.xml.internal.bind.indentString", " ");


Document History

Date Author Version Description & Notes
120207 Rick Barkhouse 1.00 : First draft
120222 Rick Barkhouse 1.10 : Updated property name

Back to the top