Added @Override
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@512 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
8df063b19e
commit
083e108162
|
|
@ -264,33 +264,39 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
|||
// 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);
|
||||
}
|
||||
|
||||
protected final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
||||
@Override
|
||||
protected final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
|
||||
throws XmlMappingException {
|
||||
Marshaller marshaller = xmlContext.createMarshaller();
|
||||
marshaller.setContentHandler(contentHandler);
|
||||
marshal(graph, marshaller);
|
||||
}
|
||||
|
||||
protected final void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||
@Override
|
||||
protected final void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||
throws XmlMappingException, IOException {
|
||||
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.setWriter(writer);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +333,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
|||
// Unmarshalling
|
||||
//
|
||||
|
||||
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||
@Override
|
||||
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||
try {
|
||||
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 {
|
||||
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 {
|
||||
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);
|
||||
try {
|
||||
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 {
|
||||
UnmarshalHandler unmarshalHandler = createUnmarshaller().createHandler();
|
||||
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);
|
||||
try {
|
||||
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";
|
||||
|
||||
protected String getBeanClassName(Element element) {
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
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";
|
||||
|
||||
protected String getBeanClassName(Element element) {
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
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");
|
||||
if (StringUtils.hasText(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";
|
||||
|
||||
protected String getBeanClassName(Element element) {
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
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";
|
||||
|
||||
protected String getBeanClassName(Element element) {
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
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");
|
||||
if (StringUtils.hasText(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())) {
|
||||
throw new IllegalArgumentException("contextPath is required");
|
||||
}
|
||||
|
|
@ -95,7 +96,8 @@ public class Jaxb1Marshaller extends AbstractJaxbMarshaller implements BeanClass
|
|||
JAXBContext.newInstance(getContextPath());
|
||||
}
|
||||
|
||||
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
||||
@Override
|
||||
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
|
||||
unmarshaller.setValidating(validating);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
|||
* JAXBContext
|
||||
*/
|
||||
|
||||
protected JAXBContext createJaxbContext() throws Exception {
|
||||
@Override
|
||||
protected JAXBContext createJaxbContext() throws Exception {
|
||||
if (JaxbUtils.getJaxbVersion() < JaxbUtils.JAXB_2) {
|
||||
throw new IllegalStateException(
|
||||
"Cannot use Jaxb2Marshaller in combination with JAXB 1.0. Use Jaxb1Marshaller instead.");
|
||||
|
|
@ -330,7 +331,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
|||
* Marshaller/Unmarshaller
|
||||
*/
|
||||
|
||||
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
|
||||
@Override
|
||||
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
|
||||
if (schema != null) {
|
||||
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) {
|
||||
unmarshaller.setSchema(schema);
|
||||
}
|
||||
|
|
@ -454,7 +457,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
|||
this.mimeContainer = mimeContainer;
|
||||
}
|
||||
|
||||
public String addMtomAttachment(byte[] data,
|
||||
@Override
|
||||
public String addMtomAttachment(byte[] data,
|
||||
int offset,
|
||||
int length,
|
||||
String mimeType,
|
||||
|
|
@ -464,7 +468,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
|||
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 contentId = UUID.randomUUID() + "@" + host;
|
||||
mimeContainer.addAttachment("<" + contentId + ">", dataHandler);
|
||||
|
|
@ -488,7 +493,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
|||
return dataHandler.getName();
|
||||
}
|
||||
|
||||
public String addSwaRefAttachment(DataHandler dataHandler) {
|
||||
@Override
|
||||
public String addSwaRefAttachment(DataHandler dataHandler) {
|
||||
String contentId = UUID.randomUUID() + "@" + dataHandler.getName();
|
||||
mimeContainer.addAttachment(contentId, dataHandler);
|
||||
return contentId;
|
||||
|
|
@ -508,7 +514,8 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
|
|||
this.mimeContainer = mimeContainer;
|
||||
}
|
||||
|
||||
public byte[] getAttachmentAsByteArray(String cid) {
|
||||
@Override
|
||||
public byte[] getAttachmentAsByteArray(String cid) {
|
||||
try {
|
||||
DataHandler dataHandler = getAttachmentAsDataHandler(cid);
|
||||
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:")) {
|
||||
contentId = contentId.substring("cid:".length());
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
|||
// Supported Marshalling
|
||||
//
|
||||
|
||||
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||
@Override
|
||||
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||
throws XmlMappingException, IOException {
|
||||
try {
|
||||
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 {
|
||||
IMarshallingContext marshallingContext = createMarshallingContext();
|
||||
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 {
|
||||
MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
|
||||
IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
|
||||
|
|
@ -210,7 +213,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
|||
// Unsupported Marshalling
|
||||
//
|
||||
|
||||
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
||||
@Override
|
||||
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
|
||||
try {
|
||||
// JiBX does not support DOM natively, so we write to a buffer first, and transform that to the Node
|
||||
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 {
|
||||
try {
|
||||
// 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);
|
||||
marshalSaxHandlers(graph, contentHandler, null);
|
||||
}
|
||||
|
|
@ -256,7 +262,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
|||
// Unmarshalling
|
||||
//
|
||||
|
||||
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||
@Override
|
||||
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||
try {
|
||||
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
|
||||
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 {
|
||||
IUnmarshallingContext unmarshallingContext = createUnmarshallingContext();
|
||||
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 {
|
||||
UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext();
|
||||
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 {
|
||||
XMLStreamReader streamReader = new XmlEventStreamReader(eventReader);
|
||||
return unmarshalXmlStreamReader(streamReader);
|
||||
|
|
@ -302,7 +312,8 @@ public class JibxMarshaller extends AbstractMarshaller implements InitializingBe
|
|||
// Unsupported Unmarshalling
|
||||
//
|
||||
|
||||
protected Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||
@Override
|
||||
protected Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||
try {
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
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 {
|
||||
try {
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
|
|
|
|||
|
|
@ -88,7 +88,8 @@ public class XmlBeansMarshaller extends AbstractMarshaller {
|
|||
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();
|
||||
Node xmlBeansNode = ((XmlObject) graph).newDomNode(getXmlOptions());
|
||||
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 {
|
||||
((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 {
|
||||
try {
|
||||
((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());
|
||||
}
|
||||
|
||||
protected final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
|
||||
@Override
|
||||
protected final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
|
||||
ContentHandler contentHandler = new StaxEventContentHandler(eventWriter);
|
||||
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);
|
||||
marshalSaxHandlers(graph, contentHandler, null);
|
||||
}
|
||||
|
||||
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||
@Override
|
||||
protected final Object unmarshalDomNode(Node node) throws XmlMappingException {
|
||||
try {
|
||||
XmlObject object = XmlObject.Factory.parse(node, getXmlOptions());
|
||||
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 {
|
||||
XmlObject object = XmlObject.Factory.parse(inputStream, getXmlOptions());
|
||||
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 {
|
||||
XmlObject object = XmlObject.Factory.parse(reader, getXmlOptions());
|
||||
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 {
|
||||
XmlSaxHandler saxHandler = XmlObject.Factory.newXmlSaxHandler(getXmlOptions());
|
||||
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);
|
||||
try {
|
||||
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 {
|
||||
XmlObject object = XmlObject.Factory.parse(streamReader, getXmlOptions());
|
||||
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;
|
||||
if (node instanceof Document) {
|
||||
streamWriter = new DomWriter((Document) node);
|
||||
|
|
@ -362,12 +363,14 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
|||
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);
|
||||
marshalSaxHandlers(graph, contentHandler, null);
|
||||
}
|
||||
|
||||
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
||||
@Override
|
||||
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
|
||||
try {
|
||||
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 {
|
||||
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 {
|
||||
SaxWriter saxWriter = new SaxWriter();
|
||||
saxWriter.setContentHandler(contentHandler);
|
||||
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) {
|
||||
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;
|
||||
if (node instanceof Document) {
|
||||
streamReader = new DomReader((Document) node);
|
||||
|
|
@ -424,7 +431,8 @@ public class XStreamMarshaller extends AbstractMarshaller {
|
|||
return unmarshal(streamReader);
|
||||
}
|
||||
|
||||
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
|
||||
@Override
|
||||
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
|
||||
try {
|
||||
XMLStreamReader streamReader = new XmlEventStreamReader(eventReader);
|
||||
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));
|
||||
}
|
||||
|
||||
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||
@Override
|
||||
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
|
||||
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) {
|
||||
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 {
|
||||
throw new UnsupportedOperationException(
|
||||
"XStreamMarshaller does not support unmarshalling using SAX XMLReaders");
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ import org.xml.sax.ContentHandler;
|
|||
|
||||
public class CastorMarshallerTest extends AbstractMarshallerTestCase {
|
||||
|
||||
protected Marshaller createMarshaller() throws Exception {
|
||||
@Override
|
||||
protected Marshaller createMarshaller() throws Exception {
|
||||
CastorMarshaller marshaller = new CastorMarshaller();
|
||||
ClassPathResource mappingLocation = new ClassPathResource("mapping.xml", CastorMarshaller.class);
|
||||
marshaller.setMappingLocation(mappingLocation);
|
||||
|
|
@ -33,7 +34,8 @@ public class CastorMarshallerTest extends AbstractMarshallerTestCase {
|
|||
return marshaller;
|
||||
}
|
||||
|
||||
protected Object createFlights() {
|
||||
@Override
|
||||
protected Object createFlights() {
|
||||
Flight flight = new Flight();
|
||||
flight.setNumber(42L);
|
||||
Flights flights = new Flights();
|
||||
|
|
|
|||
|
|
@ -25,20 +25,23 @@ import org.springframework.oxm.Unmarshaller;
|
|||
|
||||
public class CastorUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||
|
||||
protected void testFlights(Object o) {
|
||||
@Override
|
||||
protected void testFlights(Object o) {
|
||||
Flights flights = (Flights) o;
|
||||
assertNotNull("Flights is null", flights);
|
||||
assertEquals("Invalid amount of flight elements", 1, flights.getFlightCount());
|
||||
testFlight(flights.getFlight()[0]);
|
||||
}
|
||||
|
||||
protected void testFlight(Object o) {
|
||||
@Override
|
||||
protected void testFlight(Object o) {
|
||||
Flight flight = (Flight) o;
|
||||
assertNotNull("Flight is null", flight);
|
||||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||
}
|
||||
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
@Override
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
CastorMarshaller marshaller = new CastorMarshaller();
|
||||
ClassPathResource mappingLocation = new ClassPathResource("mapping.xml", CastorMarshaller.class);
|
||||
marshaller.setMappingLocation(mappingLocation);
|
||||
|
|
|
|||
|
|
@ -29,14 +29,16 @@ public class Jaxb1MarshallerTest extends AbstractJaxbMarshallerTestCase {
|
|||
|
||||
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();
|
||||
marshaller.setContextPaths(new String[]{CONTEXT_PATH});
|
||||
marshaller.afterPropertiesSet();
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
protected Object createFlights() {
|
||||
@Override
|
||||
protected Object createFlights() {
|
||||
FlightType flight = new FlightTypeImpl();
|
||||
flight.setNumber(42L);
|
||||
Flights flights = new FlightsImpl();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import org.springframework.oxm.jaxb1.Flights;
|
|||
|
||||
public class Jaxb1UnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
@Override
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
|
||||
marshaller.setContextPath("org.springframework.oxm.jaxb1");
|
||||
marshaller.setValidating(true);
|
||||
|
|
@ -30,14 +31,16 @@ public class Jaxb1UnmarshallerTest extends AbstractUnmarshallerTestCase {
|
|||
return marshaller;
|
||||
}
|
||||
|
||||
protected void testFlights(Object o) {
|
||||
@Override
|
||||
protected void testFlights(Object o) {
|
||||
Flights flights = (Flights) o;
|
||||
assertNotNull("Flights is null", flights);
|
||||
assertEquals("Invalid amount of flight elements", 1, flights.getFlight().size());
|
||||
testFlight(flights.getFlight().get(0));
|
||||
}
|
||||
|
||||
protected void testFlight(Object o) {
|
||||
@Override
|
||||
protected void testFlight(Object o) {
|
||||
FlightType flight = (FlightType) o;
|
||||
assertNotNull("Flight is null", flight);
|
||||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||
|
|
|
|||
|
|
@ -24,14 +24,16 @@ import org.springframework.xml.transform.StringResult;
|
|||
|
||||
public class JibxMarshallerTest extends AbstractMarshallerTestCase {
|
||||
|
||||
protected Marshaller createMarshaller() throws Exception {
|
||||
@Override
|
||||
protected Marshaller createMarshaller() throws Exception {
|
||||
JibxMarshaller marshaller = new JibxMarshaller();
|
||||
marshaller.setTargetClass(Flights.class);
|
||||
marshaller.afterPropertiesSet();
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
protected Object createFlights() {
|
||||
@Override
|
||||
protected Object createFlights() {
|
||||
Flights flights = new Flights();
|
||||
FlightType flight = new FlightType();
|
||||
flight.setNumber(42L);
|
||||
|
|
|
|||
|
|
@ -20,27 +20,31 @@ import org.springframework.oxm.Unmarshaller;
|
|||
|
||||
public class JibxUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
@Override
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
JibxMarshaller unmarshaller = new JibxMarshaller();
|
||||
unmarshaller.setTargetClass(Flights.class);
|
||||
unmarshaller.afterPropertiesSet();
|
||||
return unmarshaller;
|
||||
}
|
||||
|
||||
protected void testFlights(Object o) {
|
||||
@Override
|
||||
protected void testFlights(Object o) {
|
||||
Flights flights = (Flights) o;
|
||||
assertNotNull("Flights is null", flights);
|
||||
assertEquals("Invalid amount of flight elements", 1, flights.sizeFlightList());
|
||||
testFlight(flights.getFlight(0));
|
||||
}
|
||||
|
||||
protected void testFlight(Object o) {
|
||||
@Override
|
||||
protected void testFlight(Object o) {
|
||||
FlightType flight = (FlightType) o;
|
||||
assertNotNull("Flight is null", flight);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ import org.springframework.samples.flight.FlightsDocument.Flights;
|
|||
|
||||
public class XmlBeansMarshallerTest extends AbstractMarshallerTestCase {
|
||||
|
||||
protected Marshaller createMarshaller() throws Exception {
|
||||
@Override
|
||||
protected Marshaller createMarshaller() throws Exception {
|
||||
return new XmlBeansMarshaller();
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +42,8 @@ public class XmlBeansMarshallerTest extends AbstractMarshallerTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
protected Object createFlights() {
|
||||
@Override
|
||||
protected Object createFlights() {
|
||||
FlightsDocument flightsDocument = FlightsDocument.Factory.newInstance();
|
||||
Flights flights = flightsDocument.addNewFlights();
|
||||
FlightType flightType = flights.addNewFlight();
|
||||
|
|
|
|||
|
|
@ -31,11 +31,13 @@ import org.springframework.xml.transform.StringSource;
|
|||
|
||||
public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
||||
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
@Override
|
||||
protected Unmarshaller createUnmarshaller() throws Exception {
|
||||
return new XmlBeansMarshaller();
|
||||
}
|
||||
|
||||
protected void testFlights(Object o) {
|
||||
@Override
|
||||
protected void testFlights(Object o) {
|
||||
FlightsDocument flightsDocument = (FlightsDocument) o;
|
||||
assertNotNull("FlightsDocument is null", flightsDocument);
|
||||
Flights flights = flightsDocument.getFlights();
|
||||
|
|
@ -43,7 +45,8 @@ public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
|||
testFlight(flights.getFlightArray(0));
|
||||
}
|
||||
|
||||
protected void testFlight(Object o) {
|
||||
@Override
|
||||
protected void testFlight(Object o) {
|
||||
FlightType flight = null;
|
||||
if (o instanceof FlightType) {
|
||||
flight = (FlightType) o;
|
||||
|
|
@ -56,7 +59,8 @@ public class XmlBeansUnmarshallerTest extends AbstractUnmarshallerTestCase {
|
|||
assertEquals("Number is invalid", 42L, flight.getNumber());
|
||||
}
|
||||
|
||||
public void testUnmarshalPartialStaxSourceXmlStreamReader() throws Exception {
|
||||
@Override
|
||||
public void testUnmarshalPartialStaxSourceXmlStreamReader() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
|
||||
streamReader.nextTag(); // skip to flights
|
||||
|
|
|
|||
Loading…
Reference in New Issue