Java类的继承

XHTMLMapper继承 XWPFDocumentVisitor:

由于endVisitTableCell是抽象方法,XHTMLMapper中必须要实现;

existErr()子类是否重写都是自由的;

java 复制代码
public abstract class XWPFDocumentVisitor<T, O extends Options, E extends IXWPFMasterPage> implements IMasterPageHandler<E> {
	public void start() throws Exception {
        ...
        ...
        existErr()
    }
 	protected abstract void endVisitTableCell(XWPFTableCell cell, T tableContainer, T tableCellContainer)
            throws Exception;
    public boolean existErr(){return false;}
}
java 复制代码
public class XHTMLMapper extends XWPFDocumentVisitor<Object, XHTMLOptions, XHTMLMasterPage> {
	@Override
    protected void endVisitTableCell(XWPFTableCell cell, Object tableContainer, Object tableCellContainer) throws Exception {
        endElement(TD_ELEMENT);
    }
	@Override
    public boolean existErr(){
        return SAXHelper.existErr(contentHandler);
    }
}
java 复制代码
XHTMLMapper mapper = new XHTMLMapper(document, contentHandler, options);
mapper.start(); // 执行父类的start(),start()内部的 existErr()会调用子类的 existErr()
相关推荐
一只大袋鼠6 分钟前
并发编程(三):线程快照统计・grep+awk+sort+uniq 实战详解
java·开发语言·多线程·并发编程
unfeeling_10 分钟前
Tomcat实验
java·tomcat
Hx_Ma1622 分钟前
前台模块以及分页逻辑
java·开发语言
亓才孓27 分钟前
AspectJ和SpringAOP的区别
java·开发语言
大鹏说大话28 分钟前
破局单体瓶颈:SQLParser 解析器的分层架构重构实战
开发语言
tod11331 分钟前
C++ 核心知识点全解析(八)
开发语言·c++·面试经验
Ljwuhe34 分钟前
C++类与对象(上)
开发语言·c++
十启树36 分钟前
QGis开发环境部署
开发语言·gis·qgis
亚比囧1 小时前
Java基础--面向对象(二)
java·开发语言