reformat Saver.java

git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/trunk@1857662 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/store/org/apache/xmlbeans/impl/store/Saver.java b/src/store/org/apache/xmlbeans/impl/store/Saver.java
index c7832aa..a08641b 100755
--- a/src/store/org/apache/xmlbeans/impl/store/Saver.java
+++ b/src/store/org/apache/xmlbeans/impl/store/Saver.java
@@ -47,33 +47,39 @@
 import java.util.LinkedHashMap;
 import java.util.ConcurrentModificationException;
 
-abstract class Saver
-{
-    static final int ROOT     = Cur.ROOT;
-    static final int ELEM     = Cur.ELEM;
-    static final int ATTR     = Cur.ATTR;
-    static final int COMMENT  = Cur.COMMENT;
+abstract class Saver {
+    static final int ROOT = Cur.ROOT;
+    static final int ELEM = Cur.ELEM;
+    static final int ATTR = Cur.ATTR;
+    static final int COMMENT = Cur.COMMENT;
     static final int PROCINST = Cur.PROCINST;
-    static final int TEXT     = Cur.TEXT;
+    static final int TEXT = Cur.TEXT;
 
-    protected abstract boolean emitElement ( SaveCur c, ArrayList attrNames, ArrayList attrValues );
-    protected abstract void emitFinish     ( SaveCur c );
-    protected abstract void emitText       ( SaveCur c );
-    protected abstract void emitComment    ( SaveCur c );
-    protected abstract void emitProcinst   ( SaveCur c );
-    protected abstract void emitDocType    ( String docTypeName, String publicId, String systemId );
-    protected abstract void emitStartDoc   ( SaveCur c );
-    protected abstract void emitEndDoc     ( SaveCur c );
+    protected abstract boolean emitElement(SaveCur c, ArrayList attrNames, ArrayList attrValues);
 
-    protected void syntheticNamespace ( String prefix, String uri, boolean considerDefault ) { }
+    protected abstract void emitFinish(SaveCur c);
 
-    Saver ( Cur c, XmlOptions options )
-    {
+    protected abstract void emitText(SaveCur c);
+
+    protected abstract void emitComment(SaveCur c);
+
+    protected abstract void emitProcinst(SaveCur c);
+
+    protected abstract void emitDocType(String docTypeName, String publicId, String systemId);
+
+    protected abstract void emitStartDoc(SaveCur c);
+
+    protected abstract void emitEndDoc(SaveCur c);
+
+    protected void syntheticNamespace(String prefix, String uri, boolean considerDefault) {
+    }
+
+    Saver(Cur c, XmlOptions options) {
         assert c._locale.entered();
 
-        options = XmlOptions.maskNull( options );
+        options = XmlOptions.maskNull(options);
 
-        _cur = createSaveCur( c, options );
+        _cur = createSaveCur(c, options);
 
         _locale = c._locale;
         _version = _locale.version();
@@ -83,44 +89,39 @@
         _prefixMap = new HashMap();
 
         _attrNames = new ArrayList();
-        _attrValues = new ArrayList ();
+        _attrValues = new ArrayList();
 
         // Define implicit xml prefixed namespace
 
-        addMapping( "xml", Locale._xml1998Uri );
+        addMapping("xml", Locale._xml1998Uri);
 
-        if (options.hasOption( XmlOptions.SAVE_IMPLICIT_NAMESPACES ))
-        {
-            Map m = (Map) options.get( XmlOptions.SAVE_IMPLICIT_NAMESPACES );
+        if (options.hasOption(XmlOptions.SAVE_IMPLICIT_NAMESPACES)) {
+            Map m = (Map) options.get(XmlOptions.SAVE_IMPLICIT_NAMESPACES);
 
-            for ( Iterator i = m.keySet().iterator() ; i.hasNext() ; )
-            {
+            for (Iterator i = m.keySet().iterator(); i.hasNext(); ) {
                 String prefix = (String) i.next();
-                addMapping( prefix, (String) m.get( prefix ) );
+                addMapping(prefix, (String) m.get(prefix));
             }
         }
 
         // define character map for escaped replacements
-        if (options.hasOption( XmlOptions.SAVE_SUBSTITUTE_CHARACTERS ))
-        {
+        if (options.hasOption(XmlOptions.SAVE_SUBSTITUTE_CHARACTERS)) {
             _replaceChar = (XmlOptionCharEscapeMap)
-                options.get( XmlOptions.SAVE_SUBSTITUTE_CHARACTERS);
+                    options.get(XmlOptions.SAVE_SUBSTITUTE_CHARACTERS);
         }
 
         // If the default prefix has not been mapped, do so now
 
-        if (getNamespaceForPrefix( "" ) == null)
-        {
-            _initialDefaultUri = new String( "" );
-            addMapping( "", _initialDefaultUri );
+        if (getNamespaceForPrefix("") == null) {
+            _initialDefaultUri = new String("");
+            addMapping("", _initialDefaultUri);
         }
 
-        if (options.hasOption( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES ) &&
-                !(this instanceof SynthNamespaceSaver))
-        {
-            SynthNamespaceSaver saver = new SynthNamespaceSaver( c, options );
+        if (options.hasOption(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES) &&
+                !(this instanceof SynthNamespaceSaver)) {
+            SynthNamespaceSaver saver = new SynthNamespaceSaver(c, options);
 
-            while ( saver.process() )
+            while (saver.process())
                 ;
 
             if (!saver._synthNamespaces.isEmpty())
@@ -128,134 +129,114 @@
         }
 
         _useDefaultNamespace =
-            options.hasOption( XmlOptions.SAVE_USE_DEFAULT_NAMESPACE );
+                options.hasOption(XmlOptions.SAVE_USE_DEFAULT_NAMESPACE);
 
-        _saveNamespacesFirst = options.hasOption( XmlOptions.SAVE_NAMESPACES_FIRST );
+        _saveNamespacesFirst = options.hasOption(XmlOptions.SAVE_NAMESPACES_FIRST);
 
-        if (options.hasOption( XmlOptions.SAVE_SUGGESTED_PREFIXES ))
-            _suggestedPrefixes = (Map) options.get( XmlOptions.SAVE_SUGGESTED_PREFIXES);
+        if (options.hasOption(XmlOptions.SAVE_SUGGESTED_PREFIXES))
+            _suggestedPrefixes = (Map) options.get(XmlOptions.SAVE_SUGGESTED_PREFIXES);
 
         _ancestorNamespaces = _cur.getAncestorNamespaces();
     }
 
-    private static SaveCur createSaveCur ( Cur c, XmlOptions options )
-    {
-        QName synthName = (QName) options.get( XmlOptions.SAVE_SYNTHETIC_DOCUMENT_ELEMENT );
+    private static SaveCur createSaveCur(Cur c, XmlOptions options) {
+        QName synthName = (QName) options.get(XmlOptions.SAVE_SYNTHETIC_DOCUMENT_ELEMENT);
 
         QName fragName = synthName;
 
-        if (fragName == null)
-        {
+        if (fragName == null) {
             fragName =
-                options.hasOption( XmlOptions.SAVE_USE_OPEN_FRAGMENT )
-                    ? Locale._openuriFragment
-                    : Locale._xmlFragment;
+                    options.hasOption(XmlOptions.SAVE_USE_OPEN_FRAGMENT)
+                            ? Locale._openuriFragment
+                            : Locale._xmlFragment;
         }
 
         boolean saveInner =
-            options.hasOption( XmlOptions.SAVE_INNER ) &&
-                !options.hasOption( XmlOptions.SAVE_OUTER );
+                options.hasOption(XmlOptions.SAVE_INNER) &&
+                        !options.hasOption(XmlOptions.SAVE_OUTER);
 
         Cur start = c.tempCur();
-        Cur end   = c.tempCur();
+        Cur end = c.tempCur();
 
         SaveCur cur = null;
 
         int k = c.kind();
 
-        switch ( k )
-        {
-        case ROOT :
-        {
-            positionToInner( c, start, end );
+        switch (k) {
+            case ROOT: {
+                positionToInner(c, start, end);
 
-            if (Locale.isFragment( start, end ))
-                cur = new FragSaveCur( start, end, fragName );
-            else if (synthName != null)
-                cur = new FragSaveCur( start, end, synthName );
-            else
-                cur = new DocSaveCur( c );
+                if (Locale.isFragment(start, end))
+                    cur = new FragSaveCur(start, end, fragName);
+                else if (synthName != null)
+                    cur = new FragSaveCur(start, end, synthName);
+                else
+                    cur = new DocSaveCur(c);
 
-            break;
-        }
-
-        case ELEM :
-        {
-            if (saveInner)
-            {
-                positionToInner( c, start, end );
-
-                cur =
-                    new FragSaveCur(
-                        start, end, Locale.isFragment( start, end ) ? fragName : synthName );
-            }
-            else if (synthName != null)
-            {
-                positionToInner( c, start, end );
-
-                cur = new FragSaveCur( start, end, synthName );
-            }
-            else
-            {
-                start.moveToCur( c );
-                end.moveToCur( c );
-                end.skip();
-
-                cur = new FragSaveCur( start, end, null );
+                break;
             }
 
-            break;
-        }
+            case ELEM: {
+                if (saveInner) {
+                    positionToInner(c, start, end);
+
+                    cur =
+                            new FragSaveCur(
+                                    start, end, Locale.isFragment(start, end) ? fragName : synthName);
+                } else if (synthName != null) {
+                    positionToInner(c, start, end);
+
+                    cur = new FragSaveCur(start, end, synthName);
+                } else {
+                    start.moveToCur(c);
+                    end.moveToCur(c);
+                    end.skip();
+
+                    cur = new FragSaveCur(start, end, null);
+                }
+
+                break;
+            }
         }
 
-        if (cur == null)
-        {
+        if (cur == null) {
             assert k < 0 || k == ATTR || k == COMMENT || k == PROCINST || k == TEXT;
 
-            if (k < 0)
-            {
+            if (k < 0) {
                 // Save out ""
-                start.moveToCur( c );
-                end.moveToCur( c );
-            }
-            else if (k == TEXT)
-            {
-                start.moveToCur( c );
-                end.moveToCur( c );
+                start.moveToCur(c);
+                end.moveToCur(c);
+            } else if (k == TEXT) {
+                start.moveToCur(c);
+                end.moveToCur(c);
                 end.next();
-            }
-            else if (saveInner)
-            {
-                start.moveToCur( c );
+            } else if (saveInner) {
+                start.moveToCur(c);
                 start.next();
 
-                end.moveToCur( c );
+                end.moveToCur(c);
                 end.toEnd();
-            }
-            else if (k == ATTR)
-            {
-                start.moveToCur( c );
-                end.moveToCur( c );
-            }
-            else
-            {
+            } else if (k == ATTR) {
+                start.moveToCur(c);
+                end.moveToCur(c);
+            } else {
                 assert k == COMMENT || k == PROCINST;
 
-                start.moveToCur( c );
-                end.moveToCur( c );
+                start.moveToCur(c);
+                end.moveToCur(c);
                 end.skip();
             }
 
-            cur = new FragSaveCur( start, end, fragName );
+            cur = new FragSaveCur(start, end, fragName);
         }
 
-        String filterPI = (String) options.get( XmlOptions.SAVE_FILTER_PROCINST );
+        String filterPI = (String) options.get(XmlOptions.SAVE_FILTER_PROCINST);
 
         if (filterPI != null)
-            cur = new FilterPiSaveCur( cur, filterPI );
+            cur = new FilterPiSaveCur(cur, filterPI);
 
-        if (options.hasOption( XmlOptions.SAVE_PRETTY_PRINT ))
-            cur = new PrettySaveCur( cur, options );
+        if (options.hasOption(XmlOptions.SAVE_PRETTY_PRINT))
+            cur = new PrettySaveCur(cur, options);
 
         start.release();
         end.release();
@@ -263,72 +244,84 @@
         return cur;
     }
 
-    private static void positionToInner ( Cur c, Cur start, Cur end )
-    {
+    private static void positionToInner(Cur c, Cur start, Cur end) {
         assert c.isContainer();
 
-        start.moveToCur( c );
+        start.moveToCur(c);
 
         if (!start.toFirstAttr())
             start.next();
 
-        end.moveToCur( c );
+        end.moveToCur(c);
         end.toEnd();
     }
-    
+
     /**
      * Test if a character is valid in xml character content. See
      * http://www.w3.org/TR/REC-xml#NT-Char
      */
-    static boolean isBadChar ( char ch )
-    {
-        return ! (
-            Character.isHighSurrogate(ch) ||
-            Character.isLowSurrogate(ch) ||
-            (ch >= 0x20 && ch <= 0xD7FF ) ||
-            (ch >= 0xE000 && ch <= 0xFFFD) ||
-            (ch >= 0x10000 && ch <= 0x10FFFF) ||
-            (ch == 0x9) || (ch == 0xA) || (ch == 0xD)
+    static boolean isBadChar(char ch) {
+        return !(
+                Character.isHighSurrogate(ch) ||
+                        Character.isLowSurrogate(ch) ||
+                        (ch >= 0x20 && ch <= 0xD7FF) ||
+                        (ch >= 0xE000 && ch <= 0xFFFD) ||
+                        (ch >= 0x10000 && ch <= 0x10FFFF) ||
+                        (ch == 0x9) || (ch == 0xA) || (ch == 0xD)
         );
     }
-        
-    protected boolean saveNamespacesFirst ( )
-    {
+
+    protected boolean saveNamespacesFirst() {
         return _saveNamespacesFirst;
     }
 
-    protected void enterLocale()
-    {
+    protected void enterLocale() {
         _locale.enter();
     }
 
-    protected void exitLocale()
-    {
+    protected void exitLocale() {
         _locale.exit();
     }
 
-    protected final boolean process ( )
-    {
+    protected final boolean process() {
         assert _locale.entered();
 
         if (_cur == null)
             return false;
 
         if (_version != _locale.version())
-            throw new ConcurrentModificationException( "Document changed during save" );
+            throw new ConcurrentModificationException("Document changed during save");
 
-        switch ( _cur.kind() )
-        {
-            case   ROOT     : { processRoot();                        break; }
-            case   ELEM     : { processElement();                     break; }
-            case - ELEM     : { processFinish ();                     break; }
-            case   TEXT     : { emitText      ( _cur );               break; }
+        switch (_cur.kind()) {
+            case ROOT: {
+                processRoot();
+                break;
+            }
+            case ELEM: {
+                processElement();
+                break;
+            }
+            case -ELEM: {
+                processFinish();
+                break;
+            }
+            case TEXT: {
+                emitText(_cur);
+                break;
+            }
 
-            case   COMMENT  : { emitComment   ( _cur ); _cur.toEnd(); break; }
-            case   PROCINST : { emitProcinst  ( _cur ); _cur.toEnd(); break; }
+            case COMMENT: {
+                emitComment(_cur);
+                _cur.toEnd();
+                break;
+            }
+            case PROCINST: {
+                emitProcinst(_cur);
+                _cur.toEnd();
+                break;
+            }
 
-            case - ROOT :
-            {
+            case -ROOT: {
                 emitEndDoc(_cur);
                 _cur.release();
                 _cur = null;
@@ -336,7 +329,8 @@
                 return true;
             }
 
-            default : throw new RuntimeException( "Unexpected kind" );
+            default:
+                throw new RuntimeException("Unexpected kind");
         }
 
         _cur.next();
@@ -344,29 +338,24 @@
         return true;
     }
 
-    private final void processFinish ( )
-    {
-        emitFinish( _cur );
+    private final void processFinish() {
+        emitFinish(_cur);
         popMappings();
     }
 
-    private final void processRoot ( )
-    {
+    private final void processRoot() {
         assert _cur.isRoot();
 
         XmlDocumentProperties props = _cur.getDocProps();
         String systemId = null;
         String docTypeName = null;
-        if (props != null)
-        {
+        if (props != null) {
             systemId = props.getDoctypeSystemId();
             docTypeName = props.getDoctypeName();
         }
 
-        if (systemId != null || docTypeName != null)
-        {
-            if (docTypeName == null)
-            {
+        if (systemId != null || docTypeName != null) {
+            if (docTypeName == null) {
                 _cur.push();
                 while (!_cur.isElem() && _cur.next())
                     ;
@@ -377,17 +366,13 @@
 
             String publicId = props.getDoctypePublicId();
 
-            if (docTypeName != null)
-            {
+            if (docTypeName != null) {
                 QName rootElemName = _cur.getName();
 
-                if ( rootElemName == null )
-                {
+                if (rootElemName == null) {
                     _cur.push();
-                    while ( !_cur.isFinish() )
-                    {
-                        if (_cur.isElem())
-                        {
+                    while (!_cur.isFinish()) {
+                        if (_cur.isElem()) {
                             rootElemName = _cur.getName();
                             break;
                         }
@@ -396,9 +381,8 @@
                     _cur.pop();
                 }
 
-                if ( rootElemName!=null && docTypeName.equals(rootElemName.getLocalPart()) )
-                {
-                    emitDocType( docTypeName, publicId, systemId );
+                if (rootElemName != null && docTypeName.equals(rootElemName.getLocalPart())) {
+                    emitDocType(docTypeName, publicId, systemId);
                     return;
                 }
             }
@@ -407,8 +391,7 @@
         emitStartDoc(_cur);
     }
 
-    private final void processElement ( )
-    {
+    private final void processElement() {
         assert _cur.isElem() && _cur.getName() != null;
 
         QName name = _cur.getName();
@@ -419,7 +402,7 @@
 
         boolean ensureDefaultEmpty = name.getNamespaceURI().length() == 0;
 
-        pushMappings( _cur, ensureDefaultEmpty );
+        pushMappings(_cur, ensureDefaultEmpty);
 
         //
         // There are four things which use mappings:
@@ -432,7 +415,7 @@
 
         // 1) The element name (not for starts)
 
-        ensureMapping( name.getNamespaceURI(), name.getPrefix(), !ensureDefaultEmpty, false );
+        ensureMapping(name.getNamespaceURI(), name.getPrefix(), !ensureDefaultEmpty, false);
 
         //
         //
@@ -444,26 +427,22 @@
         _cur.push();
 
         attrs:
-        for ( boolean A = _cur.toFirstAttr() ; A ; A = _cur.toNextAttr() )
-        {
-            if (_cur.isNormalAttr())
-            {
+        for (boolean A = _cur.toFirstAttr(); A; A = _cur.toNextAttr()) {
+            if (_cur.isNormalAttr()) {
                 QName attrName = _cur.getName();
 
-                _attrNames.add( attrName );
+                _attrNames.add(attrName);
 
-                for ( int i = _attrNames.size() - 2 ; i >= 0 ; i-- )
-                {
-                    if (_attrNames.get( i ).equals( attrName ))
-                    {
-                        _attrNames.remove( _attrNames.size() - 1 );
+                for (int i = _attrNames.size() - 2; i >= 0; i--) {
+                    if (_attrNames.get(i).equals(attrName)) {
+                        _attrNames.remove(_attrNames.size() - 1);
                         continue attrs;
                     }
                 }
 
-                _attrValues.add( _cur.getAttrValue() );
+                _attrValues.add(_cur.getAttrValue());
 
-                ensureMapping( attrName.getNamespaceURI(), attrName.getPrefix(), false, true );
+                ensureMapping(attrName.getNamespaceURI(), attrName.getPrefix(), false, true);
             }
         }
 
@@ -474,23 +453,20 @@
         // we've computed.  Basically, I'm making sure the pre-computed
         // namespaces are mapped on the first container which has a name.
 
-        if (_preComputedNamespaces != null)
-        {
-            for ( Iterator i = _preComputedNamespaces.keySet().iterator() ; i.hasNext() ; )
-            {
+        if (_preComputedNamespaces != null) {
+            for (Iterator i = _preComputedNamespaces.keySet().iterator(); i.hasNext(); ) {
                 String uri = (String) i.next();
-                String prefix = (String) _preComputedNamespaces.get( uri );
+                String prefix = (String) _preComputedNamespaces.get(uri);
                 boolean considerDefault = prefix.length() == 0 && !ensureDefaultEmpty;
 
-                ensureMapping( uri, prefix, considerDefault, false );
+                ensureMapping(uri, prefix, considerDefault, false);
             }
 
             // Set to null so we do this once at the top
             _preComputedNamespaces = null;
         }
 
-        if (emitElement( _cur, _attrNames, _attrValues ))
-        {
+        if (emitElement(_cur, _attrNames, _attrValues)) {
             popMappings();
             _cur.toEnd();
         }
@@ -505,96 +481,84 @@
     //    Mapping
     //
 
-    boolean hasMappings ( )
-    {
+    boolean hasMappings() {
         int i = _namespaceStack.size();
 
-        return i > 0 && _namespaceStack.get( i - 1 ) != null;
+        return i > 0 && _namespaceStack.get(i - 1) != null;
     }
 
-    void iterateMappings ( )
-    {
+    void iterateMappings() {
         _currentMapping = _namespaceStack.size();
 
-        while ( _currentMapping > 0 && _namespaceStack.get( _currentMapping - 1 ) != null )
+        while (_currentMapping > 0 && _namespaceStack.get(_currentMapping - 1) != null)
             _currentMapping -= 8;
     }
 
-    boolean hasMapping ( )
-    {
+    boolean hasMapping() {
         return _currentMapping < _namespaceStack.size();
     }
 
-    void nextMapping ( )
-    {
+    void nextMapping() {
         _currentMapping += 8;
     }
 
-    String mappingPrefix ( )
-    {
+    String mappingPrefix() {
         assert hasMapping();
-        return (String) _namespaceStack.get( _currentMapping + 6 );
+        return (String) _namespaceStack.get(_currentMapping + 6);
     }
 
-    String mappingUri ( )
-    {
+    String mappingUri() {
         assert hasMapping();
-        return (String) _namespaceStack.get( _currentMapping + 7 );
+        return (String) _namespaceStack.get(_currentMapping + 7);
     }
 
-    private final void pushMappings ( SaveCur c, boolean ensureDefaultEmpty )
-    {
+    private final void pushMappings(SaveCur c, boolean ensureDefaultEmpty) {
         assert c.isContainer();
 
-        _namespaceStack.add( null );
+        _namespaceStack.add(null);
 
         c.push();
 
         namespaces:
-        for ( boolean A = c.toFirstAttr() ; A ; A = c.toNextAttr() )
+        for (boolean A = c.toFirstAttr(); A; A = c.toNextAttr())
             if (c.isXmlns())
-                addNewFrameMapping( c.getXmlnsPrefix(), c.getXmlnsUri(), ensureDefaultEmpty );
+                addNewFrameMapping(c.getXmlnsPrefix(), c.getXmlnsUri(), ensureDefaultEmpty);
 
         c.pop();
 
-        if (_ancestorNamespaces != null)
-        {
-            for ( int i = 0 ; i < _ancestorNamespaces.size() ; i += 2 )
-            {
-                String prefix = (String) _ancestorNamespaces.get( i );
-                String uri    = (String) _ancestorNamespaces.get( i + 1 );
+        if (_ancestorNamespaces != null) {
+            for (int i = 0; i < _ancestorNamespaces.size(); i += 2) {
+                String prefix = (String) _ancestorNamespaces.get(i);
+                String uri = (String) _ancestorNamespaces.get(i + 1);
 
-                addNewFrameMapping( prefix, uri, ensureDefaultEmpty );
+                addNewFrameMapping(prefix, uri, ensureDefaultEmpty);
             }
 
             _ancestorNamespaces = null;
         }
 
-        if (ensureDefaultEmpty)
-        {
-            String defaultUri = (String) _prefixMap.get( "" );
+        if (ensureDefaultEmpty) {
+            String defaultUri = (String) _prefixMap.get("");
 
             // I map the default to "" at the very beginning
             assert defaultUri != null;
 
             if (defaultUri.length() > 0)
-                addMapping( "", "" );
+                addMapping("", "");
         }
     }
 
-    private final void addNewFrameMapping ( String prefix, String uri, boolean ensureDefaultEmpty )
-    {
+    private final void addNewFrameMapping(String prefix, String uri, boolean ensureDefaultEmpty) {
         // If the prefix maps to "", this don't include this mapping 'cause it's not well formed.
         // Also, if we want to make sure that the default namespace is always "", then check that
         // here as well.
 
         if ((prefix.length() == 0 || uri.length() > 0) &&
-                (!ensureDefaultEmpty || prefix.length() > 0 || uri.length() == 0))
-        {
+                (!ensureDefaultEmpty || prefix.length() > 0 || uri.length() == 0)) {
             // Make sure the prefix is not already mapped in this frame
 
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-                if (mappingPrefix().equals( prefix ))
+            for (iterateMappings(); hasMapping(); nextMapping())
+                if (mappingPrefix().equals(prefix))
                     return;
 
             // Also make sure that the prefix declaration is not redundant
@@ -604,12 +568,11 @@
             if (uri.equals(getNamespaceForPrefix(prefix)))
                 return;
 
-            addMapping( prefix, uri );
+            addMapping(prefix, uri);
         }
     }
 
-    private final void addMapping ( String prefix, String uri )
-    {
+    private final void addMapping(String prefix, String uri) {
         assert uri != null;
         assert prefix != null;
 
@@ -617,33 +580,28 @@
         // that uri will either go out of scope or be mapped to another
         // prefix.
 
-        String renameUri = (String) _prefixMap.get( prefix );
+        String renameUri = (String) _prefixMap.get(prefix);
         String renamePrefix = null;
 
-        if (renameUri != null)
-        {
+        if (renameUri != null) {
             // See if this prefix is already mapped to this uri.  If
             // so, then add to the stack, but there is nothing to rename
 
-            if (renameUri.equals( uri ))
+            if (renameUri.equals(uri))
                 renameUri = null;
-            else
-            {
+            else {
                 int i = _namespaceStack.size();
 
-                while ( i > 0 )
-                {
-                    if (_namespaceStack.get( i - 1 ) == null)
-                    {
+                while (i > 0) {
+                    if (_namespaceStack.get(i - 1) == null) {
                         i--;
                         continue;
                     }
 
-                    if (_namespaceStack.get( i - 7 ).equals( renameUri ))
-                    {
-                        renamePrefix = (String) _namespaceStack.get( i - 8 );
+                    if (_namespaceStack.get(i - 7).equals(renameUri)) {
+                        renamePrefix = (String) _namespaceStack.get(i - 8);
 
-                        if (renamePrefix == null || !renamePrefix.equals( prefix ))
+                        if (renamePrefix == null || !renamePrefix.equals(prefix))
                             break;
                     }
 
@@ -654,114 +612,105 @@
             }
         }
 
-        _namespaceStack.add( _uriMap.get( uri ) );
-        _namespaceStack.add( uri );
+        _namespaceStack.add(_uriMap.get(uri));
+        _namespaceStack.add(uri);
 
-        if (renameUri != null)
-        {
-            _namespaceStack.add( _uriMap.get( renameUri ) );
-            _namespaceStack.add( renameUri );
-        }
-        else
-        {
-            _namespaceStack.add( null );
-            _namespaceStack.add( null );
+        if (renameUri != null) {
+            _namespaceStack.add(_uriMap.get(renameUri));
+            _namespaceStack.add(renameUri);
+        } else {
+            _namespaceStack.add(null);
+            _namespaceStack.add(null);
         }
 
-        _namespaceStack.add( prefix );
-        _namespaceStack.add( _prefixMap.get( prefix ) );
+        _namespaceStack.add(prefix);
+        _namespaceStack.add(_prefixMap.get(prefix));
 
-        _namespaceStack.add( prefix );
-        _namespaceStack.add( uri );
+        _namespaceStack.add(prefix);
+        _namespaceStack.add(uri);
 
-        _uriMap.put( uri, prefix );
-        _prefixMap.put( prefix, uri );
+        _uriMap.put(uri, prefix);
+        _prefixMap.put(prefix, uri);
 
         if (renameUri != null)
-            _uriMap.put( renameUri, renamePrefix );
+            _uriMap.put(renameUri, renamePrefix);
     }
 
-    private final void popMappings ( )
-    {
-        for ( ; ; )
-        {
+    private final void popMappings() {
+        for (; ; ) {
             int i = _namespaceStack.size();
 
             if (i == 0)
                 break;
 
-            if (_namespaceStack.get( i - 1 ) == null)
-            {
-                _namespaceStack.remove( i - 1 );
+            if (_namespaceStack.get(i - 1) == null) {
+                _namespaceStack.remove(i - 1);
                 break;
             }
 
-            Object oldUri = _namespaceStack.get( i - 7 );
-            Object oldPrefix = _namespaceStack.get( i - 8 );
+            Object oldUri = _namespaceStack.get(i - 7);
+            Object oldPrefix = _namespaceStack.get(i - 8);
 
             if (oldPrefix == null)
-                _uriMap.remove( oldUri );
+                _uriMap.remove(oldUri);
             else
-                _uriMap.put( oldUri, oldPrefix );
+                _uriMap.put(oldUri, oldPrefix);
 
-            oldPrefix = _namespaceStack.get( i - 4 );
-            oldUri = _namespaceStack.get( i - 3 );
+            oldPrefix = _namespaceStack.get(i - 4);
+            oldUri = _namespaceStack.get(i - 3);
 
             if (oldUri == null)
-                _prefixMap.remove( oldPrefix );
+                _prefixMap.remove(oldPrefix);
             else
-                _prefixMap.put( oldPrefix, oldUri );
+                _prefixMap.put(oldPrefix, oldUri);
 
-            String uri = (String) _namespaceStack.get( i - 5 );
+            String uri = (String) _namespaceStack.get(i - 5);
 
             if (uri != null)
-                _uriMap.put( uri, _namespaceStack.get( i - 6 ) );
+                _uriMap.put(uri, _namespaceStack.get(i - 6));
 
             // Hahahahahaha -- :-(
-            _namespaceStack.remove( i - 1 );
-            _namespaceStack.remove( i - 2 );
-            _namespaceStack.remove( i - 3 );
-            _namespaceStack.remove( i - 4 );
-            _namespaceStack.remove( i - 5 );
-            _namespaceStack.remove( i - 6 );
-            _namespaceStack.remove( i - 7 );
-            _namespaceStack.remove( i - 8 );
+            _namespaceStack.remove(i - 1);
+            _namespaceStack.remove(i - 2);
+            _namespaceStack.remove(i - 3);
+            _namespaceStack.remove(i - 4);
+            _namespaceStack.remove(i - 5);
+            _namespaceStack.remove(i - 6);
+            _namespaceStack.remove(i - 7);
+            _namespaceStack.remove(i - 8);
         }
     }
 
-    private final void dumpMappings ( )
-    {
-        for ( int i = _namespaceStack.size() ; i > 0 ; )
-        {
-            if (_namespaceStack.get( i - 1 ) == null)
-            {
-                System.out.println( "----------------" );
+    private final void dumpMappings() {
+        for (int i = _namespaceStack.size(); i > 0; ) {
+            if (_namespaceStack.get(i - 1) == null) {
+                System.out.println("----------------");
                 i--;
                 continue;
             }
 
-            System.out.print( "Mapping: " );
-            System.out.print( _namespaceStack.get( i - 2 ) );
-            System.out.print( " -> " );
-            System.out.print( _namespaceStack.get( i - 1 ) );
+            System.out.print("Mapping: ");
+            System.out.print(_namespaceStack.get(i - 2));
+            System.out.print(" -> ");
+            System.out.print(_namespaceStack.get(i - 1));
             System.out.println();
 
-            System.out.print( "Prefix Undo: " );
-            System.out.print( _namespaceStack.get( i - 4 ) );
-            System.out.print( " -> " );
-            System.out.print( _namespaceStack.get( i - 3 ) );
+            System.out.print("Prefix Undo: ");
+            System.out.print(_namespaceStack.get(i - 4));
+            System.out.print(" -> ");
+            System.out.print(_namespaceStack.get(i - 3));
             System.out.println();
 
-            System.out.print( "Uri Rename: " );
-            System.out.print( _namespaceStack.get( i - 5 ) );
-            System.out.print( " -> " );
-            System.out.print( _namespaceStack.get( i - 6 ) );
+            System.out.print("Uri Rename: ");
+            System.out.print(_namespaceStack.get(i - 5));
+            System.out.print(" -> ");
+            System.out.print(_namespaceStack.get(i - 6));
             System.out.println();
 
-            System.out.print( "UriUndo: " );
-            System.out.print( _namespaceStack.get( i - 7 ) );
-            System.out.print( " -> " );
-            System.out.print( _namespaceStack.get( i - 8 ) );
+            System.out.print("UriUndo: ");
+            System.out.print(_namespaceStack.get(i - 7));
+            System.out.print(" -> ");
+            System.out.print(_namespaceStack.get(i - 8));
             System.out.println();
 
             System.out.println();
@@ -770,10 +719,9 @@
         }
     }
 
-    private final String ensureMapping (
-        String uri, String candidatePrefix,
-        boolean considerCreatingDefault, boolean mustHavePrefix )
-    {
+    private final String ensureMapping(
+            String uri, String candidatePrefix,
+            boolean considerCreatingDefault, boolean mustHavePrefix) {
         assert uri != null;
 
         // Can be called for no-namespaced things
@@ -781,7 +729,7 @@
         if (uri.length() == 0)
             return null;
 
-        String prefix = (String) _uriMap.get( uri );
+        String prefix = (String) _uriMap.get(uri);
 
         if (prefix != null && (prefix.length() > 0 || !mustHavePrefix))
             return prefix;
@@ -798,24 +746,19 @@
         if (candidatePrefix != null && candidatePrefix.length() == 0)
             candidatePrefix = null;
 
-        if (candidatePrefix == null || !tryPrefix( candidatePrefix ))
-        {
+        if (candidatePrefix == null || !tryPrefix(candidatePrefix)) {
             if (_suggestedPrefixes != null &&
-                    _suggestedPrefixes.containsKey( uri ) &&
-                        tryPrefix( (String) _suggestedPrefixes.get( uri ) ))
-            {
-                candidatePrefix = (String) _suggestedPrefixes.get( uri );
-            }
-            else if (considerCreatingDefault && _useDefaultNamespace && tryPrefix( "" ))
+                    _suggestedPrefixes.containsKey(uri) &&
+                    tryPrefix((String) _suggestedPrefixes.get(uri))) {
+                candidatePrefix = (String) _suggestedPrefixes.get(uri);
+            } else if (considerCreatingDefault && _useDefaultNamespace && tryPrefix(""))
                 candidatePrefix = "";
-            else
-            {
-                String basePrefix = QNameHelper.suggestPrefix( uri );
+            else {
+                String basePrefix = QNameHelper.suggestPrefix(uri);
                 candidatePrefix = basePrefix;
 
-                for ( int i = 1 ; ; i++ )
-                {
-                    if (tryPrefix( candidatePrefix ))
+                for (int i = 1; ; i++) {
+                    if (tryPrefix(candidatePrefix))
                         break;
 
                     candidatePrefix = basePrefix + i;
@@ -825,31 +768,28 @@
 
         assert candidatePrefix != null;
 
-        syntheticNamespace( candidatePrefix, uri, considerCreatingDefault );
+        syntheticNamespace(candidatePrefix, uri, considerCreatingDefault);
 
-        addMapping( candidatePrefix, uri );
+        addMapping(candidatePrefix, uri);
 
         return candidatePrefix;
     }
 
-    protected final String getUriMapping ( String uri )
-    {
-        assert _uriMap.get( uri ) != null;
-        return (String) _uriMap.get( uri );
+    protected final String getUriMapping(String uri) {
+        assert _uriMap.get(uri) != null;
+        return (String) _uriMap.get(uri);
     }
 
-    String getNonDefaultUriMapping ( String uri )
-    {
-        String prefix = (String) _uriMap.get( uri );
+    String getNonDefaultUriMapping(String uri) {
+        String prefix = (String) _uriMap.get(uri);
 
         if (prefix != null && prefix.length() > 0)
             return prefix;
 
-        for ( Iterator keys = _prefixMap.keySet().iterator() ; keys.hasNext() ; )
-        {
+        for (Iterator keys = _prefixMap.keySet().iterator(); keys.hasNext(); ) {
             prefix = (String) keys.next();
 
-            if (prefix.length() > 0 && _prefixMap.get( prefix ).equals( uri ))
+            if (prefix.length() > 0 && _prefixMap.get(prefix).equals(uri))
                 return prefix;
         }
 
@@ -858,12 +798,11 @@
         return null;
     }
 
-    private final boolean tryPrefix ( String prefix )
-    {
-        if (prefix == null || Locale.beginsWithXml( prefix ))
+    private final boolean tryPrefix(String prefix) {
+        if (prefix == null || Locale.beginsWithXml(prefix))
             return false;
 
-        String existingUri = (String) _prefixMap.get( prefix );
+        String existingUri = (String) _prefixMap.get(prefix);
 
         // If the prefix is currently mapped, then try another prefix.  A
         // special case is that of trying to map the default prefix ("").
@@ -878,15 +817,13 @@
         return true;
     }
 
-    public final String getNamespaceForPrefix ( String prefix )
-    {
-        assert !prefix.equals( "xml" ) || _prefixMap.get( prefix ).equals( Locale._xml1998Uri );
+    public final String getNamespaceForPrefix(String prefix) {
+        assert !prefix.equals("xml") || _prefixMap.get(prefix).equals(Locale._xml1998Uri);
 
-        return (String) _prefixMap.get( prefix );
+        return (String) _prefixMap.get(prefix);
     }
 
-    protected Map getPrefixMap()
-    {
+    protected Map getPrefixMap() {
         return _prefixMap;
     }
 
@@ -894,283 +831,266 @@
     //
     //
 
-    static final class SynthNamespaceSaver extends Saver
-    {
+    static final class SynthNamespaceSaver extends Saver {
         LinkedHashMap _synthNamespaces = new LinkedHashMap();
 
-        SynthNamespaceSaver ( Cur c, XmlOptions options )
-        {
-            super( c, options );
+        SynthNamespaceSaver(Cur c, XmlOptions options) {
+            super(c, options);
         }
 
-        protected void syntheticNamespace (
-            String prefix, String uri, boolean considerCreatingDefault )
-        {
-            _synthNamespaces.put( uri, considerCreatingDefault ? "" : prefix );
+        protected void syntheticNamespace(
+                String prefix, String uri, boolean considerCreatingDefault) {
+            _synthNamespaces.put(uri, considerCreatingDefault ? "" : prefix);
         }
 
-        protected boolean emitElement (
-            SaveCur c, ArrayList attrNames, ArrayList attrValues ) { return false; }
+        protected boolean emitElement(
+                SaveCur c, ArrayList attrNames, ArrayList attrValues) {
+            return false;
+        }
 
-        protected void emitFinish    ( SaveCur c ) { }
-        protected void emitText      ( SaveCur c ) { }
-        protected void emitComment   ( SaveCur c ) { }
-        protected void emitProcinst  ( SaveCur c ) { }
-        protected void emitDocType   ( String docTypeName, String publicId, String systemId ) { }
-        protected void emitStartDoc  ( SaveCur c ) { }
-        protected void emitEndDoc    ( SaveCur c ) { }
+        protected void emitFinish(SaveCur c) {
+        }
+
+        protected void emitText(SaveCur c) {
+        }
+
+        protected void emitComment(SaveCur c) {
+        }
+
+        protected void emitProcinst(SaveCur c) {
+        }
+
+        protected void emitDocType(String docTypeName, String publicId, String systemId) {
+        }
+
+        protected void emitStartDoc(SaveCur c) {
+        }
+
+        protected void emitEndDoc(SaveCur c) {
+        }
     }
 
     //
     //
     //
 
-    static final class TextSaver extends Saver
-    {
-        TextSaver ( Cur c, XmlOptions options, String encoding )
-        {
-            super( c, options );
+    static final class TextSaver extends Saver {
+        TextSaver(Cur c, XmlOptions options, String encoding) {
+            super(c, options);
 
             boolean noSaveDecl =
-                options != null && options.hasOption( XmlOptions.SAVE_NO_XML_DECL );
+                    options != null && options.hasOption(XmlOptions.SAVE_NO_XML_DECL);
 
             if (options != null && options.hasOption(XmlOptions.SAVE_CDATA_LENGTH_THRESHOLD))
-                _cdataLengthThreshold = ((Integer)options.get(XmlOptions.SAVE_CDATA_LENGTH_THRESHOLD)).intValue();
+                _cdataLengthThreshold = ((Integer) options.get(XmlOptions.SAVE_CDATA_LENGTH_THRESHOLD)).intValue();
 
             if (options != null && options.hasOption(XmlOptions.SAVE_CDATA_ENTITY_COUNT_THRESHOLD))
-                _cdataEntityCountThreshold = ((Integer)options.get(XmlOptions.SAVE_CDATA_ENTITY_COUNT_THRESHOLD)).intValue();
+                _cdataEntityCountThreshold = ((Integer) options.get(XmlOptions.SAVE_CDATA_ENTITY_COUNT_THRESHOLD)).intValue();
 
-            if (options != null && options.hasOption(XmlOptions.LOAD_SAVE_CDATA_BOOKMARKS) )
+            if (options != null && options.hasOption(XmlOptions.LOAD_SAVE_CDATA_BOOKMARKS))
                 _useCDataBookmarks = true;
 
-            if (options != null && options.hasOption(XmlOptions.SAVE_PRETTY_PRINT) )
+            if (options != null && options.hasOption(XmlOptions.SAVE_PRETTY_PRINT))
                 _isPrettyPrint = true;
 
             _in = _out = 0;
             _free = 0;
 
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
-            if (encoding != null && !noSaveDecl)
-            {
-                XmlDocumentProperties props = Locale.getDocProps( c, false );
+            if (encoding != null && !noSaveDecl) {
+                XmlDocumentProperties props = Locale.getDocProps(c, false);
 
                 String version = props == null ? null : props.getVersion();
 
                 if (version == null)
                     version = "1.0";
 
-                emit( "<?xml version=\"" );
-                emit( version );
-                emit( "\" encoding=\"" + encoding + "\"?>" + _newLine );
+                emit("<?xml version=\"");
+                emit(version);
+                emit("\" encoding=\"" + encoding + "\"?>" + _newLine);
             }
         }
 
-        protected boolean emitElement ( SaveCur c, ArrayList attrNames, ArrayList attrValues )
-        {
+        protected boolean emitElement(SaveCur c, ArrayList attrNames, ArrayList attrValues) {
             assert c.isElem();
 
-            emit( '<' );
-            emitName( c.getName(), false );
+            emit('<');
+            emitName(c.getName(), false);
 
             if (saveNamespacesFirst())
                 emitNamespacesHelper();
 
-            for ( int i = 0 ; i < attrNames.size() ; i++ )
-                emitAttrHelper( (QName) attrNames.get( i ), (String) attrValues.get( i ) );
+            for (int i = 0; i < attrNames.size(); i++)
+                emitAttrHelper((QName) attrNames.get(i), (String) attrValues.get(i));
 
             if (!saveNamespacesFirst())
                 emitNamespacesHelper();
 
-            if (!c.hasChildren() && !c.hasText())
-            {
-                emit( '/', '>' );
+            if (!c.hasChildren() && !c.hasText()) {
+                emit('/', '>');
                 return true;
-            }
-            else
-            {
-                emit( '>' );
+            } else {
+                emit('>');
                 return false;
             }
         }
 
-        protected void emitFinish ( SaveCur c )
-        {
-            emit( '<', '/' );
-            emitName( c.getName(), false );
-            emit( '>' );
+        protected void emitFinish(SaveCur c) {
+            emit('<', '/');
+            emitName(c.getName(), false);
+            emit('>');
         }
 
-        protected void emitXmlns ( String prefix, String uri )
-        {
+        protected void emitXmlns(String prefix, String uri) {
             assert prefix != null;
             assert uri != null;
 
-            emit( "xmlns" );
+            emit("xmlns");
 
-            if (prefix.length() > 0)
-            {
-                emit( ':' );
-                emit( prefix );
+            if (prefix.length() > 0) {
+                emit(':');
+                emit(prefix);
             }
 
-            emit( '=', '\"' );
+            emit('=', '\"');
 
             // TODO - must encode uri properly
 
-            emit( uri );
+            emit(uri);
             entitizeAttrValue(false);
 
-            emit( '"' );
+            emit('"');
         }
 
-        private void emitNamespacesHelper ( )
-        {
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-            {
-                emit( ' ' );
-                emitXmlns( mappingPrefix(), mappingUri() );
+        private void emitNamespacesHelper() {
+            for (iterateMappings(); hasMapping(); nextMapping()) {
+                emit(' ');
+                emitXmlns(mappingPrefix(), mappingUri());
             }
         }
 
-        private void emitAttrHelper ( QName attrName, String attrValue )
-        {
-            emit( ' ' );
-            emitName( attrName, true );
-            emit( '=', '\"' );
-            emit( attrValue );
+        private void emitAttrHelper(QName attrName, String attrValue) {
+            emit(' ');
+            emitName(attrName, true);
+            emit('=', '\"');
+            emit(attrValue);
             entitizeAttrValue(true);
-            emit( '"' );
+            emit('"');
         }
 
-        protected void emitText ( SaveCur c )
-        {
+        protected void emitText(SaveCur c) {
             assert c.isText();
 
             // c.isTextCData() is expensive do it only if useCDataBookmarks option is enabled
             boolean forceCData = _useCDataBookmarks && c.isTextCData();
 
-            emit( c );
+            emit(c);
 
-            entitizeContent( forceCData );
+            entitizeContent(forceCData);
         }
 
-        protected void emitComment ( SaveCur c )
-        {
+        protected void emitComment(SaveCur c) {
             assert c.isComment();
 
-            emit( "<!--" );
+            emit("<!--");
 
             c.push();
             c.next();
 
-            emit( c );
+            emit(c);
 
             c.pop();
 
             entitizeComment();
-            emit( "-->" );
+            emit("-->");
         }
 
-        protected void emitProcinst ( SaveCur c )
-        {
+        protected void emitProcinst(SaveCur c) {
             assert c.isProcinst();
 
-            emit( "<?" );
+            emit("<?");
 
             // TODO - encoding issues here?
-            emit( c.getName().getLocalPart() );
+            emit(c.getName().getLocalPart());
 
             c.push();
 
             c.next();
 
-            if (c.isText())
-            {
-                emit( " " );
-                emit( c );
+            if (c.isText()) {
+                emit(" ");
+                emit(c);
                 entitizeProcinst();
             }
 
             c.pop();
 
-            emit( "?>" );
+            emit("?>");
         }
 
-        private void emitLiteral ( String literal )
-        {
+        private void emitLiteral(String literal) {
             // TODO: systemId production http://www.w3.org/TR/REC-xml/#NT-SystemLiteral
             // TODO: publicId production http://www.w3.org/TR/REC-xml/#NT-PubidLiteral
-            if (literal.indexOf( "\"" ) < 0)
-            {
-                emit( '\"' );
-                emit( literal );
-                emit( '\"' );
-            }
-            else
-            {
-                emit( '\'' );
-                emit( literal );
-                emit( '\'' );
+            if (literal.indexOf("\"") < 0) {
+                emit('\"');
+                emit(literal);
+                emit('\"');
+            } else {
+                emit('\'');
+                emit(literal);
+                emit('\'');
             }
         }
 
-        protected void emitDocType ( String docTypeName, String publicId, String systemId )
-        {
+        protected void emitDocType(String docTypeName, String publicId, String systemId) {
             assert docTypeName != null;
 
-            emit( "<!DOCTYPE " );
-            emit( docTypeName );
+            emit("<!DOCTYPE ");
+            emit(docTypeName);
 
-            if (publicId == null && systemId != null)
-            {
-                emit( " SYSTEM " );
-                emitLiteral( systemId );
-            }
-            else if (publicId != null)
-            {
-                emit( " PUBLIC " );
-                emitLiteral( publicId );
-                emit( " " );
-                emitLiteral( systemId );
+            if (publicId == null && systemId != null) {
+                emit(" SYSTEM ");
+                emitLiteral(systemId);
+            } else if (publicId != null) {
+                emit(" PUBLIC ");
+                emitLiteral(publicId);
+                emit(" ");
+                emitLiteral(systemId);
             }
 
-            emit( ">" );
-            emit( _newLine );
+            emit(">");
+            emit(_newLine);
         }
 
-        protected void emitStartDoc ( SaveCur c )
-        {
+        protected void emitStartDoc(SaveCur c) {
         }
 
-        protected void emitEndDoc ( SaveCur c )
-        {
+        protected void emitEndDoc(SaveCur c) {
         }
 
         //
         //
         //
 
-        private void emitName ( QName name, boolean needsPrefix )
-        {
+        private void emitName(QName name, boolean needsPrefix) {
             assert name != null;
 
             String uri = name.getNamespaceURI();
 
             assert uri != null;
 
-            if (uri.length() != 0)
-            {
+            if (uri.length() != 0) {
                 String prefix = name.getPrefix();
-                String mappedUri = getNamespaceForPrefix( prefix );
+                String mappedUri = getNamespaceForPrefix(prefix);
 
-                if (mappedUri == null || !mappedUri.equals( uri ))
-                    prefix = getUriMapping( uri );
+                if (mappedUri == null || !mappedUri.equals(uri))
+                    prefix = getUriMapping(uri);
 
                 // Attrs need a prefix.  If I have not found one, then there must be a default
                 // prefix obscuring the prefix needed for this attr.  Find it manually.
@@ -1180,135 +1100,121 @@
                 // here
 
                 if (needsPrefix && prefix.length() == 0)
-                    prefix = getNonDefaultUriMapping( uri );
+                    prefix = getNonDefaultUriMapping(uri);
 
-                if (prefix.length() > 0)
-                {
-                    emit( prefix );
-                    emit( ':' );
+                if (prefix.length() > 0) {
+                    emit(prefix);
+                    emit(':');
                 }
             }
 
             assert name.getLocalPart().length() > 0;
 
-            emit( name.getLocalPart() );
+            emit(name.getLocalPart());
         }
 
-        private void emit ( char ch )
-        {
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+        private void emit(char ch) {
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
-            preEmit( 1 );
+            preEmit(1);
 
-            _buf[ _in ] = ch;
+            _buf[_in] = ch;
 
             _in = (_in + 1) % _buf.length;
 
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
         }
 
-        private void emit ( char ch1, char ch2 )
-        {
-            if( preEmit( 2 ) )
+        private void emit(char ch1, char ch2) {
+            if (preEmit(2))
                 return;
 
-            _buf[ _in ] = ch1;
+            _buf[_in] = ch1;
             _in = (_in + 1) % _buf.length;
 
-            _buf[ _in ] = ch2;
+            _buf[_in] = ch2;
             _in = (_in + 1) % _buf.length;
 
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;            
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
         }
 
-        private void emit ( String s )
-        {
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+        private void emit(String s) {
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             int cch = s == null ? 0 : s.length();
 
-            if (preEmit( cch ))
+            if (preEmit(cch))
                 return;
 
             int chunk;
 
-            if (_in <= _out || cch < (chunk = _buf.length - _in))
-            {
-                s.getChars( 0, cch, _buf, _in );
+            if (_in <= _out || cch < (chunk = _buf.length - _in)) {
+                s.getChars(0, cch, _buf, _in);
                 _in += cch;
-            }
-            else
-            {
-                s.getChars( 0, chunk, _buf, _in );
-                s.getChars( chunk, cch, _buf, 0 );
+            } else {
+                s.getChars(0, chunk, _buf, _in);
+                s.getChars(chunk, cch, _buf, 0);
                 _in = (_in + cch) % _buf.length;
             }
 
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
         }
 
-        private void emit ( SaveCur c )
-        {
-            if (c.isText())
-            {
+        private void emit(SaveCur c) {
+            if (c.isText()) {
                 Object src = c.getChars();
                 int cch = c._cchSrc;
 
-                if (preEmit( cch ))
+                if (preEmit(cch))
                     return;
 
                 int chunk;
 
-                if (_in <= _out || cch < (chunk = _buf.length - _in))
-                {
-                    CharUtil.getChars( _buf, _in, src, c._offSrc, cch );
+                if (_in <= _out || cch < (chunk = _buf.length - _in)) {
+                    CharUtil.getChars(_buf, _in, src, c._offSrc, cch);
                     _in += cch;
-                }
-                else
-                {
-                    CharUtil.getChars( _buf, _in, src, c._offSrc, chunk );
-                    CharUtil.getChars( _buf, 0, src, c._offSrc + chunk, cch - chunk );
+                } else {
+                    CharUtil.getChars(_buf, _in, src, c._offSrc, chunk);
+                    CharUtil.getChars(_buf, 0, src, c._offSrc + chunk, cch - chunk);
                     _in = (_in + cch) % _buf.length;
                 }
-            }
-            else
-                preEmit( 0 );
+            } else
+                preEmit(0);
         }
 
-        private boolean preEmit ( int cch )
-        {
+        private boolean preEmit(int cch) {
             assert cch >= 0;
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             _lastEmitCch = cch;
 
@@ -1316,7 +1222,7 @@
                 return true;
 
             if (_free <= cch)
-                resize( cch, -1 );
+                resize(cch, -1);
 
             assert cch <= _free;
 
@@ -1326,8 +1232,7 @@
             // the buffer to be at the beginning so as to not grow it anymore
             // than needed.
 
-            if (used == 0)
-            {
+            if (used == 0) {
                 assert _in == _out;
                 assert _free == _buf.length;
                 _in = _out = 0;
@@ -1338,21 +1243,20 @@
             _free -= cch;
 
             assert _free >= 0;
-            assert _buf==null || _free == (_in>=_out ? _buf.length - (_in - _out) : _out - _in ) - cch : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) - cch) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in - cch ) ||                  // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length - cch) ||                 // no data, all buffer free
-                (_out==_in && _free == 0)                                    // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null || _free == (_in >= _out ? _buf.length - (_in - _out) : _out - _in) - cch : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out) - cch) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in - cch) ||                  // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length - cch) ||                 // no data, all buffer free
+                    (_out == _in && _free == 0)                                    // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             return false;
         }
 
-        private void entitizeContent ( boolean forceCData )
-        {
-            assert _free >=0;
-            
+        private void entitizeContent(boolean forceCData) {
+            assert _free >= 0;
+
             if (_lastEmitCch == 0)
                 return;
 
@@ -1364,15 +1268,14 @@
             int count = 0;
             char prevChar = 0;
             char prevPrevChar = 0;
-            for ( int cch = _lastEmitCch ; cch > 0 ; cch-- )
-            {
-                char ch = _buf[ i ];
+            for (int cch = _lastEmitCch; cch > 0; cch--) {
+                char ch = _buf[i];
 
                 if (ch == '<' || ch == '&')
                     count++;
-                else if (prevPrevChar == ']' && prevChar == ']' && ch == '>' )
+                else if (prevPrevChar == ']' && prevChar == ']' && ch == '>')
                     hasCharToBeReplaced = true;
-                else if (isBadChar( ch ) || isEscapedChar( ch ) || (!_isPrettyPrint && ch == '\r') )
+                else if (isBadChar(ch) || isEscapedChar(ch) || (!_isPrettyPrint && ch == '\r'))
                     hasCharToBeReplaced = true;
 
                 if (++i == n)
@@ -1382,7 +1285,7 @@
                 prevChar = ch;
             }
 
-            if (!forceCData && count == 0 && !hasCharToBeReplaced && count<_cdataEntityCountThreshold)
+            if (!forceCData && count == 0 && !hasCharToBeReplaced && count < _cdataEntityCountThreshold)
                 return;
 
             i = _lastEmitIn;
@@ -1390,27 +1293,25 @@
             //
             // Heuristic for knowing when to save out stuff as a CDATA.
             //
-            if (forceCData || (_lastEmitCch > _cdataLengthThreshold && count > _cdataEntityCountThreshold) )
-            {
-                boolean lastWasBracket = _buf[ i ] == ']';
+            if (forceCData || (_lastEmitCch > _cdataLengthThreshold && count > _cdataEntityCountThreshold)) {
+                boolean lastWasBracket = _buf[i] == ']';
 
-                i = replace( i, "<![CDATA[" + _buf[ i ] );
+                i = replace(i, "<![CDATA[" + _buf[i]);
 
                 boolean secondToLastWasBracket = lastWasBracket;
 
-                lastWasBracket = _buf[ i ] == ']';
+                lastWasBracket = _buf[i] == ']';
 
                 if (++i == _buf.length)
                     i = 0;
 
-                for ( int cch = _lastEmitCch - 2 ; cch > 0 ; cch-- )
-                {
-                    char ch = _buf[ i ];
+                for (int cch = _lastEmitCch - 2; cch > 0; cch--) {
+                    char ch = _buf[i];
 
                     if (ch == '>' && secondToLastWasBracket && lastWasBracket)
-                        i = replace( i, "]]>><![CDATA[" );
-                    else if (isBadChar( ch ))
-                        i = replace( i, "?" );
+                        i = replace(i, "]]>><![CDATA[");
+                    else if (isBadChar(ch))
+                        i = replace(i, "?");
                     else
                         i++;
 
@@ -1421,29 +1322,26 @@
                         i = 0;
                 }
 
-                emit( "]]>" );
-            }
-            else
-            {
+                emit("]]>");
+            } else {
                 char ch = 0, ch_1 = 0, ch_2;
-                for ( int cch = _lastEmitCch ; cch > 0 ; cch-- )
-                {
+                for (int cch = _lastEmitCch; cch > 0; cch--) {
                     ch_2 = ch_1;
                     ch_1 = ch;
-                    ch = _buf[ i ];
+                    ch = _buf[i];
 
                     if (ch == '<')
-                        i = replace( i, "&lt;" );
+                        i = replace(i, "&lt;");
                     else if (ch == '&')
-                        i = replace( i, "&amp;" );
+                        i = replace(i, "&amp;");
                     else if (ch == '>' && ch_1 == ']' && ch_2 == ']')
-                        i = replace( i, "&gt;" );
-                    else if (isBadChar( ch ))
-                        i = replace( i, "?" );
+                        i = replace(i, "&gt;");
+                    else if (isBadChar(ch))
+                        i = replace(i, "?");
                     else if (!_isPrettyPrint && ch == '\r')
-                        i = replace( i, "&#13;" );
-                    else if (isEscapedChar( ch ))
-                        i = replace( i, _replaceChar.getEscapedString( ch ) );
+                        i = replace(i, "&#13;");
+                    else if (isEscapedChar(ch))
+                        i = replace(i, _replaceChar.getEscapedString(ch));
                     else
                         i++;
 
@@ -1453,29 +1351,25 @@
             }
         }
 
-        private void entitizeAttrValue ( boolean replaceEscapedChar )
-        {
+        private void entitizeAttrValue(boolean replaceEscapedChar) {
             if (_lastEmitCch == 0)
                 return;
 
             int i = _lastEmitIn;
 
-            for ( int cch = _lastEmitCch ; cch > 0 ; cch-- )
-            {
-                char ch = _buf[ i ];
+            for (int cch = _lastEmitCch; cch > 0; cch--) {
+                char ch = _buf[i];
 
                 if (ch == '<')
-                    i = replace( i, "&lt;" );
+                    i = replace(i, "&lt;");
                 else if (ch == '&')
-                    i = replace( i, "&amp;" );
+                    i = replace(i, "&amp;");
                 else if (ch == '"')
-                    i = replace( i, "&quot;" );
-                else if (isEscapedChar( ch ))
-                {
+                    i = replace(i, "&quot;");
+                else if (isEscapedChar(ch)) {
                     if (replaceEscapedChar)
-                        i = replace( i, _replaceChar.getEscapedString( ch ) );
-                }
-                else
+                        i = replace(i, _replaceChar.getEscapedString(ch));
+                } else
                     i++;
 
                 if (i == _buf.length)
@@ -1483,8 +1377,7 @@
             }
         }
 
-        private void entitizeComment ( )
-        {
+        private void entitizeComment() {
             if (_lastEmitCch == 0)
                 return;
 
@@ -1492,28 +1385,21 @@
 
             boolean lastWasDash = false;
 
-            for ( int cch = _lastEmitCch ; cch > 0 ; cch-- )
-            {
-                char ch = _buf[ i ];
+            for (int cch = _lastEmitCch; cch > 0; cch--) {
+                char ch = _buf[i];
 
-                if (isBadChar( ch ))
-                    i = replace( i, "?" );
-                else if (ch == '-')
-                {
-                    if (lastWasDash)
-                    {
+                if (isBadChar(ch))
+                    i = replace(i, "?");
+                else if (ch == '-') {
+                    if (lastWasDash) {
                         // Replace "--" with "- " to make well formed
-                        i = replace( i, " " );
+                        i = replace(i, " ");
                         lastWasDash = false;
-                    }
-                    else
-                    {
+                    } else {
                         lastWasDash = true;
                         i++;
                     }
-                }
-                else
-                {
+                } else {
                     lastWasDash = false;
                     i++;
                 }
@@ -1526,12 +1412,11 @@
             // _lastEmitIn will still be ok
 
             int offset = (_lastEmitIn + _lastEmitCch - 1) % _buf.length;
-            if (_buf[ offset ] == '-')
-                i = replace( offset, " " );
+            if (_buf[offset] == '-')
+                i = replace(offset, " ");
         }
 
-        private void entitizeProcinst ( )
-        {
+        private void entitizeProcinst() {
             if (_lastEmitCch == 0)
                 return;
 
@@ -1539,25 +1424,21 @@
 
             boolean lastWasQuestion = false;
 
-            for ( int cch = _lastEmitCch ; cch > 0 ; cch-- )
-            {
-                char ch = _buf[ i ];
+            for (int cch = _lastEmitCch; cch > 0; cch--) {
+                char ch = _buf[i];
 
-                if (isBadChar( ch ))
-                    i = replace( i, "?" );
+                if (isBadChar(ch))
+                    i = replace(i, "?");
 
-                if (ch == '>')
-                {
-    // TODO - Had to convert to a space here ... imples not well formed XML
+                if (ch == '>') {
+                    // TODO - Had to convert to a space here ... imples not well formed XML
                     if (lastWasQuestion)
-                        i = replace( i, " " );
+                        i = replace(i, " ");
                     else
                         i++;
 
                     lastWasQuestion = false;
-                }
-                else
-                {
+                } else {
                     lastWasQuestion = ch == '?';
                     i++;
                 }
@@ -1570,27 +1451,24 @@
         /**
          * Test if a character is to be replaced with an escaped value
          */
-        private boolean isEscapedChar ( char ch )
-        {
-            return ( null != _replaceChar && _replaceChar.containsChar( ch ) );
+        private boolean isEscapedChar(char ch) {
+            return (null != _replaceChar && _replaceChar.containsChar(ch));
         }
 
-        private int replace ( int i, String replacement )
-        {
+        private int replace(int i, String replacement) {
             assert replacement.length() > 0;
 
             int dCch = replacement.length() - 1;
 
-            if (dCch == 0)
-            {
-                _buf[ i ] = replacement.charAt( 0 );
+            if (dCch == 0) {
+                _buf[i] = replacement.charAt(0);
                 return i + 1;
             }
 
             assert _free >= 0;
 
             if (dCch > _free)
-                i = resize( dCch, i );
+                i = resize(dCch, i);
 
             assert _free >= 0;
 
@@ -1599,52 +1477,44 @@
 
             int charsToCopy = dCch + 1;
 
-            if (_out > _in && i >= _out)
-            {
-                System.arraycopy( _buf, _out, _buf, _out - dCch, i - _out );
+            if (_out > _in && i >= _out) {
+                System.arraycopy(_buf, _out, _buf, _out - dCch, i - _out);
                 _out -= dCch;
                 i -= dCch;
-            }
-            else
-            {
+            } else {
                 assert i < _in;
                 int availableEndChunk = _buf.length - _in;
-                if ( dCch <= availableEndChunk )
-                {
-                    System.arraycopy( _buf, i, _buf, i + dCch, _in - i );
-                    _in = ( _in + dCch) % _buf.length;
-                }
-                else if ( dCch <= availableEndChunk + _in - i - 1 )
-                {
+                if (dCch <= availableEndChunk) {
+                    System.arraycopy(_buf, i, _buf, i + dCch, _in - i);
+                    _in = (_in + dCch) % _buf.length;
+                } else if (dCch <= availableEndChunk + _in - i - 1) {
                     int numToCopyToStart = dCch - availableEndChunk;
-                    System.arraycopy( _buf, _in-numToCopyToStart, _buf, 0, numToCopyToStart );
-                    System.arraycopy( _buf, i+1, _buf, i+1+dCch, _in-i-1-numToCopyToStart);
+                    System.arraycopy(_buf, _in - numToCopyToStart, _buf, 0, numToCopyToStart);
+                    System.arraycopy(_buf, i + 1, _buf, i + 1 + dCch, _in - i - 1 - numToCopyToStart);
 
                     _in = numToCopyToStart;
-                }
-                else
-                {
+                } else {
                     int numToCopyToStart = _in - i - 1;
                     charsToCopy = availableEndChunk + _in - i;
 
-                    System.arraycopy( _buf, _in-numToCopyToStart, _buf, dCch-charsToCopy+1, numToCopyToStart );
-                    replacement.getChars( charsToCopy, dCch + 1, _buf, 0);
+                    System.arraycopy(_buf, _in - numToCopyToStart, _buf, dCch - charsToCopy + 1, numToCopyToStart);
+                    replacement.getChars(charsToCopy, dCch + 1, _buf, 0);
 
                     _in = numToCopyToStart + dCch - charsToCopy + 1;
                 }
             }
 
-            replacement.getChars( 0, charsToCopy, _buf, i );
+            replacement.getChars(0, charsToCopy, _buf, i);
 
             _free -= dCch;
 
             assert _free >= 0;
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             return (i + dCch + 1) % _buf.length;
         }
@@ -1652,8 +1522,7 @@
         //
         //
 
-        private int ensure ( int cch )
-        {
+        private int ensure(int cch) {
             // Even if we're asked to ensure nothing, still try to ensure
             // atleast one character so we can determine if we're at the
             // end of the stream.
@@ -1663,7 +1532,7 @@
 
             int available = getAvailable();
 
-            for ( ; available < cch ; available = getAvailable() )
+            for (; available < cch; available = getAvailable())
                 if (!process())
                     break;
 
@@ -1675,53 +1544,45 @@
             return available;
         }
 
-        int getAvailable ( )
-        {
+        int getAvailable() {
             return _buf == null ? 0 : _buf.length - _free;
         }
 
-        private int resize ( int cch, int i )
-        {
+        private int resize(int cch, int i) {
             assert _free >= 0;
             assert cch > 0;
             assert cch >= _free;
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             int newLen = _buf == null ? _initialBufSize : _buf.length * 2;
             int used = getAvailable();
 
-            while ( newLen - used < cch )
+            while (newLen - used < cch)
                 newLen *= 2;
 
-            char[] newBuf = new char [ newLen ];
+            char[] newBuf = new char[newLen];
 
-            if (used > 0)
-            {
-                if (_in > _out)
-                {
+            if (used > 0) {
+                if (_in > _out) {
                     assert i == -1 || (i >= _out && i < _in);
-                    System.arraycopy( _buf, _out, newBuf, 0, used );
+                    System.arraycopy(_buf, _out, newBuf, 0, used);
                     i -= _out;
-                }
-                else
-                {
+                } else {
                     assert i == -1 || (i >= _out || i < _in);
-                    System.arraycopy( _buf, _out, newBuf, 0, used - _in );
-                    System.arraycopy( _buf, 0, newBuf, used - _in, _in );
+                    System.arraycopy(_buf, _out, newBuf, 0, used - _in);
+                    System.arraycopy(_buf, 0, newBuf, used - _in, _in);
                     i = i >= _out ? i - _out : i + _out;
                 }
 
                 _out = 0;
                 _in = used;
                 _free += newBuf.length - _buf.length;
-            }
-            else
-            {
+            } else {
                 _free = newBuf.length;
                 assert _in == 0 && _out == 0;
                 assert i == -1;
@@ -1730,47 +1591,45 @@
             _buf = newBuf;
 
             assert _free >= 0;
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             return i;
         }
 
-        public int read ( )
-        {
-            if (ensure( 1 ) == 0)
+        public int read() {
+            if (ensure(1) == 0)
                 return -1;
 
             assert getAvailable() > 0;
 
-            int ch = _buf[ _out ];
+            int ch = _buf[_out];
 
             _out = (_out + 1) % _buf.length;
             _free++;
 
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             return ch;
         }
 
-        public int read ( char[] cbuf, int off, int len )
-        {
+        public int read(char[] cbuf, int off, int len) {
             // Check for end of stream even if there is no way to return
             // characters because the Reader doc says to return -1 at end of
             // stream.
 
             int n;
 
-            if ((n = ensure( len )) == 0)
+            if ((n = ensure(len)) == 0)
                 return -1;
 
             if (cbuf == null || len <= 0)
@@ -1779,65 +1638,55 @@
             if (n < len)
                 len = n;
 
-            if (_out < _in)
-            {
-                System.arraycopy( _buf, _out, cbuf, off, len );
-            }
-            else
-            {
+            if (_out < _in) {
+                System.arraycopy(_buf, _out, cbuf, off, len);
+            } else {
                 int chunk = _buf.length - _out;
 
                 if (chunk >= len)
-                    System.arraycopy( _buf, _out, cbuf, off, len );
-                else
-                {
-                    System.arraycopy( _buf, _out, cbuf, off, chunk );
-                    System.arraycopy( _buf, 0, cbuf, off + chunk, len - chunk );
+                    System.arraycopy(_buf, _out, cbuf, off, len);
+                else {
+                    System.arraycopy(_buf, _out, cbuf, off, chunk);
+                    System.arraycopy(_buf, 0, cbuf, off + chunk, len - chunk);
                 }
             }
 
             _out = (_out + len) % _buf.length;
             _free += len;
 
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             assert _free >= 0;
 
             return len;
         }
 
-        public int write ( Writer writer, int cchMin )
-        {
-            while ( getAvailable() < cchMin)
-            {
+        public int write(Writer writer, int cchMin) {
+            while (getAvailable() < cchMin) {
                 if (!process())
                     break;
             }
 
             int charsAvailable = getAvailable();
 
-            if (charsAvailable > 0)
-            {
+            if (charsAvailable > 0) {
                 // I don't want to deal with the circular cases
 
                 assert _out == 0;
                 assert _in >= _out : "_in:" + _in + " < _out:" + _out;
                 assert _free == _buf.length - _in;
 
-                try
-                {
+                try {
 //System.out.println("-------------\nWriting in corverter: TextSaver.write():1703  " + charsAvailable + " chars\n" + new String(_buf, 0, charsAvailable));
-                    writer.write( _buf, 0, charsAvailable );
+                    writer.write(_buf, 0, charsAvailable);
                     writer.flush();
-                }
-                catch ( IOException e )
-                {
-                    throw new RuntimeException( e );
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
                 }
 
                 _free += charsAvailable;
@@ -1846,30 +1695,29 @@
 
                 _in = 0;
             }
-            assert _buf==null ||
-                (_out<_in && _free == _buf.length - ( _in - _out ) ) || // data in the middle, free on the edges
-                (_out>_in && _free == _out - _in ) ||                   // data on the edges, free in the middle
-                (_out==_in && _free == _buf.length) ||                  // no data, all buffer free
-                (_out==_in && _free == 0)                               // buffer full
-                : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
+            assert _buf == null ||
+                    (_out < _in && _free == _buf.length - (_in - _out)) || // data in the middle, free on the edges
+                    (_out > _in && _free == _out - _in) ||                   // data on the edges, free in the middle
+                    (_out == _in && _free == _buf.length) ||                  // no data, all buffer free
+                    (_out == _in && _free == 0)                               // buffer full
+                    : "_buf.length:" + _buf.length + " _in:" + _in + " _out:" + _out + " _free:" + _free;
 
             return charsAvailable;
         }
 
-        public String saveToString ( )
-        {
+        public String saveToString() {
             // We're gonna build a string.  Instead of using StringBuffer, may
             // as well use my buffer here.  Fill the whole sucker up and
             // create a String!
 
-            while ( process() )
+            while (process())
                 ;
 
             assert _out == 0;
 
             int available = getAvailable();
 
-            return available == 0 ? "" : new String( _buf, _out, available );
+            return available == 0 ? "" : new String(_buf, _out, available);
         }
 
         //
@@ -1885,9 +1733,9 @@
         private int _lastEmitIn;
         private int _lastEmitCch;
 
-        private int    _free;
-        private int    _in;
-        private int    _out;
+        private int _free;
+        private int _in;
+        private int _out;
         private char[] _buf;
         /*
         _buf is a circular buffer, useful data is before _in up to _out, there are 2 posible configurations:
@@ -1898,257 +1746,212 @@
     }
 
     static final class OptimizedForSpeedSaver
-        extends Saver
-    {
+            extends Saver {
         Writer _w;
         private char[] _buf = new char[1024];
 
 
         static private class SaverIOException
-            extends RuntimeException
-        {
-            SaverIOException(IOException e)
-            {
+                extends RuntimeException {
+            SaverIOException(IOException e) {
                 super(e);
             }
         }
 
 
-        OptimizedForSpeedSaver(Cur cur, Writer writer)
-        {
+        OptimizedForSpeedSaver(Cur cur, Writer writer) {
             super(cur, XmlOptions.maskNull(null));
             _w = writer;
         }
 
         static void save(Cur cur, Writer writer)
-            throws IOException
-        {
-            try
-            {
+                throws IOException {
+            try {
                 Saver saver = new OptimizedForSpeedSaver(cur, writer);
-                while(saver.process())
-                {}
-            }
-            catch (SaverIOException e)
-            {
-                throw (IOException)e.getCause();
+                while (saver.process()) {
+                }
+            } catch (SaverIOException e) {
+                throw (IOException) e.getCause();
             }
         }
 
-        private void emit(String s)
-        {
-            try
-            {
+        private void emit(String s) {
+            try {
                 _w.write(s);
-            }
-            catch (IOException e)
-            {
+            } catch (IOException e) {
                 throw new SaverIOException(e);
             }
         }
 
-        private void emit(char c)
-        {
-            try
-            {
+        private void emit(char c) {
+            try {
                 _buf[0] = c;
                 _w.write(_buf, 0, 1);
-            }
-            catch (IOException e)
-            {
+            } catch (IOException e) {
                 throw new SaverIOException(e);
             }
         }
 
-        private void emit(char c1, char c2)
-        {
-            try
-            {
+        private void emit(char c1, char c2) {
+            try {
                 _buf[0] = c1;
                 _buf[1] = c2;
-                _w.write(_buf, 0 , 2);
-            }
-            catch (IOException e)
-            {
+                _w.write(_buf, 0, 2);
+            } catch (IOException e) {
                 throw new SaverIOException(e);
             }
         }
 
-        private void emit(char[] buf, int start, int len)
-        {
-            try
-            {
+        private void emit(char[] buf, int start, int len) {
+            try {
                 _w.write(buf, start, len);
-            }
-            catch (IOException e)
-            {
+            } catch (IOException e) {
                 throw new SaverIOException(e);
             }
         }
 
-        protected boolean emitElement ( SaveCur c, ArrayList attrNames, ArrayList attrValues )
-        {
+        protected boolean emitElement(SaveCur c, ArrayList attrNames, ArrayList attrValues) {
             assert c.isElem();
 
-            emit( '<' );
-            emitName( c.getName(), false );
+            emit('<');
+            emitName(c.getName(), false);
 
-            for ( int i = 0 ; i < attrNames.size() ; i++ )
-                emitAttrHelper( (QName) attrNames.get( i ), (String) attrValues.get( i ) );
+            for (int i = 0; i < attrNames.size(); i++)
+                emitAttrHelper((QName) attrNames.get(i), (String) attrValues.get(i));
 
             if (!saveNamespacesFirst())
                 emitNamespacesHelper();
 
-            if (!c.hasChildren() && !c.hasText())
-            {
-                emit( '/', '>' );
+            if (!c.hasChildren() && !c.hasText()) {
+                emit('/', '>');
                 return true;
-            }
-            else
-            {
-                emit( '>' );
+            } else {
+                emit('>');
                 return false;
             }
         }
 
-        protected void emitFinish ( SaveCur c )
-        {
-            emit( '<', '/' );
-            emitName( c.getName(), false );
-            emit( '>' );
+        protected void emitFinish(SaveCur c) {
+            emit('<', '/');
+            emitName(c.getName(), false);
+            emit('>');
         }
 
-        protected void emitXmlns ( String prefix, String uri )
-        {
+        protected void emitXmlns(String prefix, String uri) {
             assert prefix != null;
             assert uri != null;
 
-            emit( "xmlns" );
+            emit("xmlns");
 
-            if (prefix.length() > 0)
-            {
-                emit( ':' );
-                emit( prefix );
+            if (prefix.length() > 0) {
+                emit(':');
+                emit(prefix);
             }
 
-            emit( '=', '\"' );
+            emit('=', '\"');
 
             // TODO - must encode uri properly
             emitAttrValue(uri);
 
-            emit( '"' );
+            emit('"');
         }
 
-        private void emitNamespacesHelper ( )
-        {
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-            {
-                emit( ' ' );
-                emitXmlns( mappingPrefix(), mappingUri() );
+        private void emitNamespacesHelper() {
+            for (iterateMappings(); hasMapping(); nextMapping()) {
+                emit(' ');
+                emitXmlns(mappingPrefix(), mappingUri());
             }
         }
 
-        private void emitAttrHelper ( QName attrName, String attrValue )
-        {
-            emit( ' ' );
-            emitName( attrName, true );
-            emit( '=', '\"' );
+        private void emitAttrHelper(QName attrName, String attrValue) {
+            emit(' ');
+            emitName(attrName, true);
+            emit('=', '\"');
             emitAttrValue(attrValue);
 
-            emit( '"' );
+            emit('"');
         }
 
-        protected void emitComment ( SaveCur c )
-        {
+        protected void emitComment(SaveCur c) {
             assert c.isComment();
 
-            emit( "<!--" );
+            emit("<!--");
 
             c.push();
             c.next();
 
-            emitCommentText( c );
+            emitCommentText(c);
 
             c.pop();
 
-            emit( "-->" );
+            emit("-->");
         }
 
-        protected void emitProcinst ( SaveCur c )
-        {
+        protected void emitProcinst(SaveCur c) {
             assert c.isProcinst();
 
-            emit( "<?" );
+            emit("<?");
 
             // TODO - encoding issues here?
-            emit( c.getName().getLocalPart() );
+            emit(c.getName().getLocalPart());
 
             c.push();
 
             c.next();
 
-            if (c.isText())
-            {
-                emit( ' ' );
-                emitPiText( c );
+            if (c.isText()) {
+                emit(' ');
+                emitPiText(c);
             }
 
             c.pop();
 
-            emit( "?>" );
+            emit("?>");
         }
 
-        protected void emitDocType ( String docTypeName, String publicId, String systemId )
-        {
+        protected void emitDocType(String docTypeName, String publicId, String systemId) {
             assert docTypeName != null;
 
-            emit( "<!DOCTYPE " );
-            emit( docTypeName );
+            emit("<!DOCTYPE ");
+            emit(docTypeName);
 
-            if (publicId == null && systemId != null)
-            {
-                emit( " SYSTEM " );
-                emitLiteral( systemId );
-            }
-            else if (publicId != null)
-            {
-                emit( " PUBLIC " );
-                emitLiteral( publicId );
+            if (publicId == null && systemId != null) {
+                emit(" SYSTEM ");
+                emitLiteral(systemId);
+            } else if (publicId != null) {
+                emit(" PUBLIC ");
+                emitLiteral(publicId);
                 emit(' ');
-                emitLiteral( systemId );
+                emitLiteral(systemId);
             }
 
-            emit( '>' );
-            emit( _newLine );
+            emit('>');
+            emit(_newLine);
         }
 
-        protected void emitStartDoc ( SaveCur c )
-        {
+        protected void emitStartDoc(SaveCur c) {
         }
 
-        protected void emitEndDoc ( SaveCur c )
-        {
+        protected void emitEndDoc(SaveCur c) {
         }
 
         //
         //
         //
 
-        private void emitName ( QName name, boolean needsPrefix )
-        {
+        private void emitName(QName name, boolean needsPrefix) {
             assert name != null;
 
             String uri = name.getNamespaceURI();
 
             assert uri != null;
 
-            if (uri.length() != 0)
-            {
+            if (uri.length() != 0) {
                 String prefix = name.getPrefix();
-                String mappedUri = getNamespaceForPrefix( prefix );
+                String mappedUri = getNamespaceForPrefix(prefix);
 
-                if (mappedUri == null || !mappedUri.equals( uri ))
-                    prefix = getUriMapping( uri );
+                if (mappedUri == null || !mappedUri.equals(uri))
+                    prefix = getUriMapping(uri);
 
                 // Attrs need a prefix.  If I have not found one, then there must be a default
                 // prefix obscuring the prefix needed for this attr.  Find it manually.
@@ -2158,59 +1961,51 @@
                 // here
 
                 if (needsPrefix && prefix.length() == 0)
-                    prefix = getNonDefaultUriMapping( uri );
+                    prefix = getNonDefaultUriMapping(uri);
 
-                if (prefix.length() > 0)
-                {
-                    emit( prefix );
-                    emit( ':' );
+                if (prefix.length() > 0) {
+                    emit(prefix);
+                    emit(':');
                 }
             }
 
             assert name.getLocalPart().length() > 0;
 
-            emit( name.getLocalPart() );
+            emit(name.getLocalPart());
         }
 
-        private void emitAttrValue ( CharSequence attVal)
-        {
+        private void emitAttrValue(CharSequence attVal) {
             int len = attVal.length();
 
-            for ( int i = 0; i<len ; i++ )
-            {
+            for (int i = 0; i < len; i++) {
                 char ch = attVal.charAt(i);
 
                 if (ch == '<')
-                    emit( "&lt;" );
+                    emit("&lt;");
                 else if (ch == '&')
-                    emit( "&amp;" );
+                    emit("&amp;");
                 else if (ch == '"')
-                    emit( "&quot;" );
+                    emit("&quot;");
                 else
                     emit(ch);
             }
         }
 
-        private void emitLiteral ( String literal )
-        {
+        private void emitLiteral(String literal) {
             // TODO: systemId production http://www.w3.org/TR/REC-xml/#NT-SystemLiteral
             // TODO: publicId production http://www.w3.org/TR/REC-xml/#NT-PubidLiteral
-            if (literal.indexOf( "\"" ) < 0)
-            {
-                emit( '\"' );
-                emit( literal );
-                emit( '\"' );
-            }
-            else
-            {
-                emit( '\'' );
-                emit( literal );
-                emit( '\'' );
+            if (literal.indexOf("\"") < 0) {
+                emit('\"');
+                emit(literal);
+                emit('\"');
+            } else {
+                emit('\'');
+                emit(literal);
+                emit('\'');
             }
         }
 
-        protected void emitText ( SaveCur c )
-        {
+        protected void emitText(SaveCur c) {
             assert c.isText();
 
             Object src = c.getChars();
@@ -2218,17 +2013,15 @@
             int off = c._offSrc;
             int index = 0;
             int indexLimit = 0;
-            while( index<cch )
-            {
+            while (index < cch) {
                 indexLimit = index + 512 > cch ? cch : index + 512;
-                CharUtil.getChars( _buf, 0, src, off+index, indexLimit-index );
-                entitizeAndWriteText(indexLimit-index);
+                CharUtil.getChars(_buf, 0, src, off + index, indexLimit - index);
+                entitizeAndWriteText(indexLimit - index);
                 index = indexLimit;
             }
         }
 
-        protected void emitPiText ( SaveCur c )
-        {
+        protected void emitPiText(SaveCur c) {
             assert c.isText();
 
             Object src = c.getChars();
@@ -2236,17 +2029,15 @@
             int off = c._offSrc;
             int index = 0;
             int indexLimit = 0;
-            while( index<cch )
-            {
+            while (index < cch) {
                 indexLimit = index + 512 > cch ? cch : 512;
-                CharUtil.getChars( _buf, 0, src, off+index, indexLimit );
-                entitizeAndWritePIText(indexLimit-index);
+                CharUtil.getChars(_buf, 0, src, off + index, indexLimit);
+                entitizeAndWritePIText(indexLimit - index);
                 index = indexLimit;
             }
         }
 
-        protected void emitCommentText ( SaveCur c )
-        {
+        protected void emitCommentText(SaveCur c) {
             assert c.isText();
 
             Object src = c.getChars();
@@ -2254,63 +2045,51 @@
             int off = c._offSrc;
             int index = 0;
             int indexLimit = 0;
-            while( index<cch )
-            {
+            while (index < cch) {
                 indexLimit = index + 512 > cch ? cch : 512;
-                CharUtil.getChars( _buf, 0, src, off+index, indexLimit );
-                entitizeAndWriteCommentText(indexLimit-index);
+                CharUtil.getChars(_buf, 0, src, off + index, indexLimit);
+                entitizeAndWriteCommentText(indexLimit - index);
                 index = indexLimit;
             }
         }
 
-        private void entitizeAndWriteText(int bufLimit)
-        {
+        private void entitizeAndWriteText(int bufLimit) {
             int index = 0;
-            for (int i = 0; i < bufLimit; i++)
-            {
+            for (int i = 0; i < bufLimit; i++) {
                 char c = _buf[i];
-                switch(c)
-                {
-                case '<':
-                    emit(_buf, index, i-index);
-                    emit("&lt;");
-                    index = i+1;
-                    break;
-                case '&':
-                    emit(_buf, index, i-index);
-                    emit("&amp;");
-                    index = i+1;
-                    break;
+                switch (c) {
+                    case '<':
+                        emit(_buf, index, i - index);
+                        emit("&lt;");
+                        index = i + 1;
+                        break;
+                    case '&':
+                        emit(_buf, index, i - index);
+                        emit("&amp;");
+                        index = i + 1;
+                        break;
                 }
             }
-            emit(_buf, index, bufLimit-index);
+            emit(_buf, index, bufLimit - index);
         }
 
-        private void entitizeAndWriteCommentText ( int bufLimit )
-        {
+        private void entitizeAndWriteCommentText(int bufLimit) {
             boolean lastWasDash = false;
 
-            for ( int i=0 ; i<bufLimit ; i++ )
-            {
-                char ch = _buf[ i ];
+            for (int i = 0; i < bufLimit; i++) {
+                char ch = _buf[i];
 
-                if (isBadChar( ch ))
+                if (isBadChar(ch))
                     _buf[i] = '?';
-                else if (ch == '-')
-                {
-                    if (lastWasDash)
-                    {
+                else if (ch == '-') {
+                    if (lastWasDash) {
                         // Replace "--" with "- " to make well formed
                         _buf[i] = ' ';
                         lastWasDash = false;
-                    }
-                    else
-                    {
+                    } else {
                         lastWasDash = true;
                     }
-                }
-                else
-                {
+                } else {
                     lastWasDash = false;
                 }
 
@@ -2318,36 +2097,30 @@
                     i = 0;
             }
 
-            if (_buf[ bufLimit-1 ] == '-')
-                _buf[ bufLimit-1 ] = ' ';
+            if (_buf[bufLimit - 1] == '-')
+                _buf[bufLimit - 1] = ' ';
 
             emit(_buf, 0, bufLimit);
         }
 
-        private void entitizeAndWritePIText(int bufLimit)
-        {
+        private void entitizeAndWritePIText(int bufLimit) {
             boolean lastWasQuestion = false;
 
-            for ( int i=0 ; i<bufLimit ; i++ )
-            {
-                char ch = _buf[ i ];
+            for (int i = 0; i < bufLimit; i++) {
+                char ch = _buf[i];
 
-                if (isBadChar( ch ))
-                {
+                if (isBadChar(ch)) {
                     _buf[i] = '?';
                     ch = '?';
                 }
 
-                if (ch == '>')
-                {
+                if (ch == '>') {
                     // Had to convert to a space here ... imples not well formed XML
                     if (lastWasQuestion)
                         _buf[i] = ' ';
 
                     lastWasQuestion = false;
-                }
-                else
-                {
+                } else {
                     lastWasQuestion = ch == '?';
                 }
             }
@@ -2355,144 +2128,196 @@
         }
     }
 
-    static final class TextReader extends Reader
-    {
-        TextReader ( Cur c, XmlOptions options )
-        {
-            _textSaver = new TextSaver( c, options, null );
+    static final class TextReader extends Reader {
+        TextReader(Cur c, XmlOptions options) {
+            _textSaver = new TextSaver(c, options, null);
             _locale = c._locale;
             _closed = false;
         }
 
-        public void close ( ) throws IOException { _closed = true; }
-
-        public boolean ready ( ) throws IOException { return !_closed; }
-
-        public int read ( ) throws IOException
-        {
-            checkClosed();
-
-            if (_locale.noSync())         { _locale.enter(); try { return _textSaver.read(); } finally { _locale.exit(); } }
-            else synchronized ( _locale ) { _locale.enter(); try { return _textSaver.read(); } finally { _locale.exit(); } }
+        public void close() throws IOException {
+            _closed = true;
         }
 
-        public int read ( char[] cbuf ) throws IOException
-        {
-            checkClosed();
-
-            if (_locale.noSync())         { _locale.enter(); try { return _textSaver.read( cbuf, 0, cbuf == null ? 0 : cbuf.length ); } finally { _locale.exit(); } }
-            else synchronized ( _locale ) { _locale.enter(); try { return _textSaver.read( cbuf, 0, cbuf == null ? 0 : cbuf.length ); } finally { _locale.exit(); } }
+        public boolean ready() throws IOException {
+            return !_closed;
         }
 
-        public int read ( char[] cbuf, int off, int len ) throws IOException
-        {
+        public int read() throws IOException {
             checkClosed();
 
-            if (_locale.noSync())         { _locale.enter(); try { return _textSaver.read( cbuf, off, len ); } finally { _locale.exit(); } }
-            else synchronized ( _locale ) { _locale.enter(); try { return _textSaver.read( cbuf, off, len ); } finally { _locale.exit(); } }
+            if (_locale.noSync()) {
+                _locale.enter();
+                try {
+                    return _textSaver.read();
+                } finally {
+                    _locale.exit();
+                }
+            } else synchronized (_locale) {
+                _locale.enter();
+                try {
+                    return _textSaver.read();
+                } finally {
+                    _locale.exit();
+                }
+            }
         }
 
-        private void checkClosed ( ) throws IOException
-        {
+        public int read(char[] cbuf) throws IOException {
+            checkClosed();
+
+            if (_locale.noSync()) {
+                _locale.enter();
+                try {
+                    return _textSaver.read(cbuf, 0, cbuf == null ? 0 : cbuf.length);
+                } finally {
+                    _locale.exit();
+                }
+            } else synchronized (_locale) {
+                _locale.enter();
+                try {
+                    return _textSaver.read(cbuf, 0, cbuf == null ? 0 : cbuf.length);
+                } finally {
+                    _locale.exit();
+                }
+            }
+        }
+
+        public int read(char[] cbuf, int off, int len) throws IOException {
+            checkClosed();
+
+            if (_locale.noSync()) {
+                _locale.enter();
+                try {
+                    return _textSaver.read(cbuf, off, len);
+                } finally {
+                    _locale.exit();
+                }
+            } else synchronized (_locale) {
+                _locale.enter();
+                try {
+                    return _textSaver.read(cbuf, off, len);
+                } finally {
+                    _locale.exit();
+                }
+            }
+        }
+
+        private void checkClosed() throws IOException {
             if (_closed)
-                throw new IOException( "Reader has been closed" );
+                throw new IOException("Reader has been closed");
         }
 
-        private Locale    _locale;
+        private Locale _locale;
         private TextSaver _textSaver;
-        private boolean   _closed;
+        private boolean _closed;
     }
 
-    static final class InputStreamSaver extends InputStream
-    {
-        InputStreamSaver ( Cur c, XmlOptions options )
-        {
+    static final class InputStreamSaver extends InputStream {
+        InputStreamSaver(Cur c, XmlOptions options) {
             _locale = c._locale;
 
             _closed = false;
 
             assert _locale.entered();
 
-            options = XmlOptions.maskNull( options );
+            options = XmlOptions.maskNull(options);
 
             _outStreamImpl = new OutputStreamImpl();
 
             String encoding = null;
 
-            XmlDocumentProperties props = Locale.getDocProps( c, false );
+            XmlDocumentProperties props = Locale.getDocProps(c, false);
 
             if (props != null && props.getEncoding() != null)
-                encoding = EncodingMap.getIANA2JavaMapping( props.getEncoding() );
+                encoding = EncodingMap.getIANA2JavaMapping(props.getEncoding());
 
-            if (options.hasOption( XmlOptions.CHARACTER_ENCODING ))
-                encoding = (String) options.get( XmlOptions.CHARACTER_ENCODING );
+            if (options.hasOption(XmlOptions.CHARACTER_ENCODING))
+                encoding = (String) options.get(XmlOptions.CHARACTER_ENCODING);
 
-            if (encoding != null)
-            {
-                String ianaEncoding = EncodingMap.getJava2IANAMapping( encoding );
+            if (encoding != null) {
+                String ianaEncoding = EncodingMap.getJava2IANAMapping(encoding);
 
                 if (ianaEncoding != null)
                     encoding = ianaEncoding;
             }
 
             if (encoding == null)
-                encoding = EncodingMap.getJava2IANAMapping( "UTF8" );
+                encoding = EncodingMap.getJava2IANAMapping("UTF8");
 
-            String javaEncoding = EncodingMap.getIANA2JavaMapping( encoding );
+            String javaEncoding = EncodingMap.getIANA2JavaMapping(encoding);
 
             if (javaEncoding == null)
-                throw new IllegalStateException( "Unknown encoding: " + encoding );
+                throw new IllegalStateException("Unknown encoding: " + encoding);
 
-            try
-            {
-                _converter = new OutputStreamWriter( _outStreamImpl, javaEncoding );
-            }
-            catch ( UnsupportedEncodingException e )
-            {
-                throw new RuntimeException( e );
+            try {
+                _converter = new OutputStreamWriter(_outStreamImpl, javaEncoding);
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeException(e);
             }
 
-            _textSaver = new TextSaver( c, options, encoding );
+            _textSaver = new TextSaver(c, options, encoding);
         }
 
-        public void close ( ) throws IOException
-        {
+        public void close() throws IOException {
             _closed = true;
         }
 
-        private void checkClosed ( ) throws IOException
-        {
+        private void checkClosed() throws IOException {
             if (_closed)
-                throw new IOException( "Stream closed" );
+                throw new IOException("Stream closed");
         }
 
         // Having the gateway here is kinda slow for the single character case.  It may be possible
         // to only enter the gate when there are no chars in the buffer.
 
-        public int read ( ) throws IOException
-        {
+        public int read() throws IOException {
             checkClosed();
 
-            if (_locale.noSync())         { _locale.enter(); try { return _outStreamImpl.read(); } finally { _locale.exit(); } }
-            else synchronized ( _locale ) { _locale.enter(); try { return _outStreamImpl.read(); } finally { _locale.exit(); } }
+            if (_locale.noSync()) {
+                _locale.enter();
+                try {
+                    return _outStreamImpl.read();
+                } finally {
+                    _locale.exit();
+                }
+            } else synchronized (_locale) {
+                _locale.enter();
+                try {
+                    return _outStreamImpl.read();
+                } finally {
+                    _locale.exit();
+                }
+            }
         }
 
-        public int read ( byte[] bbuf, int off, int len ) throws IOException
-        {
+        public int read(byte[] bbuf, int off, int len) throws IOException {
             checkClosed();
 
             if (bbuf == null)
-                throw new NullPointerException( "buf to read into is null" );
+                throw new NullPointerException("buf to read into is null");
 
             if (off < 0 || off > bbuf.length)
-                throw new IndexOutOfBoundsException( "Offset is not within buf" );
+                throw new IndexOutOfBoundsException("Offset is not within buf");
 
-            if (_locale.noSync())         { _locale.enter(); try { return _outStreamImpl.read( bbuf, off, len ); } finally { _locale.exit(); } }
-            else synchronized ( _locale ) { _locale.enter(); try { return _outStreamImpl.read( bbuf, off, len ); } finally { _locale.exit(); } }
+            if (_locale.noSync()) {
+                _locale.enter();
+                try {
+                    return _outStreamImpl.read(bbuf, off, len);
+                } finally {
+                    _locale.exit();
+                }
+            } else synchronized (_locale) {
+                _locale.enter();
+                try {
+                    return _outStreamImpl.read(bbuf, off, len);
+                } finally {
+                    _locale.exit();
+                }
+            }
         }
 
-        private int ensure ( int cbyte )
-        {
+        private int ensure(int cbyte) {
             // Even if we're asked to ensure nothing, still try to ensure
             // atleast one byte so we can determine if we're at the
             // end of the stream.
@@ -2502,10 +2327,9 @@
 
             int bytesAvailable = _outStreamImpl.getAvailable();
 
-            for ( ; bytesAvailable < cbyte ;
-                  bytesAvailable = _outStreamImpl.getAvailable() )
-            {
-                if (_textSaver.write( _converter, 2048 ) < 2048)
+            for (; bytesAvailable < cbyte;
+                 bytesAvailable = _outStreamImpl.getAvailable()) {
+                if (_textSaver.write(_converter, 2048) < 2048)
                     break;
             }
 
@@ -2518,27 +2342,33 @@
         }
 
         public int available()
-            throws IOException
-        {
-            if (_locale.noSync())
-                { _locale.enter(); try {
+                throws IOException {
+            if (_locale.noSync()) {
+                _locale.enter();
+                try {
                     return ensure(1024);
-                } finally { _locale.exit(); } }
-            else
-                synchronized ( _locale )
-                { _locale.enter(); try { return ensure(1024); } finally { _locale.exit(); } }
+                } finally {
+                    _locale.exit();
+                }
+            } else
+                synchronized (_locale) {
+                    _locale.enter();
+                    try {
+                        return ensure(1024);
+                    } finally {
+                        _locale.exit();
+                    }
+                }
         }
 
-        private final class OutputStreamImpl extends OutputStream
-        {
-            int read ( )
-            {
-                if (InputStreamSaver.this.ensure( 1 ) == 0)
+        private final class OutputStreamImpl extends OutputStream {
+            int read() {
+                if (InputStreamSaver.this.ensure(1) == 0)
                     return -1;
 
                 assert getAvailable() > 0;
 
-                int bite = _buf[ _out ];
+                int bite = _buf[_out];
 
                 _out = (_out + 1) % _buf.length;
                 _free++;
@@ -2546,15 +2376,14 @@
                 return bite;
             }
 
-            int read ( byte[] bbuf, int off, int len )
-            {
+            int read(byte[] bbuf, int off, int len) {
                 // Check for end of stream even if there is no way to return
                 // characters because the Reader doc says to return -1 at end of
                 // stream.
 
                 int n;
 
-                if ((n = ensure( len )) == 0)
+                if ((n = ensure(len)) == 0)
                     return -1;
 
                 if (bbuf == null || len <= 0)
@@ -2563,22 +2392,18 @@
                 if (n < len)
                     len = n;
 
-                if (_out < _in)
-                {
-                    System.arraycopy( _buf, _out, bbuf, off, len );
-                }
-                else
-                {
+                if (_out < _in) {
+                    System.arraycopy(_buf, _out, bbuf, off, len);
+                } else {
                     int chunk = _buf.length - _out;
 
                     if (chunk >= len)
-                        System.arraycopy( _buf, _out, bbuf, off, len );
-                    else
-                    {
-                        System.arraycopy( _buf, _out, bbuf, off, chunk );
+                        System.arraycopy(_buf, _out, bbuf, off, len);
+                    else {
+                        System.arraycopy(_buf, _out, bbuf, off, chunk);
 
                         System.arraycopy(
-                            _buf, 0, bbuf, off + chunk, len - chunk );
+                                _buf, 0, bbuf, off + chunk, len - chunk);
                     }
                 }
                 _out = (_out + len) % _buf.length;
@@ -2588,36 +2413,32 @@
                 return len;
             }
 
-            int getAvailable ( )
-            {
+            int getAvailable() {
                 return _buf == null ? 0 : _buf.length - _free;
             }
 
-            public void write ( int bite )
-            {
+            public void write(int bite) {
                 if (_free == 0)
-                    resize( 1 );
+                    resize(1);
 
                 assert _free > 0;
 
-                _buf[ _in ] = (byte) bite;
+                _buf[_in] = (byte) bite;
 
                 _in = (_in + 1) % _buf.length;
                 _free--;
             }
 
-            public void write ( byte[] buf, int off, int cbyte )
-            {
+            public void write(byte[] buf, int off, int cbyte) {
                 assert cbyte >= 0;
 //System.out.println("---------\nAfter converter, write in queue: OutputStreamImpl.write():Saver:2469  " + cbyte + " bytes \n" + new String(buf, off, cbyte));
                 if (cbyte == 0)
                     return;
 
                 if (_free < cbyte)
-                    resize( cbyte );
+                    resize(cbyte);
 
-                if (_in == _out)
-                {
+                if (_in == _out) {
                     assert getAvailable() == 0;
                     assert _free == _buf.length - getAvailable();
                     _in = _out = 0;
@@ -2625,17 +2446,14 @@
 
                 int chunk = _buf.length - _in;
 
-                if (_in <= _out || cbyte < chunk)
-                {
-                    System.arraycopy( buf, off, _buf, _in, cbyte );
+                if (_in <= _out || cbyte < chunk) {
+                    System.arraycopy(buf, off, _buf, _in, cbyte);
                     _in += cbyte;
-                }
-                else
-                {
-                    System.arraycopy( buf, off, _buf, _in, chunk );
+                } else {
+                    System.arraycopy(buf, off, _buf, _in, chunk);
 
                     System.arraycopy(
-                        buf, off + chunk, _buf, 0, cbyte - chunk );
+                            buf, off + chunk, _buf, 0, cbyte - chunk);
 
                     _in = (_in + cbyte) % _buf.length;
                 }
@@ -2643,37 +2461,32 @@
                 _free -= cbyte;
             }
 
-            void resize ( int cbyte )
-            {
+            void resize(int cbyte) {
                 assert cbyte > _free : cbyte + " !> " + _free;
 
                 int newLen = _buf == null ? _initialBufSize : _buf.length * 2;
                 int used = getAvailable();
 
-                while ( newLen - used < cbyte )
+                while (newLen - used < cbyte)
                     newLen *= 2;
 
-                byte[] newBuf = new byte [ newLen ];
+                byte[] newBuf = new byte[newLen];
 
-                if (used > 0)
-                {
+                if (used > 0) {
                     if (_in > _out)
-                        System.arraycopy( _buf, _out, newBuf, 0, used );
-                    else
-                    {
+                        System.arraycopy(_buf, _out, newBuf, 0, used);
+                    else {
                         System.arraycopy(
-                            _buf, _out, newBuf, 0, used - _in );
+                                _buf, _out, newBuf, 0, used - _in);
 
                         System.arraycopy(
-                            _buf, 0, newBuf, used - _in, _in );
+                                _buf, 0, newBuf, used - _in, _in);
                     }
 
                     _out = 0;
                     _in = used;
                     _free += newBuf.length - _buf.length;
-                }
-                else
-                {
+                } else {
                     _free = newBuf.length;
                     assert _in == _out;
                 }
@@ -2683,44 +2496,39 @@
 
             private static final int _initialBufSize = 4096;
 
-            private int    _free;
-            private int    _in;
-            private int    _out;
+            private int _free;
+            private int _in;
+            private int _out;
             private byte[] _buf;
         }
 
-        private Locale             _locale;
-        private boolean            _closed;
-        private OutputStreamImpl   _outStreamImpl;
-        private TextSaver          _textSaver;
+        private Locale _locale;
+        private boolean _closed;
+        private OutputStreamImpl _outStreamImpl;
+        private TextSaver _textSaver;
         private OutputStreamWriter _converter;
     }
 
-    static final class XmlInputStreamSaver extends Saver
-    {
-        XmlInputStreamSaver ( Cur c, XmlOptions options )
-        {
-            super( c, options );
+    static final class XmlInputStreamSaver extends Saver {
+        XmlInputStreamSaver(Cur c, XmlOptions options) {
+            super(c, options);
         }
 
-        protected boolean emitElement(SaveCur c, ArrayList attrNames, ArrayList attrValues)
-        {
+        protected boolean emitElement(SaveCur c, ArrayList attrNames, ArrayList attrValues) {
             assert c.isElem();
 
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-            {
-                enqueue( new StartPrefixMappingImpl( mappingPrefix(), mappingUri() ) );
+            for (iterateMappings(); hasMapping(); nextMapping()) {
+                enqueue(new StartPrefixMappingImpl(mappingPrefix(), mappingUri()));
             }
 
             StartElementImpl.AttributeImpl lastAttr = null;
             StartElementImpl.AttributeImpl attributes = null;
             StartElementImpl.AttributeImpl namespaces = null;
 
-            for ( int i=0; i<attrNames.size(); i++ )
-            {
-                XMLName attXMLName = computeName((QName)attrNames.get(i), this, true);
+            for (int i = 0; i < attrNames.size(); i++) {
+                XMLName attXMLName = computeName((QName) attrNames.get(i), this, true);
                 StartElementImpl.AttributeImpl attr =
-                    new StartElementImpl.NormalAttributeImpl(attXMLName, (String)attrValues.get(i) );
+                        new StartElementImpl.NormalAttributeImpl(attXMLName, (String) attrValues.get(i));
 
                 if (attributes == null)
                     attributes = attr;
@@ -2732,13 +2540,12 @@
 
             lastAttr = null;
 
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-            {
+            for (iterateMappings(); hasMapping(); nextMapping()) {
                 String prefix = mappingPrefix();
                 String uri = mappingUri();
 
                 StartElementImpl.AttributeImpl attr =
-                    new StartElementImpl.XmlnsAttributeImpl(prefix, uri);
+                        new StartElementImpl.XmlnsAttributeImpl(prefix, uri);
 
                 if (namespaces == null)
                     namespaces = attr;
@@ -2750,77 +2557,64 @@
 
 
             QName name = c.getName();
-            enqueue( new StartElementImpl( computeName(name, this, false), attributes, namespaces, getPrefixMap() ) );
+            enqueue(new StartElementImpl(computeName(name, this, false), attributes, namespaces, getPrefixMap()));
 
             return false;  // still need to be called on end element
         }
 
-        protected void emitFinish(SaveCur c)
-        {
+        protected void emitFinish(SaveCur c) {
             if (c.isRoot())
-                enqueue( new EndDocumentImpl(  ) );
-            else
-            {
+                enqueue(new EndDocumentImpl());
+            else {
                 XMLName xmlName = computeName(c.getName(), this, false);
-                enqueue( new EndElementImpl( xmlName ) );
+                enqueue(new EndElementImpl(xmlName));
             }
 
             emitEndPrefixMappings();
         }
 
-        protected void emitText(SaveCur c)
-        {
+        protected void emitText(SaveCur c) {
             assert c.isText();
             Object src = c.getChars();
             int cch = c._cchSrc;
             int off = c._offSrc;
 
-            enqueue( new CharacterDataImpl( src, cch, off ) );
+            enqueue(new CharacterDataImpl(src, cch, off));
         }
 
-        protected void emitComment(SaveCur c)
-        {
-            enqueue( new CommentImpl( c.getChars(), c._cchSrc, c._offSrc ) );
+        protected void emitComment(SaveCur c) {
+            enqueue(new CommentImpl(c.getChars(), c._cchSrc, c._offSrc));
         }
 
-        protected void emitProcinst(SaveCur c)
-        {
+        protected void emitProcinst(SaveCur c) {
             String target = null;
             QName name = c.getName();
 
-            if (name!=null)
+            if (name != null)
                 target = name.getLocalPart();
 
-            enqueue( new ProcessingInstructionImpl( target, c.getChars(), c._cchSrc, c._offSrc ) );
+            enqueue(new ProcessingInstructionImpl(target, c.getChars(), c._cchSrc, c._offSrc));
         }
 
-        protected void emitDocType( String doctypeName, String publicID, String systemID )
-        {
-            enqueue( new StartDocumentImpl( systemID, null, true, null ) ); //todo
+        protected void emitDocType(String doctypeName, String publicID, String systemID) {
+            enqueue(new StartDocumentImpl(systemID, null, true, null)); //todo
         }
 
-        protected void emitStartDoc ( SaveCur c )
-        {
+        protected void emitStartDoc(SaveCur c) {
             emitDocType(null, null, null);
         }
 
-        protected void emitEndDoc ( SaveCur c )
-        {
-            enqueue( new EndDocumentImpl());
+        protected void emitEndDoc(SaveCur c) {
+            enqueue(new EndDocumentImpl());
         }
 
-        XMLEvent dequeue ( )
-        {
-            if (_out == null)
-            {
+        XMLEvent dequeue() {
+            if (_out == null) {
                 enterLocale();
-                try
-                {
-                    if(!process())
+                try {
+                    if (!process())
                         return null;
-                }
-                finally
-                {
+                } finally {
                     exitLocale();
                 }
             }
@@ -2836,17 +2630,13 @@
             return e;
         }
 
-        private void enqueue ( XmlEventImpl e )
-        {
+        private void enqueue(XmlEventImpl e) {
             assert e._next == null;
 
-            if (_in == null)
-            {
+            if (_in == null) {
                 assert _out == null;
                 _out = _in = e;
-            }
-            else
-            {
+            } else {
                 _in._next = e;
                 _in = e;
             }
@@ -2856,19 +2646,16 @@
         //
         //
 
-        protected void emitEndPrefixMappings ( )
-        {
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-            {
+        protected void emitEndPrefixMappings() {
+            for (iterateMappings(); hasMapping(); nextMapping()) {
                 String prevPrefixUri = null; // todo mappingPrevPrefixUri();
                 String prefix = mappingPrefix();
                 String uri = mappingUri();
 
                 if (prevPrefixUri == null)
-                    enqueue( new EndPrefixMappingImpl( prefix ) );
-                else
-                {
-                    enqueue( new ChangePrefixMappingImpl( prefix, uri, prevPrefixUri ) );
+                    enqueue(new EndPrefixMappingImpl(prefix));
+                else {
+                    enqueue(new ChangePrefixMappingImpl(prefix, uri, prevPrefixUri));
                 }
             }
         }
@@ -2877,8 +2664,7 @@
         //
         //
 
-        private static XMLName computeName ( QName name, Saver saver, boolean needsPrefix )
-        {
+        private static XMLName computeName(QName name, Saver saver, boolean needsPrefix) {
             String uri = name.getNamespaceURI();
             String local = name.getLocalPart();
 
@@ -2887,13 +2673,12 @@
 
             String prefix = null;
 
-            if (uri!=null && uri.length() != 0)
-            {
+            if (uri != null && uri.length() != 0) {
                 prefix = name.getPrefix();
-                String mappedUri = saver.getNamespaceForPrefix( prefix );
+                String mappedUri = saver.getNamespaceForPrefix(prefix);
 
-                if (mappedUri == null || !mappedUri.equals( uri ))
-                    prefix = saver.getUriMapping( uri );
+                if (mappedUri == null || !mappedUri.equals(uri))
+                    prefix = saver.getUriMapping(uri);
 
                 // Attrs need a prefix.  If I have not found one, then there must be a default
                 // prefix obscuring the prefix needed for this attr.  Find it manually.
@@ -2903,37 +2688,31 @@
                 // here
 
                 if (needsPrefix && prefix.length() == 0)
-                    prefix = saver.getNonDefaultUriMapping( uri );
+                    prefix = saver.getNonDefaultUriMapping(uri);
 
             }
 
-            return new XmlNameImpl( uri, local, prefix );
+            return new XmlNameImpl(uri, local, prefix);
         }
 
-        private static abstract class XmlEventImpl extends XmlEventBase
-        {
-            XmlEventImpl ( int type )
-            {
-                super( type );
+        private static abstract class XmlEventImpl extends XmlEventBase {
+            XmlEventImpl(int type) {
+                super(type);
             }
 
-            public XMLName getName ( )
-            {
+            public XMLName getName() {
                 return null;
             }
 
-            public XMLName getSchemaType ( )
-            {
-                throw new RuntimeException( "NYI" );
+            public XMLName getSchemaType() {
+                throw new RuntimeException("NYI");
             }
 
-            public boolean hasName ( )
-            {
+            public boolean hasName() {
                 return false;
             }
 
-            public final Location getLocation ( )
-            {
+            public final Location getLocation() {
                 // (orig v1 comment)TODO - perhaps I can save a location goober sometimes?
                 return null;
             }
@@ -2942,34 +2721,28 @@
         }
 
         private static class StartDocumentImpl
-            extends XmlEventImpl implements StartDocument
-        {
-            StartDocumentImpl ( String systemID, String encoding, boolean isStandAlone, String version )
-            {
-                super( XMLEvent.START_DOCUMENT );
+                extends XmlEventImpl implements StartDocument {
+            StartDocumentImpl(String systemID, String encoding, boolean isStandAlone, String version) {
+                super(XMLEvent.START_DOCUMENT);
                 _systemID = systemID;
                 _encoding = encoding;
                 _standAlone = isStandAlone;
                 _version = version;
             }
 
-            public String getSystemId ( )
-            {
+            public String getSystemId() {
                 return _systemID;
             }
 
-            public String getCharacterEncodingScheme ( )
-            {
+            public String getCharacterEncodingScheme() {
                 return _encoding;
             }
 
-            public boolean isStandalone ( )
-            {
+            public boolean isStandalone() {
                 return _standAlone;
             }
 
-            public String getVersion ( )
-            {
+            public String getVersion() {
                 return _version;
             }
 
@@ -2980,11 +2753,9 @@
         }
 
         private static class StartElementImpl
-            extends XmlEventImpl implements StartElement
-        {
-            StartElementImpl ( XMLName name, AttributeImpl attributes, AttributeImpl namespaces, Map prefixMap )
-            {
-                super( XMLEvent.START_ELEMENT );
+                extends XmlEventImpl implements StartElement {
+            StartElementImpl(XMLName name, AttributeImpl attributes, AttributeImpl namespaces, Map prefixMap) {
+                super(XMLEvent.START_ELEMENT);
 
                 _name = name;
                 _attributes = attributes;
@@ -2992,81 +2763,64 @@
                 _prefixMap = prefixMap;
             }
 
-            public boolean hasName()
-            {
+            public boolean hasName() {
                 return true;
             }
 
-            public XMLName getName ( )
-            {
+            public XMLName getName() {
                 return _name;
             }
 
-            public AttributeIterator getAttributes ( )
-            {
-                return new AttributeIteratorImpl( _attributes, null );
+            public AttributeIterator getAttributes() {
+                return new AttributeIteratorImpl(_attributes, null);
             }
 
-            public AttributeIterator getNamespaces ( )
-            {
-                return new AttributeIteratorImpl( null, _namespaces );
+            public AttributeIterator getNamespaces() {
+                return new AttributeIteratorImpl(null, _namespaces);
             }
 
-            public AttributeIterator getAttributesAndNamespaces ( )
-            {
-                return  new AttributeIteratorImpl( _attributes, _namespaces );
+            public AttributeIterator getAttributesAndNamespaces() {
+                return new AttributeIteratorImpl(_attributes, _namespaces);
             }
 
-            public Attribute getAttributeByName ( XMLName xmlName )
-            {
-                for ( AttributeImpl a = _attributes ; a != null ; a = a._next )
-                {
-                    if (xmlName.equals( a.getName() ))
+            public Attribute getAttributeByName(XMLName xmlName) {
+                for (AttributeImpl a = _attributes; a != null; a = a._next) {
+                    if (xmlName.equals(a.getName()))
                         return a;
                 }
 
                 return null;
             }
 
-            public String getNamespaceUri ( String prefix )
-            {
-                return (String) _prefixMap.get( prefix == null ? "" : prefix );
+            public String getNamespaceUri(String prefix) {
+                return (String) _prefixMap.get(prefix == null ? "" : prefix);
             }
 
-            public Map getNamespaceMap ( )
-            {
+            public Map getNamespaceMap() {
                 return _prefixMap;
             }
 
             private static class AttributeIteratorImpl
-                implements AttributeIterator
-            {
-                AttributeIteratorImpl( AttributeImpl attributes, AttributeImpl namespaces )
-                {
+                    implements AttributeIterator {
+                AttributeIteratorImpl(AttributeImpl attributes, AttributeImpl namespaces) {
                     _attributes = attributes;
                     _namespaces = namespaces;
                 }
 
-                public Object monitor()
-                {
+                public Object monitor() {
                     return this;
                 }
 
-                public Attribute next ( )
-                {
-                    synchronized (monitor())
-                    {
+                public Attribute next() {
+                    synchronized (monitor()) {
                         checkVersion();
 
                         AttributeImpl attr = null;
 
-                        if (_attributes != null)
-                        {
+                        if (_attributes != null) {
                             attr = _attributes;
                             _attributes = attr._next;
-                        }
-                        else if (_namespaces != null)
-                        {
+                        } else if (_namespaces != null) {
                             attr = _namespaces;
                             _namespaces = attr._next;
                         }
@@ -3075,20 +2829,16 @@
                     }
                 }
 
-                public boolean hasNext ( )
-                {
-                    synchronized (monitor())
-                    {
+                public boolean hasNext() {
+                    synchronized (monitor()) {
                         checkVersion();
 
                         return _attributes != null || _namespaces != null;
                     }
                 }
 
-                public Attribute peek ( )
-                {
-                    synchronized (monitor())
-                    {
+                public Attribute peek() {
+                    synchronized (monitor()) {
                         checkVersion();
 
                         if (_attributes != null)
@@ -3100,10 +2850,8 @@
                     }
                 }
 
-                public void skip ( )
-                {
-                    synchronized (monitor())
-                    {
+                public void skip() {
+                    synchronized (monitor()) {
                         checkVersion();
 
                         if (_attributes != null)
@@ -3113,40 +2861,34 @@
                     }
                 }
 
-                private final void checkVersion ( )
-                {
+                private final void checkVersion() {
 //                    if (_version != _root.getVersion())
 //                        throw new IllegalStateException( "Document changed" );
                 }
 
-//                private long          _version;
+                //                private long          _version;
                 private AttributeImpl _attributes;
                 private AttributeImpl _namespaces;
             }
 
-            private static abstract class AttributeImpl implements Attribute
-            {
+            private static abstract class AttributeImpl implements Attribute {
                 /**
                  * Don't forget to set _name
                  */
-                AttributeImpl ()
-                {
+                AttributeImpl() {
                 }
 
-                public XMLName getName ( )
-                {
+                public XMLName getName() {
                     return _name;
                 }
 
-                public String getType ( )
-                {
+                public String getType() {
                     // (from v1 impl) TODO - Make sure throwing away this DTD info is ok.
                     // (from v1 impl) Is there schema info which can return more useful info?
                     return "CDATA";
                 }
 
-                public XMLName getSchemaType ( )
-                {
+                public XMLName getSchemaType() {
                     // (from v1 impl) TODO - Can I return something reasonable here?
                     return null;
                 }
@@ -3156,47 +2898,38 @@
                 protected XMLName _name;
             }
 
-            private static class XmlnsAttributeImpl extends AttributeImpl
-            {
-                XmlnsAttributeImpl ( String prefix, String uri )
-                {
+            private static class XmlnsAttributeImpl extends AttributeImpl {
+                XmlnsAttributeImpl(String prefix, String uri) {
                     super();
                     _uri = uri;
 
                     String local;
 
-                    if (prefix.length() == 0)
-                    {
+                    if (prefix.length() == 0) {
                         prefix = null;
                         local = "xmlns";
-                    }
-                    else
-                    {
+                    } else {
                         local = prefix;
                         prefix = "xmlns";
                     }
 
-                    _name = new XmlNameImpl( null, local, prefix );
+                    _name = new XmlNameImpl(null, local, prefix);
                 }
 
-                public String getValue ( )
-                {
+                public String getValue() {
                     return _uri;
                 }
 
                 private String _uri;
             }
 
-            private static class NormalAttributeImpl extends AttributeImpl
-            {
-                NormalAttributeImpl (XMLName name, String value)
-                {
+            private static class NormalAttributeImpl extends AttributeImpl {
+                NormalAttributeImpl(XMLName name, String value) {
                     _name = name;
                     _value = value;
                 }
 
-                public String getValue ( )
-                {
+                public String getValue() {
                     return _value;
                 }
 
@@ -3204,30 +2937,26 @@
             }
 
             private XMLName _name;
-            private Map     _prefixMap;
+            private Map _prefixMap;
 
             private AttributeImpl _attributes;
             private AttributeImpl _namespaces;
         }
 
         private static class StartPrefixMappingImpl
-            extends XmlEventImpl implements StartPrefixMapping
-        {
-            StartPrefixMappingImpl ( String prefix, String uri )
-            {
-                super( XMLEvent.START_PREFIX_MAPPING );
+                extends XmlEventImpl implements StartPrefixMapping {
+            StartPrefixMappingImpl(String prefix, String uri) {
+                super(XMLEvent.START_PREFIX_MAPPING);
 
                 _prefix = prefix;
                 _uri = uri;
             }
 
-            public String getNamespaceUri ( )
-            {
+            public String getNamespaceUri() {
                 return _uri;
             }
 
-            public String getPrefix ( )
-            {
+            public String getPrefix() {
                 return _prefix;
             }
 
@@ -3235,29 +2964,24 @@
         }
 
         private static class ChangePrefixMappingImpl
-            extends XmlEventImpl implements ChangePrefixMapping
-        {
-            ChangePrefixMappingImpl ( String prefix, String oldUri, String newUri )
-            {
-                super( XMLEvent.CHANGE_PREFIX_MAPPING );
+                extends XmlEventImpl implements ChangePrefixMapping {
+            ChangePrefixMappingImpl(String prefix, String oldUri, String newUri) {
+                super(XMLEvent.CHANGE_PREFIX_MAPPING);
 
                 _oldUri = oldUri;
                 _newUri = newUri;
                 _prefix = prefix;
             }
 
-            public String getOldNamespaceUri ( )
-            {
+            public String getOldNamespaceUri() {
                 return _oldUri;
             }
 
-            public String getNewNamespaceUri ( )
-            {
+            public String getNewNamespaceUri() {
                 return _newUri;
             }
 
-            public String getPrefix ( )
-            {
+            public String getPrefix() {
                 return _prefix;
             }
 
@@ -3265,16 +2989,13 @@
         }
 
         private static class EndPrefixMappingImpl
-            extends XmlEventImpl implements EndPrefixMapping
-        {
-            EndPrefixMappingImpl ( String prefix )
-            {
-                super( XMLEvent.END_PREFIX_MAPPING );
+                extends XmlEventImpl implements EndPrefixMapping {
+            EndPrefixMappingImpl(String prefix) {
+                super(XMLEvent.END_PREFIX_MAPPING);
                 _prefix = prefix;
             }
 
-            public String getPrefix ( )
-            {
+            public String getPrefix() {
                 return _prefix;
             }
 
@@ -3282,22 +3003,18 @@
         }
 
         private static class EndElementImpl
-            extends XmlEventImpl implements EndElement
-        {
-            EndElementImpl ( XMLName name )
-            {
-                super( XMLEvent.END_ELEMENT );
+                extends XmlEventImpl implements EndElement {
+            EndElementImpl(XMLName name) {
+                super(XMLEvent.END_ELEMENT);
 
                 _name = name;
             }
 
-            public boolean hasName ( )
-            {
+            public boolean hasName() {
                 return true;
             }
 
-            public XMLName getName ( )
-            {
+            public XMLName getName() {
                 return _name;
             }
 
@@ -3305,74 +3022,60 @@
         }
 
         private static class EndDocumentImpl
-            extends XmlEventImpl implements EndDocument
-        {
-            EndDocumentImpl ( )
-            {
-                super( XMLEvent.END_DOCUMENT );
+                extends XmlEventImpl implements EndDocument {
+            EndDocumentImpl() {
+                super(XMLEvent.END_DOCUMENT);
             }
         }
 
         private static class TripletEventImpl
-            extends XmlEventImpl implements CharacterData
-        {
-            TripletEventImpl ( int eventType, Object obj, int cch, int off )
-            {
+                extends XmlEventImpl implements CharacterData {
+            TripletEventImpl(int eventType, Object obj, int cch, int off) {
                 super(eventType);
                 _obj = obj;
                 _cch = cch;
                 _off = off;
             }
 
-            public String getContent ( )
-            {
+            public String getContent() {
                 return CharUtil.getString(_obj, _off, _cch);
             }
 
-            public boolean hasContent ( )
-            {
+            public boolean hasContent() {
                 return _cch > 0;
             }
 
             private Object _obj;
-            private int    _cch;
-            private int    _off;
+            private int _cch;
+            private int _off;
         }
 
         private static class CharacterDataImpl
-            extends TripletEventImpl implements CharacterData
-        {
-            CharacterDataImpl ( Object obj, int cch, int off )
-            {
+                extends TripletEventImpl implements CharacterData {
+            CharacterDataImpl(Object obj, int cch, int off) {
                 super(XMLEvent.CHARACTER_DATA, obj, cch, off);
             }
         }
 
         private static class CommentImpl
-            extends TripletEventImpl implements Comment
-        {
-            CommentImpl ( Object obj, int cch, int off )
-            {
-                super( XMLEvent.COMMENT, obj, cch, off);
+                extends TripletEventImpl implements Comment {
+            CommentImpl(Object obj, int cch, int off) {
+                super(XMLEvent.COMMENT, obj, cch, off);
             }
         }
 
         private static class ProcessingInstructionImpl
-            extends TripletEventImpl implements ProcessingInstruction
-        {
-            ProcessingInstructionImpl ( String target, Object obj, int cch, int off)
-            {
-                super( XMLEvent.PROCESSING_INSTRUCTION, obj, cch, off);
+                extends TripletEventImpl implements ProcessingInstruction {
+            ProcessingInstructionImpl(String target, Object obj, int cch, int off) {
+                super(XMLEvent.PROCESSING_INSTRUCTION, obj, cch, off);
                 _target = target;
             }
 
-            public String getTarget ( )
-            {
+            public String getTarget() {
                 return _target;
             }
 
-            public String getData ( )
-            {
+            public String getData() {
                 return getContent();
             }
 
@@ -3382,12 +3085,10 @@
         private XmlEventImpl _in, _out;
     }
 
-    static final class XmlInputStreamImpl extends GenericXmlInputStream
-    {
-        XmlInputStreamImpl ( Cur cur, XmlOptions options )
-        {
+    static final class XmlInputStreamImpl extends GenericXmlInputStream {
+        XmlInputStreamImpl(Cur cur, XmlOptions options) {
             _xmlInputStreamSaver =
-                new XmlInputStreamSaver( cur, options );
+                    new XmlInputStreamSaver(cur, options);
 
             // Make the saver grind away just a bit to throw any exceptions
             // related to the inability to create a stream on this xml
@@ -3395,61 +3096,52 @@
             _xmlInputStreamSaver.process();
         }
 
-        protected XMLEvent nextEvent ( ) throws XMLStreamException
-        {
+        protected XMLEvent nextEvent() throws XMLStreamException {
             return _xmlInputStreamSaver.dequeue();
         }
 
         private XmlInputStreamSaver _xmlInputStreamSaver;
     }
 
-    static final class SaxSaver extends Saver
-    {
-        SaxSaver ( Cur c, XmlOptions options, ContentHandler ch, LexicalHandler lh )
-            throws SAXException
-        {
-            super( c, options );
+    static final class SaxSaver extends Saver {
+        SaxSaver(Cur c, XmlOptions options, ContentHandler ch, LexicalHandler lh)
+                throws SAXException {
+            super(c, options);
 
             _contentHandler = ch;
             _lexicalHandler = lh;
 
             _attributes = new AttributesImpl();
-            _nsAsAttrs = !options.hasOption( XmlOptions.SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES );
+            _nsAsAttrs = !options.hasOption(XmlOptions.SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES);
 
             _contentHandler.startDocument();
 
-            try
-            {
-                while ( process() )
+            try {
+                while (process())
                     ;
-            }
-            catch ( SaverSAXException e )
-            {
+            } catch (SaverSAXException e) {
                 throw e._saxException;
             }
 
             _contentHandler.endDocument();
         }
 
-        private class SaverSAXException extends RuntimeException
-        {
-            SaverSAXException ( SAXException e )
-            {
+        private class SaverSAXException extends RuntimeException {
+            SaverSAXException(SAXException e) {
                 _saxException = e;
             }
 
             SAXException _saxException;
         }
 
-        private String getPrefixedName ( QName name )
-        {
+        private String getPrefixedName(QName name) {
             String uri = name.getNamespaceURI();
             String local = name.getLocalPart();
 
             if (uri.length() == 0)
                 return local;
 
-            String prefix = getUriMapping( uri );
+            String prefix = getUriMapping(uri);
 
             if (prefix.length() == 0)
                 return local;
@@ -3457,44 +3149,37 @@
             return prefix + ":" + local;
         }
 
-        private void emitNamespacesHelper ( )
-        {
-            for ( iterateMappings() ; hasMapping() ; nextMapping() )
-            {
+        private void emitNamespacesHelper() {
+            for (iterateMappings(); hasMapping(); nextMapping()) {
                 String prefix = mappingPrefix();
                 String uri = mappingUri();
 
-                try
-                {
-                    _contentHandler.startPrefixMapping( prefix, uri );
-                }
-                catch ( SAXException e )
-                {
-                    throw new SaverSAXException( e );
+                try {
+                    _contentHandler.startPrefixMapping(prefix, uri);
+                } catch (SAXException e) {
+                    throw new SaverSAXException(e);
                 }
 
                 if (_nsAsAttrs)
                     if (prefix == null || prefix.length() == 0)
-                        _attributes.addAttribute( "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns", "CDATA", uri );
+                        _attributes.addAttribute("http://www.w3.org/2000/xmlns/", "xmlns", "xmlns", "CDATA", uri);
                     else
-                        _attributes.addAttribute( "http://www.w3.org/2000/xmlns/", prefix, "xmlns:" + prefix, "CDATA", uri );
+                        _attributes.addAttribute("http://www.w3.org/2000/xmlns/", prefix, "xmlns:" + prefix, "CDATA", uri);
             }
         }
 
-        protected boolean emitElement ( SaveCur c, ArrayList attrNames, ArrayList attrValues )
-        {
+        protected boolean emitElement(SaveCur c, ArrayList attrNames, ArrayList attrValues) {
             _attributes.clear();
 
             if (saveNamespacesFirst())
                 emitNamespacesHelper();
 
-            for ( int i = 0 ; i < attrNames.size() ; i++ )
-            {
-                QName name = (QName) attrNames.get( i );
+            for (int i = 0; i < attrNames.size(); i++) {
+                QName name = (QName) attrNames.get(i);
 
                 _attributes.addAttribute(
-                    name.getNamespaceURI(), name.getLocalPart(), getPrefixedName( name ),
-                    "CDATA", (String) attrValues.get( i ) );
+                        name.getNamespaceURI(), name.getLocalPart(), getPrefixedName(name),
+                        "CDATA", (String) attrValues.get(i));
             }
 
             if (!saveNamespacesFirst())
@@ -3502,160 +3187,125 @@
 
             QName elemName = c.getName();
 
-            try
-            {
+            try {
                 _contentHandler.startElement(
-                    elemName.getNamespaceURI(), elemName.getLocalPart(),
-                    getPrefixedName( elemName ), _attributes );
-            }
-            catch ( SAXException e )
-            {
-                throw new SaverSAXException( e );
+                        elemName.getNamespaceURI(), elemName.getLocalPart(),
+                        getPrefixedName(elemName), _attributes);
+            } catch (SAXException e) {
+                throw new SaverSAXException(e);
             }
 
             return false;
         }
 
-        protected void emitFinish ( SaveCur c )
-        {
+        protected void emitFinish(SaveCur c) {
             QName name = c.getName();
 
-            try
-            {
+            try {
                 _contentHandler.endElement(
-                    name.getNamespaceURI(), name.getLocalPart(), getPrefixedName( name ) );
+                        name.getNamespaceURI(), name.getLocalPart(), getPrefixedName(name));
 
-                for ( iterateMappings() ; hasMapping() ; nextMapping() )
-                    _contentHandler.endPrefixMapping( mappingPrefix() );
-            }
-            catch ( SAXException e )
-            {
-                throw new SaverSAXException( e );
+                for (iterateMappings(); hasMapping(); nextMapping())
+                    _contentHandler.endPrefixMapping(mappingPrefix());
+            } catch (SAXException e) {
+                throw new SaverSAXException(e);
             }
         }
 
-        protected void emitText ( SaveCur c )
-        {
+        protected void emitText(SaveCur c) {
             assert c.isText();
 
             Object src = c.getChars();
 
-            try
-            {
-                if (src instanceof char[])
-                {
+            try {
+                if (src instanceof char[]) {
                     // Pray the user does not modify the buffer ....
-                    _contentHandler.characters( (char[]) src, c._offSrc, c._cchSrc );
-                }
-                else
-                {
+                    _contentHandler.characters((char[]) src, c._offSrc, c._cchSrc);
+                } else {
                     if (_buf == null)
-                        _buf = new char [ 1024 ];
+                        _buf = new char[1024];
 
-                    while ( c._cchSrc > 0 )
-                    {
-                        int cch = java.lang.Math.min( _buf.length, c._cchSrc );
+                    while (c._cchSrc > 0) {
+                        int cch = java.lang.Math.min(_buf.length, c._cchSrc);
 
-                        CharUtil.getChars( _buf, 0, src, c._offSrc, cch );
+                        CharUtil.getChars(_buf, 0, src, c._offSrc, cch);
 
-                        _contentHandler.characters( _buf, 0, cch );
+                        _contentHandler.characters(_buf, 0, cch);
 
                         c._offSrc += cch;
                         c._cchSrc -= cch;
                     }
                 }
-            }
-            catch ( SAXException e )
-            {
-                throw new SaverSAXException( e );
+            } catch (SAXException e) {
+                throw new SaverSAXException(e);
             }
         }
 
-        protected void emitComment ( SaveCur c )
-        {
-            if (_lexicalHandler != null)
-            {
+        protected void emitComment(SaveCur c) {
+            if (_lexicalHandler != null) {
                 c.push();
 
                 c.next();
 
-                try
-                {
+                try {
                     if (!c.isText())
-                        _lexicalHandler.comment( null, 0, 0 );
-                    else
-                    {
+                        _lexicalHandler.comment(null, 0, 0);
+                    else {
                         Object src = c.getChars();
 
-                        if (src instanceof char[])
-                        {
+                        if (src instanceof char[]) {
                             // Pray the user does not modify the buffer ....
-                            _lexicalHandler.comment( (char[]) src, c._offSrc, c._cchSrc );
-                        }
-                        else
-                        {
+                            _lexicalHandler.comment((char[]) src, c._offSrc, c._cchSrc);
+                        } else {
                             if (_buf == null || _buf.length < c._cchSrc)
-                                _buf = new char [ java.lang.Math.max( 1024, c._cchSrc ) ];
+                                _buf = new char[java.lang.Math.max(1024, c._cchSrc)];
 
-                            CharUtil.getChars( _buf, 0, src, c._offSrc, c._cchSrc );
+                            CharUtil.getChars(_buf, 0, src, c._offSrc, c._cchSrc);
 
-                            _lexicalHandler.comment( _buf, 0, c._cchSrc );
+                            _lexicalHandler.comment(_buf, 0, c._cchSrc);
                         }
                     }
-                }
-                catch ( SAXException e )
-                {
-                    throw new SaverSAXException( e );
+                } catch (SAXException e) {
+                    throw new SaverSAXException(e);
                 }
 
                 c.pop();
             }
         }
 
-        protected void emitProcinst ( SaveCur c )
-        {
+        protected void emitProcinst(SaveCur c) {
             String target = c.getName().getLocalPart();
 
             c.push();
 
             c.next();
 
-            String value = CharUtil.getString( c.getChars(), c._offSrc, c._cchSrc );
+            String value = CharUtil.getString(c.getChars(), c._offSrc, c._cchSrc);
 
             c.pop();
 
-            try
-            {
-                _contentHandler.processingInstruction( c.getName().getLocalPart(), value );
-            }
-            catch ( SAXException e )
-            {
-                throw new SaverSAXException( e );
+            try {
+                _contentHandler.processingInstruction(c.getName().getLocalPart(), value);
+            } catch (SAXException e) {
+                throw new SaverSAXException(e);
             }
         }
 
-        protected void emitDocType ( String docTypeName, String publicId, String systemId )
-        {
-            if (_lexicalHandler != null)
-            {
-                try
-                {
-                    _lexicalHandler.startDTD( docTypeName, publicId, systemId );
+        protected void emitDocType(String docTypeName, String publicId, String systemId) {
+            if (_lexicalHandler != null) {
+                try {
+                    _lexicalHandler.startDTD(docTypeName, publicId, systemId);
                     _lexicalHandler.endDTD();
-                }
-                catch ( SAXException e )
-                {
-                    throw new SaverSAXException( e );
+                } catch (SAXException e) {
+                    throw new SaverSAXException(e);
                 }
             }
         }
 
-        protected void emitStartDoc ( SaveCur c )
-        {
+        protected void emitStartDoc(SaveCur c) {
         }
 
-        protected void emitEndDoc ( SaveCur c )
-        {
+        protected void emitEndDoc(SaveCur c) {
         }
 
         private ContentHandler _contentHandler;
@@ -3671,47 +3321,85 @@
     //
     //
 
-    static abstract class SaveCur
-    {
-        final boolean isRoot       ( ) { return kind() == ROOT;     }
-        final boolean isElem       ( ) { return kind() == ELEM;     }
-        final boolean isAttr       ( ) { return kind() == ATTR;     }
-        final boolean isText       ( ) { return kind() == TEXT;     }
-        final boolean isComment    ( ) { return kind() == COMMENT;  }
-        final boolean isProcinst   ( ) { return kind() == PROCINST; }
-        final boolean isFinish     ( ) { return Cur.kindIsFinish( kind() ); }
-        final boolean isContainer  ( ) { return Cur.kindIsContainer( kind() ); }
-        final boolean isNormalAttr ( ) { return kind() == ATTR && !isXmlns(); }
+    static abstract class SaveCur {
+        final boolean isRoot() {
+            return kind() == ROOT;
+        }
 
-        final boolean skip ( ) { toEnd(); return next(); }
+        final boolean isElem() {
+            return kind() == ELEM;
+        }
 
-        abstract void release ( );
+        final boolean isAttr() {
+            return kind() == ATTR;
+        }
 
-        abstract int kind ( );
+        final boolean isText() {
+            return kind() == TEXT;
+        }
 
-        abstract QName  getName ( );
-        abstract String getXmlnsPrefix ( );
-        abstract String getXmlnsUri ( );
+        final boolean isComment() {
+            return kind() == COMMENT;
+        }
 
-        abstract boolean isXmlns ( );
+        final boolean isProcinst() {
+            return kind() == PROCINST;
+        }
 
-        abstract boolean hasChildren  ( );
-        abstract boolean hasText      ( );
-        abstract boolean isTextCData  ( );
+        final boolean isFinish() {
+            return Cur.kindIsFinish(kind());
+        }
 
-        abstract boolean toFirstAttr ( );
-        abstract boolean toNextAttr ( );
-        abstract String  getAttrValue ( );
+        final boolean isContainer() {
+            return Cur.kindIsContainer(kind());
+        }
 
-        abstract boolean next  ( );
-        abstract void    toEnd ( );
+        final boolean isNormalAttr() {
+            return kind() == ATTR && !isXmlns();
+        }
 
-        abstract void push ( );
-        abstract void pop ( );
+        final boolean skip() {
+            toEnd();
+            return next();
+        }
 
-        abstract Object getChars ( );
-        abstract List  getAncestorNamespaces ( );
-        abstract XmlDocumentProperties getDocProps ( );
+        abstract void release();
+
+        abstract int kind();
+
+        abstract QName getName();
+
+        abstract String getXmlnsPrefix();
+
+        abstract String getXmlnsUri();
+
+        abstract boolean isXmlns();
+
+        abstract boolean hasChildren();
+
+        abstract boolean hasText();
+
+        abstract boolean isTextCData();
+
+        abstract boolean toFirstAttr();
+
+        abstract boolean toNextAttr();
+
+        abstract String getAttrValue();
+
+        abstract boolean next();
+
+        abstract void toEnd();
+
+        abstract void push();
+
+        abstract void pop();
+
+        abstract Object getChars();
+
+        abstract List getAncestorNamespaces();
+
+        abstract XmlDocumentProperties getDocProps();
 
         int _offSrc;
         int _cchSrc;
@@ -3720,47 +3408,84 @@
     // TODO - saving a fragment need to take namesapces from root and
     // reflect them on the document element
 
-    private static final class DocSaveCur extends SaveCur
-    {
-        DocSaveCur ( Cur c )
-        {
+    private static final class DocSaveCur extends SaveCur {
+        DocSaveCur(Cur c) {
             assert c.isRoot();
-            _cur = c.weakCur( this );
+            _cur = c.weakCur(this);
         }
 
-        void release ( )
-        {
+        void release() {
             _cur.release();
             _cur = null;
         }
 
-        int kind ( ) { return _cur.kind(); }
+        int kind() {
+            return _cur.kind();
+        }
 
-        QName  getName        ( ) { return _cur.getName(); }
-        String getXmlnsPrefix ( ) { return _cur.getXmlnsPrefix(); }
-        String getXmlnsUri    ( ) { return _cur.getXmlnsUri(); }
+        QName getName() {
+            return _cur.getName();
+        }
 
-        boolean isXmlns       ( ) { return _cur.isXmlns();     }
+        String getXmlnsPrefix() {
+            return _cur.getXmlnsPrefix();
+        }
 
-        boolean hasChildren   ( ) { return _cur.hasChildren(); }
-        boolean hasText       ( ) { return _cur.hasText();     }
-        boolean isTextCData   ( ) { return _cur.isTextCData(); }
+        String getXmlnsUri() {
+            return _cur.getXmlnsUri();
+        }
 
-        boolean toFirstAttr   ( ) { return _cur.toFirstAttr(); }
-        boolean toNextAttr    ( ) { return _cur.toNextAttr();  }
-        String  getAttrValue  ( ) { assert _cur.isAttr(); return _cur.getValueAsString(); }
+        boolean isXmlns() {
+            return _cur.isXmlns();
+        }
 
-        void    toEnd         ( ) { _cur.toEnd();              }
-        boolean next          ( ) { return _cur.next();        }
+        boolean hasChildren() {
+            return _cur.hasChildren();
+        }
 
-        void push ( )         { _cur.push(); }
-        void pop  ( )         { _cur.pop(); }
+        boolean hasText() {
+            return _cur.hasText();
+        }
 
-        List getAncestorNamespaces ( ) { return null; }
+        boolean isTextCData() {
+            return _cur.isTextCData();
+        }
 
-        Object getChars ( )
-        {
-            Object o = _cur.getChars( -1 );
+        boolean toFirstAttr() {
+            return _cur.toFirstAttr();
+        }
+
+        boolean toNextAttr() {
+            return _cur.toNextAttr();
+        }
+
+        String getAttrValue() {
+            assert _cur.isAttr();
+            return _cur.getValueAsString();
+        }
+
+        void toEnd() {
+            _cur.toEnd();
+        }
+
+        boolean next() {
+            return _cur.next();
+        }
+
+        void push() {
+            _cur.push();
+        }
+
+        void pop() {
+            _cur.pop();
+        }
+
+        List getAncestorNamespaces() {
+            return null;
+        }
+
+        Object getChars() {
+            Object o = _cur.getChars(-1);
 
             _offSrc = _cur._offSrc;
             _cchSrc = _cur._cchSrc;
@@ -3768,48 +3493,76 @@
             return o;
         }
 
-        XmlDocumentProperties getDocProps ( ) { return Locale.getDocProps(_cur, false); }
+        XmlDocumentProperties getDocProps() {
+            return Locale.getDocProps(_cur, false);
+        }
 
         private Cur _cur;
     }
 
-    private static abstract class FilterSaveCur extends SaveCur
-    {
-        FilterSaveCur ( SaveCur c )
-        {
+    private static abstract class FilterSaveCur extends SaveCur {
+        FilterSaveCur(SaveCur c) {
             assert c.isRoot();
             _cur = c;
         }
 
         // Can filter anything by root and attributes and text
-        protected abstract boolean filter ( );
+        protected abstract boolean filter();
 
-        void release ( )
-        {
+        void release() {
             _cur.release();
             _cur = null;
         }
 
-        int kind ( ) { return _cur.kind(); }
+        int kind() {
+            return _cur.kind();
+        }
 
-        QName  getName        ( ) { return _cur.getName();        }
-        String getXmlnsPrefix ( ) { return _cur.getXmlnsPrefix(); }
-        String getXmlnsUri    ( ) { return _cur.getXmlnsUri();    }
+        QName getName() {
+            return _cur.getName();
+        }
 
-        boolean isXmlns       ( ) { return _cur.isXmlns();      }
+        String getXmlnsPrefix() {
+            return _cur.getXmlnsPrefix();
+        }
 
-        boolean hasChildren   ( ) { return _cur.hasChildren();  }
-        boolean hasText       ( ) { return _cur.hasText();      }
-        boolean isTextCData   ( ) { return _cur.isTextCData(); }
+        String getXmlnsUri() {
+            return _cur.getXmlnsUri();
+        }
 
-        boolean toFirstAttr   ( ) { return _cur.toFirstAttr();  }
-        boolean toNextAttr    ( ) { return _cur.toNextAttr();   }
-        String  getAttrValue  ( ) { return _cur.getAttrValue(); }
+        boolean isXmlns() {
+            return _cur.isXmlns();
+        }
 
-        void toEnd ( ) { _cur.toEnd(); }
+        boolean hasChildren() {
+            return _cur.hasChildren();
+        }
 
-        boolean next ( )
-        {
+        boolean hasText() {
+            return _cur.hasText();
+        }
+
+        boolean isTextCData() {
+            return _cur.isTextCData();
+        }
+
+        boolean toFirstAttr() {
+            return _cur.toFirstAttr();
+        }
+
+        boolean toNextAttr() {
+            return _cur.toNextAttr();
+        }
+
+        String getAttrValue() {
+            return _cur.getAttrValue();
+        }
+
+        void toEnd() {
+            _cur.toEnd();
+        }
+
+        boolean next() {
             if (!_cur.next())
                 return false;
 
@@ -3823,13 +3576,19 @@
             return next();
         }
 
-        void push ( ) { _cur.push(); }
-        void pop  ( ) { _cur.pop(); }
+        void push() {
+            _cur.push();
+        }
 
-        List getAncestorNamespaces ( ) { return _cur.getAncestorNamespaces(); }
+        void pop() {
+            _cur.pop();
+        }
 
-        Object getChars ( )
-        {
+        List getAncestorNamespaces() {
+            return _cur.getAncestorNamespaces();
+        }
+
+        Object getChars() {
             Object o = _cur.getChars();
 
             _offSrc = _cur._offSrc;
@@ -3838,78 +3597,68 @@
             return o;
         }
 
-        XmlDocumentProperties getDocProps ( ) { return _cur.getDocProps(); }
+        XmlDocumentProperties getDocProps() {
+            return _cur.getDocProps();
+        }
 
         private SaveCur _cur;
     }
 
-    private static final class FilterPiSaveCur extends FilterSaveCur
-    {
-        FilterPiSaveCur ( SaveCur c, String target )
-        {
-            super( c );
+    private static final class FilterPiSaveCur extends FilterSaveCur {
+        FilterPiSaveCur(SaveCur c, String target) {
+            super(c);
 
             _piTarget = target;
         }
 
-        protected boolean filter ( )
-        {
-            return kind() == PROCINST && getName().getLocalPart().equals( _piTarget );
+        protected boolean filter() {
+            return kind() == PROCINST && getName().getLocalPart().equals(_piTarget);
         }
 
         private String _piTarget;
     }
 
-    private static final class FragSaveCur extends SaveCur
-    {
-        FragSaveCur ( Cur start, Cur end, QName synthElem )
-        {
-            _saveAttr = start.isAttr() && start.isSamePos( end );
+    private static final class FragSaveCur extends SaveCur {
+        FragSaveCur(Cur start, Cur end, QName synthElem) {
+            _saveAttr = start.isAttr() && start.isSamePos(end);
 
-            _cur = start.weakCur( this );
-            _end = end.weakCur( this );
+            _cur = start.weakCur(this);
+            _end = end.weakCur(this);
 
             _elem = synthElem;
 
             _state = ROOT_START;
 
-            _stateStack = new int [ 8 ];
+            _stateStack = new int[8];
 
             start.push();
-            computeAncestorNamespaces( start );
+            computeAncestorNamespaces(start);
             start.pop();
         }
 
-        List getAncestorNamespaces ( )
-        {
+        List getAncestorNamespaces() {
             return _ancestorNamespaces;
         }
 
-        private void computeAncestorNamespaces ( Cur c )
-        {
+        private void computeAncestorNamespaces(Cur c) {
             _ancestorNamespaces = new ArrayList();
 
-            while ( c.toParentRaw() )
-            {
-                if (c.toFirstAttr())
-                {
-                    do
-                    {
-                        if (c.isXmlns())
-                        {
+            while (c.toParentRaw()) {
+                if (c.toFirstAttr()) {
+                    do {
+                        if (c.isXmlns()) {
                             String prefix = c.getXmlnsPrefix();
                             String uri = c.getXmlnsUri();
 
                             // Don't let xmlns:foo="" get used
 
-                            if (uri.length() > 0 || prefix.length() == 0)
-                            {
-                                _ancestorNamespaces.add( c.getXmlnsPrefix() );
-                                _ancestorNamespaces.add( c.getXmlnsUri() );
+                            if (uri.length() > 0 || prefix.length() == 0) {
+                                _ancestorNamespaces.add(c.getXmlnsPrefix());
+                                _ancestorNamespaces.add(c.getXmlnsUri());
                             }
                         }
                     }
-                    while ( c.toNextAttr() );
+                    while (c.toNextAttr());
 
                     c.toParent();
                 }
@@ -3920,8 +3669,7 @@
         //
         //
 
-        void release ( )
-        {
+        void release() {
             _cur.release();
             _cur = null;
 
@@ -3929,14 +3677,16 @@
             _end = null;
         }
 
-        int kind ( )
-        {
-            switch ( _state )
-            {
-            case ROOT_START : return  ROOT;
-            case ELEM_START : return  ELEM;
-            case ELEM_END   : return -ELEM;
-            case ROOT_END   : return -ROOT;
+        int kind() {
+            switch (_state) {
+                case ROOT_START:
+                    return ROOT;
+                case ELEM_START:
+                    return ELEM;
+                case ELEM_END:
+                    return -ELEM;
+                case ROOT_END:
+                    return -ROOT;
             }
 
             assert _state == CUR;
@@ -3944,14 +3694,14 @@
             return _cur.kind();
         }
 
-        QName getName ( )
-        {
-            switch ( _state )
-            {
-            case ROOT_START :
-            case ROOT_END   : return null;
-            case ELEM_START :
-            case ELEM_END   : return _elem;
+        QName getName() {
+            switch (_state) {
+                case ROOT_START:
+                case ROOT_END:
+                    return null;
+                case ELEM_START:
+                case ELEM_END:
+                    return _elem;
             }
 
             assert _state == CUR;
@@ -3959,30 +3709,25 @@
             return _cur.getName();
         }
 
-        String getXmlnsPrefix ( )
-        {
+        String getXmlnsPrefix() {
             assert _state == CUR && _cur.isAttr();
             return _cur.getXmlnsPrefix();
         }
 
-        String getXmlnsUri ( )
-        {
+        String getXmlnsUri() {
             assert _state == CUR && _cur.isAttr();
             return _cur.getXmlnsUri();
         }
 
-        boolean isXmlns ( )
-        {
+        boolean isXmlns() {
             assert _state == CUR && _cur.isAttr();
             return _cur.isXmlns();
         }
 
-        boolean hasChildren ( )
-        {
+        boolean hasChildren() {
             boolean hasChildren = false;
 
-            if (isContainer())
-            {   // is there a faster way to do this?
+            if (isContainer()) {   // is there a faster way to do this?
                 push();
                 next();
 
@@ -3995,12 +3740,10 @@
             return hasChildren;
         }
 
-        boolean hasText ( )
-        {
+        boolean hasText() {
             boolean hasText = false;
 
-            if (isContainer())
-            {
+            if (isContainer()) {
                 push();
                 next();
 
@@ -4013,16 +3756,14 @@
             return hasText;
         }
 
-        boolean isTextCData ( )
-        {
+        boolean isTextCData() {
             return _cur.isTextCData();
         }
 
-        Object getChars ( )
-        {
+        Object getChars() {
             assert _state == CUR && _cur.isText();
 
-            Object src = _cur.getChars( -1 );
+            Object src = _cur.getChars(-1);
 
             _offSrc = _cur._offSrc;
             _cchSrc = _cur._cchSrc;
@@ -4030,69 +3771,64 @@
             return src;
         }
 
-        boolean next ( )
-        {
-            switch ( _state )
-            {
-            case ROOT_START :
-            {
-                _state = _elem == null ? CUR : ELEM_START;
-                break;
-            }
-
-            case ELEM_START :
-            {
-                if (_saveAttr)
-                    _state = ELEM_END;
-                else
-                {
-                    if (_cur.isAttr())
-                    {
-                        _cur.toParent();
-                        _cur.next();
-                    }
-
-                    if (_cur.isSamePos( _end ))
-                        _state = ELEM_END;
-                    else
-                        _state = CUR;
+        boolean next() {
+            switch (_state) {
+                case ROOT_START: {
+                    _state = _elem == null ? CUR : ELEM_START;
+                    break;
                 }
 
-                break;
-            }
+                case ELEM_START: {
+                    if (_saveAttr)
+                        _state = ELEM_END;
+                    else {
+                        if (_cur.isAttr()) {
+                            _cur.toParent();
+                            _cur.next();
+                        }
 
-            case CUR :
-            {
-                assert !_cur.isAttr();
+                        if (_cur.isSamePos(_end))
+                            _state = ELEM_END;
+                        else
+                            _state = CUR;
+                    }
 
-                _cur.next();
+                    break;
+                }
 
-                if (_cur.isSamePos( _end ))
-                    _state = _elem == null ? ROOT_END : ELEM_END;
+                case CUR: {
+                    assert !_cur.isAttr();
 
-                break;
-            }
+                    _cur.next();
 
-            case ELEM_END :
-            {
-                _state = ROOT_END;
-                break;
-            }
-            case ROOT_END :
-                return false;
+                    if (_cur.isSamePos(_end))
+                        _state = _elem == null ? ROOT_END : ELEM_END;
+
+                    break;
+                }
+
+                case ELEM_END: {
+                    _state = ROOT_END;
+                    break;
+                }
+                case ROOT_END:
+                    return false;
             }
 
             return true;
         }
 
-        void toEnd ( )
-        {
-            switch ( _state )
-            {
-            case ROOT_START : _state = ROOT_END; return;
-            case ELEM_START : _state = ELEM_END; return;
-            case ROOT_END   :
-            case ELEM_END   : return;
+        void toEnd() {
+            switch (_state) {
+                case ROOT_START:
+                    _state = ROOT_END;
+                    return;
+                case ELEM_START:
+                    _state = ELEM_END;
+                    return;
+                case ROOT_END:
+                case ELEM_END:
+                    return;
             }
 
             assert _state == CUR && !_cur.isAttr() && !_cur.isText();
@@ -4100,14 +3836,14 @@
             _cur.toEnd();
         }
 
-        boolean toFirstAttr ( )
-        {
-            switch ( _state )
-            {
-            case ROOT_END   :
-            case ELEM_END   :
-            case ROOT_START : return false;
-            case CUR        : return _cur.toFirstAttr();
+        boolean toFirstAttr() {
+            switch (_state) {
+                case ROOT_END:
+                case ELEM_END:
+                case ROOT_START:
+                    return false;
+                case CUR:
+                    return _cur.toFirstAttr();
             }
 
             assert _state == ELEM_START;
@@ -4120,38 +3856,35 @@
             return true;
         }
 
-        boolean toNextAttr ( )
-        {
+        boolean toNextAttr() {
             assert _state == CUR;
             return !_saveAttr && _cur.toNextAttr();
         }
 
-        String getAttrValue ( )
-        {
+        String getAttrValue() {
             assert _state == CUR && _cur.isAttr();
             return _cur.getValueAsString();
         }
 
-        void push ( )
-        {
-            if (_stateStackSize == _stateStack.length)
-            {
-                int[] newStateStack = new int [ _stateStackSize * 2 ];
-                System.arraycopy( _stateStack, 0, newStateStack, 0, _stateStackSize );
+        void push() {
+            if (_stateStackSize == _stateStack.length) {
+                int[] newStateStack = new int[_stateStackSize * 2];
+                System.arraycopy(_stateStack, 0, newStateStack, 0, _stateStackSize);
                 _stateStack = newStateStack;
             }
 
-            _stateStack [ _stateStackSize++ ] = _state;
+            _stateStack[_stateStackSize++] = _state;
             _cur.push();
         }
 
-        void pop ()
-        {
+        void pop() {
             _cur.pop();
-            _state = _stateStack [ --_stateStackSize ];
+            _state = _stateStack[--_stateStackSize];
         }
 
-        XmlDocumentProperties getDocProps ( ) { return Locale.getDocProps(_cur, false); }
+        XmlDocumentProperties getDocProps() {
+            return Locale.getDocProps(_cur, false);
+        }
 
         //
         //
@@ -4168,20 +3901,18 @@
 
         private static final int ROOT_START = 1;
         private static final int ELEM_START = 2;
-        private static final int ROOT_END   = 3;
-        private static final int ELEM_END   = 4;
-        private static final int CUR        = 5;
+        private static final int ROOT_END = 3;
+        private static final int ELEM_END = 4;
+        private static final int CUR = 5;
 
         private int _state;
 
         private int[] _stateStack;
-        private int   _stateStackSize;
+        private int _stateStackSize;
     }
 
-    private static final class PrettySaveCur extends SaveCur
-    {
-        PrettySaveCur ( SaveCur c, XmlOptions options )
-        {
+    private static final class PrettySaveCur extends SaveCur {
+        PrettySaveCur(SaveCur c, XmlOptions options) {
             _sb = new StringBuffer();
             _stack = new ArrayList();
 
@@ -4191,49 +3922,82 @@
 
             _prettyIndent = 2;
 
-            if (options.hasOption( XmlOptions.SAVE_PRETTY_PRINT_INDENT ))
-            {
+            if (options.hasOption(XmlOptions.SAVE_PRETTY_PRINT_INDENT)) {
                 _prettyIndent =
-                    ((Integer) options.get( XmlOptions.SAVE_PRETTY_PRINT_INDENT )).intValue();
+                        ((Integer) options.get(XmlOptions.SAVE_PRETTY_PRINT_INDENT)).intValue();
             }
 
-            if (options.hasOption( XmlOptions.SAVE_PRETTY_PRINT_OFFSET ))
-            {
+            if (options.hasOption(XmlOptions.SAVE_PRETTY_PRINT_OFFSET)) {
                 _prettyOffset =
-                    ((Integer) options.get( XmlOptions.SAVE_PRETTY_PRINT_OFFSET )).intValue();
+                        ((Integer) options.get(XmlOptions.SAVE_PRETTY_PRINT_OFFSET)).intValue();
             }
 
-            if (options.hasOption( XmlOptions.LOAD_SAVE_CDATA_BOOKMARKS ))
-            {
+            if (options.hasOption(XmlOptions.LOAD_SAVE_CDATA_BOOKMARKS)) {
                 _useCDataBookmarks = true;
             }
         }
 
-        List getAncestorNamespaces ( ) { return _cur.getAncestorNamespaces(); }
+        List getAncestorNamespaces() {
+            return _cur.getAncestorNamespaces();
+        }
 
-        void release ( ) { _cur.release(); }
+        void release() {
+            _cur.release();
+        }
 
-        int kind ( ) { return _txt == null ? _cur.kind() : TEXT; }
+        int kind() {
+            return _txt == null ? _cur.kind() : TEXT;
+        }
 
-        QName  getName        ( ) { assert _txt == null; return _cur.getName(); }
-        String getXmlnsPrefix ( ) { assert _txt == null; return _cur.getXmlnsPrefix(); }
-        String getXmlnsUri    ( ) { assert _txt == null; return _cur.getXmlnsUri(); }
+        QName getName() {
+            assert _txt == null;
+            return _cur.getName();
+        }
 
-        boolean isXmlns       ( ) { return _txt == null ? _cur.isXmlns()      : false; }
+        String getXmlnsPrefix() {
+            assert _txt == null;
+            return _cur.getXmlnsPrefix();
+        }
 
-        boolean hasChildren   ( ) { return _txt == null ? _cur.hasChildren() : false; }
-        boolean hasText       ( ) { return _txt == null ? _cur.hasText()     : false; }
+        String getXmlnsUri() {
+            assert _txt == null;
+            return _cur.getXmlnsUri();
+        }
+
+        boolean isXmlns() {
+            return _txt == null ? _cur.isXmlns() : false;
+        }
+
+        boolean hasChildren() {
+            return _txt == null ? _cur.hasChildren() : false;
+        }
+
+        boolean hasText() {
+            return _txt == null ? _cur.hasText() : false;
+        }
 
         // _cur.isTextCData() is expensive do it only if useCDataBookmarks option is enabled
-        boolean isTextCData   ( ) { return _txt == null ? (_useCDataBookmarks && _cur.isTextCData())
-                                                        : _isTextCData; }
+        boolean isTextCData() {
+            return _txt == null ? (_useCDataBookmarks && _cur.isTextCData())
+                    : _isTextCData;
+        }
 
-        boolean toFirstAttr   ( ) { assert _txt == null; return _cur.toFirstAttr(); }
-        boolean toNextAttr    ( ) { assert _txt == null; return _cur.toNextAttr(); }
-        String  getAttrValue  ( ) { assert _txt == null; return _cur.getAttrValue(); }
+        boolean toFirstAttr() {
+            assert _txt == null;
+            return _cur.toFirstAttr();
+        }
 
-        void toEnd ( )
-        {
+        boolean toNextAttr() {
+            assert _txt == null;
+            return _cur.toNextAttr();
+        }
+
+        String getAttrValue() {
+            assert _txt == null;
+            return _cur.getAttrValue();
+        }
+
+        void toEnd() {
             assert _txt == null;
             _cur.toEnd();
 
@@ -4241,37 +4005,32 @@
                 _depth--;
         }
 
-        boolean next ( )
-        {
+        boolean next() {
             int k;
 
-            if (_txt != null)
-            {
+            if (_txt != null) {
                 assert _txt.length() > 0;
                 assert !_cur.isText();
                 _txt = null;
                 _isTextCData = false;
                 k = _cur.kind();
-            }
-            else
-            {
+            } else {
                 int prevKind = k = _cur.kind();
 
                 if (!_cur.next())
                     return false;
 
-                _sb.delete( 0, _sb.length() );
+                _sb.delete(0, _sb.length());
 
                 assert _txt == null;
 
                 // place any text encountered in the buffer
-                if (_cur.isText())
-                {
+                if (_cur.isText()) {
                     // _cur.isTextCData() is expensive do it only if useCDataBookmarks option is enabled
                     _isTextCData = _useCDataBookmarks && _cur.isTextCData();
-                    CharUtil.getString( _sb, _cur.getChars(), _cur._offSrc, _cur._cchSrc );
+                    CharUtil.getString(_sb, _cur.getChars(), _cur._offSrc, _cur._cchSrc);
                     _cur.next();
-                    trim( _sb );
+                    trim(_sb);
                 }
 
                 k = _cur.kind();
@@ -4279,27 +4038,24 @@
                 // Check for non leaf, _prettyIndent < 0 means that the save is all on one line
 
                 if (_prettyIndent >= 0 &&
-                      prevKind != COMMENT && prevKind != PROCINST && (prevKind != ELEM || k != -ELEM))
+                        prevKind != COMMENT && prevKind != PROCINST && (prevKind != ELEM || k != -ELEM))
 //                if (prevKind != COMMENT && prevKind != PROCINST && (prevKind != ELEM || k != -ELEM))
                 {
-                    if (_sb.length() > 0)
-                    {
-                        _sb.insert( 0, _newLine );
-                        spaces( _sb, _newLine.length(), _prettyOffset + _prettyIndent * _depth );
+                    if (_sb.length() > 0) {
+                        _sb.insert(0, _newLine);
+                        spaces(_sb, _newLine.length(), _prettyOffset + _prettyIndent * _depth);
                     }
 
-                    if (k != -ROOT)
-                    {
+                    if (k != -ROOT) {
                         if (prevKind != ROOT)
-                            _sb.append( _newLine );
+                            _sb.append(_newLine);
 
                         int d = k < 0 ? _depth - 1 : _depth;
-                        spaces( _sb, _sb.length(), _prettyOffset + _prettyIndent * d );
+                        spaces(_sb, _sb.length(), _prettyOffset + _prettyIndent * d);
                     }
                 }
 
-                if (_sb.length() > 0)
-                {
+                if (_sb.length() > 0) {
                     _txt = _sb.toString();
                     k = TEXT;
                 }
@@ -4313,26 +4069,22 @@
             return true;
         }
 
-        void push ( )
-        {
+        void push() {
             _cur.push();
-            _stack.add( _txt );
-            _stack.add( new Integer( _depth ) );
+            _stack.add(_txt);
+            _stack.add(new Integer(_depth));
             _isTextCData = false;
         }
 
-        void pop ( )
-        {
+        void pop() {
             _cur.pop();
-            _depth = ((Integer) _stack.remove( _stack.size() - 1 )).intValue();
-            _txt = (String) _stack.remove( _stack.size() - 1 );
+            _depth = ((Integer) _stack.remove(_stack.size() - 1)).intValue();
+            _txt = (String) _stack.remove(_stack.size() - 1);
             _isTextCData = false;
         }
 
-        Object getChars ( )
-        {
-            if (_txt != null)
-            {
+        Object getChars() {
+            if (_txt != null) {
                 _offSrc = 0;
                 _cchSrc = _txt.length();
                 return _txt;
@@ -4346,29 +4098,29 @@
             return o;
         }
 
-        XmlDocumentProperties getDocProps ( ) { return _cur.getDocProps(); }
-
-        static void spaces ( StringBuffer sb, int offset, int count )
-        {
-            while ( count-- > 0 )
-                sb.insert( offset, ' ' );
+        XmlDocumentProperties getDocProps() {
+            return _cur.getDocProps();
         }
 
-        static void trim ( StringBuffer sb )
-        {
+        static void spaces(StringBuffer sb, int offset, int count) {
+            while (count-- > 0)
+                sb.insert(offset, ' ');
+        }
+
+        static void trim(StringBuffer sb) {
             int i;
 
-            for ( i = 0 ; i < sb.length() ; i++ )
-                if (!CharUtil.isWhiteSpace( sb.charAt( i ) ))
+            for (i = 0; i < sb.length(); i++)
+                if (!CharUtil.isWhiteSpace(sb.charAt(i)))
                     break;
 
-            sb.delete( 0, i );
+            sb.delete(0, i);
 
-            for ( i = sb.length() ; i > 0 ; i-- )
-                if (!CharUtil.isWhiteSpace( sb.charAt( i - 1 ) ))
+            for (i = sb.length(); i > 0; i--)
+                if (!CharUtil.isWhiteSpace(sb.charAt(i - 1)))
                     break;
 
-            sb.delete( i, sb.length() );
+            sb.delete(i, sb.length());
         }
 
         private SaveCur _cur;
@@ -4376,14 +4128,14 @@
         private int _prettyIndent;
         private int _prettyOffset;
 
-        private String       _txt;
+        private String _txt;
         private StringBuffer _sb;
 
-        private int          _depth;
+        private int _depth;
 
-        private ArrayList    _stack;
-        private boolean      _isTextCData = false;
-        private boolean      _useCDataBookmarks = false;
+        private ArrayList _stack;
+        private boolean _isTextCData = false;
+        private boolean _useCDataBookmarks = false;
     }
 
 
@@ -4392,28 +4144,28 @@
     //
 
     private final Locale _locale;
-    private final long   _version;
+    private final long _version;
 
     private SaveCur _cur;
 
-    private List    _ancestorNamespaces;
-    private Map     _suggestedPrefixes;
+    private List _ancestorNamespaces;
+    private Map _suggestedPrefixes;
     protected XmlOptionCharEscapeMap _replaceChar;
     private boolean _useDefaultNamespace;
-    private Map     _preComputedNamespaces;
+    private Map _preComputedNamespaces;
     private boolean _saveNamespacesFirst;
 
     private ArrayList _attrNames;
     private ArrayList _attrValues;
 
     private ArrayList _namespaceStack;
-    private int       _currentMapping;
-    private HashMap   _uriMap;
-    private HashMap   _prefixMap;
-    private String    _initialDefaultUri;
+    private int _currentMapping;
+    private HashMap _uriMap;
+    private HashMap _prefixMap;
+    private String _initialDefaultUri;
 
     static final String _newLine =
-        SystemProperties.getProperty( "line.separator" ) == null
-            ? "\n"
-            : SystemProperties.getProperty( "line.separator" );
+            SystemProperties.getProperty("line.separator") == null
+                    ? "\n"
+                    : SystemProperties.getProperty("line.separator");
 }