poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1881423 [3/4] - in /xmlbeans/trunk/src/main: java/org/apache/xmlbeans/ java/org/apache/xmlbeans/impl/common/ java/org/apache/xmlbeans/impl/schema/ java/org/apache/xmlbeans/impl/store/ java/org/apache/xmlbeans/impl/xpath/ java/org/apache/xm...
Date Thu, 03 Sep 2020 23:18:23 GMT
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java?rev=1881423&r1=1881422&r2=1881423&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java Thu Sep  3 23:18:22 2020
@@ -33,56 +33,71 @@ import java.util.*;
 
 // DOM Level 3
 
-final class DomImpl
-{
-    static final int ELEMENT   = Node.ELEMENT_NODE;
-    static final int ATTR      = Node.ATTRIBUTE_NODE;
-    static final int TEXT      = Node.TEXT_NODE;
-    static final int CDATA     = Node.CDATA_SECTION_NODE;
+public final class DomImpl {
+    static final int ELEMENT = Node.ELEMENT_NODE;
+    static final int ATTR = Node.ATTRIBUTE_NODE;
+    static final int TEXT = Node.TEXT_NODE;
+    static final int CDATA = Node.CDATA_SECTION_NODE;
     static final int ENTITYREF = Node.ENTITY_REFERENCE_NODE;
-    static final int ENTITY    = Node.ENTITY_NODE;
-    static final int PROCINST  = Node.PROCESSING_INSTRUCTION_NODE;
-    static final int COMMENT   = Node.COMMENT_NODE;
-    static final int DOCUMENT  = Node.DOCUMENT_NODE;
-    static final int DOCTYPE   = Node.DOCUMENT_TYPE_NODE;
-    static final int DOCFRAG   = Node.DOCUMENT_FRAGMENT_NODE;
-    static final int NOTATION  = Node.NOTATION_NODE;
-
-    interface Dom
-    {
-        Locale locale   ( );
-        int    nodeType ( );
-        Cur    tempCur  ( );
-        QName  getQName ( );
-        boolean nodeCanHavePrefixUri( );
-
-        void   dump ( );
-        void   dump ( PrintStream o );
-        void   dump ( PrintStream o, Object ref );
-    };
-
-    static Dom parent      ( Dom d ) { return node_getParentNode ( d ); }
-    static Dom firstChild  ( Dom d ) { return node_getFirstChild ( d ); }
-    static Dom nextSibling ( Dom d ) { return node_getNextSibling( d ); }
-    static Dom prevSibling ( Dom d ) { return node_getPreviousSibling( d ); }
-
-    public static Dom append ( Dom n, Dom p )
-    {
-        return node_insertBefore( p, n, null );
+    static final int ENTITY = Node.ENTITY_NODE;
+    static final int PROCINST = Node.PROCESSING_INSTRUCTION_NODE;
+    static final int COMMENT = Node.COMMENT_NODE;
+    static final int DOCUMENT = Node.DOCUMENT_NODE;
+    static final int DOCTYPE = Node.DOCUMENT_TYPE_NODE;
+    static final int DOCFRAG = Node.DOCUMENT_FRAGMENT_NODE;
+    static final int NOTATION = Node.NOTATION_NODE;
+
+    public interface Dom {
+        Locale locale();
+
+        int nodeType();
+
+        Cur tempCur();
+
+        QName getQName();
+
+        boolean nodeCanHavePrefixUri();
+
+        void dump();
+
+        void dump(PrintStream o);
+
+        void dump(PrintStream o, Object ref);
+    }
+
+    ;
+
+    static Dom parent(Dom d) {
+        return node_getParentNode(d);
+    }
+
+    static Dom firstChild(Dom d) {
+        return node_getFirstChild(d);
+    }
+
+    static Dom nextSibling(Dom d) {
+        return node_getNextSibling(d);
+    }
+
+    static Dom prevSibling(Dom d) {
+        return node_getPreviousSibling(d);
+    }
+
+    public static Dom append(Dom n, Dom p) {
+        return node_insertBefore(p, n, null);
     }
 
-    public static Dom insert ( Dom n, Dom b )
-    {
+    public static Dom insert(Dom n, Dom b) {
         assert b != null;
-        return node_insertBefore( parent( b ), n, b );
+        return node_insertBefore(parent(b), n, b);
     }
 
-    public static Dom remove ( Dom n )
-    {
-        Dom p = parent( n );
+    public static Dom remove(Dom n) {
+        Dom p = parent(n);
 
-        if (p != null)
-            node_removeChild( p, n );
+        if (p != null) {
+            node_removeChild(p, n);
+        }
 
         return n;
     }
@@ -91,304 +106,356 @@ final class DomImpl
     // Handy dandy Dom exceptions
     //
 
-    static class HierarchyRequestErr extends DOMException
-    {
-        HierarchyRequestErr ( ) { this( "This node isn't allowed there" ); }
-        HierarchyRequestErr ( String message ) { super( HIERARCHY_REQUEST_ERR, message ); }
+    static class HierarchyRequestErr extends DOMException {
+        HierarchyRequestErr() {
+            this("This node isn't allowed there");
+        }
+
+        HierarchyRequestErr(String message) {
+            super(HIERARCHY_REQUEST_ERR, message);
+        }
     }
 
-    static class WrongDocumentErr extends DOMException
-    {
-        WrongDocumentErr ( ) { this( "Nodes do not belong to the same document" ); }
-        WrongDocumentErr ( String message ) { super( WRONG_DOCUMENT_ERR, message ); }
+    static class WrongDocumentErr extends DOMException {
+        WrongDocumentErr() {
+            this("Nodes do not belong to the same document");
+        }
+
+        WrongDocumentErr(String message) {
+            super(WRONG_DOCUMENT_ERR, message);
+        }
     }
 
-    static class NotFoundErr extends DOMException
-    {
-        NotFoundErr ( ) { this( "Node not found" ); }
-        NotFoundErr ( String message ) { super( NOT_FOUND_ERR, message ); }
+    static class NotFoundErr extends DOMException {
+        NotFoundErr() {
+            this("Node not found");
+        }
+
+        NotFoundErr(String message) {
+            super(NOT_FOUND_ERR, message);
+        }
     }
 
-    static class NamespaceErr extends DOMException
-    {
-        NamespaceErr ( ) { this( "Namespace error" ); }
-        NamespaceErr ( String message ) { super( NAMESPACE_ERR, message ); }
+    static class NamespaceErr extends DOMException {
+        NamespaceErr() {
+            this("Namespace error");
+        }
+
+        NamespaceErr(String message) {
+            super(NAMESPACE_ERR, message);
+        }
     }
 
-    static class NoModificationAllowedErr extends DOMException
-    {
-        NoModificationAllowedErr ( ) { this( "No modification allowed error" ); }
-        NoModificationAllowedErr ( String message ) { super( NO_MODIFICATION_ALLOWED_ERR, message ); }
+    static class NoModificationAllowedErr extends DOMException {
+        NoModificationAllowedErr() {
+            this("No modification allowed error");
+        }
+
+        NoModificationAllowedErr(String message) {
+            super(NO_MODIFICATION_ALLOWED_ERR, message);
+        }
     }
 
-    static class InuseAttributeError extends DOMException
-    {
-        InuseAttributeError ( ) { this( "Attribute currently in use error" ); }
-        InuseAttributeError ( String message ) { super( INUSE_ATTRIBUTE_ERR, message ); }
+    static class InuseAttributeError extends DOMException {
+        InuseAttributeError() {
+            this("Attribute currently in use error");
+        }
+
+        InuseAttributeError(String message) {
+            super(INUSE_ATTRIBUTE_ERR, message);
+        }
     }
 
-    static class IndexSizeError extends DOMException
-    {
-        IndexSizeError ( ) { this( "Index Size Error" ); }
-        IndexSizeError ( String message ) { super( INDEX_SIZE_ERR, message ); }
+    static class IndexSizeError extends DOMException {
+        IndexSizeError() {
+            this("Index Size Error");
+        }
+
+        IndexSizeError(String message) {
+            super(INDEX_SIZE_ERR, message);
+        }
     }
 
-    static class NotSupportedError extends DOMException
-    {
-        NotSupportedError ( ) { this( "This operation is not supported" ); }
-        NotSupportedError ( String message ) { super( NOT_SUPPORTED_ERR, message ); }
+    static class NotSupportedError extends DOMException {
+        NotSupportedError() {
+            this("This operation is not supported");
+        }
+
+        NotSupportedError(String message) {
+            super(NOT_SUPPORTED_ERR, message);
+        }
     }
 
-    static class InvalidCharacterError extends DOMException
-    {
-        InvalidCharacterError ( ) { this( "The name contains an invalid character" ); }
-        InvalidCharacterError ( String message ) { super( INVALID_CHARACTER_ERR, message ); }
+    static class InvalidCharacterError extends DOMException {
+        InvalidCharacterError() {
+            this("The name contains an invalid character");
+        }
+
+        InvalidCharacterError(String message) {
+            super(INVALID_CHARACTER_ERR, message);
+        }
     }
 
     //
     // Helper fcns
     //
 
-    private static final class EmptyNodeList implements NodeList
-    {
-        public int getLength ( ) { return 0; }
-        public Node item ( int i ) { return null; }
+    private static final class EmptyNodeList implements NodeList {
+        public int getLength() {
+            return 0;
+        }
+
+        public Node item(int i) {
+            return null;
+        }
     }
 
     public static NodeList _emptyNodeList = new EmptyNodeList();
 
-    static String nodeKindName ( int t )
-    {
-        switch ( t )
-        {
-        case ATTR      : return "attribute";
-        case CDATA     : return "cdata section";
-        case COMMENT   : return "comment";
-        case DOCFRAG   : return "document fragment";
-        case DOCUMENT  : return "document";
-        case DOCTYPE   : return "document type";
-        case ELEMENT   : return "element";
-        case ENTITY    : return "entity";
-        case ENTITYREF : return "entity reference";
-        case NOTATION  : return "notation";
-        case PROCINST  : return "processing instruction";
-        case TEXT      : return "text";
+    static String nodeKindName(int t) {
+        switch (t) {
+            case ATTR:
+                return "attribute";
+            case CDATA:
+                return "cdata section";
+            case COMMENT:
+                return "comment";
+            case DOCFRAG:
+                return "document fragment";
+            case DOCUMENT:
+                return "document";
+            case DOCTYPE:
+                return "document type";
+            case ELEMENT:
+                return "element";
+            case ENTITY:
+                return "entity";
+            case ENTITYREF:
+                return "entity reference";
+            case NOTATION:
+                return "notation";
+            case PROCINST:
+                return "processing instruction";
+            case TEXT:
+                return "text";
 
-        default : throw new RuntimeException( "Unknown node type" );
+            default:
+                throw new RuntimeException("Unknown node type");
         }
     }
 
-    private static String isValidChild ( Dom parent, Dom child )
-    {
+    private static String isValidChild(Dom parent, Dom child) {
         int pk = parent.nodeType();
         int ck = child.nodeType();
 
-        switch ( pk )
-        {
-        case DOCUMENT :
-        {
-            switch ( ck )
-            {
-            case ELEMENT :
-            {
-                if (document_getDocumentElement( parent ) != null)
-                    return "Documents may only have a maximum of one document element";
+        switch (pk) {
+            case DOCUMENT: {
+                switch (ck) {
+                    case ELEMENT: {
+                        if (document_getDocumentElement(parent) != null) {
+                            return "Documents may only have a maximum of one document element";
+                        }
 
-                return null;
-            }
-            case DOCTYPE :
-            {
-                if (document_getDoctype( parent ) != null)
-                    return "Documents may only have a maximum of one document type node";
+                        return null;
+                    }
+                    case DOCTYPE: {
+                        if (document_getDoctype(parent) != null) {
+                            return "Documents may only have a maximum of one document type node";
+                        }
 
-                return null;
-            }
-            case PROCINST :
-            case COMMENT  :
-                return null;
+                        return null;
+                    }
+                    case PROCINST:
+                    case COMMENT:
+                        return null;
+                }
+
+                break;
             }
 
-            break;
-        }
+            case ATTR: {
+                if (ck == TEXT || ck == ENTITYREF) {
+                    return null;
+                }
 
-        case ATTR :
-        {
-            if (ck == TEXT || ck == ENTITYREF)
-                return null;
+                // TODO -- traverse the entity tree, making sure that there are
+                // only entity refs and text nodes in it.
 
-            // TODO -- traverse the entity tree, making sure that there are
-            // only entity refs and text nodes in it.
+                break;
+            }
 
-            break;
-        }
+            case DOCFRAG:
+            case ELEMENT:
+            case ENTITY:
+            case ENTITYREF: {
+                switch (ck) {
+                    case ELEMENT:
+                    case ENTITYREF:
+                    case CDATA:
+                    case TEXT:
+                    case COMMENT:
+                    case PROCINST:
+                        return null;
+                }
 
-        case DOCFRAG   :
-        case ELEMENT   :
-        case ENTITY    :
-        case ENTITYREF :
-        {
-            switch ( ck )
-            {
-            case ELEMENT :
-            case ENTITYREF:
-            case CDATA :
-            case TEXT :
-            case COMMENT :
-            case PROCINST :
-                return null;
+                break;
             }
 
-            break;
-        }
-
-        case CDATA :
-        case TEXT :
-        case COMMENT :
-        case PROCINST :
-        case DOCTYPE :
-        case NOTATION :
-            return nodeKindName( pk ) + " nodes may not have any children";
+            case CDATA:
+            case TEXT:
+            case COMMENT:
+            case PROCINST:
+            case DOCTYPE:
+            case NOTATION:
+                return nodeKindName(pk) + " nodes may not have any children";
         }
 
         return
-            nodeKindName( pk ) + " nodes may not have " +
-                nodeKindName( ck ) + " nodes as children";
+            nodeKindName(pk) + " nodes may not have " +
+            nodeKindName(ck) + " nodes as children";
     }
 
-    private static void validateNewChild ( Dom parent, Dom child )
-    {
-        String msg = isValidChild( parent, child );
+    private static void validateNewChild(Dom parent, Dom child) {
+        String msg = isValidChild(parent, child);
 
-        if (msg != null)
-            throw new HierarchyRequestErr( msg );
+        if (msg != null) {
+            throw new HierarchyRequestErr(msg);
+        }
 
-        if (parent == child)
-            throw new HierarchyRequestErr( "New child and parent are the same node" );
+        if (parent == child) {
+            throw new HierarchyRequestErr("New child and parent are the same node");
+        }
 
-        while ( (parent = parent( parent )) != null )
-        {
+        while ((parent = parent(parent)) != null) {
             // TODO - use read only state on a node to know if it is under an
             // entity ref
 
-            if (child.nodeType() == ENTITYREF)
-                throw new NoModificationAllowedErr( "Entity reference trees may not be modified" );
+            if (child.nodeType() == ENTITYREF) {
+                throw new NoModificationAllowedErr("Entity reference trees may not be modified");
+            }
 
-            if (child == parent)
-                throw new HierarchyRequestErr( "New child is an ancestor node of the parent node" );
+            if (child == parent) {
+                throw new HierarchyRequestErr("New child is an ancestor node of the parent node");
+            }
         }
     }
 
-    private static String validatePrefix (
-        String prefix, String uri, String local, boolean isAttr )
-    {
-        validateNcName( prefix );
+    private static String validatePrefix(
+        String prefix, String uri, String local, boolean isAttr) {
+        validateNcName(prefix);
 
-        if (prefix == null)
+        if (prefix == null) {
             prefix = "";
+        }
 
-        if (uri == null)
+        if (uri == null) {
             uri = "";
+        }
 
-        if (prefix.length() > 0 && uri.length() == 0)
-            throw new NamespaceErr( "Attempt to give a prefix for no namespace" );
+        if (prefix.length() > 0 && uri.length() == 0) {
+            throw new NamespaceErr("Attempt to give a prefix for no namespace");
+        }
 
-        if (prefix.equals( "xml" ) && !uri.equals( Locale._xml1998Uri ))
-            throw new NamespaceErr( "Invalid prefix - begins with 'xml'" );
+        if (prefix.equals("xml") && !uri.equals(Locale._xml1998Uri)) {
+            throw new NamespaceErr("Invalid prefix - begins with 'xml'");
+        }
 
-        if (isAttr)
-        {
-            if (prefix.length() > 0)
-            {
-                if (local.equals( "xmlns" ))
-                    throw new NamespaceErr( "Invalid namespace - attr is default namespace already" );
+        if (isAttr) {
+            if (prefix.length() > 0) {
+                if (local.equals("xmlns")) {
+                    throw new NamespaceErr("Invalid namespace - attr is default namespace already");
+                }
 
-                if (Locale.beginsWithXml( local ))
-                    throw new NamespaceErr( "Invalid namespace - attr prefix begins with 'xml'" );
+                if (Locale.beginsWithXml(local)) {
+                    throw new NamespaceErr("Invalid namespace - attr prefix begins with 'xml'");
+                }
 
-                if (prefix.equals( "xmlns" ) && !uri.equals( Locale._xmlnsUri ))
-                    throw new NamespaceErr( "Invalid namespace - uri is not '" + Locale._xmlnsUri+";" );
-            }
-            else
-            {
-                if (local.equals( "xmlns" ) && !uri.equals( Locale._xmlnsUri ))
-                    throw new NamespaceErr( "Invalid namespace - uri is not '" + Locale._xmlnsUri+";" );
+                if (prefix.equals("xmlns") && !uri.equals(Locale._xmlnsUri)) {
+                    throw new NamespaceErr("Invalid namespace - uri is not '" + Locale._xmlnsUri + ";");
+                }
+            } else {
+                if (local.equals("xmlns") && !uri.equals(Locale._xmlnsUri)) {
+                    throw new NamespaceErr("Invalid namespace - uri is not '" + Locale._xmlnsUri + ";");
+                }
             }
+        } else if (Locale.beginsWithXml(prefix)) {
+            throw new NamespaceErr("Invalid prefix - begins with 'xml'");
         }
-        else if (Locale.beginsWithXml( prefix ))
-            throw new NamespaceErr( "Invalid prefix - begins with 'xml'" );
 
         return prefix;
     }
 
-    private static void validateName ( String name )
-    {
-        if (name == null)
-            throw new IllegalArgumentException( "Name is null" );
+    private static void validateName(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name is null");
+        }
 
-        if (name.length() == 0)
-            throw new IllegalArgumentException( "Name is empty" );
+        if (name.length() == 0) {
+            throw new IllegalArgumentException("Name is empty");
+        }
 
-        if (!XMLChar.isValidName( name ))
-            throw new InvalidCharacterError( "Name has an invalid character" );
+        if (!XMLChar.isValidName(name)) {
+            throw new InvalidCharacterError("Name has an invalid character");
+        }
     }
 
-    private static void validateNcName ( String name )
-    {
-        if (name != null && name.length() > 0 && !XMLChar.isValidNCName( name ))
+    private static void validateNcName(String name) {
+        if (name != null && name.length() > 0 && !XMLChar.isValidNCName(name)) {
             throw new InvalidCharacterError();
+        }
     }
 
-    private static void validateQualifiedName ( String name, String uri, boolean isAttr )
-    {
+    private static void validateQualifiedName(String name, String uri, boolean isAttr) {
         assert name != null;
 
-        if (uri == null)
+        if (uri == null) {
             uri = "";
+        }
 
-        int i = name.indexOf( ':' );
+        int i = name.indexOf(':');
 
         String local;
 
-        if (i < 0)
-        {
-            validateNcName( local = name );
+        if (i < 0) {
+            validateNcName(local = name);
 
-            if (isAttr && local.equals( "xmlns" ) && !uri.equals( Locale._xmlnsUri ))
-            {
+            if (isAttr && local.equals("xmlns") && !uri.equals(Locale._xmlnsUri)) {
                 throw
                     new NamespaceErr(
-                        "Default xmlns attribute does not have namespace: " + Locale._xmlnsUri );
+                        "Default xmlns attribute does not have namespace: " + Locale._xmlnsUri);
+            }
+        } else {
+            if (i == 0) {
+                throw new NamespaceErr("Invalid qualified name, no prefix specified");
             }
-        }
-        else
-        {
-            if (i == 0)
-                throw new NamespaceErr( "Invalid qualified name, no prefix specified" );
 
-            String prefix = name.substring( 0, i );
+            String prefix = name.substring(0, i);
 
-            validateNcName( prefix );
+            validateNcName(prefix);
 
-            if (uri.length() == 0)
-                throw new NamespaceErr( "Attempt to give a prefix for no namespace" );
+            if (uri.length() == 0) {
+                throw new NamespaceErr("Attempt to give a prefix for no namespace");
+            }
 
-            local = name.substring( i + 1 );
+            local = name.substring(i + 1);
 
-            if (local.indexOf( ':' ) >= 0)
-                throw new NamespaceErr( "Invalid qualified name, more than one colon" );
+            if (local.indexOf(':') >= 0) {
+                throw new NamespaceErr("Invalid qualified name, more than one colon");
+            }
 
-            validateNcName( local );
+            validateNcName(local);
 
-            if (prefix.equals( "xml" ) && !uri.equals( Locale._xml1998Uri ))
-                throw new NamespaceErr( "Invalid prefix - begins with 'xml'" );
+            if (prefix.equals("xml") && !uri.equals(Locale._xml1998Uri)) {
+                throw new NamespaceErr("Invalid prefix - begins with 'xml'");
+            }
         }
 
-        if (local.length() == 0)
-            throw new NamespaceErr( "Invalid qualified name, no local part specified" );
+        if (local.length() == 0) {
+            throw new NamespaceErr("Invalid qualified name, no local part specified");
+        }
     }
 
-    private static void removeNode ( Dom n )
-    {
+    private static void removeNode(Dom n) {
         assert n.nodeType() != TEXT && n.nodeType() != CDATA;
 
         Cur cFrom = n.tempCur();
@@ -399,28 +466,24 @@ final class DomImpl
         // Next here does two things, it tells me if I can get after the move to remove (all nodes
         // but the root) and it positions me at the place where there are char nodes after.
 
-        if (cFrom.next())
-        {
+        if (cFrom.next()) {
             CharNode fromNodes = cFrom.getCharNodes();
 
-            if (fromNodes != null)
-            {
-                cFrom.setCharNodes( null );
+            if (fromNodes != null) {
+                cFrom.setCharNodes(null);
                 Cur cTo = n.tempCur();
-                cTo.setCharNodes( CharNode.appendNodes( cTo.getCharNodes(), fromNodes ) );
+                cTo.setCharNodes(CharNode.appendNodes(cTo.getCharNodes(), fromNodes));
                 cTo.release();
             }
         }
 
         cFrom.release();
 
-        Cur.moveNode( (Xobj) n, null );
+        Cur.moveNode((Xobj) n, null);
     }
 
-    private abstract static class ElementsNodeList implements NodeList
-    {
-        ElementsNodeList ( Dom root )
-        {
+    private abstract static class ElementsNodeList implements NodeList {
+        ElementsNodeList(Dom root) {
             assert root.nodeType() == DOCUMENT || root.nodeType() == ELEMENT;
 
             _root = root;
@@ -428,24 +491,22 @@ final class DomImpl
             _version = 0;
         }
 
-        public int getLength ( )
-        {
+        public int getLength() {
             ensureElements();
 
             return _elements.size();
         }
 
-        public Node item ( int i )
-        {
+        public Node item(int i) {
             ensureElements();
 
-            return i < 0 || i >= _elements.size() ? (Node) null : (Node) _elements.get( i );
+            return i < 0 || i >= _elements.size() ? (Node) null : (Node) _elements.get(i);
         }
 
-        private void ensureElements ( )
-        {
-            if (_version == _locale.version())
+        private void ensureElements() {
+            if (_version == _locale.version()) {
                 return;
+            }
 
             _version = _locale.version();
 
@@ -453,66 +514,74 @@ final class DomImpl
 
             Locale l = _locale;
 
-            if (l.noSync())         { l.enter(); try { addElements( _root ); } finally { l.exit(); } }
-            else synchronized ( l ) { l.enter(); try { addElements( _root ); } finally { l.exit(); } }
+            if (l.noSync()) {
+                l.enter();
+                try {
+                    addElements(_root);
+                } finally {
+                    l.exit();
+                }
+            } else {
+                synchronized (l) {
+                    l.enter();
+                    try {
+                        addElements(_root);
+                    } finally {
+                        l.exit();
+                    }
+                }
+            }
         }
 
-        private void addElements ( Dom node )
-        {
-            for ( Dom c = firstChild( node ) ; c != null ; c = nextSibling( c ) )
-            {
-                if (c.nodeType() == ELEMENT)
-                {
-                    if (match( c ))
-                        _elements.add( c );
+        private void addElements(Dom node) {
+            for (Dom c = firstChild(node); c != null; c = nextSibling(c)) {
+                if (c.nodeType() == ELEMENT) {
+                    if (match(c)) {
+                        _elements.add(c);
+                    }
 
-                    addElements( c );
+                    addElements(c);
                 }
             }
         }
 
-        protected abstract boolean match ( Dom element );
+        protected abstract boolean match(Dom element);
 
-        private Dom       _root;
-        private Locale    _locale;
-        private long      _version;
+        private Dom _root;
+        private Locale _locale;
+        private long _version;
         private ArrayList _elements;
     }
 
-    private static class ElementsByTagNameNodeList extends ElementsNodeList
-    {
-        ElementsByTagNameNodeList ( Dom root, String name )
-        {
-            super( root );
+    private static class ElementsByTagNameNodeList extends ElementsNodeList {
+        ElementsByTagNameNodeList(Dom root, String name) {
+            super(root);
 
             _name = name;
         }
 
-        protected boolean match ( Dom element )
-        {
-            return _name.equals( "*" ) ? true : _node_getNodeName( element ).equals( _name );
+        protected boolean match(Dom element) {
+            return _name.equals("*") ? true : _node_getNodeName(element).equals(_name);
         }
 
         private String _name;
     }
 
-    private static class ElementsByTagNameNSNodeList extends ElementsNodeList
-    {
-        ElementsByTagNameNSNodeList ( Dom root, String uri, String local )
-        {
-            super( root );
+    private static class ElementsByTagNameNSNodeList extends ElementsNodeList {
+        ElementsByTagNameNSNodeList(Dom root, String uri, String local) {
+            super(root);
 
             _uri = uri == null ? "" : uri;
             _local = local;
         }
 
-        protected boolean match ( Dom element )
-        {
-            if (!(_uri.equals( "*" ) ? true : _node_getNamespaceURI( element ).equals( _uri )))
+        protected boolean match(Dom element) {
+            if (!(_uri.equals("*") ? true : _node_getNamespaceURI(element).equals(_uri))) {
                 return false;
+            }
 
-            return _local.equals( "*" ) ? true : _node_getLocalName( element ).equals( _local );
-           }
+            return _local.equals("*") ? true : _node_getLocalName(element).equals(_local);
+        }
 
         private String _uri;
         private String _local;
@@ -522,19 +591,32 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Document _domImplementation_createDocument (
-        Locale l, String u, String n, DocumentType t )
-    {
+    public static Document _domImplementation_createDocument(
+        Locale l, String u, String n, DocumentType t) {
         Document d;
 
-        if (l.noSync())         { l.enter(); try { return domImplementation_createDocument( l, u, n, t ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { return domImplementation_createDocument( l, u, n, t ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                return domImplementation_createDocument(l, u, n, t);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    return domImplementation_createDocument(l, u, n, t);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
     }
 
-    public static Document domImplementation_createDocument (
-        Locale l, String namespaceURI, String qualifiedName, DocumentType doctype )
-    {
-        validateQualifiedName( qualifiedName, namespaceURI, false );
+    public static Document domImplementation_createDocument(
+        Locale l, String namespaceURI, String qualifiedName, DocumentType doctype) {
+        validateQualifiedName(qualifiedName, namespaceURI, false);
 
         Cur c = l.tempCur();
 
@@ -544,20 +626,18 @@ final class DomImpl
 
         c.next();
 
-        c.createElement( l.makeQualifiedQName( namespaceURI, qualifiedName ) );
+        c.createElement(l.makeQualifiedQName(namespaceURI, qualifiedName));
 
-        if (doctype != null)
-            throw new RuntimeException( "Not impl" );
+        if (doctype != null) {
+            throw new RuntimeException("Not impl");
+        }
 
         c.toParent();
 
-        try
-        {
-            Locale.autoTypeDocument( c, null, null );
-        }
-        catch (XmlException e )
-        {
-            throw new XmlRuntimeException( e );
+        try {
+            Locale.autoTypeDocument(c, null, null);
+        } catch (XmlException e) {
+            throw new XmlRuntimeException(e);
         }
 
         c.release();
@@ -569,22 +649,23 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static boolean _domImplementation_hasFeature ( Locale l, String feature, String version )
-    {
-        if (feature == null)
+    public static boolean _domImplementation_hasFeature(Locale l, String feature, String version) {
+        if (feature == null) {
             return false;
+        }
 
         if (version != null && version.length() > 0 &&
-              !version.equals( "1.0" ) && !version.equals( "2.0" ))
-        {
+            !version.equals("1.0") && !version.equals("2.0")) {
             return false;
         }
 
-        if (feature.equalsIgnoreCase( "core" ))
+        if (feature.equalsIgnoreCase("core")) {
             return true;
+        }
 
-        if (feature.equalsIgnoreCase( "xml" ))
+        if (feature.equalsIgnoreCase("xml")) {
             return true;
+        }
 
         return false;
     }
@@ -593,24 +674,37 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Element _document_getDocumentElement ( Dom d )
-    {
+    public static Element _document_getDocumentElement(Dom d) {
         Locale l = d.locale();
 
         Dom e;
 
-        if (l.noSync())         { l.enter(); try { e = document_getDocumentElement( d ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { e = document_getDocumentElement( d ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                e = document_getDocumentElement(d);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    e = document_getDocumentElement(d);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Element) e;
     }
 
-    public static Dom document_getDocumentElement ( Dom d )
-    {
-        for ( d = firstChild( d ) ; d != null ; d = nextSibling( d ) )
-        {
-            if (d.nodeType() == ELEMENT)
+    public static Dom document_getDocumentElement(Dom d) {
+        for (d = firstChild(d); d != null; d = nextSibling(d)) {
+            if (d.nodeType() == ELEMENT) {
                 return d;
+            }
         }
 
         return null;
@@ -620,20 +714,33 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static DocumentFragment _document_createDocumentFragment ( Dom d )
-    {
+    public static DocumentFragment _document_createDocumentFragment(Dom d) {
         Locale l = d.locale();
 
         Dom f;
 
-        if (l.noSync())         { l.enter(); try { f = document_createDocumentFragment( d ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { f = document_createDocumentFragment( d ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                f = document_createDocumentFragment(d);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    f = document_createDocumentFragment(d);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (DocumentFragment) f;
     }
 
-    public static Dom document_createDocumentFragment ( Dom d )
-    {
+    public static Dom document_createDocumentFragment(Dom d) {
         Cur c = d.locale().tempCur();
 
         c.createDomDocFragRoot();
@@ -649,32 +756,45 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Element _document_createElement ( Dom d, String name )
-    {
+    public static Element _document_createElement(Dom d, String name) {
         Locale l = d.locale();
 
         Dom e;
 
-        if (l.noSync())         { l.enter(); try { e = document_createElement( d, name ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { e = document_createElement( d, name ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                e = document_createElement(d, name);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    e = document_createElement(d, name);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Element) e;
     }
 
-    public static Dom document_createElement ( Dom d, String name )
-    {
-        validateName( name );
+    public static Dom document_createElement(Dom d, String name) {
+        validateName(name);
 
         Locale l = d.locale();
 
         Cur c = l.tempCur();
 
-        c.createElement( l.makeQualifiedQName( "", name ) );
+        c.createElement(l.makeQualifiedQName("", name));
 
         Dom e = c.getDom();
 
         c.release();
-        ((ElementXobj)e)._canHavePrefixUri = false;
+        ((ElementXobj) e)._canHavePrefixUri = false;
         return e;
     }
 
@@ -682,27 +802,40 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Element _document_createElementNS ( Dom d, String uri, String qname )
-    {
+    public static Element _document_createElementNS(Dom d, String uri, String qname) {
         Locale l = d.locale();
 
         Dom e;
 
-        if (l.noSync())         { l.enter(); try { e = document_createElementNS( d, uri, qname ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { e = document_createElementNS( d, uri, qname ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                e = document_createElementNS(d, uri, qname);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    e = document_createElementNS(d, uri, qname);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Element) e;
     }
 
-    public static Dom document_createElementNS ( Dom d, String uri, String qname )
-    {
-        validateQualifiedName( qname, uri, false );
+    public static Dom document_createElementNS(Dom d, String uri, String qname) {
+        validateQualifiedName(qname, uri, false);
 
         Locale l = d.locale();
 
         Cur c = l.tempCur();
 
-        c.createElement( l.makeQualifiedQName( uri, qname ) );
+        c.createElement(l.makeQualifiedQName(uri, qname));
 
         Dom e = c.getDom();
 
@@ -715,32 +848,45 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Attr _document_createAttribute ( Dom d, String name )
-    {
+    public static Attr _document_createAttribute(Dom d, String name) {
         Locale l = d.locale();
 
         Dom a;
 
-        if (l.noSync())         { l.enter(); try { a = document_createAttribute( d, name ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { a = document_createAttribute( d, name ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                a = document_createAttribute(d, name);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    a = document_createAttribute(d, name);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Attr) a;
     }
 
-    public static Dom document_createAttribute ( Dom d, String name )
-    {
-        validateName( name );
+    public static Dom document_createAttribute(Dom d, String name) {
+        validateName(name);
 
         Locale l = d.locale();
 
         Cur c = l.tempCur();
 
-        c.createAttr( l.makeQualifiedQName( "", name ) );
+        c.createAttr(l.makeQualifiedQName("", name));
 
         Dom e = c.getDom();
 
         c.release();
-        ((AttrXobj)e)._canHavePrefixUri = false;
+        ((AttrXobj) e)._canHavePrefixUri = false;
         return e;
     }
 
@@ -748,27 +894,40 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Attr _document_createAttributeNS ( Dom d, String uri, String qname )
-    {
+    public static Attr _document_createAttributeNS(Dom d, String uri, String qname) {
         Locale l = d.locale();
 
         Dom a;
 
-        if (l.noSync())         { l.enter(); try { a = document_createAttributeNS( d, uri, qname ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { a = document_createAttributeNS( d, uri, qname ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                a = document_createAttributeNS(d, uri, qname);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    a = document_createAttributeNS(d, uri, qname);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Attr) a;
     }
 
-    public static Dom document_createAttributeNS ( Dom d, String uri, String qname )
-    {
-        validateQualifiedName( qname, uri, true );
+    public static Dom document_createAttributeNS(Dom d, String uri, String qname) {
+        validateQualifiedName(qname, uri, true);
 
         Locale l = d.locale();
 
         Cur c = l.tempCur();
 
-        c.createAttr( l.makeQualifiedQName( uri, qname ) );
+        c.createAttr(l.makeQualifiedQName(uri, qname));
 
         Dom e = c.getDom();
 
@@ -781,20 +940,33 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Comment _document_createComment ( Dom d, String data )
-    {
+    public static Comment _document_createComment(Dom d, String data) {
         Locale l = d.locale();
 
         Dom c;
 
-        if (l.noSync())         { l.enter(); try { c = document_createComment( d, data ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { c = document_createComment( d, data ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                c = document_createComment(d, data);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    c = document_createComment(d, data);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Comment) c;
     }
 
-    public static Dom document_createComment ( Dom d, String data )
-    {
+    public static Dom document_createComment(Dom d, String data) {
         Locale l = d.locale();
 
         Cur c = l.tempCur();
@@ -803,10 +975,9 @@ final class DomImpl
 
         Dom comment = c.getDom();
 
-        if (data != null)
-        {
+        if (data != null) {
             c.next();
-            c.insertString( data );
+            c.insertString(data);
         }
 
         c.release();
@@ -818,44 +989,60 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static ProcessingInstruction _document_createProcessingInstruction ( Dom d, String target, String data )
-    {
+    public static ProcessingInstruction _document_createProcessingInstruction(Dom d, String target, String data) {
         Locale l = d.locale();
 
         Dom pi;
 
-        if (l.noSync())         { l.enter(); try { pi = document_createProcessingInstruction( d, target, data ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { pi = document_createProcessingInstruction( d, target, data ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                pi = document_createProcessingInstruction(d, target, data);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    pi = document_createProcessingInstruction(d, target, data);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (ProcessingInstruction) pi;
     }
 
-    public static Dom document_createProcessingInstruction ( Dom d, String target, String data )
-    {
-        if (target == null)
-            throw new IllegalArgumentException( "Target is null" );
+    public static Dom document_createProcessingInstruction(Dom d, String target, String data) {
+        if (target == null) {
+            throw new IllegalArgumentException("Target is null");
+        }
 
-        if (target.length() == 0)
-            throw new IllegalArgumentException( "Target is empty" );
+        if (target.length() == 0) {
+            throw new IllegalArgumentException("Target is empty");
+        }
 
-        if (!XMLChar.isValidName( target ))
-            throw new InvalidCharacterError( "Target has an invalid character" );
+        if (!XMLChar.isValidName(target)) {
+            throw new InvalidCharacterError("Target has an invalid character");
+        }
 
-        if (Locale.beginsWithXml( target ) && target.length() == 3)
-            throw new InvalidCharacterError( "Invalid target - is 'xml'" );
+        if (Locale.beginsWithXml(target) && target.length() == 3) {
+            throw new InvalidCharacterError("Invalid target - is 'xml'");
+        }
 
         Locale l = d.locale();
 
         Cur c = l.tempCur();
 
-        c.createProcinst( target );
+        c.createProcinst(target);
 
         Dom pi = c.getDom();
 
-        if (data != null)
-        {
+        if (data != null) {
             c.next();
-            c.insertString( data );
+            c.insertString(data);
         }
 
         c.release();
@@ -867,19 +1054,18 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static CDATASection _document_createCDATASection ( Dom d, String data )
-    {
-        return (CDATASection) document_createCDATASection( d, data );
+    public static CDATASection _document_createCDATASection(Dom d, String data) {
+        return (CDATASection) document_createCDATASection(d, data);
     }
 
-    public static Dom document_createCDATASection ( Dom d, String data )
-    {
+    public static Dom document_createCDATASection(Dom d, String data) {
         TextNode t = d.locale().createCdataNode();
 
-        if (data == null)
+        if (data == null) {
             data = "";
+        }
 
-        t.setChars( data, 0, data.length() );
+        t.setChars(data, 0, data.length());
 
         return t;
     }
@@ -888,19 +1074,18 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Text _document_createTextNode ( Dom d, String data )
-    {
-        return (Text) document_createTextNode( d, data );
+    public static Text _document_createTextNode(Dom d, String data) {
+        return (Text) document_createTextNode(d, data);
     }
 
-    public static CharNode document_createTextNode ( Dom d, String data )
-    {
+    public static CharNode document_createTextNode(Dom d, String data) {
         TextNode t = d.locale().createTextNode();
 
-        if (data == null)
+        if (data == null) {
             data = "";
+        }
 
-        t.setChars( data, 0, data.length() );
+        t.setChars(data, 0, data.length());
 
         return t;
     }
@@ -909,60 +1094,83 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static EntityReference _document_createEntityReference ( Dom d, String name )
-    {
-        throw new RuntimeException( "Not implemented" );
+    public static EntityReference _document_createEntityReference(Dom d, String name) {
+        throw new RuntimeException("Not implemented");
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Element _document_getElementById ( Dom d, String elementId )
-    {
-        throw new RuntimeException( "Not implemented" );
+    public static Element _document_getElementById(Dom d, String elementId) {
+        throw new RuntimeException("Not implemented");
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static NodeList _document_getElementsByTagName ( Dom d, String name )
-    {
+    public static NodeList _document_getElementsByTagName(Dom d, String name) {
         Locale l = d.locale();
 
-        if (l.noSync())         { l.enter(); try { return document_getElementsByTagName( d, name ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { return document_getElementsByTagName( d, name ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                return document_getElementsByTagName(d, name);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    return document_getElementsByTagName(d, name);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
     }
 
-    public static NodeList document_getElementsByTagName ( Dom d, String name )
-    {
-        return new ElementsByTagNameNodeList( d, name );
+    public static NodeList document_getElementsByTagName(Dom d, String name) {
+        return new ElementsByTagNameNodeList(d, name);
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static NodeList _document_getElementsByTagNameNS ( Dom d, String uri, String local )
-    {
+    public static NodeList _document_getElementsByTagNameNS(Dom d, String uri, String local) {
         Locale l = d.locale();
 
-        if (l.noSync())         { l.enter(); try { return document_getElementsByTagNameNS( d, uri, local ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { return document_getElementsByTagNameNS( d, uri, local ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                return document_getElementsByTagNameNS(d, uri, local);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    return document_getElementsByTagNameNS(d, uri, local);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
     }
 
-    public static NodeList document_getElementsByTagNameNS ( Dom d, String uri, String local )
-    {
-        return new ElementsByTagNameNSNodeList( d, uri, local );
+    public static NodeList document_getElementsByTagNameNS(Dom d, String uri, String local) {
+        return new ElementsByTagNameNSNodeList(d, uri, local);
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static DOMImplementation _document_getImplementation ( Dom d )
-    {
+    public static DOMImplementation _document_getImplementation(Dom d) {
         return (DOMImplementation) d.locale();
     }
 
@@ -970,8 +1178,7 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _document_importNode ( Dom d, Node n, boolean deep )
-    {
+    public static Node _document_importNode(Dom d, Node n, boolean deep) {
         Locale l = d.locale();
         Dom i;
 
@@ -981,128 +1188,137 @@ final class DomImpl
 //        else
 // TODO -- I'm importing my own nodes through DOM methods!  -- make this faster
         {
-            if (l.noSync())         { l.enter(); try { i = document_importNode( d, n, deep ); } finally { l.exit(); } }
-            else synchronized ( l ) { l.enter(); try { i = document_importNode( d, n, deep ); } finally { l.exit(); } }
+            if (l.noSync()) {
+                l.enter();
+                try {
+                    i = document_importNode(d, n, deep);
+                } finally {
+                    l.exit();
+                }
+            } else {
+                synchronized (l) {
+                    l.enter();
+                    try {
+                        i = document_importNode(d, n, deep);
+                    } finally {
+                        l.exit();
+                    }
+                }
+            }
         }
 
         return (Node) i;
     }
 
-    public static Dom document_importNode ( Dom d, Node n, boolean deep )
-    {
-        if (n == null)
+    public static Dom document_importNode(Dom d, Node n, boolean deep) {
+        if (n == null) {
             return null;
+        }
 
         Dom i;
 
         boolean copyChildren = false;
 
-        switch ( n.getNodeType() )
-        {
-        case DOCUMENT :
-            throw new NotSupportedError( "Document nodes may not be imported" );
+        switch (n.getNodeType()) {
+            case DOCUMENT:
+                throw new NotSupportedError("Document nodes may not be imported");
+
+            case DOCTYPE:
+                throw new NotSupportedError("Document type nodes may not be imported");
+
+            case ELEMENT: {
+                String local = n.getLocalName();
+
+                if (local == null || local.length() == 0) {
+                    i = document_createElement(d, n.getNodeName());
+                } else {
+                    String prefix = n.getPrefix();
+                    String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
+                    String uri = n.getNamespaceURI();
+
+                    if (uri == null || uri.length() == 0) {
+                        i = document_createElement(d, name);
+                    } else {
+                        i = document_createElementNS(d, uri, name);
+                    }
+                }
 
-        case DOCTYPE :
-            throw new NotSupportedError( "Document type nodes may not be imported" );
+                NamedNodeMap attrs = n.getAttributes();
 
-        case ELEMENT :
-        {
-            String local = n.getLocalName();
+                for (int a = 0; a < attrs.getLength(); a++) {
+                    attributes_setNamedItem(i, document_importNode(d, attrs.item(a), true));
+                }
 
-            if (local == null || local.length() == 0)
-                i = document_createElement( d, n.getNodeName() );
-            else
-            {
-                String prefix = n.getPrefix();
-                String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
-                String uri = n.getNamespaceURI();
+                copyChildren = deep;
 
-                if (uri == null || uri.length() == 0)
-                    i = document_createElement( d, name );
-                else
-                    i = document_createElementNS( d, uri, name );
+                break;
             }
 
-            NamedNodeMap attrs = n.getAttributes();
-
-            for ( int a = 0 ; a < attrs.getLength() ; a++ )
-                attributes_setNamedItem( i, document_importNode( d, attrs.item( a ), true ) );
+            case ATTR: {
+                String local = n.getLocalName();
 
-            copyChildren = deep;
-
-            break;
-        }
-
-        case ATTR :
-        {
-            String local = n.getLocalName();
+                if (local == null || local.length() == 0) {
+                    i = document_createAttribute(d, n.getNodeName());
+                } else {
+                    String prefix = n.getPrefix();
+                    String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
+                    String uri = n.getNamespaceURI();
+
+                    if (uri == null || uri.length() == 0) {
+                        i = document_createAttribute(d, name);
+                    } else {
+                        i = document_createAttributeNS(d, uri, name);
+                    }
+                }
 
-            if (local == null || local.length() == 0)
-                i = document_createAttribute( d, n.getNodeName() );
-            else
-            {
-                String prefix = n.getPrefix();
-                String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
-                String uri = n.getNamespaceURI();
+                copyChildren = true;
 
-                if (uri == null || uri.length() == 0)
-                    i = document_createAttribute( d, name );
-                else
-                    i = document_createAttributeNS( d, uri, name );
+                break;
             }
 
-            copyChildren = true;
-
-            break;
-        }
-
-        case DOCFRAG :
-        {
-            i = document_createDocumentFragment( d );
+            case DOCFRAG: {
+                i = document_createDocumentFragment(d);
 
-            copyChildren = deep;
+                copyChildren = deep;
 
-            break;
-        }
+                break;
+            }
 
-        case PROCINST :
-        {
-            i = document_createProcessingInstruction( d, n.getNodeName(), n.getNodeValue() );
-            break;
-        }
+            case PROCINST: {
+                i = document_createProcessingInstruction(d, n.getNodeName(), n.getNodeValue());
+                break;
+            }
 
-        case COMMENT :
-        {
-            i = document_createComment( d, n.getNodeValue() );
-            break;
-        }
+            case COMMENT: {
+                i = document_createComment(d, n.getNodeValue());
+                break;
+            }
 
-        case TEXT :
-        {
-            i = document_createTextNode( d, n.getNodeValue() );
-            break;
-        }
+            case TEXT: {
+                i = document_createTextNode(d, n.getNodeValue());
+                break;
+            }
 
-        case CDATA :
-        {
-            i = document_createCDATASection( d, n.getNodeValue() );
-            break;
-        }
+            case CDATA: {
+                i = document_createCDATASection(d, n.getNodeValue());
+                break;
+            }
 
-        case ENTITYREF :
-        case ENTITY :
-        case NOTATION :
-            throw new RuntimeException( "Not impl" );
+            case ENTITYREF:
+            case ENTITY:
+            case NOTATION:
+                throw new RuntimeException("Not impl");
 
-        default : throw new RuntimeException( "Unknown kind" );
+            default:
+                throw new RuntimeException("Unknown kind");
         }
 
-        if (copyChildren)
-        {
+        if (copyChildren) {
             NodeList children = n.getChildNodes();
 
-            for ( int c = 0 ; c < children.getLength() ; c++ )
-                node_insertBefore( i, document_importNode( d, children.item( c ), true ), null);
+            for (int c = 0; c < children.getLength(); c++) {
+                node_insertBefore(i, document_importNode(d, children.item(c), true), null);
+            }
         }
 
         return i;
@@ -1112,20 +1328,33 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static DocumentType _document_getDoctype ( Dom d )
-    {
+    public static DocumentType _document_getDoctype(Dom d) {
         Locale l = d.locale();
 
         Dom dt;
 
-        if (l.noSync())         { l.enter(); try { dt = document_getDoctype( d ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { dt = document_getDoctype( d ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                dt = document_getDoctype(d);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    dt = document_getDoctype(d);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (DocumentType) dt;
     }
 
-    public static Dom document_getDoctype ( Dom d )
-    {
+    public static Dom document_getDoctype(Dom d) {
         return null;
     }
 
@@ -1133,27 +1362,40 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Document _node_getOwnerDocument ( Dom n )
-    {
+    public static Document _node_getOwnerDocument(Dom n) {
         Locale l = n.locale();
 
         Dom d;
 
-        if (l.noSync())         { l.enter(); try { d = node_getOwnerDocument( n ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { d = node_getOwnerDocument( n ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                d = node_getOwnerDocument(n);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    d = node_getOwnerDocument(n);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Document) d;
     }
 
-    public static Dom node_getOwnerDocument ( Dom n )
-    {
-        if (n.nodeType() == DOCUMENT)
+    public static Dom node_getOwnerDocument(Dom n) {
+        if (n.nodeType() == DOCUMENT) {
             return null;
+        }
 
         Locale l = n.locale();
 
-        if (l._ownerDoc == null)
-        {
+        if (l._ownerDoc == null) {
             Cur c = l.tempCur();
             c.createDomDocumentRoot();
             l._ownerDoc = c.getDom();
@@ -1167,64 +1409,76 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_getParentNode ( Dom n )
-    {
+    public static Node _node_getParentNode(Dom n) {
         Locale l = n.locale();
 
         Dom p;
 
-        if (l.noSync())         { l.enter(); try { p = node_getParentNode( n ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { p = node_getParentNode( n ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                p = node_getParentNode(n);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    p = node_getParentNode(n);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Node) p;
     }
 
-    public static Dom node_getParentNode ( Dom n )
-    {
+    public static Dom node_getParentNode(Dom n) {
         Cur c = null;
 
-        switch ( n.nodeType() )
-        {
-        case DOCUMENT :
-        case DOCFRAG :
-        case ATTR :
-            break;
-
-        case PROCINST :
-        case COMMENT :
-        case ELEMENT :
-        {
-            if (!(c = n.tempCur()).toParentRaw())
-            {
-                c.release();
-                c = null;
-            }
+        switch (n.nodeType()) {
+            case DOCUMENT:
+            case DOCFRAG:
+            case ATTR:
+                break;
 
-            break;
-        }
+            case PROCINST:
+            case COMMENT:
+            case ELEMENT: {
+                if (!(c = n.tempCur()).toParentRaw()) {
+                    c.release();
+                    c = null;
+                }
 
-        case TEXT :
-        case CDATA :
-        {
-            if ((c = n.tempCur()) != null)
-                c.toParent();
+                break;
+            }
 
-            break;
-        }
+            case TEXT:
+            case CDATA: {
+                if ((c = n.tempCur()) != null) {
+                    c.toParent();
+                }
 
-        case ENTITYREF :
-            throw new RuntimeException( "Not impl" );
+                break;
+            }
+
+            case ENTITYREF:
+                throw new RuntimeException("Not impl");
 
-        case ENTITY :
-        case DOCTYPE :
-        case NOTATION :
-            throw new RuntimeException( "Not impl" );
+            case ENTITY:
+            case DOCTYPE:
+            case NOTATION:
+                throw new RuntimeException("Not impl");
 
-        default : throw new RuntimeException( "Unknown kind" );
+            default:
+                throw new RuntimeException("Unknown kind");
         }
 
-        if (c == null)
+        if (c == null) {
             return null;
+        }
 
         Dom d = c.getDom();
 
@@ -1237,73 +1491,79 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_getFirstChild ( Dom n ) {
+    public static Node _node_getFirstChild(Dom n) {
         Locale l = n.locale();
 
         Dom fc;
         assert n instanceof Xobj;
-        Xobj node = (Xobj)n;
-        if (!node.isVacant())
-        {
-            if (node.isFirstChildPtrDomUsable())
+        Xobj node = (Xobj) n;
+        if (!node.isVacant()) {
+            if (node.isFirstChildPtrDomUsable()) {
                 return (Node) node._firstChild;
+            }
             Xobj lastAttr = node.lastAttr();
             if (lastAttr != null &&
-                lastAttr.isNextSiblingPtrDomUsable())
+                lastAttr.isNextSiblingPtrDomUsable()) {
                 return (NodeXobj) lastAttr._nextSibling;
-            if (node.isExistingCharNodesValueUsable())
+            }
+            if (node.isExistingCharNodesValueUsable()) {
                 return node._charNodesValue;
+            }
+        }
+        if (l.noSync()) {
+            fc = node_getFirstChild(n);
+        } else {
+            synchronized (l) {
+                fc = node_getFirstChild(n);
+            }
         }
-        if (l.noSync())         {  fc = node_getFirstChild( n );  }
-        else synchronized ( l ) {  fc = node_getFirstChild( n ); }
 
         return (Node) fc;
     }
 
-    public static Dom node_getFirstChild ( Dom n )
-    {
+    public static Dom node_getFirstChild(Dom n) {
         Dom fc = null;
 
-        switch ( n.nodeType() )
-        {
-        case TEXT :
-        case CDATA :
-        case PROCINST :
-        case COMMENT :
-            break;
-
-        case ENTITYREF :
-            throw new RuntimeException( "Not impl" );
-
-        case ENTITY :
-        case DOCTYPE :
-        case NOTATION :
-            throw new RuntimeException( "Not impl" );
-
-        case ELEMENT :
-        case DOCUMENT :
-        case DOCFRAG :
-        case ATTR :
-        {
+        switch (n.nodeType()) {
+            case TEXT:
+            case CDATA:
+            case PROCINST:
+            case COMMENT:
+                break;
 
-            Xobj node = (Xobj) n;
-            node.ensureOccupancy();
-            if (node.isFirstChildPtrDomUsable())
-                return (NodeXobj) node._firstChild;
-            Xobj lastAttr = node.lastAttr();
-            if (lastAttr != null)
-            {
-                if (lastAttr.isNextSiblingPtrDomUsable())
-                    return (NodeXobj) lastAttr._nextSibling;
-                else if (lastAttr.isCharNodesAfterUsable())
-                    return (CharNode) lastAttr._charNodesAfter;
-            }
-            if (node.isCharNodesValueUsable())
-                return node._charNodesValue;
+            case ENTITYREF:
+                throw new RuntimeException("Not impl");
 
+            case ENTITY:
+            case DOCTYPE:
+            case NOTATION:
+                throw new RuntimeException("Not impl");
+
+            case ELEMENT:
+            case DOCUMENT:
+            case DOCFRAG:
+            case ATTR: {
 
-            break;
-        }
+                Xobj node = (Xobj) n;
+                node.ensureOccupancy();
+                if (node.isFirstChildPtrDomUsable()) {
+                    return (NodeXobj) node._firstChild;
+                }
+                Xobj lastAttr = node.lastAttr();
+                if (lastAttr != null) {
+                    if (lastAttr.isNextSiblingPtrDomUsable()) {
+                        return (NodeXobj) lastAttr._nextSibling;
+                    } else if (lastAttr.isCharNodesAfterUsable()) {
+                        return (CharNode) lastAttr._charNodesAfter;
+                    }
+                }
+                if (node.isCharNodesValueUsable()) {
+                    return node._charNodesValue;
+                }
+
+
+                break;
+            }
         }
 
         // TODO - handle entity refs here ...
@@ -1315,40 +1575,52 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_getLastChild ( Dom n )
-    {
+    public static Node _node_getLastChild(Dom n) {
         Locale l = n.locale();
 
         Dom lc;
 
-        if (l.noSync())         { l.enter(); try { lc = node_getLastChild( n ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { lc = node_getLastChild( n ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                lc = node_getLastChild(n);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    lc = node_getLastChild(n);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
 
         return (Node) lc;
     }
 
-    public static Dom node_getLastChild ( Dom n )
-    {
-        switch ( n.nodeType() )
-        {
-            case TEXT :
-            case CDATA :
-            case PROCINST :
-            case COMMENT :
+    public static Dom node_getLastChild(Dom n) {
+        switch (n.nodeType()) {
+            case TEXT:
+            case CDATA:
+            case PROCINST:
+            case COMMENT:
                 return null;
 
-            case ENTITYREF :
-                throw new RuntimeException( "Not impl" );
+            case ENTITYREF:
+                throw new RuntimeException("Not impl");
 
-            case ENTITY :
-            case DOCTYPE :
-            case NOTATION :
-                throw new RuntimeException( "Not impl" );
-
-            case ELEMENT :
-            case DOCUMENT :
-            case DOCFRAG :
-            case ATTR :
+            case ENTITY:
+            case DOCTYPE:
+            case NOTATION:
+                throw new RuntimeException("Not impl");
+
+            case ELEMENT:
+            case DOCUMENT:
+            case DOCFRAG:
+            case ATTR:
                 break;
         }
 
@@ -1357,25 +1629,23 @@ final class DomImpl
 
         Cur c = n.tempCur();
 
-        if (c.toLastChild())
-        {
+        if (c.toLastChild()) {
             lc = c.getDom();
 
             c.skip();
 
-            if ((nodes = c.getCharNodes()) != null)
+            if ((nodes = c.getCharNodes()) != null) {
                 lc = null;
-        }
-        else
-        {
+            }
+        } else {
             c.next();
             nodes = c.getCharNodes();
         }
 
-        if (lc == null && nodes != null)
-        {
-            while ( nodes._next != null )
+        if (lc == null && nodes != null) {
+            while (nodes._next != null) {
                 nodes = nodes._next;
+            }
 
             lc = nodes;
         }
@@ -1391,85 +1661,89 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_getNextSibling ( Dom n )
-    {
+    public static Node _node_getNextSibling(Dom n) {
         Locale l = n.locale();
 
         Dom ns;
 
-        if (l.noSync())         {  ns = node_getNextSibling( n );  }
-        else synchronized ( l ) {  ns = node_getNextSibling( n );  }
+        if (l.noSync()) {
+            ns = node_getNextSibling(n);
+        } else {
+            synchronized (l) {
+                ns = node_getNextSibling(n);
+            }
+        }
 
         return (Node) ns;
     }
 
-    public static Dom node_getNextSibling ( Dom n )
-    {
+    public static Dom node_getNextSibling(Dom n) {
         Dom ns = null;
 
-        switch ( n.nodeType() )
-        {
-        case DOCUMENT :
-        case DOCFRAG :
-        case ATTR :
-            break;
+        switch (n.nodeType()) {
+            case DOCUMENT:
+            case DOCFRAG:
+            case ATTR:
+                break;
 
-        case TEXT :
-        case CDATA :
-        {
-            CharNode cn = (CharNode) n;
-            //if src is attr & next is null , ret null;
-            //if src is container and
-            // a) this node is aftertext && src._nextSib = null; ret null
-            // b) this node is value && src._fc = null; ret null
+            case TEXT:
+            case CDATA: {
+                CharNode cn = (CharNode) n;
+                //if src is attr & next is null , ret null;
+                //if src is container and
+                // a) this node is aftertext && src._nextSib = null; ret null
+                // b) this node is value && src._fc = null; ret null
 
 
-            if (! (cn.getObject() instanceof Xobj) )
-                return null;
-            Xobj src = (Xobj) cn.getObject();
-            //if src is attr this node is always value and
-            // next is always the next ptr of the attr
-            src._charNodesAfter =
-                                    Cur.updateCharNodes( src._locale, src, src._charNodesAfter, src._cchAfter );
-
-            src._charNodesValue =
-                                  Cur.updateCharNodes( src._locale, src, src._charNodesValue, src._cchValue );
-
-            if (cn._next != null)
-            {
-                ns = cn._next;
+                if (!(cn.getObject() instanceof Xobj)) {
+                    return null;
+                }
+                Xobj src = (Xobj) cn.getObject();
+                //if src is attr this node is always value and
+                // next is always the next ptr of the attr
+                src._charNodesAfter =
+                    Cur.updateCharNodes(src._locale, src, src._charNodesAfter, src._cchAfter);
+
+                src._charNodesValue =
+                    Cur.updateCharNodes(src._locale, src, src._charNodesValue, src._cchValue);
+
+                if (cn._next != null) {
+                    ns = cn._next;
+                    break;
+                }
+                boolean isThisNodeAfterText = cn.isNodeAftertext();
+
+                if (isThisNodeAfterText) {
+                    ns = (NodeXobj) src._nextSibling;
+                } else     //srcValue or attribute source
+                {
+                    ns = (NodeXobj) src._firstChild;
+                }
                 break;
-            }
-            boolean isThisNodeAfterText = cn.isNodeAftertext();
 
-            if (isThisNodeAfterText)
-                ns = (NodeXobj) src._nextSibling;
-            else     //srcValue or attribute source
-                ns = (NodeXobj) src._firstChild;
-            break;
+            }
 
-        }
+            case PROCINST:
+            case COMMENT:
+            case ELEMENT: {
+                assert n instanceof Xobj : "PI, Comments and Elements always backed up by Xobj";
+                Xobj node = (Xobj) n;
+                node.ensureOccupancy();
+                if (node.isNextSiblingPtrDomUsable()) {
+                    return
+                        (NodeXobj) node._nextSibling;
+                }
+                if (node.isCharNodesAfterUsable()) {
+                    return node._charNodesAfter;
+                }
+                break;
+            }
 
-        case PROCINST :
-        case COMMENT :
-        case ELEMENT :
-        {
-            assert n instanceof Xobj: "PI, Comments and Elements always backed up by Xobj";
-            Xobj node = (Xobj) n;
-            node.ensureOccupancy();
-            if (node.isNextSiblingPtrDomUsable())
-                return
-                    (NodeXobj) node._nextSibling;
-            if (node.isCharNodesAfterUsable())
-                return node._charNodesAfter;
-            break;
-        }
-
-        case ENTITY :
-        case NOTATION :
-        case ENTITYREF :
-        case DOCTYPE :
-            throw new RuntimeException( "Not implemented" );
+            case ENTITY:
+            case NOTATION:
+            case ENTITYREF:
+            case DOCTYPE:
+                throw new RuntimeException("Not implemented");
         }
 
         // TODO - handle entity refs here ...
@@ -1481,35 +1755,40 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_getPreviousSibling ( Dom n )
-    {
+    public static Node _node_getPreviousSibling(Dom n) {
         Locale l = n.locale();
 
         Dom ps;
 
-        if (l.noSync())         {  ps = node_getPreviousSibling( n ); }
-        else synchronized ( l ) {  ps = node_getPreviousSibling( n ); }
+        if (l.noSync()) {
+            ps = node_getPreviousSibling(n);
+        } else {
+            synchronized (l) {
+                ps = node_getPreviousSibling(n);
+            }
+        }
 
         return (Node) ps;
     }
 
-    public static Dom node_getPreviousSibling ( Dom n )
-    {
+    public static Dom node_getPreviousSibling(Dom n) {
         Dom prev;
         switch (n.nodeType()) {
             case TEXT:
             case CDATA: {
-                assert n instanceof CharNode: "Text/CData should be a CharNode";
+                assert n instanceof CharNode : "Text/CData should be a CharNode";
                 CharNode node = (CharNode) n;
-                if (!(node.getObject() instanceof Xobj))
+                if (!(node.getObject() instanceof Xobj)) {
                     return null;
+                }
                 Xobj src = (Xobj) node.getObject();
                 src.ensureOccupancy();
                 boolean isThisNodeAfterText = node.isNodeAftertext();
                 prev = node._prev;
-                if (prev == null)
+                if (prev == null) {
                     prev = isThisNodeAfterText ? (Dom) src :
                         src._charNodesValue;
+                }
                 break;
             }
             default: {
@@ -1533,20 +1812,32 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static boolean _node_hasAttributes ( Dom n )
-    {
+    public static boolean _node_hasAttributes(Dom n) {
         Locale l = n.locale();
 
-        if (l.noSync())         { l.enter(); try { return node_hasAttributes( n ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { return node_hasAttributes( n ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                return node_hasAttributes(n);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    return node_hasAttributes(n);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
     }
 
-    public static boolean node_hasAttributes ( Dom n )
-    {
+    public static boolean node_hasAttributes(Dom n) {
         boolean hasAttrs = false;
 
-        if (n.nodeType() == ELEMENT)
-        {
+        if (n.nodeType() == ELEMENT) {
             Cur c = n.tempCur();
 
             hasAttrs = c.hasAttrs();
@@ -1561,45 +1852,56 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static boolean _node_isSupported ( Dom n, String feature, String version )
-    {
-        return _domImplementation_hasFeature( n.locale(), feature, version );
+    public static boolean _node_isSupported(Dom n, String feature, String version) {
+        return _domImplementation_hasFeature(n.locale(), feature, version);
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static void _node_normalize ( Dom n )
-    {
+    public static void _node_normalize(Dom n) {
         Locale l = n.locale();
 
-        if (l.noSync())         { l.enter(); try { node_normalize( n ); } finally { l.exit(); } }
-        else synchronized ( l ) { l.enter(); try { node_normalize( n ); } finally { l.exit(); } }
+        if (l.noSync()) {
+            l.enter();
+            try {
+                node_normalize(n);
+            } finally {
+                l.exit();
+            }
+        } else {
+            synchronized (l) {
+                l.enter();
+                try {
+                    node_normalize(n);
+                } finally {
+                    l.exit();
+                }
+            }
+        }
     }
 
-    public static void node_normalize ( Dom n )
-    {
-        switch ( n.nodeType() )
-        {
-            case TEXT :
-            case CDATA :
-            case PROCINST :
-            case COMMENT :
+    public static void node_normalize(Dom n) {
+        switch (n.nodeType()) {
+            case TEXT:
+            case CDATA:
+            case PROCINST:
+            case COMMENT:
                 return;
 
-            case ENTITYREF :
-                throw new RuntimeException( "Not impl" );
+            case ENTITYREF:
+                throw new RuntimeException("Not impl");
 
-            case ENTITY :
-            case DOCTYPE :
-            case NOTATION :
-                throw new RuntimeException( "Not impl" );
-
-            case ELEMENT :
-            case DOCUMENT :
-            case DOCFRAG :
-            case ATTR :
+            case ENTITY:
+            case DOCTYPE:
+            case NOTATION:
+                throw new RuntimeException("Not impl");
+
+            case ELEMENT:
+            case DOCUMENT:
+            case DOCFRAG:
+            case ATTR:
                 break;
         }
 
@@ -1607,37 +1909,30 @@ final class DomImpl
 
         c.push();
 
-        do
-        {
+        do {
             c.nextWithAttrs();
 
             CharNode cn = c.getCharNodes();
 
-            if (cn != null)
-            {
-                if (!c.isText())
-                {
-                    while ( cn != null )
-                    {
-                        cn.setChars( null, 0, 0 );
-                        cn = CharNode.remove( cn, cn );
+            if (cn != null) {
+                if (!c.isText()) {
+                    while (cn != null) {
+                        cn.setChars(null, 0, 0);
+                        cn = CharNode.remove(cn, cn);
                     }
-                }
-                else if (cn._next != null)
-                {
-                    while ( cn._next != null )
-                    {
-                        cn.setChars( null, 0, 0 );
-                        cn = CharNode.remove( cn, cn._next );
+                } else if (cn._next != null) {
+                    while (cn._next != null) {
+                        cn.setChars(null, 0, 0);
+                        cn = CharNode.remove(cn, cn._next);
                     }
 
                     cn._cch = Integer.MAX_VALUE;
                 }
 
-                c.setCharNodes( cn );
+                c.setCharNodes(cn);
             }
         }
-        while ( ! c.isAtEndOfLastPush() );
+        while (!c.isAtEndOfLastPush());
 
         c.release();
 
@@ -1648,68 +1943,81 @@ final class DomImpl
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static boolean _node_hasChildNodes ( Dom n ) {
+    public static boolean _node_hasChildNodes(Dom n) {
         // TODO - make this faster
-        return n instanceof Xobj &&  _node_getFirstChild( n ) != null;
+        return n instanceof Xobj && _node_getFirstChild(n) != null;
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_appendChild ( Dom p, Node newChild )
-    {
-        return _node_insertBefore( p, newChild, null );
+    public static Node _node_appendChild(Dom p, Node newChild) {
+        return _node_insertBefore(p, newChild, null);
     }
 
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////
 
-    public static Node _node_replaceChild ( Dom p, Node newChild, Node oldChild )
-    {
+    public static Node _node_replaceChild(Dom p, Node newChild, Node oldChild) {
         Locale l = p.locale();
 
-        if (newChild == null)
-            throw new IllegalArgumentException( "Child to add is null" );
+        if (newChild == null) {
+            throw new IllegalArgumentException("Child to add is null");
+        }
 
-        if (oldChild == null)
-            throw new NotFoundErr( "Child to replace is null" );
+        if (oldChild == null) {
+            throw new NotFoundErr("Child to replace is null");
+        }
 
         Dom nc;
 
-        if (!(newChild instanceof Dom) || (nc = (Dom) newChild).locale() != l)
-            throw new WrongDocumentErr( "Child to add is from another document" );

[... 5295 lines stripped ...]


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message