Say I'm trying to unmarshal an XML file with an integer field (xs:integer): 13131546456131653154156415616
This value is > Java Long's max value.
I was hoping to get and catch an exception when Jaxb tried to unmarshal it.
Instead, there is no exception, and my pojo's object.Value is set to null.
Is there a way to detect when this happens and log it?
I've tried using vec, but it caught nothing (empty list):
ValidationEventCollector vec = new ValidationEventCollector();
JAXBContext jaxbContext = JAXBContext.newInstance(MyPojo.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
jaxbUnmarshaller.setEventHandler(vec);
System.out.println(vec.getEvents().length);
MyPojo model = (MyPojo) jaxbUnmarshaller.unmarshal(new FileInputStream(file));
xs:integer
is not limited, it can be values of any length.The comparable Java type is
BigInteger
.xs:int
is however constrained to:And
xs:long
is constrained to:So if you want the XML Schema Validator to check the value ranges, use the appropriate type.