Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/MOXy/Simple Values/Special Schema Types/Binary Types"

Line 19: Line 19:
 
<div style="width:700px">
 
<div style="width:700px">
 
<source lang="java">
 
<source lang="java">
 +
package example;
 +
 +
import javax.xml.bind.annotation.*;
 +
 +
@XmlRootElement
 +
@XmlAccessorType(AccessType.FIELD)
 +
public class Employee {
 +
 +
  private String name;
 +
  private byte[] photo;
 +
  private Byte[] pgpKey;
 +
  ...
 
</source>
 
</source>

Revision as of 11:36, 28 June 2011

EclipseLink MOXy

link="http://wiki.eclipse.org/EclipseLink"
EclipseLink
Website
Download
Community
Mailing ListForumsIRC
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse Source

Elug api package icon.png Key API

Binary Types

There are a few extra things to consider when mapping to fields of type byte[ ] or Byte[ ].


byte[ ] versus Byte[ ]

Unlike other Java primitive/wrapper types, Eclipselink differentiates between byte[ ] (primitive) and Byte[ ] (wrapper) data types. By default, byte[ ] will marshal to an element or attribute of type base64Binary, whereas Byte[ ] will marshal each byte as its own element.

package example;
 
import javax.xml.bind.annotation.*;
 
@XmlRootElement
@XmlAccessorType(AccessType.FIELD)
public class Employee {
 
   private String name;
   private byte[] photo;
   private Byte[] pgpKey;
   ...