Permalink
Browse files

Refactor - Move/Rename the StAX Stream classes

  • Loading branch information...
rolfl committed Mar 3, 2013
1 parent 98bbbd5 commit 64c077319f8e5ec52c7f466cb66f963ec157af83
@@ -52,7 +52,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
-package org.jdom2.jaxb;
+package org.jdom2.input;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -82,6 +82,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.output.support.AbstractOutputProcessor;
import org.jdom2.output.support.FormatStack;
import org.jdom2.output.support.Walker;
+import org.jdom2.util.JDOMNamespaceContext;
import org.jdom2.util.NamespaceStack;
/**
@@ -92,7 +93,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* events as it encounters them in the DOM.
* @author gordon burgett https://github.com/gburgett
*/
-public class JDOMStreamReader extends AbstractOutputProcessor implements XMLStreamReader {
+public class StAXStreamReader extends AbstractOutputProcessor implements XMLStreamReader {
private static final class DocumentWalker implements Walker {
@@ -149,22 +150,22 @@ public boolean isCDATA() {
private int currentEvt = START_DOCUMENT;
/**
- * Create a new JDOMStreamReader that outputs a JDOM Document as an XMLStream.
+ * Create a new StAXStreamReader that outputs a JDOM Document as an XMLStream.
* @param document the document to output.
* @param format The output format to use.
*/
- public JDOMStreamReader(Document document, Format format){
+ public StAXStreamReader(Document document, Format format){
this.document = document;
this.formatstack = new FormatStack(format);
stack[0] = new DocumentWalker(document);
}
/**
- * Create a new JDOMStreamReader that outputs a JDOM Document as an XMLStream using
+ * Create a new StAXStreamReader that outputs a JDOM Document as an XMLStream using
* the Format.getRawFormat() format.
* @param document the document to output.
*/
- public JDOMStreamReader(Document document) {
+ public StAXStreamReader(Document document) {
this(document, Format.getRawFormat());
}
@@ -57,7 +57,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import javax.xml.stream.XMLStreamReader;
import org.jdom2.Document;
-import org.jdom2.jaxb.JDOMStreamReader;
+import org.jdom2.input.StAXStreamReader;
import org.jdom2.output.support.AbstractStAXAsStreamProcessor;
import org.jdom2.output.support.StAXAsStreamProcessor;
@@ -109,7 +109,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
private static final class DefaultStAXAsStreamProcessor implements StAXAsStreamProcessor {
- private static final class MyXMLStreamReader extends JDOMStreamReader {
+ private static final class MyXMLStreamReader extends StAXStreamReader {
public MyXMLStreamReader(Document doc, Format format) {
super(doc, format);
}
@@ -51,7 +51,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
on the JDOM Project, please see <http://www.jdom.org/>.
*/
-package org.jdom2.jaxb;
+package org.jdom2.output;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -68,6 +68,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.Namespace;
import org.jdom2.Parent;
import org.jdom2.Text;
+import org.jdom2.util.JDOMNamespaceContext;
import org.jdom2.util.NamespaceStack;
/**
@@ -76,7 +77,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*
* @author gordon burgett https://github.com/gburgett
*/
-public class JDOMStreamWriter implements XMLStreamWriter {
+public class StAXStreamWriter implements XMLStreamWriter {
private static final DefaultJDOMFactory DEFFAC = new DefaultJDOMFactory();
@@ -106,23 +107,23 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
private final JDOMFactory factory;
/**
- * Create a JDOMStreamWriter with the default JDOMFactory for creating JDOM
+ * Create a StAXStreamWriter with the default JDOMFactory for creating JDOM
* Content.
*/
- public JDOMStreamWriter() {
+ public StAXStreamWriter() {
this(DEFFAC, true);
}
/**
- * Create a JDOMStreamWriter with the specified JDOMFactory for creating
+ * Create a StAXStreamWriter with the specified JDOMFactory for creating
* JDOM Content.
*
* @param fac
* The JDOMFactory to use.
* @param repairnamespace
* If true, then repair namespace errors.
*/
- public JDOMStreamWriter(final JDOMFactory fac, final boolean repairnamespace) {
+ public StAXStreamWriter(final JDOMFactory fac, final boolean repairnamespace) {
this.factory = fac;
this.repairnamespace = repairnamespace;
// create an empty level in the namespace stack.
@@ -57,7 +57,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import javax.xml.stream.XMLStreamReader;
import org.jdom2.Document;
-import org.jdom2.jaxb.JDOMStreamReader;
+import org.jdom2.input.StAXStreamReader;
import org.jdom2.output.Format;
/**
@@ -73,7 +73,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
public class AbstractStAXAsStreamProcessor implements StAXAsStreamProcessor {
- private static final class MyXMLStreamReader extends JDOMStreamReader {
+ private static final class MyXMLStreamReader extends StAXStreamReader {
public MyXMLStreamReader(Document doc, Format format) {
super(doc, format);
@@ -57,14 +57,14 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import javax.xml.stream.XMLStreamReader;
import org.jdom2.Document;
-import org.jdom2.jaxb.JDOMStreamReader;
+import org.jdom2.input.StAXStreamReader;
import org.jdom2.output.Format;
/**
* A simple interface that allows the implementation of a StAX XMLStreamReader
* instance for representing a JDOM Document. If a user needs to create a custom
* way to output as an XMLStreamReader they can implement their own XMLStreamReader
- * class (perhaps by extending {@link JDOMStreamReader}) and then creating an
+ * class (perhaps by extending {@link StAXStreamReader}) and then creating an
* implementation of this class that creates their own custom XMLStreamReader
* version. The implementation of this class could then be given to the
* StAXAsStreamReader.
@@ -52,7 +52,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
-package org.jdom2.jaxb;
+package org.jdom2.util;
import java.util.ArrayList;
import java.util.Collections;
@@ -11,7 +11,7 @@
import org.jdom2.JDOMConstants;
import org.jdom2.Namespace;
-import org.jdom2.jaxb.JDOMNamespaceContext;
+import org.jdom2.util.JDOMNamespaceContext;
@SuppressWarnings("javadoc")
public class TestJDOMNamespaceContext {
@@ -66,11 +66,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.jdom2.Text;
+import org.jdom2.input.StAXStreamReader;
import org.jdom2.input.StAXStreamBuilder;
-import org.jdom2.jaxb.JDOMStreamReader;
/**
- * Tests for {@link JDOMStreamReader}
+ * Tests for {@link StAXStreamReader}
* @author gordon burgett https://github.com/gburgett
*/
@SuppressWarnings("javadoc")
@@ -87,7 +87,7 @@ public void testSimpleDocument_BuildsFromReader_SameDocument() throws Exception
doc.setRootElement(new Element("simple"));
Document read;
- JDOMStreamReader instance = new JDOMStreamReader(doc);
+ StAXStreamReader instance = new StAXStreamReader(doc);
try{
StAXStreamBuilder builder = new StAXStreamBuilder();
read = builder.build(instance);
@@ -117,7 +117,7 @@ public void testSimpleDocWithNamespace_BuildsFromReader_SameDocument() throws Ex
doc.getRootElement().addContent(content);
Document read;
- JDOMStreamReader instance = new JDOMStreamReader(doc);
+ StAXStreamReader instance = new StAXStreamReader(doc);
try{
StAXStreamBuilder builder = new StAXStreamBuilder();
read = builder.build(instance);
@@ -161,7 +161,7 @@ public void testDocWithAttributes_HasAttributes() throws Exception {
doc.getRootElement().addContent(content);
Document read;
- JDOMStreamReader instance = new JDOMStreamReader(doc);
+ StAXStreamReader instance = new StAXStreamReader(doc);
try{
StAXStreamBuilder builder = new StAXStreamBuilder();
read = builder.build(instance);
@@ -194,7 +194,7 @@ public void testDocWithMixedContent_HandlesMixedContent() throws Exception {
doc.getRootElement().addContent(new CDATA("post-element text"));
Document read;
- JDOMStreamReader instance = new JDOMStreamReader(doc);
+ StAXStreamReader instance = new StAXStreamReader(doc);
try{
StAXStreamBuilder builder = new StAXStreamBuilder();
read = builder.build(instance);
@@ -67,10 +67,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
-import org.jdom2.jaxb.JDOMStreamWriter;
+import org.jdom2.output.StAXStreamWriter;
/**
- * Tests for {@link JDOMStreamWriter}
+ * Tests for {@link StAXStreamWriter}
* @author gordon burgett https://github.com/gburgett
*/
@SuppressWarnings("javadoc")
@@ -84,7 +84,7 @@ public void testEmptyRootElement_DocumentHasEmptyRoot() throws Exception {
System.out.println("testEmptyRootElement_DocumentHasEmptyRoot");
Document doc;
- JDOMStreamWriter writer = new JDOMStreamWriter();
+ StAXStreamWriter writer = new StAXStreamWriter();
try{
writer.writeStartDocument();
@@ -108,7 +108,7 @@ public void testMultipleElementsWithText_DocHasElements() throws Exception {
System.out.println("testMultipleElementsWithText_DocHasElements");
Document doc;
- JDOMStreamWriter writer = new JDOMStreamWriter();
+ StAXStreamWriter writer = new StAXStreamWriter();
try{
writer.writeStartDocument();
writer.writeStartElement("testroot");
@@ -156,7 +156,7 @@ public void testElementsWithNamespace() throws Exception {
Document doc;
//XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
- JDOMStreamWriter writer = new JDOMStreamWriter();
+ StAXStreamWriter writer = new StAXStreamWriter();
try{
writer.writeStartDocument();
writer.setPrefix("", "testUri");
@@ -3,15 +3,15 @@
import javax.xml.stream.XMLStreamException;
import org.jdom2.Document;
-import org.jdom2.jaxb.JDOMStreamWriter;
+import org.jdom2.output.StAXStreamWriter;
import org.jdom2.output.StAXStreamOutputter;
@SuppressWarnings("javadoc")
public class TestStAXReaderWriter extends AbstractTestRoundTrip {
@Override
Document roundTrip(final Document doc) {
- final JDOMStreamWriter sw = new JDOMStreamWriter();
+ final StAXStreamWriter sw = new StAXStreamWriter();
final StAXStreamOutputter so = new StAXStreamOutputter();
try {
so.output(doc, sw);

0 comments on commit 64c0773

Please sign in to comment.