java.is.for.desktop
java.is.for.desktop

Reputation: 11216

JAXB: Which elements are marshallable|unmarshallable by default?

I know that this is specified somewhere, but just can't find it.

Somewhere in the JAXB api docs or spec there must be information about which properties a class must fulfill, so that JAXB can marshal|unmarshal it without the necessity of an JAXB type adapter.

It was something about toString(), the List interface, certain ctor signature must fit, and so on ...

Please point me to a location.

Upvotes: 2

Views: 1265

Answers (1)

bdoughan
bdoughan

Reputation: 149017

Section 5.4.1 of the JAXB 2.2 specification (JSR-222) talks about the creation requirements:

Creation

  • A value class supports creation via a public constructor, either an explicit one or the default no-arg constructor.
  • A factory method in the package’s ObjectFactory class (introduced in Section 5.2, “Java Package”). The factory method returns the type of the Java value class. The name of the factory method is generated by concatenating the following components:
    • The string constant create.
    • If the Java value class is nested within another value class, then the concatenation of all outer Java class names.
    • The name of the Java value class. For example, a Java value class named Foo that is nested within Java value class Bar would have the following factory method signature generated in the containing Java package’s ObjectFactory class: Bar.Foo createBarFoo() {...}

Section 5.5 covers Properties

Other

  • There is nothing in the JAXB specification regarding toString().

Upvotes: 2

Related Questions