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()
相关推荐
one31240 分钟前
高精度MEMS电容式倾角传感器:原理、结构与Python三维可视化
开发语言·python
程序员小八7771 小时前
Go 语言特性
开发语言·后端·golang
luteres1 小时前
Spring学习笔记
java·后端·spring
南城以南溫暖如初1471 小时前
从零搭建24小时自助健身系统:技术选型与核心模块实战
java·spring boot·redis·mysql·vue·mybatis
重生之后端学习1 小时前
53. 最大子数组和[中等]✅
java·数据结构·算法·leetcode·职场和发展
XS0301062 小时前
【无标题】
java·tomcat·maven·intellij-idea
陈皮波比茶2 小时前
java日志框架
java
INGNIGHT2 小时前
1908 · 布尔表达式求值(stack单调栈&dfs)
开发语言·c++·算法
এ慕ོ冬℘゜2 小时前
深入理解浏览器全屏 API:从 requestFullscreen 到全屏实战
开发语言·html
thefool1122662 小时前
随机链表的复制
java