[jdom-interest] PATCH: changes to other outputters

guru at stinky.com guru at stinky.com
Tue Jun 19 08:11:11 PDT 2001


Here are some changes I made to other files.  Also a new file:

samples/BracketOutputter.java
	demonstrates use of new ability to subclass XMLOutputter
outside the package


=== samples/BracketOutputter.java:
package samples;

import java.io.*;
import java.util.*;
   
import org.jdom.*;
import org.jdom.output.*;

/**
 * Overrides XMLOutputter to put a useless bracket around each
 * element.  Demonstrates that we can now subclass XMLOutputter.
 **/
public class BracketOutputter extends XMLOutputter
{
    protected void printElement(Element element, Writer out,
                                int indentLevel, NamespaceStack namespaces)
                                throws IOException
    {
	out.write("[");
	super.printElement(element, out, indentLevel, namespaces);
	out.write("]");
    }
}


Index: samples/TestXMLOutputter.java
===================================================================
RCS file: /home/cvspublic/jdom/samples/TestXMLOutputter.java,v
retrieving revision 1.4
diff -u -r1.4 TestXMLOutputter.java
--- samples/TestXMLOutputter.java	2001/02/26 07:00:05	1.4
+++ samples/TestXMLOutputter.java	2001/06/19 13:43:34
@@ -158,6 +158,7 @@
 
         String saxDriverClass = DEFAULT_SAX_DRIVER_CLASS;
         boolean testElements = false;
+	boolean verbose = false;
         XMLOutputter outputter = new XMLOutputter();
         int i = 0;
         do {
@@ -173,6 +174,9 @@
                 i=args.length;
                 break;
             }
+	    else if (args[i].equals("-v") || args[i].equals("-verbose")) {
+		verbose = true;
+	    }
             else if (!args[i].startsWith("-"))  // we're at the file list
                 break;
             ++i;
@@ -182,10 +186,12 @@
             System.out.println
                 ("Usage: java TestXMLOutputter " +
                  "[-driver SAX Driver Class] [-testElements]\n" +
-                 "\t[-suppressDeclaration] [-omitEncoding]\n" +
+		 "\t[-v|verbose]\n" +
+                 "\t[-omitDeclaration] [-omitEncoding]\n" +
                  "\t[-indent x] [-indentSize x] [-indentLevel x]\n" +
-                 "\t[-expandEmpty] [-encoding x] [-newlines] [-lineSeparator x]\n" +
-                 "\t[-trimText]\n" +
+                 "\t[-expandEmpty] [-encoding x]\n" +
+		 "\t[-newlines] [-lineSeparator x]\n" +
+                 "\t[-textNormalize]\n" +
                  "\t(XML document filename)...\n" 
                  );
             return;
@@ -195,6 +201,10 @@
         TestXMLOutputter demo = new TestXMLOutputter(saxDriverClass);
         demo.outputter = outputter;
         demo.testElements = testElements;
+
+	if (verbose) {
+	    System.out.println(outputter.getSettings());
+	}
         
         for (; i<args.length; ++i) {
             // Load filename

Index: src/java/org/jdom/output/DOMOutputter.java
===================================================================
RCS file: /home/cvspublic/jdom/src/java/org/jdom/output/DOMOutputter.java,v
retrieving revision 1.24
diff -u -r1.24 DOMOutputter.java
--- src/java/org/jdom/output/DOMOutputter.java	2001/05/19 03:10:05	1.24
+++ src/java/org/jdom/output/DOMOutputter.java	2001/06/19 13:43:35
@@ -456,4 +456,18 @@
         }
         return attrName;
     }
+
+    /**
+     * Our own null subclass of NamespaceStack.  This plays a little
+     * trick with Java access protection.  We want subclasses of
+     * this class to be able to override protected methods that
+     * declare a NamespaceStack parameter, but we don't want to
+     * declare the parent NamespaceStack class as public.  
+     **/
+    protected class NamespaceStack
+	extends org.jdom.output.NamespaceStack
+    {
+    }
+    
+    
 }
Index: src/java/org/jdom/output/SAXOutputter.java
===================================================================
RCS file: /home/cvspublic/jdom/src/java/org/jdom/output/SAXOutputter.java,v
retrieving revision 1.10
diff -u -r1.10 SAXOutputter.java
--- src/java/org/jdom/output/SAXOutputter.java	2001/06/11 16:17:56	1.10
+++ src/java/org/jdom/output/SAXOutputter.java	2001/06/19 13:43:35
@@ -646,4 +646,18 @@
         }
         return atts;
     }
+
+
+    /**
+     * Our own null subclass of NamespaceStack.  This plays a little
+     * trick with Java access protection.  We want subclasses of
+     * this class to be able to override protected methods that
+     * declare a NamespaceStack parameter, but we don't want to
+     * declare the parent NamespaceStack class as public.  
+     **/
+    protected class NamespaceStack
+	extends org.jdom.output.NamespaceStack
+    {
+    }
+    
 }





More information about the jdom-interest mailing list