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()
相关推荐
研☆香1 分钟前
数组方法 splice讲解 拓展
开发语言·前端·javascript
码视野3 分钟前
基于 Spring Boot + Vue3 的【城市地下燃气管网微泄漏感知与相邻地下空间燃爆预警中台】设计与实现(含PRD/三端高保真源码/大屏)
java·前端·人工智能·spring boot·后端
峥嵘life20 分钟前
Android16 系统 APEX 模块说明
android·大数据·开发语言
2601_9620715724 分钟前
数据库系统架构与DBMS功能探微:现代信息时代数据管理的关键
java·开发语言·数据库
————A25 分钟前
Agent 文件处理中间件
开发语言·javascript·ecmascript
梦想的旅途226 分钟前
如何高效调用企业微信通讯录API管理组织架构
java·开发语言·企业微信
whcyhhh43 分钟前
头歌实践教学平台:大数据存储2023(十三3)
大数据·开发语言·python
2601_962065251 小时前
2.启动mysql容器
java·数据库·mysql
2601_962065491 小时前
PHP For 循环
android·java·php
2601_962201721 小时前
Java进阶,集合,Colllection,常见数据结构
java·数据结构·windows