SWS-229 in 1.0 branch

This commit is contained in:
Arjen Poutsma
2007-11-21 01:07:21 +00:00
parent df1b8ad87d
commit b9329053cb
2 changed files with 19 additions and 7 deletions

View File

@@ -49,6 +49,12 @@ import org.jibx.runtime.impl.MarshallingContext;
import org.jibx.runtime.impl.StAXReaderWrapper;
import org.jibx.runtime.impl.StAXWriter;
import org.jibx.runtime.impl.UnmarshallingContext;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.oxm.AbstractMarshaller;
import org.springframework.oxm.XmlMappingException;
@@ -56,11 +62,6 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.xml.stream.StaxEventContentHandler;
import org.springframework.xml.stream.XmlEventStreamReader;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
/**
* Implementation of the <code>Marshaller</code> and <code>Unmarshaller</code> interfaces for JiBX.
@@ -138,7 +139,15 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
}
public boolean supports(Class clazz) {
return targetClass.isAssignableFrom(clazz);
Assert.notNull(clazz, "'clazz' must not be null");
String[] mappedClasses = bindingFactory.getMappedClasses();
String className = clazz.getName();
for (int i = 0; i < mappedClasses.length; i++) {
if (className.equals(mappedClasses[i])) {
return true;
}
}
return false;
}
/**

View File

@@ -17,6 +17,7 @@
package org.springframework.oxm.jibx;
import org.custommonkey.xmlunit.XMLUnit;
import org.springframework.oxm.AbstractMarshallerTestCase;
import org.springframework.oxm.Marshaller;
import org.springframework.xml.transform.StringResult;
@@ -69,7 +70,9 @@ public class JibxMarshallerTest extends AbstractMarshallerTestCase {
}
public void testSupports() throws Exception {
assertTrue("Jaxb2Marshaller does not support Flights", marshaller.supports(Flights.class));
assertTrue("JibxMarshaller does not support Flights", marshaller.supports(Flights.class));
assertTrue("JibxMarshaller does not support FlightType", marshaller.supports(FlightType.class));
assertFalse("JibxMarshaller supports illegal type", marshaller.supports(getClass()));
}