当前位置: 首页>>代码示例>>Java>>正文


Java HTMLEditorKit.ParserCallback方法代码示例

本文整理汇总了Java中javax.swing.text.html.HTMLEditorKit.ParserCallback方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLEditorKit.ParserCallback方法的具体用法?Java HTMLEditorKit.ParserCallback怎么用?Java HTMLEditorKit.ParserCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.html.HTMLEditorKit的用法示例。


在下文中一共展示了HTMLEditorKit.ParserCallback方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int N = 10;

    for (int i = 0; i < N; i++) {
        HTMLEditorKit kit = new HTMLEditorKit();
        Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
        HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
        HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
        HTMLEditorKit.ParserCallback htmlReader = doc.getReader(0);
        parser.parse(new CharArrayReader(htmlDoc.toCharArray()), htmlReader, true);
        htmlReader.flush();
        CharArrayWriter writer = new CharArrayWriter(1000);
        kit.write(writer, doc, 0, doc.getLength());
        writer.flush();

        String result = writer.toString();
        if (!result.contains("<tt><a")) {
            throw new RuntimeException("The <a> and <tt> tags are swapped");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:bug8005391.java

示例2: main

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
public static void main(String[] args) {
    String htmlDoc = "<pre><p> </pre>";
    try {
        HTMLEditorKit kit = new HTMLEditorKit();
        Class c = Class.forName(
                "javax.swing.text.html.parser.ParserDelegator");
        HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
        HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
        HTMLEditorKit.ParserCallback htmlReader = doc.getReader(0);
        parser.parse(new CharArrayReader(htmlDoc.toCharArray()),
                htmlReader, true);
        htmlReader.flush();
        CharArrayWriter writer = new CharArrayWriter(1000);
        kit.write(writer, doc, 0, doc.getLength());
        writer.flush();
    } catch (Exception ex) {
        throw new RuntimeException("Test Failed " + ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:HTMLEditorKitWriterBug.java

示例3: parse

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
public void parse(Reader in,  HTMLEditorKit.ParserCallback callback, boolean ignoreCharSet) throws IOException {
    this.ignoreCharSet = ignoreCharSet;
    this.callback = callback;
    parse(in);
    // end of line
    callback.handleEndOfLineString(getEndOfLineString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:DocumentParser.java

示例4: parse

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
public void parse(Reader r, HTMLEditorKit.ParserCallback cb, boolean ignoreCharSet) throws IOException {
    new DocumentParser(getDefaultDTD()).parse(r, cb, ignoreCharSet);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:ParserDelegator.java

示例5: parse

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
/**
 * Parse an HTML stream, given a DTD.
 *
 * @param in the reader to read the source from
 * @param callback the callback
 * @param ignoreCharSet if {@code true} the charset is ignored
 * @throws IOException if an I/O error occurs
 */
public void parse(Reader in, HTMLEditorKit.ParserCallback callback, boolean ignoreCharSet) throws IOException {
    this.ignoreCharSet = ignoreCharSet;
    this.callback = callback;
    parse(in);
    // end of line
    callback.handleEndOfLineString(getEndOfLineString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DocumentParser.java


注:本文中的javax.swing.text.html.HTMLEditorKit.ParserCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。