Small Stax fixes.
This commit is contained in:
parent
f92f295055
commit
449337a544
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -32,6 +32,7 @@ import javax.xml.stream.util.XMLEventConsumer;
|
|||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -58,6 +59,7 @@ class StaxEventContentHandler extends AbstractStaxContentHandler {
|
|||
* @param consumer the consumer to write events to
|
||||
*/
|
||||
StaxEventContentHandler(XMLEventConsumer consumer) {
|
||||
Assert.notNull(consumer, "'consumer' must not be null");
|
||||
eventFactory = XMLEventFactory.newInstance();
|
||||
eventConsumer = consumer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import org.xml.sax.SAXException;
|
|||
import org.xml.sax.ext.Locator2;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -78,6 +79,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
|
|||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxEventXMLReader(XMLEventReader reader) {
|
||||
Assert.notNull(reader, "'reader' must not be null");
|
||||
try {
|
||||
XMLEvent event = reader.peek();
|
||||
if (event != null && !(event.isStartDocument() || event.isStartElement())) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -24,6 +24,7 @@ import javax.xml.stream.XMLStreamWriter;
|
|||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -44,6 +45,7 @@ class StaxStreamContentHandler extends AbstractStaxContentHandler {
|
|||
* @param streamWriter the stream writer to write to
|
||||
*/
|
||||
StaxStreamContentHandler(XMLStreamWriter streamWriter) {
|
||||
Assert.notNull(streamWriter, "'streamWriter' must not be null");
|
||||
this.streamWriter = streamWriter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.xml.sax.SAXException;
|
|||
import org.xml.sax.ext.Locator2;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -60,6 +61,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
|
|||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxStreamXMLReader(XMLStreamReader reader) {
|
||||
Assert.notNull(reader, "'reader' must not be null");
|
||||
int event = reader.getEventType();
|
||||
if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) {
|
||||
throw new IllegalStateException("XMLEventReader not at start of document or element");
|
||||
|
|
|
|||
Loading…
Reference in New Issue