赞
踩
XHTMLMapper继承 XWPFDocumentVisitor:
由于endVisitTableCell是抽象方法,XHTMLMapper中必须要实现;
existErr()子类是否重写都是自由的;
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;}
}
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);
}
}
XHTMLMapper mapper = new XHTMLMapper(document, contentHandler, options);
mapper.start(); // 执行父类的start(),start()内部的 existErr()会调用子类的 existErr()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。