Added @Override
This commit is contained in:
parent
03582973d7
commit
6ba9ad8116
|
|
@ -264,33 +264,39 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
// Marshalling
|
// Marshalling
|
||||||
//
|
//
|
||||||
|
|
||||||
protected final void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected final void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
||||||
marshalSaxHandlers(graph, new DomContentHandler(node), null);
|
marshalSaxHandlers(graph, new DomContentHandler(node), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
@Override
|
||||||
|
protected final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
||||||
throws XmlMappingException {
|
throws XmlMappingException {
|
||||||
Marshaller marshaller = xmlContext.createMarshaller();
|
Marshaller marshaller = xmlContext.createMarshaller();
|
||||||
marshaller.setContentHandler(contentHandler);
|
marshaller.setContentHandler(contentHandler);
|
||||||
marshal(graph, marshaller);
|
marshal(graph, marshaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalOutputStream(Object graph, OutputStream outputStream)
|
@Override
|
||||||
|
protected final void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
marshalWriter(graph, new OutputStreamWriter(outputStream, encoding));
|
marshalWriter(graph, new OutputStreamWriter(outputStream, encoding));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected final void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
||||||
Marshaller marshaller = xmlContext.createMarshaller();
|
Marshaller marshaller = xmlContext.createMarshaller();
|
||||||
marshaller.setWriter(writer);
|
marshaller.setWriter(writer);
|
||||||
marshal(graph, marshaller);
|
marshal(graph, marshaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) throws XmlMappingException {
|
@Override
|
||||||
|
protected final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) throws XmlMappingException {
|
||||||
marshalSaxHandlers(graph, new StaxEventContentHandler(eventWriter), null);
|
marshalSaxHandlers(graph, new StaxEventContentHandler(eventWriter), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
@Override
|
||||||
|
protected final void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
||||||
marshalSaxHandlers(graph, new StaxStreamContentHandler(streamWriter), null);
|
marshalSaxHandlers(graph, new StaxStreamContentHandler(streamWriter), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,7 +333,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
// Unmarshalling
|
// Unmarshalling
|
||||||
//
|
//
|
||||||
|
|
||||||
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
return createUnmarshaller().unmarshal(node);
|
return createUnmarshaller().unmarshal(node);
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +343,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
return createUnmarshaller().unmarshal(new InputSource(inputStream));
|
return createUnmarshaller().unmarshal(new InputSource(inputStream));
|
||||||
}
|
}
|
||||||
|
|
@ -345,7 +353,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected final Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
return createUnmarshaller().unmarshal(new InputSource(reader));
|
return createUnmarshaller().unmarshal(new InputSource(reader));
|
||||||
}
|
}
|
||||||
|
|
@ -354,7 +363,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalXmlEventReader(XMLEventReader eventReader) {
|
@Override
|
||||||
|
protected final Object unmarshalXmlEventReader(XMLEventReader eventReader) {
|
||||||
XMLReader reader = new StaxEventXmlReader(eventReader);
|
XMLReader reader = new StaxEventXmlReader(eventReader);
|
||||||
try {
|
try {
|
||||||
return unmarshalSaxReader(reader, new InputSource());
|
return unmarshalSaxReader(reader, new InputSource());
|
||||||
|
|
@ -364,7 +374,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
@Override
|
||||||
|
protected final Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
UnmarshalHandler unmarshalHandler = createUnmarshaller().createHandler();
|
UnmarshalHandler unmarshalHandler = createUnmarshaller().createHandler();
|
||||||
try {
|
try {
|
||||||
|
|
@ -378,7 +389,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalXmlStreamReader(XMLStreamReader streamReader) {
|
@Override
|
||||||
|
protected final Object unmarshalXmlStreamReader(XMLStreamReader streamReader) {
|
||||||
XMLReader reader = new StaxStreamXmlReader(streamReader);
|
XMLReader reader = new StaxStreamXmlReader(streamReader);
|
||||||
try {
|
try {
|
||||||
return unmarshalSaxReader(reader, new InputSource());
|
return unmarshalSaxReader(reader, new InputSource());
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ class Jaxb1MarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionPa
|
||||||
|
|
||||||
public static final String JAXB1_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb1Marshaller";
|
public static final String JAXB1_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb1Marshaller";
|
||||||
|
|
||||||
protected String getBeanClassName(Element element) {
|
@Override
|
||||||
|
protected String getBeanClassName(Element element) {
|
||||||
return JAXB1_MARSHALLER_CLASS_NAME;
|
return JAXB1_MARSHALLER_CLASS_NAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,13 @@ class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionPa
|
||||||
|
|
||||||
private static final String JAXB2_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller";
|
private static final String JAXB2_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller";
|
||||||
|
|
||||||
protected String getBeanClassName(Element element) {
|
@Override
|
||||||
|
protected String getBeanClassName(Element element) {
|
||||||
return JAXB2_MARSHALLER_CLASS_NAME;
|
return JAXB2_MARSHALLER_CLASS_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
@Override
|
||||||
|
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||||
String contextPath = element.getAttribute("contextPath");
|
String contextPath = element.getAttribute("contextPath");
|
||||||
if (StringUtils.hasText(contextPath)) {
|
if (StringUtils.hasText(contextPath)) {
|
||||||
beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
|
beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ class JibxMarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionPar
|
||||||
|
|
||||||
private static final String JIBX_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jibx.JibxMarshaller";
|
private static final String JIBX_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jibx.JibxMarshaller";
|
||||||
|
|
||||||
protected String getBeanClassName(Element element) {
|
@Override
|
||||||
|
protected String getBeanClassName(Element element) {
|
||||||
return JIBX_MARSHALLER_CLASS_NAME;
|
return JIBX_MARSHALLER_CLASS_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,13 @@ class XmlBeansMarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitio
|
||||||
|
|
||||||
public static final String XML_BEANS_MARSHALLER_CLASS_NAME = "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
|
public static final String XML_BEANS_MARSHALLER_CLASS_NAME = "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
|
||||||
|
|
||||||
protected String getBeanClassName(Element element) {
|
@Override
|
||||||
|
protected String getBeanClassName(Element element) {
|
||||||
return XML_BEANS_MARSHALLER_CLASS_NAME;
|
return XML_BEANS_MARSHALLER_CLASS_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
@Override
|
||||||
|
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
|
||||||
String optionsName = element.getAttribute("options");
|
String optionsName = element.getAttribute("options");
|
||||||
if (StringUtils.hasText(optionsName)) {
|
if (StringUtils.hasText(optionsName)) {
|
||||||
beanDefinitionBuilder.addPropertyReference("xmlOptions", optionsName);
|
beanDefinitionBuilder.addPropertyReference("xmlOptions", optionsName);
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ public class Jaxb1Marshaller extends AbstractJaxbMarshaller implements BeanClass
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final JAXBContext createJaxbContext() throws JAXBException {
|
@Override
|
||||||
|
protected final JAXBContext createJaxbContext() throws JAXBException {
|
||||||
if (!StringUtils.hasLength(getContextPath())) {
|
if (!StringUtils.hasLength(getContextPath())) {
|
||||||
throw new IllegalArgumentException("contextPath is required");
|
throw new IllegalArgumentException("contextPath is required");
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +96,8 @@ public class Jaxb1Marshaller extends AbstractJaxbMarshaller implements BeanClass
|
||||||
JAXBContext.newInstance(getContextPath());
|
JAXBContext.newInstance(getContextPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
@Override
|
||||||
|
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
||||||
unmarshaller.setValidating(validating);
|
unmarshaller.setValidating(validating);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
* JAXBContext
|
* JAXBContext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected JAXBContext createJaxbContext() throws Exception {
|
@Override
|
||||||
|
protected JAXBContext createJaxbContext() throws Exception {
|
||||||
if (JaxbUtils.getJaxbVersion() < JaxbUtils.JAXB_2) {
|
if (JaxbUtils.getJaxbVersion() < JaxbUtils.JAXB_2) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Cannot use Jaxb2Marshaller in combination with JAXB 1.0. Use Jaxb1Marshaller instead.");
|
"Cannot use Jaxb2Marshaller in combination with JAXB 1.0. Use Jaxb1Marshaller instead.");
|
||||||
|
|
@ -330,7 +331,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
* Marshaller/Unmarshaller
|
* Marshaller/Unmarshaller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
|
@Override
|
||||||
|
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
|
||||||
if (schema != null) {
|
if (schema != null) {
|
||||||
marshaller.setSchema(schema);
|
marshaller.setSchema(schema);
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +346,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
@Override
|
||||||
|
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
||||||
if (schema != null) {
|
if (schema != null) {
|
||||||
unmarshaller.setSchema(schema);
|
unmarshaller.setSchema(schema);
|
||||||
}
|
}
|
||||||
|
|
@ -454,7 +457,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
this.mimeContainer = mimeContainer;
|
this.mimeContainer = mimeContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String addMtomAttachment(byte[] data,
|
@Override
|
||||||
|
public String addMtomAttachment(byte[] data,
|
||||||
int offset,
|
int offset,
|
||||||
int length,
|
int length,
|
||||||
String mimeType,
|
String mimeType,
|
||||||
|
|
@ -464,7 +468,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
return addMtomAttachment(new DataHandler(dataSource), elementNamespace, elementLocalName);
|
return addMtomAttachment(new DataHandler(dataSource), elementNamespace, elementLocalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String addMtomAttachment(DataHandler dataHandler, String elementNamespace, String elementLocalName) {
|
@Override
|
||||||
|
public String addMtomAttachment(DataHandler dataHandler, String elementNamespace, String elementLocalName) {
|
||||||
String host = getHost(elementNamespace, dataHandler);
|
String host = getHost(elementNamespace, dataHandler);
|
||||||
String contentId = UUID.randomUUID() + "@" + host;
|
String contentId = UUID.randomUUID() + "@" + host;
|
||||||
mimeContainer.addAttachment("<" + contentId + ">", dataHandler);
|
mimeContainer.addAttachment("<" + contentId + ">", dataHandler);
|
||||||
|
|
@ -488,7 +493,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
return dataHandler.getName();
|
return dataHandler.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String addSwaRefAttachment(DataHandler dataHandler) {
|
@Override
|
||||||
|
public String addSwaRefAttachment(DataHandler dataHandler) {
|
||||||
String contentId = UUID.randomUUID() + "@" + dataHandler.getName();
|
String contentId = UUID.randomUUID() + "@" + dataHandler.getName();
|
||||||
mimeContainer.addAttachment(contentId, dataHandler);
|
mimeContainer.addAttachment(contentId, dataHandler);
|
||||||
return contentId;
|
return contentId;
|
||||||
|
|
@ -508,7 +514,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
this.mimeContainer = mimeContainer;
|
this.mimeContainer = mimeContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getAttachmentAsByteArray(String cid) {
|
@Override
|
||||||
|
public byte[] getAttachmentAsByteArray(String cid) {
|
||||||
try {
|
try {
|
||||||
DataHandler dataHandler = getAttachmentAsDataHandler(cid);
|
DataHandler dataHandler = getAttachmentAsDataHandler(cid);
|
||||||
return FileCopyUtils.copyToByteArray(dataHandler.getInputStream());
|
return FileCopyUtils.copyToByteArray(dataHandler.getInputStream());
|
||||||
|
|
@ -518,7 +525,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataHandler getAttachmentAsDataHandler(String contentId) {
|
@Override
|
||||||
|
public DataHandler getAttachmentAsDataHandler(String contentId) {
|
||||||
if (contentId.startsWith("cid:")) {
|
if (contentId.startsWith("cid:")) {
|
||||||
contentId = contentId.substring("cid:".length());
|
contentId = contentId.substring("cid:".length());
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
// Supported Marshalling
|
// Supported Marshalling
|
||||||
//
|
//
|
||||||
|
|
||||||
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
@Override
|
||||||
|
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
IMarshallingContext marshallingContext = createMarshallingContext();
|
IMarshallingContext marshallingContext = createMarshallingContext();
|
||||||
|
|
@ -184,7 +185,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
IMarshallingContext marshallingContext = createMarshallingContext();
|
IMarshallingContext marshallingContext = createMarshallingContext();
|
||||||
marshallingContext.marshalDocument(graph, encoding, standalone, writer);
|
marshallingContext.marshalDocument(graph, encoding, standalone, writer);
|
||||||
|
|
@ -194,7 +196,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
@Override
|
||||||
|
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
|
MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
|
||||||
IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
|
IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
|
||||||
|
|
@ -210,7 +213,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
// Unsupported Marshalling
|
// Unsupported Marshalling
|
||||||
//
|
//
|
||||||
|
|
||||||
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
// JiBX does not support DOM natively, so we write to a buffer first, and transform that to the Node
|
// JiBX does not support DOM natively, so we write to a buffer first, and transform that to the Node
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
|
@ -227,7 +231,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
@Override
|
||||||
|
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
||||||
throws XmlMappingException {
|
throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
// JiBX does not support SAX natively, so we write to a buffer first, and transform that to the handlers
|
// JiBX does not support SAX natively, so we write to a buffer first, and transform that to the handlers
|
||||||
|
|
@ -247,7 +252,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
|
@Override
|
||||||
|
protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
|
||||||
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
||||||
marshalSaxHandlers(graph, contentHandler, null);
|
marshalSaxHandlers(graph, contentHandler, null);
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +262,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
// Unmarshalling
|
// Unmarshalling
|
||||||
//
|
//
|
||||||
|
|
||||||
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
|
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
|
||||||
return unmarshallingContext.unmarshalDocument(inputStream, null);
|
return unmarshallingContext.unmarshalDocument(inputStream, null);
|
||||||
|
|
@ -266,7 +273,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
|
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
|
||||||
return unmarshallingContext.unmarshalDocument(reader);
|
return unmarshallingContext.unmarshalDocument(reader);
|
||||||
|
|
@ -276,7 +284,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) {
|
@Override
|
||||||
|
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) {
|
||||||
try {
|
try {
|
||||||
UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext();
|
UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext();
|
||||||
IXMLReader xmlReader = new StAXReaderWrapper(streamReader, null, true);
|
IXMLReader xmlReader = new StAXReaderWrapper(streamReader, null, true);
|
||||||
|
|
@ -288,7 +297,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) {
|
@Override
|
||||||
|
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) {
|
||||||
try {
|
try {
|
||||||
XMLStreamReader streamReader = new XmlEventStreamReader(eventReader);
|
XMLStreamReader streamReader = new XmlEventStreamReader(eventReader);
|
||||||
return unmarshalXmlStreamReader(streamReader);
|
return unmarshalXmlStreamReader(streamReader);
|
||||||
|
|
@ -302,7 +312,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
// Unsupported Unmarshalling
|
// Unsupported Unmarshalling
|
||||||
//
|
//
|
||||||
|
|
||||||
protected Object unmarshalDomNode(Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
Transformer transformer = transformerFactory.newTransformer();
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
|
@ -318,7 +329,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
@Override
|
||||||
|
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
Transformer transformer = transformerFactory.newTransformer();
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
return XmlObject.class.isAssignableFrom(clazz);
|
return XmlObject.class.isAssignableFrom(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected final void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
||||||
Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node : node.getOwnerDocument();
|
Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node : node.getOwnerDocument();
|
||||||
Node xmlBeansNode = ((XmlObject) graph).newDomNode(getXmlOptions());
|
Node xmlBeansNode = ((XmlObject) graph).newDomNode(getXmlOptions());
|
||||||
NodeList xmlBeansChildNodes = xmlBeansNode.getChildNodes();
|
NodeList xmlBeansChildNodes = xmlBeansNode.getChildNodes();
|
||||||
|
|
@ -99,12 +100,14 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalOutputStream(Object graph, OutputStream outputStream)
|
@Override
|
||||||
|
protected final void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
((XmlObject) graph).save(outputStream, getXmlOptions());
|
((XmlObject) graph).save(outputStream, getXmlOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
@Override
|
||||||
|
protected final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
||||||
throws XmlMappingException {
|
throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
((XmlObject) graph).save(contentHandler, lexicalHandler, getXmlOptions());
|
((XmlObject) graph).save(contentHandler, lexicalHandler, getXmlOptions());
|
||||||
|
|
@ -114,21 +117,25 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected final void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
||||||
((XmlObject) graph).save(writer, getXmlOptions());
|
((XmlObject) graph).save(writer, getXmlOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
|
@Override
|
||||||
|
protected final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
|
||||||
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
||||||
marshalSaxHandlers(graph, contentHandler, null);
|
marshalSaxHandlers(graph, contentHandler, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
@Override
|
||||||
|
protected final void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
||||||
ContentHandler contentHandler = new StaxStreamContentHandler(streamWriter);
|
ContentHandler contentHandler = new StaxStreamContentHandler(streamWriter);
|
||||||
marshalSaxHandlers(graph, contentHandler, null);
|
marshalSaxHandlers(graph, contentHandler, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
XmlObject object = XmlObject.Factory.parse(node, getXmlOptions());
|
XmlObject object = XmlObject.Factory.parse(node, getXmlOptions());
|
||||||
validate(object);
|
validate(object);
|
||||||
|
|
@ -139,7 +146,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected final Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
XmlObject object = XmlObject.Factory.parse(inputStream, getXmlOptions());
|
XmlObject object = XmlObject.Factory.parse(inputStream, getXmlOptions());
|
||||||
validate(object);
|
validate(object);
|
||||||
|
|
@ -150,7 +158,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected final Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
||||||
try {
|
try {
|
||||||
XmlObject object = XmlObject.Factory.parse(reader, getXmlOptions());
|
XmlObject object = XmlObject.Factory.parse(reader, getXmlOptions());
|
||||||
validate(object);
|
validate(object);
|
||||||
|
|
@ -161,7 +170,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
@Override
|
||||||
|
protected final Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
XmlSaxHandler saxHandler = XmlObject.Factory.newXmlSaxHandler(getXmlOptions());
|
XmlSaxHandler saxHandler = XmlObject.Factory.newXmlSaxHandler(getXmlOptions());
|
||||||
xmlReader.setContentHandler(saxHandler.getContentHandler());
|
xmlReader.setContentHandler(saxHandler.getContentHandler());
|
||||||
|
|
@ -188,7 +198,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
|
@Override
|
||||||
|
protected final Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
|
||||||
XMLReader reader = new StaxEventXmlReader(eventReader);
|
XMLReader reader = new StaxEventXmlReader(eventReader);
|
||||||
try {
|
try {
|
||||||
return unmarshalSaxReader(reader, new InputSource());
|
return unmarshalSaxReader(reader, new InputSource());
|
||||||
|
|
@ -198,7 +209,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException {
|
@Override
|
||||||
|
protected final Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
XmlObject object = XmlObject.Factory.parse(streamReader, getXmlOptions());
|
XmlObject object = XmlObject.Factory.parse(streamReader, getXmlOptions());
|
||||||
validate(object);
|
validate(object);
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,8 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
||||||
HierarchicalStreamWriter streamWriter;
|
HierarchicalStreamWriter streamWriter;
|
||||||
if (node instanceof Document) {
|
if (node instanceof Document) {
|
||||||
streamWriter = new DomWriter((Document) node);
|
streamWriter = new DomWriter((Document) node);
|
||||||
|
|
@ -362,12 +363,14 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
marshal(graph, streamWriter);
|
marshal(graph, streamWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) throws XmlMappingException {
|
@Override
|
||||||
|
protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) throws XmlMappingException {
|
||||||
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
||||||
marshalSaxHandlers(graph, contentHandler, null);
|
marshalSaxHandlers(graph, contentHandler, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
@Override
|
||||||
|
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
marshal(graph, new StaxWriter(new QNameMap(), streamWriter));
|
marshal(graph, new StaxWriter(new QNameMap(), streamWriter));
|
||||||
}
|
}
|
||||||
|
|
@ -376,19 +379,22 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
@Override
|
||||||
|
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
marshalWriter(graph, new OutputStreamWriter(outputStream, getEncoding()));
|
marshalWriter(graph, new OutputStreamWriter(outputStream, getEncoding()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
@Override
|
||||||
|
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
||||||
throws XmlMappingException {
|
throws XmlMappingException {
|
||||||
SaxWriter saxWriter = new SaxWriter();
|
SaxWriter saxWriter = new SaxWriter();
|
||||||
saxWriter.setContentHandler(contentHandler);
|
saxWriter.setContentHandler(contentHandler);
|
||||||
marshal(graph, saxWriter);
|
marshal(graph, saxWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
|
||||||
if (streamDriver != null) {
|
if (streamDriver != null) {
|
||||||
marshal(graph, streamDriver.createWriter(writer));
|
marshal(graph, streamDriver.createWriter(writer));
|
||||||
}
|
}
|
||||||
|
|
@ -410,7 +416,8 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalDomNode(Node node) throws XmlMappingException {
|
@Override
|
||||||
|
protected Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||||
HierarchicalStreamReader streamReader;
|
HierarchicalStreamReader streamReader;
|
||||||
if (node instanceof Document) {
|
if (node instanceof Document) {
|
||||||
streamReader = new DomReader((Document) node);
|
streamReader = new DomReader((Document) node);
|
||||||
|
|
@ -424,7 +431,8 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
return unmarshal(streamReader);
|
return unmarshal(streamReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
|
@Override
|
||||||
|
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
|
||||||
try {
|
try {
|
||||||
XMLStreamReader streamReader = new XmlEventStreamReader(eventReader);
|
XMLStreamReader streamReader = new XmlEventStreamReader(eventReader);
|
||||||
return unmarshalXmlStreamReader(streamReader);
|
return unmarshalXmlStreamReader(streamReader);
|
||||||
|
|
@ -434,15 +442,18 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException {
|
@Override
|
||||||
|
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException {
|
||||||
return unmarshal(new StaxReader(new QNameMap(), streamReader));
|
return unmarshal(new StaxReader(new QNameMap(), streamReader));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||||
return unmarshalReader(new InputStreamReader(inputStream, getEncoding()));
|
return unmarshalReader(new InputStreamReader(inputStream, getEncoding()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
@Override
|
||||||
|
protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
|
||||||
if (streamDriver != null) {
|
if (streamDriver != null) {
|
||||||
return unmarshal(streamDriver.createReader(reader));
|
return unmarshal(streamDriver.createReader(reader));
|
||||||
}
|
}
|
||||||
|
|
@ -451,7 +462,8 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
@Override
|
||||||
|
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
|
||||||
throws XmlMappingException, IOException {
|
throws XmlMappingException, IOException {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"XStreamMarshaller does not support unmarshalling using SAX XMLReaders");
|
"XStreamMarshaller does not support unmarshalling using SAX XMLReaders");
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ import org.xml.sax.ContentHandler;
|
||||||
|
|
||||||
public class CastorMarshallerTest extends AbstractMarshallerTestCase {
|
public class CastorMarshallerTest extends AbstractMarshallerTestCase {
|
||||||
|
|
||||||
protected Marshaller createMarshaller() throws Exception {
|
@Override
|
||||||
|
protected Marshaller createMarshaller() throws Exception {
|
||||||
CastorMarshaller marshaller = new CastorMarshaller();
|
CastorMarshaller marshaller = new CastorMarshaller();
|
||||||
ClassPathResource mappingLocation = new ClassPathResource("mapping.xml", CastorMarshaller.class);
|
ClassPathResource mappingLocation = new ClassPathResource("mapping.xml", CastorMarshaller.class);
|
||||||
marshaller.setMappingLocation(mappingLocation);
|
marshaller.setMappingLocation(mappingLocation);
|
||||||
|
|
@ -33,7 +34,8 @@ public class CastorMarshallerTest extends AbstractMarshallerTestCase {
|
||||||
return marshaller;
|
return marshaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object createFlights() {
|
@Override
|
||||||
|
protected Object createFlights() {
|
||||||
Flight flight = new Flight();
|
Flight flight = new Flight();
|
||||||
flight.setNumber(42L);
|
flight.setNumber(42L);
|
||||||
Flights flights = new Flights();
|
Flights flights = new Flights();
|
||||||
|
|
|
||||||
|
|
@ -25,20 +25,23 @@ import org.springframework.oxm.Unmarshaller;
|
||||||
|
|
||||||
public class CastorUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
public class CastorUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
|
|
||||||
protected void testFlights(Object o) {
|
@Override
|
||||||
|
protected void testFlights(Object o) {
|
||||||
Flights flights = (Flights) o;
|
Flights flights = (Flights) o;
|
||||||
assertNotNull("Flights is null", flights);
|
assertNotNull("Flights is null", flights);
|
||||||
assertEquals("Invalid amount of flight elements", 1, flights.getFlightCount());
|
assertEquals("Invalid amount of flight elements", 1, flights.getFlightCount());
|
||||||
testFlight(flights.getFlight()[0]);
|
testFlight(flights.getFlight()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlight(Object o) {
|
@Override
|
||||||
|
protected void testFlight(Object o) {
|
||||||
Flight flight = (Flight) o;
|
Flight flight = (Flight) o;
|
||||||
assertNotNull("Flight is null", flight);
|
assertNotNull("Flight is null", flight);
|
||||||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
@Override
|
||||||
|
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||||
CastorMarshaller marshaller = new CastorMarshaller();
|
CastorMarshaller marshaller = new CastorMarshaller();
|
||||||
ClassPathResource mappingLocation = new ClassPathResource("mapping.xml", CastorMarshaller.class);
|
ClassPathResource mappingLocation = new ClassPathResource("mapping.xml", CastorMarshaller.class);
|
||||||
marshaller.setMappingLocation(mappingLocation);
|
marshaller.setMappingLocation(mappingLocation);
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,16 @@ public class Jaxb1MarshallerTest extends AbstractJaxbMarshallerTestCase {
|
||||||
|
|
||||||
private static final String CONTEXT_PATH = "org.springframework.oxm.jaxb1";
|
private static final String CONTEXT_PATH = "org.springframework.oxm.jaxb1";
|
||||||
|
|
||||||
protected final Marshaller createMarshaller() throws Exception {
|
@Override
|
||||||
|
protected final Marshaller createMarshaller() throws Exception {
|
||||||
Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
|
Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
|
||||||
marshaller.setContextPaths(new String[]{CONTEXT_PATH});
|
marshaller.setContextPaths(new String[]{CONTEXT_PATH});
|
||||||
marshaller.afterPropertiesSet();
|
marshaller.afterPropertiesSet();
|
||||||
return marshaller;
|
return marshaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object createFlights() {
|
@Override
|
||||||
|
protected Object createFlights() {
|
||||||
FlightType flight = new FlightTypeImpl();
|
FlightType flight = new FlightTypeImpl();
|
||||||
flight.setNumber(42L);
|
flight.setNumber(42L);
|
||||||
Flights flights = new FlightsImpl();
|
Flights flights = new FlightsImpl();
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ import org.springframework.oxm.jaxb1.Flights;
|
||||||
|
|
||||||
public class Jaxb1UnmarshallerTest extends AbstractUnmarshallerTestCase {
|
public class Jaxb1UnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
|
|
||||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
@Override
|
||||||
|
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||||
Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
|
Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
|
||||||
marshaller.setContextPath("org.springframework.oxm.jaxb1");
|
marshaller.setContextPath("org.springframework.oxm.jaxb1");
|
||||||
marshaller.setValidating(true);
|
marshaller.setValidating(true);
|
||||||
|
|
@ -30,14 +31,16 @@ public class Jaxb1UnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
return marshaller;
|
return marshaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlights(Object o) {
|
@Override
|
||||||
|
protected void testFlights(Object o) {
|
||||||
Flights flights = (Flights) o;
|
Flights flights = (Flights) o;
|
||||||
assertNotNull("Flights is null", flights);
|
assertNotNull("Flights is null", flights);
|
||||||
assertEquals("Invalid amount of flight elements", 1, flights.getFlight().size());
|
assertEquals("Invalid amount of flight elements", 1, flights.getFlight().size());
|
||||||
testFlight(flights.getFlight().get(0));
|
testFlight(flights.getFlight().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlight(Object o) {
|
@Override
|
||||||
|
protected void testFlight(Object o) {
|
||||||
FlightType flight = (FlightType) o;
|
FlightType flight = (FlightType) o;
|
||||||
assertNotNull("Flight is null", flight);
|
assertNotNull("Flight is null", flight);
|
||||||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,16 @@ import org.springframework.xml.transform.StringResult;
|
||||||
|
|
||||||
public class JibxMarshallerTest extends AbstractMarshallerTestCase {
|
public class JibxMarshallerTest extends AbstractMarshallerTestCase {
|
||||||
|
|
||||||
protected Marshaller createMarshaller() throws Exception {
|
@Override
|
||||||
|
protected Marshaller createMarshaller() throws Exception {
|
||||||
JibxMarshaller marshaller = new JibxMarshaller();
|
JibxMarshaller marshaller = new JibxMarshaller();
|
||||||
marshaller.setTargetClass(Flights.class);
|
marshaller.setTargetClass(Flights.class);
|
||||||
marshaller.afterPropertiesSet();
|
marshaller.afterPropertiesSet();
|
||||||
return marshaller;
|
return marshaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object createFlights() {
|
@Override
|
||||||
|
protected Object createFlights() {
|
||||||
Flights flights = new Flights();
|
Flights flights = new Flights();
|
||||||
FlightType flight = new FlightType();
|
FlightType flight = new FlightType();
|
||||||
flight.setNumber(42L);
|
flight.setNumber(42L);
|
||||||
|
|
|
||||||
|
|
@ -20,27 +20,31 @@ import org.springframework.oxm.Unmarshaller;
|
||||||
|
|
||||||
public class JibxUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
public class JibxUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
|
|
||||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
@Override
|
||||||
|
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||||
JibxMarshaller unmarshaller = new JibxMarshaller();
|
JibxMarshaller unmarshaller = new JibxMarshaller();
|
||||||
unmarshaller.setTargetClass(Flights.class);
|
unmarshaller.setTargetClass(Flights.class);
|
||||||
unmarshaller.afterPropertiesSet();
|
unmarshaller.afterPropertiesSet();
|
||||||
return unmarshaller;
|
return unmarshaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlights(Object o) {
|
@Override
|
||||||
|
protected void testFlights(Object o) {
|
||||||
Flights flights = (Flights) o;
|
Flights flights = (Flights) o;
|
||||||
assertNotNull("Flights is null", flights);
|
assertNotNull("Flights is null", flights);
|
||||||
assertEquals("Invalid amount of flight elements", 1, flights.sizeFlightList());
|
assertEquals("Invalid amount of flight elements", 1, flights.sizeFlightList());
|
||||||
testFlight(flights.getFlight(0));
|
testFlight(flights.getFlight(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlight(Object o) {
|
@Override
|
||||||
|
protected void testFlight(Object o) {
|
||||||
FlightType flight = (FlightType) o;
|
FlightType flight = (FlightType) o;
|
||||||
assertNotNull("Flight is null", flight);
|
assertNotNull("Flight is null", flight);
|
||||||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnmarshalPartialStaxSourceXmlStreamReader() throws Exception {
|
@Override
|
||||||
|
public void testUnmarshalPartialStaxSourceXmlStreamReader() throws Exception {
|
||||||
// JiBX does not support reading XML fragments, hence the override here
|
// JiBX does not support reading XML fragments, hence the override here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ import org.springframework.samples.flight.FlightsDocument.Flights;
|
||||||
|
|
||||||
public class XmlBeansMarshallerTest extends AbstractMarshallerTestCase {
|
public class XmlBeansMarshallerTest extends AbstractMarshallerTestCase {
|
||||||
|
|
||||||
protected Marshaller createMarshaller() throws Exception {
|
@Override
|
||||||
|
protected Marshaller createMarshaller() throws Exception {
|
||||||
return new XmlBeansMarshaller();
|
return new XmlBeansMarshaller();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +42,8 @@ public class XmlBeansMarshallerTest extends AbstractMarshallerTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object createFlights() {
|
@Override
|
||||||
|
protected Object createFlights() {
|
||||||
FlightsDocument flightsDocument = FlightsDocument.Factory.newInstance();
|
FlightsDocument flightsDocument = FlightsDocument.Factory.newInstance();
|
||||||
Flights flights = flightsDocument.addNewFlights();
|
Flights flights = flightsDocument.addNewFlights();
|
||||||
FlightType flightType = flights.addNewFlight();
|
FlightType flightType = flights.addNewFlight();
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,13 @@ import org.springframework.xml.transform.StringSource;
|
||||||
|
|
||||||
public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
|
|
||||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
@Override
|
||||||
|
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||||
return new XmlBeansMarshaller();
|
return new XmlBeansMarshaller();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlights(Object o) {
|
@Override
|
||||||
|
protected void testFlights(Object o) {
|
||||||
FlightsDocument flightsDocument = (FlightsDocument) o;
|
FlightsDocument flightsDocument = (FlightsDocument) o;
|
||||||
assertNotNull("FlightsDocument is null", flightsDocument);
|
assertNotNull("FlightsDocument is null", flightsDocument);
|
||||||
Flights flights = flightsDocument.getFlights();
|
Flights flights = flightsDocument.getFlights();
|
||||||
|
|
@ -43,7 +45,8 @@ public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
testFlight(flights.getFlightArray(0));
|
testFlight(flights.getFlightArray(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testFlight(Object o) {
|
@Override
|
||||||
|
protected void testFlight(Object o) {
|
||||||
FlightType flight = null;
|
FlightType flight = null;
|
||||||
if (o instanceof FlightType) {
|
if (o instanceof FlightType) {
|
||||||
flight = (FlightType) o;
|
flight = (FlightType) o;
|
||||||
|
|
@ -56,7 +59,8 @@ public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnmarshalPartialStaxSourceXmlStreamReader() throws Exception {
|
@Override
|
||||||
|
public void testUnmarshalPartialStaxSourceXmlStreamReader() throws Exception {
|
||||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
|
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
|
||||||
streamReader.nextTag(); // skip to flights
|
streamReader.nextTag(); // skip to flights
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue