本文整理汇总了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");
}
}
}
示例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);
}
}
示例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());
}
示例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);
}
示例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());
}