DocumentVisitor

Inheritance: java.lang.Object

public abstract class DocumentVisitor

Base class for custom document visitors.

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:

  1. Create a class derived from DocumentVisitor.
  2. Override and provide implementations for some or all of the VisitXXX methods to perform some custom operations.
  3. Call 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.

Methods

Method Description
equals(Object arg0)
getClass()
hashCode()
notify()
notifyAll()
toString()
visitAbsolutePositionTab(AbsolutePositionTab tab) Called when a AbsolutePositionTab node is encountered in the document.
visitBodyEnd(Body body) Called when enumeration of the main text story in a section has ended.
visitBodyStart(Body body) Called when enumeration of the main text story in a section has started.
visitBookmarkEnd(BookmarkEnd bookmarkEnd) Called when an end of a bookmark is encountered in the document.
visitBookmarkStart(BookmarkStart bookmarkStart) Called when a start of a bookmark is encountered in the document.
visitBuildingBlockEnd(BuildingBlock block) Called when enumeration of a building block has ended.
visitBuildingBlockStart(BuildingBlock block) Called when enumeration of a building block has started.
visitCellEnd(Cell cell) Called when enumeration of a table cell has ended.
visitCellStart(Cell cell) Called when enumeration of a table cell has started.
visitCommentEnd(Comment comment) Called when enumeration of a comment text has ended.
visitCommentRangeEnd(CommentRangeEnd commentRangeEnd) Called when the end of a commented range of text is encountered.
visitCommentRangeStart(CommentRangeStart commentRangeStart) Called when the start of a commented range of text is encountered.
visitCommentStart(Comment comment) Called when enumeration of a comment text has started.
visitDocumentEnd(Document doc) Called when enumeration of the document has finished.
visitDocumentStart(Document doc) Called when enumeration of the document has started.
visitEditableRangeEnd(EditableRangeEnd editableRangeEnd) Called when an end of an editable range is encountered in the document.
visitEditableRangeStart(EditableRangeStart editableRangeStart) Called when a start of an editable range is encountered in the document.
visitFieldEnd(FieldEnd fieldEnd) Called when a field ends in the document.
visitFieldSeparator(FieldSeparator fieldSeparator) Called when a field separator is encountered in the document.
visitFieldStart(FieldStart fieldStart) Called when a field starts in the document.
visitFootnoteEnd(Footnote footnote) Called when enumeration of a footnote or endnote text has ended.
visitFootnoteStart(Footnote footnote) Called when enumeration of a footnote or endnote text has started.
visitFormField(FormField formField) Called when a form field is encountered in the document.
visitGlossaryDocumentEnd(GlossaryDocument glossary) Called when enumeration of a glossary document has ended.
visitGlossaryDocumentStart(GlossaryDocument glossary) Called when enumeration of a glossary document has started.
visitGroupShapeEnd(GroupShape groupShape) Called when enumeration of a group shape has ended.
visitGroupShapeStart(GroupShape groupShape) Called when enumeration of a group shape has started.
visitHeaderFooterEnd(HeaderFooter headerFooter) Called when enumeration of a header or footer in a section has ended.
visitHeaderFooterStart(HeaderFooter headerFooter) Called when enumeration of a header or footer in a section has started.
visitOfficeMathEnd(OfficeMath officeMath) Called when enumeration of a Office Math object has ended.
visitOfficeMathStart(OfficeMath officeMath) Called when enumeration of a Office Math object has started.
visitParagraphEnd(Paragraph paragraph) Called when enumeration of a paragraph has ended.
visitParagraphStart(Paragraph paragraph) Called when enumeration of a paragraph has started.
visitRowEnd(Row row) Called when enumeration of a table row has ended.
visitRowStart(Row row) Called when enumeration of a table row has started.
visitRun(Run run) Called when a run of text in the is encountered.
visitSectionEnd(Section section) Called when enumeration of a section has ended.
visitSectionStart(Section section) Called when enumeration of a section has started.
visitShapeEnd(Shape shape) Called when enumeration of a shape has ended.
visitShapeStart(Shape shape) Called when enumeration of a shape has started.
visitSmartTagEnd(SmartTag smartTag) Called when enumeration of a smart tag has ended.
visitSmartTagStart(SmartTag smartTag) Called when enumeration of a smart tag has started.
visitSpecialChar(SpecialChar specialChar) Called when a SpecialChar node is encountered in the document.
visitStructuredDocumentTagEnd(StructuredDocumentTag sdt) Called when enumeration of a structured document tag has ended.
visitStructuredDocumentTagRangeEnd(StructuredDocumentTagRangeEnd sdtRangeEnd) Called when a StructuredDocumentTagRangeEnd is encountered.
visitStructuredDocumentTagRangeStart(StructuredDocumentTagRangeStart sdtRangeStart) Called when a StructuredDocumentTagRangeStart is encountered.
visitStructuredDocumentTagStart(StructuredDocumentTag sdt) Called when enumeration of a structured document tag has started.
visitSubDocument(SubDocument subDocument) Called when a sub-document is encountered.
visitTableEnd(Table table) Called when enumeration of a table has ended.
visitTableStart(Table table) Called when enumeration of a table has started.
wait()
wait(long arg0)
wait(long arg0, int arg1)

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

Parameter Type Description
arg0 java.lang.Object

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

hashCode()

public native int hashCode()

Returns: int

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

toString()

public String toString()

Returns: java.lang.String

visitAbsolutePositionTab(AbsolutePositionTab tab)

public int visitAbsolutePositionTab(AbsolutePositionTab tab)

Called when a AbsolutePositionTab node is encountered in the document.

Parameters:

Parameter Type Description
tab AbsolutePositionTab The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitBodyEnd(Body body)

public int visitBodyEnd(Body body)

Called when enumeration of the main text story in a section has ended.

Parameters:

Parameter Type Description
body Body The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitBodyStart(Body body)

public int visitBodyStart(Body body)

Called when enumeration of the main text story in a section has started.

Parameters:

Parameter Type Description
body Body The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitBookmarkEnd(BookmarkEnd bookmarkEnd)

public int visitBookmarkEnd(BookmarkEnd bookmarkEnd)

Called when an end of a bookmark is encountered in the document.

Parameters:

Parameter Type Description
bookmarkEnd BookmarkEnd The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitBookmarkStart(BookmarkStart bookmarkStart)

public int visitBookmarkStart(BookmarkStart bookmarkStart)

Called when a start of a bookmark is encountered in the document.

Parameters:

Parameter Type Description
bookmarkStart BookmarkStart The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitBuildingBlockEnd(BuildingBlock block)

public int visitBuildingBlockEnd(BuildingBlock block)

Called when enumeration of a building block has ended.

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).

Parameters:

Parameter Type Description
block BuildingBlock The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitBuildingBlockStart(BuildingBlock block)

public int visitBuildingBlockStart(BuildingBlock block)

Called when enumeration of a building block has started.

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).

Parameters:

Parameter Type Description
block BuildingBlock The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitCellEnd(Cell cell)

public int visitCellEnd(Cell cell)

Called when enumeration of a table cell has ended.

Parameters:

Parameter Type Description
cell Cell The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitCellStart(Cell cell)

public int visitCellStart(Cell cell)

Called when enumeration of a table cell has started.

Parameters:

Parameter Type Description
cell Cell The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitCommentEnd(Comment comment)

public int visitCommentEnd(Comment comment)

Called when enumeration of a comment text has ended.

Parameters:

Parameter Type Description
comment Comment The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitCommentRangeEnd(CommentRangeEnd commentRangeEnd)

public int visitCommentRangeEnd(CommentRangeEnd commentRangeEnd)

Called when the end of a commented range of text is encountered.

Parameters:

Parameter Type Description
commentRangeEnd CommentRangeEnd The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitCommentRangeStart(CommentRangeStart commentRangeStart)

public int visitCommentRangeStart(CommentRangeStart commentRangeStart)

Called when the start of a commented range of text is encountered.

Parameters:

Parameter Type Description
commentRangeStart CommentRangeStart The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitCommentStart(Comment comment)

public int visitCommentStart(Comment comment)

Called when enumeration of a comment text has started.

Parameters:

Parameter Type Description
comment Comment The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitDocumentEnd(Document doc)

public int visitDocumentEnd(Document doc)

Called when enumeration of the document has finished.

Parameters:

Parameter Type Description
doc Document The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitDocumentStart(Document doc)

public int visitDocumentStart(Document doc)

Called when enumeration of the document has started.

Parameters:

Parameter Type Description
doc Document The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitEditableRangeEnd(EditableRangeEnd editableRangeEnd)

public int visitEditableRangeEnd(EditableRangeEnd editableRangeEnd)

Called when an end of an editable range is encountered in the document.

Parameters:

Parameter Type Description
editableRangeEnd EditableRangeEnd The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitEditableRangeStart(EditableRangeStart editableRangeStart)

public int visitEditableRangeStart(EditableRangeStart editableRangeStart)

Called when a start of an editable range is encountered in the document.

Parameters:

Parameter Type Description
editableRangeStart EditableRangeStart The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitFieldEnd(FieldEnd fieldEnd)

public int visitFieldEnd(FieldEnd fieldEnd)

Called when a field ends in the document.

For more info see visitFieldStart(com.aspose.words.FieldStart)

Parameters:

Parameter Type Description
fieldEnd FieldEnd The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitFieldSeparator(FieldSeparator fieldSeparator)

public int visitFieldSeparator(FieldSeparator fieldSeparator)

Called when a field separator is encountered in the document.

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)

Parameters:

Parameter Type Description
fieldSeparator FieldSeparator The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitFieldStart(FieldStart fieldStart)

public int visitFieldStart(FieldStart fieldStart)

Called when a field starts in the document.

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.

Parameters:

Parameter Type Description
fieldStart FieldStart The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitFootnoteEnd(Footnote footnote)

public int visitFootnoteEnd(Footnote footnote)

Called when enumeration of a footnote or endnote text has ended.

Parameters:

Parameter Type Description
footnote Footnote The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitFootnoteStart(Footnote footnote)

public int visitFootnoteStart(Footnote footnote)

Called when enumeration of a footnote or endnote text has started.

Parameters:

Parameter Type Description
footnote Footnote The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitFormField(FormField formField)

public int visitFormField(FormField formField)

Called when a form field is encountered in the document.

Parameters:

Parameter Type Description
formField FormField The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitGlossaryDocumentEnd(GlossaryDocument glossary)

public int visitGlossaryDocumentEnd(GlossaryDocument glossary)

Called when enumeration of a glossary document has ended.

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).

Parameters:

Parameter Type Description
glossary GlossaryDocument The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitGlossaryDocumentStart(GlossaryDocument glossary)

public int visitGlossaryDocumentStart(GlossaryDocument glossary)

Called when enumeration of a glossary document has started.

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).

Parameters:

Parameter Type Description
glossary GlossaryDocument The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitGroupShapeEnd(GroupShape groupShape)

public int visitGroupShapeEnd(GroupShape groupShape)

Called when enumeration of a group shape has ended.

Parameters:

Parameter Type Description
groupShape GroupShape The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitGroupShapeStart(GroupShape groupShape)

public int visitGroupShapeStart(GroupShape groupShape)

Called when enumeration of a group shape has started.

Parameters:

Parameter Type Description
groupShape GroupShape The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitHeaderFooterEnd(HeaderFooter headerFooter)

public int visitHeaderFooterEnd(HeaderFooter headerFooter)

Called when enumeration of a header or footer in a section has ended.

Parameters:

Parameter Type Description
headerFooter HeaderFooter The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitHeaderFooterStart(HeaderFooter headerFooter)

public int visitHeaderFooterStart(HeaderFooter headerFooter)

Called when enumeration of a header or footer in a section has started.

Parameters:

Parameter Type Description
headerFooter HeaderFooter The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitOfficeMathEnd(OfficeMath officeMath)

public int visitOfficeMathEnd(OfficeMath officeMath)

Called when enumeration of a Office Math object has ended.

Parameters:

Parameter Type Description
officeMath OfficeMath The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitOfficeMathStart(OfficeMath officeMath)

public int visitOfficeMathStart(OfficeMath officeMath)

Called when enumeration of a Office Math object has started.

Parameters:

Parameter Type Description
officeMath OfficeMath The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitParagraphEnd(Paragraph paragraph)

public int visitParagraphEnd(Paragraph paragraph)

Called when enumeration of a paragraph has ended.

Parameters:

Parameter Type Description
paragraph Paragraph The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitParagraphStart(Paragraph paragraph)

public int visitParagraphStart(Paragraph paragraph)

Called when enumeration of a paragraph has started.

Parameters:

Parameter Type Description
paragraph Paragraph The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitRowEnd(Row row)

public int visitRowEnd(Row row)

Called when enumeration of a table row has ended.

Parameters:

Parameter Type Description
row Row The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitRowStart(Row row)

public int visitRowStart(Row row)

Called when enumeration of a table row has started.

Parameters:

Parameter Type Description
row Row The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitRun(Run run)

public int visitRun(Run run)

Called when a run of text in the is encountered.

Parameters:

Parameter Type Description
run Run The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitSectionEnd(Section section)

public int visitSectionEnd(Section section)

Called when enumeration of a section has ended.

Parameters:

Parameter Type Description
section Section The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitSectionStart(Section section)

public int visitSectionStart(Section section)

Called when enumeration of a section has started.

Parameters:

Parameter Type Description
section Section The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitShapeEnd(Shape shape)

public int visitShapeEnd(Shape shape)

Called when enumeration of a shape has ended.

Parameters:

Parameter Type Description
shape Shape The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitShapeStart(Shape shape)

public int visitShapeStart(Shape shape)

Called when enumeration of a shape has started.

Parameters:

Parameter Type Description
shape Shape The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitSmartTagEnd(SmartTag smartTag)

public int visitSmartTagEnd(SmartTag smartTag)

Called when enumeration of a smart tag has ended.

Parameters:

Parameter Type Description
smartTag SmartTag The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitSmartTagStart(SmartTag smartTag)

public int visitSmartTagStart(SmartTag smartTag)

Called when enumeration of a smart tag has started.

Parameters:

Parameter Type Description
smartTag SmartTag The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitSpecialChar(SpecialChar specialChar)

public int visitSpecialChar(SpecialChar specialChar)

Called when a SpecialChar node is encountered in the document.

Parameters:

Parameter Type Description
specialChar SpecialChar The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants. This method is not be called for generic control characters (see ControlChar) that can be present in the document.

visitStructuredDocumentTagEnd(StructuredDocumentTag sdt)

public int visitStructuredDocumentTagEnd(StructuredDocumentTag sdt)

Called when enumeration of a structured document tag has ended.

Parameters:

Parameter Type Description
sdt StructuredDocumentTag The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitStructuredDocumentTagRangeEnd(StructuredDocumentTagRangeEnd sdtRangeEnd)

public int visitStructuredDocumentTagRangeEnd(StructuredDocumentTagRangeEnd sdtRangeEnd)

Called when a StructuredDocumentTagRangeEnd is encountered.

Parameters:

Parameter Type Description
sdtRangeEnd StructuredDocumentTagRangeEnd

Returns: int

visitStructuredDocumentTagRangeStart(StructuredDocumentTagRangeStart sdtRangeStart)

public int visitStructuredDocumentTagRangeStart(StructuredDocumentTagRangeStart sdtRangeStart)

Called when a StructuredDocumentTagRangeStart is encountered.

Parameters:

Parameter Type Description
sdtRangeStart StructuredDocumentTagRangeStart

Returns: int

visitStructuredDocumentTagStart(StructuredDocumentTag sdt)

public int visitStructuredDocumentTagStart(StructuredDocumentTag sdt)

Called when enumeration of a structured document tag has started.

Parameters:

Parameter Type Description
sdt StructuredDocumentTag The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitSubDocument(SubDocument subDocument)

public int visitSubDocument(SubDocument subDocument)

Called when a sub-document is encountered.

Parameters:

Parameter Type Description
subDocument SubDocument The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitTableEnd(Table table)

public int visitTableEnd(Table table)

Called when enumeration of a table has ended.

Parameters:

Parameter Type Description
table Table The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

visitTableStart(Table table)

public int visitTableStart(Table table)

Called when enumeration of a table has started.

Parameters:

Parameter Type Description
table Table The object that is being visited.

Returns: int - A VisitorAction value that specifies how to continue the enumeration. The returned value is one of VisitorAction constants.

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

Parameter Type Description
arg0 long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

Parameter Type Description
arg0 long
arg1 int