|
java.lang.Object
Node
com.aspose.words.BookmarkEnd
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Iterable
public class BookmarkEnd - extends Node
Represents an end of a bookmark in a Word document.
A complete bookmark in a Word document consists of a BookmarkStart
and a matching BookmarkEnd with the same bookmark name. BookmarkStart and BookmarkEnd are just markers inside a document
that specify where the bookmark starts and ends. Use the Bookmark class as a "facade" to work with a bookmark
as a single object. Note: Currently bookmarks are only supported in Body (main text story)
of the document. Note: Currently bookmarks are supported only at the inline-level, that is
inside Paragraph. However BookmarkStart and BookmarkEnd
can be in different paragraphs.
|
Constructor Summary |
BookmarkEnd(Document doc, java.lang.String name)
Initializes a new instance of the BookmarkEnd class.
|
|
Method Summary |
boolean | accept(DocumentVisitor visitor) | |
|
Accepts a visitor.
|
Node | deepClone(boolean isCloneChildren) | → inherited from Node |
|
Creates a duplicate of the node.
|
Node | getAncestor(int ancestorType) | → inherited from Node |
|
Gets the first ancestor of the specified NodeType.
|
Node | getAncestor(java.lang.Class ancestorType) | → inherited from Node |
|
Gets the first ancestor of the specified object type.
|
java.lang.String | getText() | → inherited from Node |
|
Gets the text of this node and of all its children.
|
java.util.Iterator | iterator() | → inherited from Node |
| Provides support for the for each style iteration over child nodes of the node. |
Node | nextPreOrder(Node rootNode) | → inherited from Node |
|
Gets next node according to the pre-order tree traversal algorithm.
|
Node | previousPreOrder(Node rootNode) | → inherited from Node |
|
Gets the previous node according to the pre-order tree traversal algorithm.
|
void | remove() | → inherited from Node |
|
Removes itself from the parent.
|
java.lang.String | toTxt() | → inherited from Node |
|
Exports the content of the node into a string in plain text format.
|
BookmarkEnd
public BookmarkEnd(Document doc, java.lang.String name)
-
Initializes a new instance of the BookmarkEnd class.
- Parameters:
doc - The owner document.name - The name of the bookmark.
|
Property Getters/Setters Detail |
getNodeType | |
public int getNodeType()
|
-
Returns NodeType.BookmarkEnd.
The value of the property is NodeType integer constant.
getName | |
public java.lang.String getName()
|
-
Gets the name of the bookmark.
-
Gets the immediate parent of this node.
If a node has just been created and not yet added to the tree,
or if it has been removed from the tree, the parent is null. Example: Shows how to access the parent node.
// Create a new empty document. It has one section.
Document doc = new Document();
// The section is the first child node of the document.
Node section = doc.getFirstChild();
// The section's parent node is the document.
Assert.assertEquals(doc, section.getParentNode()); Example: Shows that when you create any node, it requires a document that will own the node.
// Open a file from disk.
Document doc = new Document();
// Creating a new node of any type requires a document passed into the constructor.
Paragraph para = new Paragraph(doc);
// The new paragraph node does not yet have a parent.
Assert.assertNull(para.getParentNode());
// But the paragraph node knows its document.
Assert.assertEquals(doc, para.getDocument());
// The fact that a node always belongs to a document allows us to access and modify
// properties that reference the document-wide data such as styles or lists.
para.getParagraphFormat().setStyleName("Heading 1");
// Now add the paragaph to the main text of the first section.
doc.getFirstSection().getBody().appendChild(para);
// The paragraph node is now a child of the Body node.
Assert.assertNotNull(para.getParentNode());
getDocument | → inherited from Node |
public Document getDocument()
|
-
Gets the document to which this node belongs.
The node always belongs to a document even if it has just been created
and not yed added to the tree, or if it has been removed from the tree. Example: Shows that when you create any node, it requires a document that will own the node.
// Open a file from disk.
Document doc = new Document();
// Creating a new node of any type requires a document passed into the constructor.
Paragraph para = new Paragraph(doc);
// The new paragraph node does not yet have a parent.
Assert.assertNull(para.getParentNode());
// But the paragraph node knows its document.
Assert.assertEquals(doc, para.getDocument());
// The fact that a node always belongs to a document allows us to access and modify
// properties that reference the document-wide data such as styles or lists.
para.getParagraphFormat().setStyleName("Heading 1");
// Now add the paragaph to the main text of the first section.
doc.getFirstSection().getBody().appendChild(para);
// The paragraph node is now a child of the Body node.
Assert.assertNotNull(para.getParentNode());
getPreviousSibling | → inherited from Node |
public Node getPreviousSibling()
|
-
Gets the node immediately preceding this node.
If there is no preceding node, a null is returned. Note: Calculating the value of this property iterates from the first child node of ParenNode
to this node. Example: Demonstrates use of methods of Node and CompositeNode to remove a section before the last section in the document.
// Document is a CompositeNode and LastChild returns the last child node in the Document node.
// Since the Document can contain only Section nodes, the last child is the last section.
Node lastSection = doc.getLastChild();
// Each node knows its next and previous sibling nodes.
// Previous sibling of a section is a section before the specified section.
// If the node is the first child, PreviousSibling will return null.
Node sectionBeforeLast = lastSection.getPreviousSibling();
if (sectionBeforeLast != null)
doc.removeChild(sectionBeforeLast);
|