| Revision 1351,
747 bytes
checked in by jharrop, 18 months ago
(diff) |
|
Apply Dave Brown's patch of 3 Dec 2010: - declare a JAXB type adapter (package-info.java) for java.math.BigInteger?
(BigIntegerAdapter?.java).
This works around a bug in old JAXB releases, where null numbers are serialized out as empty
string "", and cause deserialization errors later, on the way back in.
This simple workaround avoids great pain in environments where it is not easy to ensure a proper JAXB installation
|
| Line | |
|---|
| 1 | package org.docx4j.wml; |
|---|
| 2 | |
|---|
| 3 | import java.math.BigInteger; |
|---|
| 4 | import javax.xml.bind.annotation.adapters.XmlAdapter; |
|---|
| 5 | |
|---|
| 6 | public class BigIntegerAdapter extends XmlAdapter<String,BigInteger> { |
|---|
| 7 | |
|---|
| 8 | @Override |
|---|
| 9 | public String marshal(BigInteger bigDecimal) throws Exception { |
|---|
| 10 | if (bigDecimal != null){ |
|---|
| 11 | return bigDecimal.toString(); |
|---|
| 12 | } |
|---|
| 13 | else { |
|---|
| 14 | return null; |
|---|
| 15 | } |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | @Override |
|---|
| 19 | public BigInteger unmarshal(String s) throws Exception { |
|---|
| 20 | try { |
|---|
| 21 | return new BigInteger(s); |
|---|
| 22 | } catch (NumberFormatException e) { |
|---|
| 23 | return null; |
|---|
| 24 | } |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.