private Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException { XMLStreamReader streamReader = TraxUtils.getXMLStreamReader(staxSource); if (streamReader != null) { return jaxbUnmarshaller.unmarshal(streamReader); } else { XMLEventReader eventReader = TraxUtils.getXMLEventReader(staxSource); if (eventReader != null) { return jaxbUnmarshaller.unmarshal(eventReader); } else { throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader"); } } }
/** * Template method for handling <code>StaxSource</code>s. This implementation defers to * <code>unmarshalXmlStreamReader</code>, or <code>unmarshalXmlEventReader</code>. * * @param staxSource the <code>StaxSource</code> * @return the object graph * @throws XmlMappingException if the given source cannot be mapped to an object */ protected Object unmarshalStaxSource(Source staxSource) throws XmlMappingException { XMLStreamReader streamReader = TraxUtils.getXMLStreamReader(staxSource); if (streamReader != null) { return unmarshalXmlStreamReader(streamReader); } else { XMLEventReader eventReader = TraxUtils.getXMLEventReader(staxSource); if (eventReader != null) { return unmarshalXmlEventReader(eventReader); } else { throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader"); } } }
public Object unmarshal(Source source) { if (TraxUtils.isStaxSource(source)) { XMLStreamReader streamReader = TraxUtils.getXMLStreamReader(source); if (streamReader != null) { source = new StaxSource(streamReader); } else { XMLEventReader eventReader = TraxUtils.getXMLEventReader(source); if (eventReader != null) { source = new StaxSource(eventReader); } else { throw new IllegalArgumentException( "StAXSource contains neither XMLStreamReader nor XMLEventReader"); } } } try { return createUnmarshaller().unmarshal(source); } catch (JAXBException ex) { throw convertJaxbException(ex); } }