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()
相关推荐
GSDjisidi4 分钟前
东京IT软件会社-(株)GSD|多种技术栈募集,高度人才+20分
开发语言·面试·职场和发展
zwxu_9 分钟前
Nginx NIO对比Java NIO
java·nginx·nio
程序员zgh1 小时前
Linux系统常用命令集合
linux·运维·服务器·c语言·开发语言·c++
獭.獭.1 小时前
C++ -- STL【unordered_set与unordered_map的实现】
开发语言·c++·unordered_map·unordered_set
可观测性用观测云1 小时前
Pyroscope Java 接入最佳实践
java
山海青风2 小时前
语音合成 - 用 Python 合成藏语三大方言语音
开发语言·python·音视频
占疏2 小时前
dify API访问工作流/聊天
开发语言·数据库·python
似水এ᭄往昔2 小时前
【C++】--AVL树的认识和实现
开发语言·数据结构·c++·算法·stl
气π2 小时前
【JavaWeb】——(若依 + AI)-基础学习笔记
java·spring boot·笔记·学习·java-ee·mybatis·ruoyi
aningxiaoxixi2 小时前
TTS 之 PYTHON库 pyttsx3
开发语言·python·语音识别