public abstract class DocumentVisitor
extends java.lang.Object
To learn more, visit the Aspose.Words Document Object Model (DOM) documentation article.
With DocumentVisitor you can define and execute custom operations that require enumeration over the document tree.
For example, Aspose.Words uses DocumentVisitor internally for saving Document in various formats and for other operations like finding fields or bookmarks over a fragment of a document.
To use DocumentVisitor:
Node.accept(com.aspose.words.DocumentVisitor) on the Node that you want to start the enumeration from.
DocumentVisitor provides default implementations for all of the VisitXXX methods to make it easier to create new document visitors as only the methods required for the particular visitor need to be overridden. It is not necessary to override all of the visitor methods.
For more information see the Visitor design pattern.
| Modifier | Constructor and Description |
|---|---|
protected |
DocumentVisitor()
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
int |
visitAbsolutePositionTab(AbsolutePositionTab tab)
Called when a
AbsolutePositionTab node is encountered in the document. |
int |
visitBodyEnd(Body body)
Called when enumeration of the main text story in a section has ended.
|
int |
visitBodyStart(Body body)
Called when enumeration of the main text story in a section has started.
|
int |
visitBookmarkEnd(BookmarkEnd bookmarkEnd)
Called when an end of a bookmark is encountered in the document.
|
int |
visitBookmarkStart(BookmarkStart bookmarkStart)
Called when a start of a bookmark is encountered in the document.
|
int |
visitBuildingBlockEnd(BuildingBlock block)
Called when enumeration of a building block has ended.
|
int |
visitBuildingBlockStart(BuildingBlock block)
Called when enumeration of a building block has started.
|
int |
visitCellEnd(Cell cell)
Called when enumeration of a table cell has ended.
|
int |
visitCellStart(Cell cell)
Called when enumeration of a table cell has started.
|
int |
visitCommentEnd(Comment comment)
Called when enumeration of a comment text has ended.
|
int |
visitCommentRangeEnd(CommentRangeEnd commentRangeEnd)
Called when the end of a commented range of text is encountered.
|
int |
visitCommentRangeStart(CommentRangeStart commentRangeStart)
Called when the start of a commented range of text is encountered.
|
int |
visitCommentStart(Comment comment)
Called when enumeration of a comment text has started.
|
int |
visitDocumentEnd(Document doc)
Called when enumeration of the document has finished.
|
int |
visitDocumentStart(Document doc)
Called when enumeration of the document has started.
|
int |
visitEditableRangeEnd(EditableRangeEnd editableRangeEnd)
Called when an end of an editable range is encountered in the document.
|
int |
visitEditableRangeStart(EditableRangeStart editableRangeStart)
Called when a start of an editable range is encountered in the document.
|
int |
visitFieldEnd(FieldEnd fieldEnd)
Called when a field ends in the document.
|
int |
visitFieldSeparator(FieldSeparator fieldSeparator)
Called when a field separator is encountered in the document.
|
int |
visitFieldStart(FieldStart fieldStart)
Called when a field starts in the document.
|
int |
visitFootnoteEnd(Footnote footnote)
Called when enumeration of a footnote or endnote text has ended.
|
int |
visitFootnoteStart(Footnote footnote)
Called when enumeration of a footnote or endnote text has started.
|
int |
visitFormField(FormField formField)
Called when a form field is encountered in the document.
|
int |
visitGlossaryDocumentEnd(GlossaryDocument glossary)
Called when enumeration of a glossary document has ended.
|
int |
visitGlossaryDocumentStart(GlossaryDocument glossary)
Called when enumeration of a glossary document has started.
|
int |
visitGroupShapeEnd(GroupShape groupShape)
Called when enumeration of a group shape has ended.
|
int |
visitGroupShapeStart(GroupShape groupShape)
Called when enumeration of a group shape has started.
|
int |
visitHeaderFooterEnd(HeaderFooter headerFooter)
Called when enumeration of a header or footer in a section has ended.
|
int |
visitHeaderFooterStart(HeaderFooter headerFooter)
Called when enumeration of a header or footer in a section has started.
|
int |
visitOfficeMathEnd(OfficeMath officeMath)
Called when enumeration of a Office Math object has ended.
|
int |
visitOfficeMathStart(OfficeMath officeMath)
Called when enumeration of a Office Math object has started.
|
int |
visitParagraphEnd(Paragraph paragraph)
Called when enumeration of a paragraph has ended.
|
int |
visitParagraphStart(Paragraph paragraph)
Called when enumeration of a paragraph has started.
|
int |
visitRowEnd(Row row)
Called when enumeration of a table row has ended.
|
int |
visitRowStart(Row row)
Called when enumeration of a table row has started.
|
int |
visitRun(Run run)
Called when a run of text in the is encountered.
|
int |
visitSectionEnd(Section section)
Called when enumeration of a section has ended.
|
int |
visitSectionStart(Section section)
Called when enumeration of a section has started.
|
int |
visitShapeEnd(Shape shape)
Called when enumeration of a shape has ended.
|
int |
visitShapeStart(Shape shape)
Called when enumeration of a shape has started.
|
int |
visitSmartTagEnd(SmartTag smartTag)
Called when enumeration of a smart tag has ended.
|
int |
visitSmartTagStart(SmartTag smartTag)
Called when enumeration of a smart tag has started.
|
int |
visitSpecialChar(SpecialChar specialChar)
Called when a
SpecialChar node is encountered in the document. |
int |
visitStructuredDocumentTagEnd(StructuredDocumentTag sdt)
Called when enumeration of a structured document tag has ended.
|
int |
visitStructuredDocumentTagRangeEnd(StructuredDocumentTagRangeEnd sdtRangeEnd) |
int |
visitStructuredDocumentTagRangeStart(StructuredDocumentTagRangeStart sdtRangeStart) |
int |
visitStructuredDocumentTagStart(StructuredDocumentTag sdt)
Called when enumeration of a structured document tag has started.
|
int |
visitSubDocument(SubDocument subDocument)
Called when a subDocument is encountered.
|
int |
visitTableEnd(Table table)
Called when enumeration of a table has ended.
|
int |
visitTableStart(Table table)
Called when enumeration of a table has started.
|
protected DocumentVisitor()
public int visitDocumentStart(Document doc) throws java.lang.Exception
doc - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitDocumentEnd(Document doc) throws java.lang.Exception
doc - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitSectionStart(Section section) throws java.lang.Exception
section - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitSectionEnd(Section section) throws java.lang.Exception
section - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitBodyStart(Body body) throws java.lang.Exception
body - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitBodyEnd(Body body) throws java.lang.Exception
body - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitHeaderFooterStart(HeaderFooter headerFooter) throws java.lang.Exception
headerFooter - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitHeaderFooterEnd(HeaderFooter headerFooter) throws java.lang.Exception
headerFooter - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitParagraphStart(Paragraph paragraph) throws java.lang.Exception
paragraph - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitParagraphEnd(Paragraph paragraph) throws java.lang.Exception
paragraph - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitTableStart(Table table) throws java.lang.Exception
table - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitTableEnd(Table table) throws java.lang.Exception
table - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitRowStart(Row row) throws java.lang.Exception
row - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitRowEnd(Row row) throws java.lang.Exception
row - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitCellStart(Cell cell) throws java.lang.Exception
cell - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitCellEnd(Cell cell) throws java.lang.Exception
cell - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitRun(Run run) throws java.lang.Exception
run - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitFieldStart(FieldStart fieldStart) throws java.lang.Exception
A field in a Word document consists of a field code and field value.
For example, a field that displays a page number can be represented as follows:
[FieldStart]PAGE[FieldSeparator]98[FieldEnd]
The field separator separates field code from field value in the document. Note that some fields have only field code and do not have field separator and field value.
Fields can be nested.
fieldStart - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitFieldSeparator(FieldSeparator fieldSeparator) throws java.lang.Exception
The field separator separates field code from field value in the document. Note that some fields have only field code and do not have field separator and field value.
For more info see visitFieldStart(com.aspose.words.FieldStart)
fieldSeparator - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitFieldEnd(FieldEnd fieldEnd) throws java.lang.Exception
For more info see visitFieldStart(com.aspose.words.FieldStart)
fieldEnd - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitFormField(FormField formField) throws java.lang.Exception
formField - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitBookmarkStart(BookmarkStart bookmarkStart) throws java.lang.Exception
bookmarkStart - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitBookmarkEnd(BookmarkEnd bookmarkEnd) throws java.lang.Exception
bookmarkEnd - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitFootnoteStart(Footnote footnote) throws java.lang.Exception
footnote - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitFootnoteEnd(Footnote footnote) throws java.lang.Exception
footnote - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitCommentStart(Comment comment) throws java.lang.Exception
comment - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitCommentEnd(Comment comment) throws java.lang.Exception
comment - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitEditableRangeStart(EditableRangeStart editableRangeStart) throws java.lang.Exception
editableRangeStart - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitEditableRangeEnd(EditableRangeEnd editableRangeEnd) throws java.lang.Exception
editableRangeEnd - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitShapeStart(Shape shape) throws java.lang.Exception
shape - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitShapeEnd(Shape shape) throws java.lang.Exception
shape - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitGroupShapeStart(GroupShape groupShape) throws java.lang.Exception
groupShape - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitGroupShapeEnd(GroupShape groupShape) throws java.lang.Exception
groupShape - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitOfficeMathStart(OfficeMath officeMath) throws java.lang.Exception
officeMath - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitOfficeMathEnd(OfficeMath officeMath) throws java.lang.Exception
officeMath - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitSpecialChar(SpecialChar specialChar) throws java.lang.Exception
SpecialChar node is encountered in the document.specialChar - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitAbsolutePositionTab(AbsolutePositionTab tab) throws java.lang.Exception
AbsolutePositionTab node is encountered in the document.tab - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitSmartTagStart(SmartTag smartTag) throws java.lang.Exception
smartTag - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitSmartTagEnd(SmartTag smartTag) throws java.lang.Exception
smartTag - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitStructuredDocumentTagStart(StructuredDocumentTag sdt) throws java.lang.Exception
sdt - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitStructuredDocumentTagEnd(StructuredDocumentTag sdt) throws java.lang.Exception
sdt - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitGlossaryDocumentStart(GlossaryDocument glossary) throws java.lang.Exception
Note: A glossary document node and its children are not visited when you execute a Visitor over a Document. If you want to execute a Visitor over a glossary document, you need to call GlossaryDocument.accept(com.aspose.words.DocumentVisitor).
glossary - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitGlossaryDocumentEnd(GlossaryDocument glossary) throws java.lang.Exception
Note: A glossary document node and its children are not visited when you execute a Visitor over a Document. If you want to execute a Visitor over a glossary document, you need to call GlossaryDocument.accept(com.aspose.words.DocumentVisitor).
glossary - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitBuildingBlockStart(BuildingBlock block) throws java.lang.Exception
Note: A building block node and its children are not visited when you execute a Visitor over a Document. If you want to execute a Visitor over a building block, you need to execute the visitor over GlossaryDocument or call BuildingBlock.accept(com.aspose.words.DocumentVisitor).
block - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitBuildingBlockEnd(BuildingBlock block) throws java.lang.Exception
Note: A building block node and its children are not visited when you execute a Visitor over a Document. If you want to execute a Visitor over a building block, you need to execute the visitor over GlossaryDocument or call BuildingBlock.accept(com.aspose.words.DocumentVisitor).
block - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitCommentRangeStart(CommentRangeStart commentRangeStart) throws java.lang.Exception
commentRangeStart - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitCommentRangeEnd(CommentRangeEnd commentRangeEnd) throws java.lang.Exception
commentRangeEnd - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitSubDocument(SubDocument subDocument) throws java.lang.Exception
subDocument - The object that is being visited.VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.java.lang.Exceptionpublic int visitStructuredDocumentTagRangeStart(StructuredDocumentTagRangeStart sdtRangeStart) throws java.lang.Exception
java.lang.Exceptionpublic int visitStructuredDocumentTagRangeEnd(StructuredDocumentTagRangeEnd sdtRangeEnd) throws java.lang.Exception
java.lang.Exception