jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java
author mullan
Mon, 26 Sep 2011 17:20:45 -0700
changeset 10694 cf59e2badd14
parent 1337 e8d6cef36199
child 18780 f47b920867e7
permissions -rw-r--r--
7088502: Security libraries don't build with javac -Werror Summary: Changes to files in src/share/classes/com/sun/org/apache/xml/internal/security and its subpackages to remove warnings Reviewed-by: mullan Contributed-by: kurchi.subhra.hazra@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * Copyright  1999-2004 The Apache Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *  Licensed under the Apache License, Version 2.0 (the "License");
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *  you may not use this file except in compliance with the License.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *  You may obtain a copy of the License at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *  Unless required by applicable law or agreed to in writing, software
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *  distributed under the License is distributed on an "AS IS" BASIS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *  See the License for the specific language governing permissions and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *  limitations under the License.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
package com.sun.org.apache.xml.internal.security.signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
import java.io.StringWriter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
import java.io.Writer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.org.apache.xml.internal.security.c14n.helper.AttrCompare;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import org.w3c.dom.Attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import org.w3c.dom.Comment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import org.w3c.dom.Document;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import org.w3c.dom.Element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import org.w3c.dom.NamedNodeMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import org.w3c.dom.Node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import org.w3c.dom.ProcessingInstruction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Class XMLSignatureInputDebugger
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    42
 * @author $Author: mullan $
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
    43
 * @version $Revision: 1.3 $
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class XMLSignatureInputDebugger {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        /** Field _xmlSignatureInput */
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
    50
        private Set<Node> _xpathNodeSet;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
    52
        private Set<String> _inclusiveNamespaces;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        /** Field _doc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        private Document _doc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        /** Field _writer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        private Writer _writer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        // J-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        // public static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        // \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><style
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        // type=\"text/css\"><!-- .INCLUDED { color: #000000; background-color:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        // #FFFFFF; font-weight: bold; } .EXCLUDED { color: #666666;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        // background-color: #999999; } .INCLUDEDINCLUSIVENAMESPACE { color:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        // #0000FF; background-color: #FFFFFF; font-weight: bold; font-style:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        // italic; } .EXCLUDEDINCLUSIVENAMESPACE { color: #0000FF; background-color:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        // #999999; font-style: italic; } --> </style> </head><body
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        // bgcolor=\"#999999\"><pre>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        /** The HTML Prefix* */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                        + "<html>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                        + "<head>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                        + "<title>Caninical XML node set</title>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                        + "<style type=\"text/css\">\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                        + "<!-- \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                        + ".INCLUDED { \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                        + "   color: #000000; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                        + "   background-color: \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                        + "   #FFFFFF; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                        + "   font-weight: bold; } \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                        + ".EXCLUDED { \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                        + "   color: #666666; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                        + "   background-color: \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                        + "   #999999; } \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                        + ".INCLUDEDINCLUSIVENAMESPACE { \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                        + "   color: #0000FF; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                        + "   background-color: #FFFFFF; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                        + "   font-weight: bold; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                        + "   font-style: italic; } \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                        + ".EXCLUDEDINCLUSIVENAMESPACE { \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                        + "   color: #0000FF; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                        + "   background-color: #999999; \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                        + "   font-style: italic; } \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                        + "--> \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                        + "</style> \n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                        + "</head>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                        + "<body bgcolor=\"#999999\">\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                        + "<h1>Explanation of the output</h1>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                        + "<p>The following text contains the nodeset of the given Reference before it is canonicalized. There exist four different styles to indicate how a given node is treated.</p>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                        + "<ul>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                        + "<li class=\"INCLUDED\">A node which is in the node set is labeled using the INCLUDED style.</li>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                        + "<li class=\"EXCLUDED\">A node which is <em>NOT</em> in the node set is labeled EXCLUDED style.</li>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                        + "<li class=\"INCLUDEDINCLUSIVENAMESPACE\">A namespace which is in the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                        + "<li class=\"EXCLUDEDINCLUSIVENAMESPACE\">A namespace which is in NOT the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                        + "</ul>\n" + "<h1>Output</h1>\n" + "<pre>\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        /** HTML Suffix * */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        static final String HTMLSuffix = "</pre></body></html>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        static final String HTMLExcludePrefix = "<span class=\"EXCLUDED\">";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        static final String HTMLExcludeSuffix = "</span>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        static final String HTMLIncludePrefix = "<span class=\"INCLUDED\">";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        static final String HTMLIncludeSuffix = "</span>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        static final String HTMLIncludedInclusiveNamespacePrefix = "<span class=\"INCLUDEDINCLUSIVENAMESPACE\">";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        static final String HTMLIncludedInclusiveNamespaceSuffix = "</span>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        static final String HTMLExcludedInclusiveNamespacePrefix = "<span class=\"EXCLUDEDINCLUSIVENAMESPACE\">";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        static final String HTMLExcludedInclusiveNamespaceSuffix = "</span>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        private static final int NODE_BEFORE_DOCUMENT_ELEMENT = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        private static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        private static final int NODE_AFTER_DOCUMENT_ELEMENT = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        static final AttrCompare ATTR_COMPARE = new AttrCompare();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        // J+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        private XMLSignatureInputDebugger() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                // do nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
         * Constructor XMLSignatureInputDebugger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
         * @param xmlSignatureInput the signatur to pretty print
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        public XMLSignatureInputDebugger(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                        XMLSignatureInput xmlSignatureInput) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                if (!xmlSignatureInput.isNodeSet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                        this._xpathNodeSet = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                        this._xpathNodeSet = xmlSignatureInput._inputNodeSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
         * Constructor XMLSignatureInputDebugger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
         * @param xmlSignatureInput the signatur to pretty print
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
         * @param inclusiveNamespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        public XMLSignatureInputDebugger(
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
   162
                        XMLSignatureInput xmlSignatureInput, Set<String> inclusiveNamespace) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                this(xmlSignatureInput);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                this._inclusiveNamespaces = inclusiveNamespace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
         * Method getHTMLRepresentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         * @return The HTML Representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         * @throws XMLSignatureException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        public String getHTMLRepresentation() throws XMLSignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                if ((this._xpathNodeSet == null) || (this._xpathNodeSet.size() == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                        return HTMLPrefix + "<blink>no node set, sorry</blink>"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                        + HTMLSuffix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                        // get only a single node as anchor to fetch the owner document
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
   185
                        Node n = this._xpathNodeSet.iterator().next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                        this._doc = XMLUtils.getOwnerDocument(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                        this._writer = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        this.canonicalizeXPathNodeSet(this._doc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                        this._writer.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                        return this._writer.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        throw new XMLSignatureException("empty", ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        this._xpathNodeSet = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                        this._doc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                        this._writer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
         * Method canonicalizeXPathNodeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
         * @param currentNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
         * @throws XMLSignatureException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
         * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        private void canonicalizeXPathNodeSet(Node currentNode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                        throws XMLSignatureException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                int currentNodeType = currentNode.getNodeType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                switch (currentNodeType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                case Node.DOCUMENT_TYPE_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                case Node.ENTITY_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                case Node.NOTATION_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                case Node.DOCUMENT_FRAGMENT_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                case Node.ATTRIBUTE_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                        throw new XMLSignatureException("empty");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                case Node.DOCUMENT_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                        this._writer.write(HTMLPrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                        for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                        .getNextSibling()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                                this.canonicalizeXPathNodeSet(currentChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                        this._writer.write(HTMLSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                case Node.COMMENT_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                        int position = getPositionRelativeToDocumentElement(currentNode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                        if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                this._writer.write("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                        this.outputCommentToWriter((Comment) currentNode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                        if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                this._writer.write("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                case Node.PROCESSING_INSTRUCTION_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                        position = getPositionRelativeToDocumentElement(currentNode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                        if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                                this._writer.write("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                        this.outputPItoWriter((ProcessingInstruction) currentNode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                        if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                                this._writer.write("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                case Node.TEXT_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                case Node.CDATA_SECTION_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                        outputTextToWriter(currentNode.getNodeValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                        for (Node nextSibling = currentNode.getNextSibling(); (nextSibling != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                                        && ((nextSibling.getNodeType() == Node.TEXT_NODE) || (nextSibling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                                                        .getNodeType() == Node.CDATA_SECTION_NODE)); nextSibling = nextSibling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                        .getNextSibling()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                                 * The XPath data model allows to select only the first of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                                 * sequence of mixed text and CDATA nodes. But we must output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                 * them all, so we must search:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                                 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                                 * @see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                                this.outputTextToWriter(nextSibling.getNodeValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                case Node.ELEMENT_NODE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                        Element currentElement = (Element) currentNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                        this._writer.write("&lt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                        this._writer.write(currentElement.getTagName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                        // we output all Attrs which are available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                        NamedNodeMap attrs = currentElement.getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                        int attrsLength = attrs.getLength();
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
   344
                        Attr attrs2[] = new Attr[attrsLength];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                        for (int i = 0; i < attrsLength; i++) {
10694
cf59e2badd14 7088502: Security libraries don't build with javac -Werror
mullan
parents: 1337
diff changeset
   347
                                attrs2[i] = (Attr)attrs.item(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                        Arrays.sort(attrs2, ATTR_COMPARE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                        Object attrs3[] = attrs2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                        for (int i = 0; i < attrsLength; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                                Attr a = (Attr) attrs3[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                                boolean included = this._xpathNodeSet.contains(a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                                boolean inclusive = this._inclusiveNamespaces.contains(a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                                                .getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                                if (included) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                                        if (inclusive) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                                                // included and inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                                                this._writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                                                                .write(HTMLIncludedInclusiveNamespacePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                                                // included and not inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                                        if (inclusive) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                                                // excluded and inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                                this._writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                                                .write(HTMLExcludedInclusiveNamespacePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                                                // excluded and not inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                                this.outputAttrToWriter(a.getNodeName(), a.getNodeValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                                if (included) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                        if (inclusive) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                                                // included and inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                                                this._writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                                                .write(HTMLIncludedInclusiveNamespaceSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                                                // included and not inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                                        if (inclusive) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                                                // excluded and inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                                                this._writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                                                                .write(HTMLExcludedInclusiveNamespaceSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                                                // excluded and not inclusive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                        this._writer.write("&gt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                        // traversal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                        for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                                        .getNextSibling()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                                this.canonicalizeXPathNodeSet(currentChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                this._writer.write(HTMLIncludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                this._writer.write(HTMLExcludePrefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                        this._writer.write("&lt;/");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        this._writer.write(currentElement.getTagName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                        this._writer.write("&gt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                        if (this._xpathNodeSet.contains(currentNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                this._writer.write(HTMLIncludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                                this._writer.write(HTMLExcludeSuffix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
         * Checks whether a Comment or ProcessingInstruction is before or after the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
         * document element. This is needed for prepending or appending "\n"s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
         * @param currentNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
         *            comment or pi to check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
         * @return NODE_BEFORE_DOCUMENT_ELEMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
         *         NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
         *         NODE_AFTER_DOCUMENT_ELEMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
         * @see #NODE_BEFORE_DOCUMENT_ELEMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
         * @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
         * @see #NODE_AFTER_DOCUMENT_ELEMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        private int getPositionRelativeToDocumentElement(Node currentNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                if (currentNode == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                        return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                Document doc = currentNode.getOwnerDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                if (currentNode.getParentNode() != doc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                        return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                Element documentElement = doc.getDocumentElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                if (documentElement == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                        return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                if (documentElement == currentNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                        return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                for (Node x = currentNode; x != null; x = x.getNextSibling()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                        if (x == documentElement) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                                return NODE_BEFORE_DOCUMENT_ELEMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                return NODE_AFTER_DOCUMENT_ELEMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
         * Normalizes an {@link Attr}ibute value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
         * The string value of the node is modified by replacing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
         * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
         * <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
         * <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
         * <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
         * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
         * with character references. The character references are written in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
         * uppercase hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
         * is represented by the character reference <CODE>&amp;#xD;</CODE>)</LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
         * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
         * @param name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
         * @param value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
         * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        private void outputAttrToWriter(String name, String value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                this._writer.write(" ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                this._writer.write(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                this._writer.write("=\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                int length = value.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                for (int i = 0; i < length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                        char c = value.charAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                        switch (c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                        case '&':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                                this._writer.write("&amp;amp;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                        case '<':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                                this._writer.write("&amp;lt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                        case '"':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                this._writer.write("&amp;quot;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                        case 0x09: // '\t'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                                this._writer.write("&amp;#x9;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                        case 0x0A: // '\n'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                this._writer.write("&amp;#xA;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                        case 0x0D: // '\r'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                                this._writer.write("&amp;#xD;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                                this._writer.write(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                this._writer.write("\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
         * Normalizes a {@link org.w3c.dom.Comment} value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
         * @param currentPI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
         * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        private void outputPItoWriter(ProcessingInstruction currentPI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                if (currentPI == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                this._writer.write("&lt;?");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                String target = currentPI.getTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                int length = target.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                for (int i = 0; i < length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                        char c = target.charAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                        switch (c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                        case 0x0D:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                                this._writer.write("&amp;#xD;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                        case ' ':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                                this._writer.write("&middot;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                        case '\n':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                                this._writer.write("&para;\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                this._writer.write(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                String data = currentPI.getData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                length = data.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   603
                if (length > 0) {
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   604
                    this._writer.write(" ");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   606
                    for (int i = 0; i < length; i++) {
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   607
                        char c = data.charAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   609
                        switch (c) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   611
                            case 0x0D:
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   612
                                this._writer.write("&amp;#xD;");
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   613
                                break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   615
                            default:
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   616
                                this._writer.write(c);
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   617
                                break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                        }
1337
e8d6cef36199 6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
mullan
parents: 2
diff changeset
   619
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                this._writer.write("?&gt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
         * Method outputCommentToWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
         * @param currentComment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
         * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        private void outputCommentToWriter(Comment currentComment)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                if (currentComment == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                this._writer.write("&lt;!--");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                String data = currentComment.getData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                int length = data.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                for (int i = 0; i < length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                        char c = data.charAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                        switch (c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                        case 0x0D:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                                this._writer.write("&amp;#xD;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                        case ' ':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                                this._writer.write("&middot;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                        case '\n':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                                this._writer.write("&para;\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                                this._writer.write(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                this._writer.write("--&gt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
         * Method outputTextToWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
         * @param text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
         * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        private void outputTextToWriter(String text) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                if (text == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                int length = text.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                for (int i = 0; i < length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                        char c = text.charAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                        switch (c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                        case '&':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                                this._writer.write("&amp;amp;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                        case '<':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                                this._writer.write("&amp;lt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                        case '>':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                                this._writer.write("&amp;gt;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                        case 0xD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                                this._writer.write("&amp;#xD;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                        case ' ':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                                this._writer.write("&middot;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                        case '\n':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                                this._writer.write("&para;\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                                this._writer.write(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
}