Renamed XmlReader classes to XMLReader classes

This commit is contained in:
Arjen Poutsma 2009-01-06 16:43:49 +00:00
parent 5f8d442708
commit 8152b266b1
8 changed files with 22 additions and 22 deletions

View File

@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
* @see #setErrorHandler(org.xml.sax.ErrorHandler) * @see #setErrorHandler(org.xml.sax.ErrorHandler)
* @since 3.0 * @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"; private static final String NAMESPACES_FEATURE_NAME = "http://xml.org/sax/features/namespaces";

View File

@ -36,7 +36,7 @@ import org.xml.sax.ext.LexicalHandler;
* @see #setErrorHandler(org.xml.sax.ErrorHandler) * @see #setErrorHandler(org.xml.sax.ErrorHandler)
* @since 3.0 * @since 3.0
*/ */
abstract class AbstractXmlReader implements XMLReader { abstract class AbstractXMLReader implements XMLReader {
private DTDHandler dtdHandler; private DTDHandler dtdHandler;

View File

@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
* @see #setErrorHandler(org.xml.sax.ErrorHandler) * @see #setErrorHandler(org.xml.sax.ErrorHandler)
* @since 1.0.0 * @since 1.0.0
*/ */
class StaxEventXmlReader extends AbstractStaxXmlReader { class StaxEventXMLReader extends AbstractStaxXMLReader {
private final XMLEventReader reader; private final XMLEventReader reader;
@ -64,7 +64,7 @@ class StaxEventXmlReader extends AbstractStaxXmlReader {
* @param reader the <code>XMLEventReader</code> to read from * @param reader the <code>XMLEventReader</code> to read from
* @throws IllegalStateException if the reader is not at the start of a document or element * @throws IllegalStateException if the reader is not at the start of a document or element
*/ */
StaxEventXmlReader(XMLEventReader reader) { StaxEventXMLReader(XMLEventReader reader) {
try { try {
XMLEvent event = reader.peek(); XMLEvent event = reader.peek();
if (event == null || !(event.isStartDocument() || event.isStartElement())) { if (event == null || !(event.isStartDocument() || event.isStartElement())) {

View File

@ -58,7 +58,7 @@ public class StaxSource extends SAXSource {
* @throws IllegalStateException if the reader is not at the start of a document or element * @throws IllegalStateException if the reader is not at the start of a document or element
*/ */
public StaxSource(XMLStreamReader streamReader) { public StaxSource(XMLStreamReader streamReader) {
super(new StaxStreamXmlReader(streamReader), new InputSource()); super(new StaxStreamXMLReader(streamReader), new InputSource());
this.streamReader = streamReader; 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 * @throws IllegalStateException if the reader is not at the start of a document or element
*/ */
public StaxSource(XMLEventReader eventReader) { public StaxSource(XMLEventReader eventReader) {
super(new StaxEventXmlReader(eventReader), new InputSource()); super(new StaxEventXMLReader(eventReader), new InputSource());
this.eventReader = eventReader; this.eventReader = eventReader;
} }

View File

@ -39,7 +39,7 @@ import org.springframework.util.StringUtils;
* @see #setErrorHandler(org.xml.sax.ErrorHandler) * @see #setErrorHandler(org.xml.sax.ErrorHandler)
* @since 1.0.0 * @since 1.0.0
*/ */
class StaxStreamXmlReader extends AbstractStaxXmlReader { class StaxStreamXMLReader extends AbstractStaxXMLReader {
private final XMLStreamReader reader; private final XMLStreamReader reader;
@ -51,7 +51,7 @@ class StaxStreamXmlReader extends AbstractStaxXmlReader {
* @param reader the <code>XMLEventReader</code> to read from * @param reader the <code>XMLEventReader</code> to read from
* @throws IllegalStateException if the reader is not at the start of a document or element * @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(); int event = reader.getEventType();
if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) { if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) {
throw new IllegalStateException("XMLEventReader not at start of document or element"); throw new IllegalStateException("XMLEventReader not at start of document or element");

View File

@ -40,7 +40,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
public abstract class AbstractStaxXmlReaderTestCase { public abstract class AbstractStaxXMLReaderTestCase {
protected static XMLInputFactory inputFactory; protected static XMLInputFactory inputFactory;
@ -73,7 +73,7 @@ public abstract class AbstractStaxXmlReaderTestCase {
standardReader.parse(new InputSource(createTestInputStream())); standardReader.parse(new InputSource(createTestInputStream()));
contentHandlerControl.replay(); 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/namespaces", true);
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false); staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
@ -90,7 +90,7 @@ public abstract class AbstractStaxXmlReaderTestCase {
standardReader.parse(new InputSource(createTestInputStream())); standardReader.parse(new InputSource(createTestInputStream()));
contentHandlerControl.replay(); 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/namespaces", true);
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
@ -107,7 +107,7 @@ public abstract class AbstractStaxXmlReaderTestCase {
standardReader.parse(new InputSource(createTestInputStream())); standardReader.parse(new InputSource(createTestInputStream()));
contentHandlerControl.replay(); 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/namespaces", false);
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); 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.isReplacingEntityReferences", Boolean.FALSE);
inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", 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.setProperty("http://xml.org/sax/properties/lexical-handler", lexicalHandler);
staxXmlReader.parse(new InputSource()); staxXmlReader.parse(new InputSource());
lexicalHandlerControl.verify(); 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. */ /** Easymock <code>ArgumentMatcher</code> implementation that matches SAX arguments. */
protected static class SaxArgumentMatcher extends AbstractMatcher { protected static class SaxArgumentMatcher extends AbstractMatcher {

View File

@ -27,20 +27,20 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.helpers.AttributesImpl; 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>"; public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
@Override @Override
protected AbstractStaxXmlReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException { protected AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
return new StaxEventXmlReader(inputFactory.createXMLEventReader(inputStream)); return new StaxEventXMLReader(inputFactory.createXMLEventReader(inputStream));
} }
public void testPartial() throws Exception { public void testPartial() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT)); XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT));
eventReader.nextTag(); // skip to root eventReader.nextTag(); // skip to root
StaxEventXmlReader xmlReader = new StaxEventXmlReader(eventReader); StaxEventXMLReader xmlReader = new StaxEventXMLReader(eventReader);
MockControl mockControl = MockControl.createStrictControl(ContentHandler.class); MockControl mockControl = MockControl.createStrictControl(ContentHandler.class);
mockControl.setDefaultMatcher(new SaxArgumentMatcher()); mockControl.setDefaultMatcher(new SaxArgumentMatcher());

View File

@ -30,13 +30,13 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.helpers.AttributesImpl; 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>"; public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
@Override @Override
protected AbstractStaxXmlReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException { protected AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException {
return new StaxStreamXmlReader(inputFactory.createXMLStreamReader(inputStream)); return new StaxStreamXMLReader(inputFactory.createXMLStreamReader(inputStream));
} }
@Test @Test
@ -49,7 +49,7 @@ public class StaxStreamXmlReaderTest extends AbstractStaxXmlReaderTestCase {
streamReader.nextTag(); // skip to child streamReader.nextTag(); // skip to child
assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "child"), assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "child"),
streamReader.getName()); streamReader.getName());
StaxStreamXmlReader xmlReader = new StaxStreamXmlReader(streamReader); StaxStreamXMLReader xmlReader = new StaxStreamXMLReader(streamReader);
MockControl mockControl = MockControl.createStrictControl(ContentHandler.class); MockControl mockControl = MockControl.createStrictControl(ContentHandler.class);
mockControl.setDefaultMatcher(new SaxArgumentMatcher()); mockControl.setDefaultMatcher(new SaxArgumentMatcher());