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()
相关推荐
xierui12312323 分钟前
AI Agent 隐私架构:本地化重点为什么是登录态与执行权限
java·人工智能·网络安全·架构
cfm_291433 分钟前
Spring AI Tool 调用架构全解
java·人工智能·spring
法哥201239 分钟前
用 C++ 控制 CMW100,到底在干什么?
开发语言·c++
sun༒44 分钟前
Spring @Scheduled 定时任务详解:Cron表达式、执行顺序、优先级与并行调度
java·后端·spring
QH139292318801 小时前
NVIDIA H200 H300服务器
运维·服务器·开发语言·网络·信息与通信
一次旅行1 小时前
DeepSeek‑V4‑Flash‑Vision‑Exp 小白入门实战|3种传图方式、完整可跑代码、避坑排障
java·前端·人工智能
OPEN-F1 小时前
Python进阶教程:单元测试与代码质量
开发语言·python·单元测试
阿里嘎多学长1 小时前
2026-08-20 GitHub 热点项目精选
开发语言·程序员·github·代码托管
野生技术架构师1 小时前
Spring Boot 实现数据脱敏:自定义注解 + Jackson 序列化器
java·spring boot·后端
其实防守也摸鱼1 小时前
Codex破局:前端组件秒级生成的技术文章大纲
开发语言·前端·人工智能·学习·安全·web安全