Renamed XmlReader classes to XMLReader classes
This commit is contained in:
parent
5f8d442708
commit
8152b266b1
|
@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
|
|||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 3.0
|
||||
*/
|
||||
abstract class AbstractStaxXmlReader extends AbstractXmlReader {
|
||||
abstract class AbstractStaxXMLReader extends AbstractXMLReader {
|
||||
|
||||
private static final String NAMESPACES_FEATURE_NAME = "http://xml.org/sax/features/namespaces";
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.xml.sax.ext.LexicalHandler;
|
|||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 3.0
|
||||
*/
|
||||
abstract class AbstractXmlReader implements XMLReader {
|
||||
abstract class AbstractXMLReader implements XMLReader {
|
||||
|
||||
private DTDHandler dtdHandler;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
|
|||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class StaxEventXmlReader extends AbstractStaxXmlReader {
|
||||
class StaxEventXMLReader extends AbstractStaxXMLReader {
|
||||
|
||||
private final XMLEventReader reader;
|
||||
|
||||
|
@ -64,7 +64,7 @@ class StaxEventXmlReader extends AbstractStaxXmlReader {
|
|||
* @param reader the <code>XMLEventReader</code> to read from
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxEventXmlReader(XMLEventReader reader) {
|
||||
StaxEventXMLReader(XMLEventReader reader) {
|
||||
try {
|
||||
XMLEvent event = reader.peek();
|
||||
if (event == null || !(event.isStartDocument() || event.isStartElement())) {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class StaxSource extends SAXSource {
|
|||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
public StaxSource(XMLStreamReader streamReader) {
|
||||
super(new StaxStreamXmlReader(streamReader), new InputSource());
|
||||
super(new StaxStreamXMLReader(streamReader), new InputSource());
|
||||
this.streamReader = streamReader;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class StaxSource extends SAXSource {
|
|||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
public StaxSource(XMLEventReader eventReader) {
|
||||
super(new StaxEventXmlReader(eventReader), new InputSource());
|
||||
super(new StaxEventXMLReader(eventReader), new InputSource());
|
||||
this.eventReader = eventReader;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.springframework.util.StringUtils;
|
|||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class StaxStreamXmlReader extends AbstractStaxXmlReader {
|
||||
class StaxStreamXMLReader extends AbstractStaxXMLReader {
|
||||
|
||||
private final XMLStreamReader reader;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class StaxStreamXmlReader extends AbstractStaxXmlReader {
|
|||
* @param reader the <code>XMLEventReader</code> to read from
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxStreamXmlReader(XMLStreamReader reader) {
|
||||
StaxStreamXMLReader(XMLStreamReader reader) {
|
||||
int event = reader.getEventType();
|
||||
if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) {
|
||||
throw new IllegalStateException("XMLEventReader not at start of document or element");
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
|
|||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
public abstract class AbstractStaxXmlReaderTestCase {
|
||||
public abstract class AbstractStaxXMLReaderTestCase {
|
||||
|
||||
protected static XMLInputFactory inputFactory;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public abstract class AbstractStaxXmlReaderTestCase {
|
|||
standardReader.parse(new InputSource(createTestInputStream()));
|
||||
contentHandlerControl.replay();
|
||||
|
||||
AbstractStaxXmlReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public abstract class AbstractStaxXmlReaderTestCase {
|
|||
standardReader.parse(new InputSource(createTestInputStream()));
|
||||
contentHandlerControl.replay();
|
||||
|
||||
AbstractStaxXmlReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public abstract class AbstractStaxXmlReaderTestCase {
|
|||
standardReader.parse(new InputSource(createTestInputStream()));
|
||||
contentHandlerControl.replay();
|
||||
|
||||
AbstractStaxXmlReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespaces", false);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
|
||||
|
@ -136,14 +136,14 @@ public abstract class AbstractStaxXmlReaderTestCase {
|
|||
inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE);
|
||||
inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
|
||||
AbstractStaxXmlReader staxXmlReader = createStaxXmlReader(testLexicalHandlerXml.getInputStream());
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(testLexicalHandlerXml.getInputStream());
|
||||
|
||||
staxXmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", lexicalHandler);
|
||||
staxXmlReader.parse(new InputSource());
|
||||
lexicalHandlerControl.verify();
|
||||
}
|
||||
|
||||
protected abstract AbstractStaxXmlReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException;
|
||||
protected abstract AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException;
|
||||
|
||||
/** Easymock <code>ArgumentMatcher</code> implementation that matches SAX arguments. */
|
||||
protected static class SaxArgumentMatcher extends AbstractMatcher {
|
||||
|
|
|
@ -27,20 +27,20 @@ import org.xml.sax.ContentHandler;
|
|||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class StaxEventXmlReaderTest extends AbstractStaxXmlReaderTestCase {
|
||||
public class StaxEventXMLReaderTest extends AbstractStaxXMLReaderTestCase {
|
||||
|
||||
public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
||||
|
||||
@Override
|
||||
protected AbstractStaxXmlReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
|
||||
return new StaxEventXmlReader(inputFactory.createXMLEventReader(inputStream));
|
||||
protected AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
|
||||
return new StaxEventXMLReader(inputFactory.createXMLEventReader(inputStream));
|
||||
}
|
||||
|
||||
public void testPartial() throws Exception {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT));
|
||||
eventReader.nextTag(); // skip to root
|
||||
StaxEventXmlReader xmlReader = new StaxEventXmlReader(eventReader);
|
||||
StaxEventXMLReader xmlReader = new StaxEventXMLReader(eventReader);
|
||||
|
||||
MockControl mockControl = MockControl.createStrictControl(ContentHandler.class);
|
||||
mockControl.setDefaultMatcher(new SaxArgumentMatcher());
|
||||
|
|
|
@ -30,13 +30,13 @@ import org.xml.sax.ContentHandler;
|
|||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class StaxStreamXmlReaderTest extends AbstractStaxXmlReaderTestCase {
|
||||
public class StaxStreamXMLReaderTest extends AbstractStaxXMLReaderTestCase {
|
||||
|
||||
public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
||||
|
||||
@Override
|
||||
protected AbstractStaxXmlReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
|
||||
return new StaxStreamXmlReader(inputFactory.createXMLStreamReader(inputStream));
|
||||
protected AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
|
||||
return new StaxStreamXMLReader(inputFactory.createXMLStreamReader(inputStream));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -49,7 +49,7 @@ public class StaxStreamXmlReaderTest extends AbstractStaxXmlReaderTestCase {
|
|||
streamReader.nextTag(); // skip to child
|
||||
assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "child"),
|
||||
streamReader.getName());
|
||||
StaxStreamXmlReader xmlReader = new StaxStreamXmlReader(streamReader);
|
||||
StaxStreamXMLReader xmlReader = new StaxStreamXMLReader(streamReader);
|
||||
|
||||
MockControl mockControl = MockControl.createStrictControl(ContentHandler.class);
|
||||
mockControl.setDefaultMatcher(new SaxArgumentMatcher());
|
||||
|
|
Loading…
Reference in New Issue