org.w3c.dom.Comment#getData ( )源码实例Demo

下面列出了org.w3c.dom.Comment#getData ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("<!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码3 项目: jdk8u_jdk   文件: XMLSignatureInputDebugger.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码4 项目: TencentKona-8   文件: XMLSignatureInputDebugger.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码5 项目: TencentKona-8   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码6 项目: jdk8u60   文件: XMLSignatureInputDebugger.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码7 项目: jdk8u60   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码9 项目: jdk8u-dev-jdk   文件: XMLSignatureInputDebugger.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码10 项目: openjdk-jdk8u   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码13 项目: openjdk-8   文件: XMLSignatureInputDebugger.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @throws IOException
 */
private void outputCommentToWriter(Comment currentComment) throws IOException {

    if (currentComment == null) {
        return;
    }

    this.writer.write("&lt;!--");

    String data = currentComment.getData();
    int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);

        switch (c) {

        case 0x0D:
            this.writer.write("&amp;#xD;");
            break;

        case ' ':
            this.writer.write("&middot;");
            break;

        case '\n':
            this.writer.write("&para;\n");
            break;

        default:
            this.writer.write(c);
            break;
        }
    }

    this.writer.write("--&gt;");
}
 
源代码14 项目: jdk8u_jdk   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码15 项目: openjdk-jdk9   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码16 项目: ph-commons   文件: XMLSerializer.java
private void _writeComment (@Nonnull final XMLEmitter aXMLWriter, @Nonnull final Comment aComment)
{
  if (m_aSettings.getSerializeComments ().isEmit ())
  {
    final String sComment = aComment.getData ();
    aXMLWriter.onComment (sComment);
    if (sComment.indexOf ('\n') >= 0)
    {
      // Newline only after multi-line comments
      aXMLWriter.newLine ();
    }
  }
}
 
源代码17 项目: jdk8u-jdk   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码18 项目: jdk8u-jdk   文件: CanonicalizerBase.java
/**
 * Method outputCommentToWriter
 *
 * @param currentComment
 * @param writer writer where to write the things
 * @throws IOException
 */
protected void outputCommentToWriter(
    Comment currentComment, OutputStream writer, int position
) throws IOException {
    if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
    writer.write(BEGIN_COMM.clone());

    final String data = currentComment.getData();
    final int length = data.length();

    for (int i = 0; i < length; i++) {
        char c = data.charAt(i);
        if (c == 0x0D) {
            writer.write(XD.clone());
        } else {
            if (c < 0x80) {
                writer.write(c);
            } else {
                UtfHelpper.writeCharToUtf8(c, writer);
            }
        }
    }

    writer.write(END_COMM.clone());
    if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
        writer.write('\n');
    }
}
 
源代码19 项目: mybatis-generator-plus   文件: XmlFileMergerJaxp.java
private static boolean isGeneratedNode(Node node) {
    boolean rc = false;

    if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
        Element element = (Element) node;
        String id = element.getAttribute("id"); //$NON-NLS-1$
        if (id != null) {
            for (String prefix : MergeConstants.OLD_XML_ELEMENT_PREFIXES) {
                if (id.startsWith(prefix)) {
                    rc = true;
                    break;
                }
            }
        }

        if (rc == false) {
            // check for new node format - if the first non-whitespace node
            // is an XML comment, and the comment includes
            // one of the old element tags,
            // then it is a generated node
            NodeList children = node.getChildNodes();
            int length = children.getLength();
            for (int i = 0; i < length; i++) {
                Node childNode = children.item(i);
                if (isWhiteSpace(childNode)) {
                    continue;
                } else if (childNode.getNodeType() == Node.COMMENT_NODE) {
                    Comment comment = (Comment) childNode;
                    String commentData = comment.getData();
                    for (String tag : MergeConstants.OLD_ELEMENT_TAGS) {
                        if (commentData.contains(tag)) {
                            rc = true;
                            break;
                        }
                    }
                } else {
                    break;
                }
            }
        }
    }

    return rc;
}
 
private static boolean isGeneratedNode(Node node) {
    boolean rc = false;

    if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
        Element element = (Element) node;
        String id = element.getAttribute("id"); //$NON-NLS-1$
        if (id != null) {
            for (String prefix : MergeConstants.OLD_XML_ELEMENT_PREFIXES) {
                if (id.startsWith(prefix)) {
                    rc = true;
                    break;
                }
            }
        }

        if (rc == false) {
            // check for new node format - if the first non-whitespace node
            // is an XML comment, and the comment includes
            // one of the old element tags,
            // then it is a generated node
            NodeList children = node.getChildNodes();
            int length = children.getLength();
            for (int i = 0; i < length; i++) {
                Node childNode = children.item(i);
                if (isWhiteSpace(childNode)) {
                    continue;
                } else if (childNode.getNodeType() == Node.COMMENT_NODE) {
                    Comment comment = (Comment) childNode;
                    String commentData = comment.getData();
                    for (String tag : MergeConstants.OLD_ELEMENT_TAGS) {
                        if (commentData.contains(tag)) {
                            rc = true;
                            break;
                        }
                    }
                } else {
                    break;
                }
            }
        }
    }

    return rc;
}
 
 方法所在类
 同类方法