下面列出了org.springframework.util.xml.StaxUtils#getXMLEventReader ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Template method for handling {@code StaxSource}s.
* <p>This implementation delegates to {@code unmarshalXmlStreamReader} or
* {@code unmarshalXmlEventReader}.
* @param staxSource the {@code StaxSource}
* @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 = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
return unmarshalXmlStreamReader(streamReader);
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
return unmarshalXmlEventReader(eventReader);
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}
}
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
return (this.mappedClass != null ?
jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
jaxbUnmarshaller.unmarshal(streamReader));
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
return (this.mappedClass != null ?
jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
jaxbUnmarshaller.unmarshal(eventReader));
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}
}
/**
* Template method for handling {@code StaxSource}s.
* <p>This implementation delegates to {@code unmarshalXmlStreamReader} or
* {@code unmarshalXmlEventReader}.
* @param staxSource the {@code StaxSource}
* @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 = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
return unmarshalXmlStreamReader(streamReader);
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
return unmarshalXmlEventReader(eventReader);
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}
}
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
return (this.mappedClass != null ?
jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
jaxbUnmarshaller.unmarshal(streamReader));
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
return (this.mappedClass != null ?
jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
jaxbUnmarshaller.unmarshal(eventReader));
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}
}
/**
* Template method for handling {@code StaxSource}s.
* <p>This implementation delegates to {@code unmarshalXmlStreamReader} or
* {@code unmarshalXmlEventReader}.
* @param staxSource the {@code StaxSource}
* @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 = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
return unmarshalXmlStreamReader(streamReader);
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
return unmarshalXmlEventReader(eventReader);
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}
}
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
return (this.mappedClass != null ?
jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
jaxbUnmarshaller.unmarshal(streamReader));
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
return (this.mappedClass != null ?
jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
jaxbUnmarshaller.unmarshal(eventReader));
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}
}