@API(type=NOT_EXTENDABLE,
src=PUBLIC)
public interface AuthorDocumentController
Modifier and Type | Method and Description |
---|---|
void |
addAuthorListener(AuthorListener listener)
Add an Author listener to be notified about changes regarding the document
and the document structure.
|
void |
addAuthorPersistentHighlightListener(AuthorPersistentHighlightsListener listener)
Adds a listener to be notified about changes regarding the persistent
highlights.
|
void |
addClipboardFragmentProcessor(ClipboardFragmentProcessor clipboardFragmentProcessor)
Add a processor which can analyze and modify
AuthorDocumentFragment objects before they are inserted in the Author. |
void |
addPersistentHighlightsFilter(AuthorPersistentHighlightsFilter persistentHighlightsFilter)
Add a persistent highlights filter.
|
void |
addUniqueAttributesProcessor(UniqueAttributesProcessor uniqueAttributesProcessor)
Add a processor which is asked to automatically generate unique IDs after content has been inserted in the Author.
|
void |
beginCompoundEdit()
Begin a compound edit.
|
void |
cancelCompoundEdit()
Cancel the current compound edit.
|
AuthorDocumentFragment |
createDocumentFragment(AuthorNode node,
boolean copyContent)
Create a document fragment containing a copy of the node.
|
AuthorDocumentFragment |
createDocumentFragment(int startOffset,
int endOffset)
Create an Author content fragment containing a clone of the document content for the
given range of offsets.
|
AuthorDocumentFragment |
createNewDocumentFragmentInContext(java.lang.String xmlFragment,
int contentOffset)
Create a new
AuthorDocumentFragment from an XML string in a specified context. |
AuthorDocumentFragment[] |
createNewDocumentFragmentsInContext(java.lang.String[] xmlFragments,
int[] contentOffsets)
Create an array of
AuthorDocumentFragment from an array of XML strings
in specified contexts. |
AuthorDocumentFragment |
createNewDocumentTextFragment(java.lang.String textFragment)
Create a new
AuthorDocumentFragment from an string. |
javax.swing.text.Position |
createPositionInContent(int offset)
Create a flexible position in the Author Content.
|
boolean |
delete(int startOffset,
int endOffset)
Deletes a document fragment between the start and end offset.
|
boolean |
delete(int startOffset,
int endOffset,
boolean backspace)
Deletes a document fragment between the start and end offset.
|
boolean |
deleteNode(AuthorNode node)
Delete a node.
|
void |
disableLayoutUpdate()
INTERNAL USE ONLY.
|
void |
enableLayoutUpdate(AuthorNode ancestorOfChanges)
INTERNAL USE ONLY.
|
void |
endCompoundEdit()
End a compound edit.
|
java.lang.Object[] |
evaluateXPath(java.lang.String xpathExpression,
AuthorNode contextNode,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers)
Evaluates an XPath 2.0 expression.
|
java.lang.Object[] |
evaluateXPath(java.lang.String xpathExpression,
AuthorNode contextNode,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers,
XPathVersion xpathVersion)
Evaluates an XPath expression.
|
java.lang.Object[] |
evaluateXPath(java.lang.String xpathExpression,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments)
Evaluates an XPath 2.0 expression.
|
java.lang.Object[] |
evaluateXPath(java.lang.String xpathExpression,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers)
Evaluates an XPath 2.0 expression.
|
AuthorNode[] |
findNodesByXPath(java.lang.String xpathExpression,
AuthorNode contextNode,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers)
Finds the author nodes selected by the given XPath 2.0 expression.
|
AuthorNode[] |
findNodesByXPath(java.lang.String xpathExpression,
AuthorNode contextNode,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers,
XPathVersion xpathVersion)
Finds the author nodes selected by the given XPath expression.
|
AuthorNode[] |
findNodesByXPath(java.lang.String xpathExpression,
AuthorNode contextNode,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers,
XPathVersion xpathVersion,
boolean transparentReferences)
Finds the author nodes selected by the given XPath expression.
|
AuthorNode[] |
findNodesByXPath(java.lang.String xpathExpression,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments)
Finds the author nodes selected by the given XPath 2.0 expression.
|
AuthorNode[] |
findNodesByXPath(java.lang.String xpathExpression,
boolean ignoreTexts,
boolean ignoreCData,
boolean ignoreComments,
boolean processChangeMarkers)
Finds the author nodes selected by the given XPath 2.0 expression.
|
AuthorDocument |
getAuthorDocumentNode()
Returns the edited author document.
|
AuthorSchemaManager |
getAuthorSchemaManager() |
void |
getChars(int where,
int len,
javax.swing.text.Segment chars)
The content represents the entire text content of the Author page + additional markers/sentinels
at offsets which are pointed to by the AuthorNodes.
|
AuthorNode |
getCommonAncestor(AuthorNode[] nodes)
Get the common parent for the nodes.
|
AuthorNode |
getCommonParentNode(AuthorDocument doc,
int startOffset,
int endOffset)
Find the common ancestor node of the two offsets.
|
OffsetInformation |
getContentInformationAtOffset(int offset)
Returns content information for the offset.
|
AuthorDocumentType |
getDoctype()
Returns information about the internal associated document type.
|
AuthorDocumentFilter |
getDocumentFilter()
Gets the
AuthorDocumentFilter which is currently set for altering the document edits. |
AuthorFilteredContent |
getFilteredContent(int start,
int end,
AuthorNodesFilter nodesFilter)
Retrieves the content between the given start and end offset, excluding the
content of the invisible nodes (that have display none style property), the
content deleted with track changes, the sentinels of inline elements and the
content of filtered nodes.
|
java.lang.String |
getFilteredText(int offset,
int length)
Gets a sequence of text from the document content.
|
AuthorNode |
getNodeAtOffset(int offset)
Returns the node at the given offset.
|
java.util.List<AuthorNode> |
getNodesToSelect(int selectionStart,
int selectionEnd)
Compute the list with nodes to select when a selection is present in editor.
|
java.lang.String |
getText(int offset,
int length)
Deprecated.
Please use the API
getChars(int, int, Segment) . |
TextContentIterator |
getTextContentIterator(int startOffset,
int endOffset)
Get an iterator over the text content between two offsets.
|
int |
getTextContentLength()
Deprecated.
Use the API based on the
AuthorNode to get the length
of the displayed text only, without mark-up markers. |
javax.swing.undo.UndoManager |
getUndoManager()
Get access to the Author undo manager.
|
UniqueAttributesProcessor |
getUniqueAttributesProcessor()
Get the compound unique attributes processor which can be asked if a certain attribute should get copied on a split.
|
java.lang.String |
getUnparsedEntityUri(AuthorNode contextNode,
java.lang.String entityName)
Returns the URI of the unparsed entity with the specified name, in the
same document as the context node.
|
java.lang.String |
getXPathExpression(int offset)
Returns the XPath expression of the node identified by the given offset.
|
java.lang.String |
getXPathExpression(int offset,
boolean processChanges)
Returns the XPath expression of the node identified by the given offset.
|
int |
getXPathLocationOffset(java.lang.String xpathLocation,
java.lang.String relativePosition)
Compute the document offset defined by the XPath location and relative position.
|
int |
getXPathLocationOffset(java.lang.String xpathLocation,
java.lang.String relativePosition,
boolean processChangeMarkers)
Compute the document offset defined by the XPath location and relative position.
|
boolean |
inInlineContext(int offset)
Test if the context at the given
offset is inline(as defined in the CSS specs) or not. |
void |
insertFragment(int insertOffset,
AuthorDocumentFragment frag)
Insert an
AuthorDocumentFragment at the given offset. |
SchemaAwareHandlerResult |
insertFragmentSchemaAware(int insertOffset,
AuthorDocumentFragment frag)
Insert an
AuthorDocumentFragment at the given offset in schema aware mode. |
void |
insertMultipleElements(AuthorElement parentElement,
java.lang.String[] elementNames,
int[] offsets,
java.lang.String namespace)
Insert multiple elements at the given offsets.
|
boolean |
insertMultipleFragments(AuthorElement parentElement,
AuthorDocumentFragment[] fragments,
int[] offsets)
Insert multiple fragments at the given offsets.
|
void |
insertText(int offset,
java.lang.String text)
Inserts a text at the given offset.
|
void |
insertXMLFragment(java.lang.String xmlFragment,
AuthorNode relativeTo,
java.lang.String relativePosition)
Insert an XML fragment relative to the given node and according with the
relativePosition . |
void |
insertXMLFragment(java.lang.String xmlFragment,
int offset)
Insert an XML fragment at the given offset.
|
void |
insertXMLFragment(java.lang.String xmlFragment,
java.lang.String xpathLocation,
java.lang.String relativePosition)
Insert an XML fragment relative to the node identified by the
xpathLocation
and according with the relativePosition . |
SchemaAwareHandlerResult |
insertXMLFragmentSchemaAware(java.lang.String xmlFragment,
int offset)
Insert an XML fragment at the given offset in schema aware mode.
|
SchemaAwareHandlerResult |
insertXMLFragmentSchemaAware(java.lang.String xmlFragment,
int offset,
boolean replaceSelection)
Insert an XML fragment at the given offset in schema aware mode.
|
SchemaAwareHandlerResult |
insertXMLFragmentSchemaAware(java.lang.String xmlFragment,
int offset,
int actionID,
boolean replaceSelection)
Insert an XML fragment at the given offset in schema aware mode.
|
SchemaAwareHandlerResult |
insertXMLFragmentSchemaAware(java.lang.String xmlFragment,
java.lang.String xpathLocation,
java.lang.String relativePosition)
Insert an XML fragment relative to the node identified by the
xpathLocation
and according with the relativePosition . |
boolean |
isEditable(AuthorNode node)
Test if a node is editable or not.
|
void |
multipleDelete(AuthorElement parentElement,
int[] startOffsets,
int[] endOffsets)
Deletes the given intervals.
|
boolean |
processContentRange(int startOffset,
int endOffset,
RangeProcessor rangeProcessor)
This method is useful if you want to make text processing on a given Author selection.
|
void |
refreshNodeReferences(AuthorNode node)
Refresh node references recursively.
|
void |
removeAttribute(java.lang.String attributeName,
AuthorElement element)
Removes an attribute from the given element.
|
void |
removeAuthorListener(AuthorListener listener)
Remove an Author listener.
|
void |
removeAuthorPersistentHighlightListener(AuthorPersistentHighlightsListener listener)
Removes a persistent highlights listener.
|
void |
removeClipboardFragmentProcessor(ClipboardFragmentProcessor clipboardFragmentProcessor)
Remove a processor which can analyze and modify
AuthorDocumentFragment objects before they are inserted in the Author. |
void |
removePseudoClass(java.lang.String pseudoClass,
AuthorElement element)
Removes a pseudo class from the given element.
|
void |
removeUniqueAttributesProcessor(UniqueAttributesProcessor uniqueAttributesProcessor)
Remove a processor which is asked to automatically generate unique IDs after content has been inserted in the Author.
|
void |
renameElement(AuthorElement contextNode,
java.lang.String newName)
Rename an Author Element, set another qualified name to it.
|
void |
replaceRoot(AuthorDocumentFragment fragment)
Replace the current root element with the new given one.
|
java.lang.String |
serializeFragmentToXML(AuthorDocumentFragment fragment)
Takes the given fragment and serializes it to XML text in the context
of the current document.
|
void |
setAttribute(java.lang.String attributeName,
AttrValue value,
AuthorElement element)
Sets the value of an attribute in the specified element.
|
void |
setDoctype(AuthorDocumentType docType)
Set a new internal document type to the Author content.
|
void |
setDocumentFilter(AuthorDocumentFilter authorDocumentFilter)
Sets the
AuthorDocumentFilter to be used for altering the document edits. |
void |
setMultipleAttributes(int parentElementStartOffset,
int[] elementOffsets,
java.util.Map<java.lang.String,AttrValue> attributes)
Sets the value of the given attribute in the specified elements.
|
void |
setMultipleDistinctAttributes(int parentElementStartOffset,
int[] elementOffsets,
java.util.List<java.util.Map<java.lang.String,AttrValue>> attributes)
For each element look at the corresponding map of attributes from the list and set it on the element.
|
void |
setPseudoClass(java.lang.String pseudoClass,
AuthorElement element)
Sets a pseudo class in the specified element.
|
void |
setRenderingInfoChangedListener(RenderingInfoChangedListener listener)
Sets the listener to be notified when the rendering info of a node has
changed.
|
boolean |
split(AuthorNode toSplit,
int splitOffset)
Split the node at the given offset.
|
void |
surroundInFragment(AuthorDocumentFragment xmlFragment,
int startOffset,
int endOffset)
Surround the content between the given offsets with the
xmlFragment . |
void |
surroundInFragment(java.lang.String xmlFragment,
int startOffset,
int endOffset)
Surround the content between the given offsets with the
xmlFragment . |
void |
surroundInText(java.lang.String header,
java.lang.String footer,
int startOffset,
int endOffset)
Surround the content between the given offsets with plain text fragments(without XML parsing).
|
AuthorDocumentFragment |
unwrapDocumentFragment(AuthorDocumentFragment fragmentToUnwrap)
Unwrap a given Author document fragment.
|
boolean delete(int startOffset, int endOffset)
startOffset
- Start offset, 0 based, inclusive.endOffset
- End offset, 0 based, inclusive.true
if the delete operation was successful.boolean delete(int startOffset, int endOffset, boolean backspace)
startOffset
- Start offset, 0 based, inclusive.endOffset
- End offset, 0 based, inclusive.backspace
- true
if delete operation was triggered
by the user pressing the backspace key.true
if the delete operation was successful.boolean deleteNode(AuthorNode node)
node
- The AuthorNode
to delete.true
if the delete node operation was successful.void replaceRoot(AuthorDocumentFragment fragment)
fragment
- The document fragment containing the new root element.AuthorDocumentFragment createDocumentFragment(int startOffset, int endOffset) throws javax.swing.text.BadLocationException
startOffset
- The start offset, 0 based, inclusive.endOffset
- The end offset, 0 based, inclusive.AuthorDocumentFragment
.
It does not return a null
fragment.javax.swing.text.BadLocationException
- When the offsets are not between 0 and the
content length, or the startOffset
is greater than the endOffset
.AuthorDocumentFragment createNewDocumentFragmentInContext(java.lang.String xmlFragment, int contentOffset) throws AuthorOperationException
AuthorDocumentFragment
from an XML string in a specified context.
xmlFragment
- The XML Fragment.contentOffset
- The offset where the XML fragment should be inserted.
This method doesn't perform any insertion. This parameter is used to
resolve entities and default attribute values from the DTD in the
specified XML fragment.AuthorDocumentFragment
.
It does not return a null
fragment.AuthorOperationException
- If the new fragment creation fails.AuthorDocumentFragment[] createNewDocumentFragmentsInContext(java.lang.String[] xmlFragments, int[] contentOffsets) throws AuthorOperationException
AuthorDocumentFragment
from an array of XML strings
in specified contexts.
createNewDocumentFragmentInContext(String, int)
method.
xmlFragments
- The array of XML fragments.contentOffsets
- The offsets where the XML fragments should be inserted.
The xml fragments and context offsets arrays must have the same size. The
nth offset corresponds to the nth xml fragment.AuthorDocumentFragment
.
It does not return a null
fragment.AuthorOperationException
- If the xml fragments and context offsets sizes are different or
a fragment creation fails.AuthorDocumentFragment createNewDocumentTextFragment(java.lang.String textFragment) throws AuthorOperationException
AuthorDocumentFragment
from an string. The returned
fragment will contain only a text node and if the text fragment contains
mark-up, it will be escaped. If the text has mark-up and you actually want
to create author nodes from it then you should use createNewDocumentFragmentInContext(String, int)
.textFragment
- The text fragment.AuthorDocumentFragment
holding the text node.
If the text fragment contains mark-up, it will be escaped.
It does not return a null
fragment.AuthorOperationException
- If the new fragment creation fails.java.lang.String serializeFragmentToXML(AuthorDocumentFragment fragment) throws javax.swing.text.BadLocationException
if(authorAccess.getEditorAccess().hasSelection()) { AuthorDocumentController documentController = authorAccess.getDocumentController(); AuthorDocumentFragment selectionAsAFragment = documentController.createDocumentFragment( authorAccess.getEditorAccess().getSelectionStart(), authorAccess.getEditorAccess().getSelectionEnd()); String selectionAsXML = documentController.serializeFragmentToXML(selectionAsAFragment); //Deletes the selection authorAccess.getEditorAccess().deleteSelection(); //Process the selectionAsXML fragment, modify it. //................ //Insert the XML fragment back at caret position. documentController.insertXMLFragment(selectionAsXML, authorAccess.getEditorAccess().getCaretOffset()); }
fragment
- The AuthorDocumentFragment
to serialize.String
representation of the given fragment.
It does not return a null
String. If the fragment cannot be serialized
it will return an empty String.javax.swing.text.BadLocationException
- If the serialization could not be accomplished,
usually because the fragment was not properly built.void setAttribute(java.lang.String attributeName, AttrValue value, AuthorElement element)
AuthorElement.setAttribute(String, AttrValue)
directly)
will be subject to undo/redo.attributeName
- Name of the attribute being changed.value
- New AttrValue
for the attribute. If null
, the attribute is
removed from the element.element
- The AuthorElement
whose attribute is changing.void setMultipleAttributes(int parentElementStartOffset, int[] elementOffsets, java.util.Map<java.lang.String,AttrValue> attributes)
parentElementStartOffset
- The start offset of the parent element.elementOffsets
- The start offset for each element.attributes
- The list with attributes. Every attribute name is mapped to
an AttrValue
object. If the value is null
, the attribute will
be removed.void setMultipleDistinctAttributes(int parentElementStartOffset, int[] elementOffsets, java.util.List<java.util.Map<java.lang.String,AttrValue>> attributes)
parentElementStartOffset
- The start offset of an ancestor node which contains all other elements.elementOffsets
- The start offset for each element.attributes
- The list with attribute sets. Every attribute name is mapped to
an AttrValue
object. If the value is null
, the attribute will
be removed.void removeAttribute(java.lang.String attributeName, AuthorElement element)
AuthorElement.setAttribute(String, AttrValue)
directly) will
be subject to undo/redo.attributeName
- Name of the attribute to remove.element
- The AuthorElement
whose attribute will be removed.void setPseudoClass(java.lang.String pseudoClass, AuthorElement element)
Sets a pseudo class in the specified element.
This change in not subject to undo/redo.
What is good for: You can use a non standard (custom) pseudo class to impose a style change on a specific element. For instance you can have CSS styles matching a custom pseudo-class, like the one below:
section:access-control-user { display:block; } section { display:none; }
By setting the pseudoClass
"access-control-user", the
element section
will become visible.
Another example:
*:caret-visited { color:red; }You could create an
AuthorCaretListener
that sets the caret-visited
pseudo class to the element at the caret location. The effect will be that all the
elements traversed by the caret become red.pseudoClass
- Name of the pseudo class being set.element
- The AuthorElement
whose attribute is changing.void removePseudoClass(java.lang.String pseudoClass, AuthorElement element)
pseudoClass
- Name of the pseudo class being set.element
- The AuthorElement
whose attribute will be removed.AuthorNode getNodeAtOffset(int offset) throws javax.swing.text.BadLocationException
offset
- The offset in the content, zero based.AuthorNode
containing the offset,
or null
when the actual document is null
.javax.swing.text.BadLocationException
- When the offset is negative or greater
than the content length.OffsetInformation getContentInformationAtOffset(int offset) throws javax.swing.text.BadLocationException
offset
- The offset in the content, zero based.javax.swing.text.BadLocationException
AuthorDocumentFragment createDocumentFragment(AuthorNode node, boolean copyContent) throws javax.swing.text.BadLocationException
copyContent
is true
the node content
will be copied also.node
- The AuthorNode
to be duplicated.copyContent
- If true
the content of the node will
also be duplicated.AuthorDocumentFragment
containing the duplicated node.
It does not return a null
fragment.javax.swing.text.BadLocationException
- When the operation fails.@Deprecated java.lang.String getText(int offset, int length) throws javax.swing.text.BadLocationException
getChars(int, int, Segment)
.offset
is considered to be relative to the
text content start offset. So the 0 offset corresponds to the offset of
the first valid char in the document.
length
represents also a number of valid chars encountered
after the real start offset was determined.
[?PI?][article][!COMMENT][para]PARAGRAPH[/para][/article]
getText(0, 18)
returns "PICOMMENTPARAGRAPH"
getText(5, 8)
returns "MENTPARA"offset
- The starting offset >= 0.length
- The number of characters to retrieve >= 0javax.swing.text.BadLocationException
- The range given includes a position
that is not a valid position within the document text content.@Deprecated int getTextContentLength() throws javax.swing.text.BadLocationException
AuthorNode
to get the length
of the displayed text only, without mark-up markers.
[?PI?][article][!COMMENT][para]PARAGRAPH[/para][/article]
The text content length will be:
"PI".length() + "COMMENT".length() + "PARAGRAPH".length()
2 + 7 + 9 = 18
javax.swing.text.BadLocationException
javax.swing.undo.UndoManager getUndoManager()
null
.void beginCompoundEdit()
beginCompoundEdit()
and endCompoundEdit()
methods calls are regarded by the UndoManager
as a single operation which can be undone/redone in one step.void endCompoundEdit()
beginCompoundEdit()
void cancelCompoundEdit()
beginCompoundEdit()
will be undo by the UndoManager.
Note that the compound edit does not end after a call to this method, so an
explicit call to endCompoundEdit()
is required.beginCompoundEdit()
,
endCompoundEdit()
void insertText(int offset, java.lang.String text)
offset
- The insert position, 0 based.text
- The text to be inserted.void insertXMLFragment(java.lang.String xmlFragment, int offset) throws AuthorOperationException
xmlFragment
- The XML fragment to insert.offset
- The insert position, 0 based.AuthorOperationException
- If the fragment could not be inserted.void insertXMLFragment(java.lang.String xmlFragment, java.lang.String xpathLocation, java.lang.String relativePosition) throws AuthorOperationException
xpathLocation
and according with the relativePosition
.
Note: if the xpathLocation
is not specified then the XML fragment
will be inserted at caret position and the relativePosition
will be ignored.
After the operation the caret will be positioned in the first leaf of the fragment.
xmlFragment
- The XML fragment.xpathLocation
- The XPath location.relativePosition
- The position relative to the node identified by the XPath location.
Can be one of the constants: AuthorConstants.POSITION_BEFORE
, AuthorConstants.POSITION_AFTER
,
AuthorConstants.POSITION_INSIDE_FIRST
or AuthorConstants.POSITION_INSIDE_LAST
.AuthorOperationException
- If the fragment could not be inserted.void insertXMLFragment(java.lang.String xmlFragment, AuthorNode relativeTo, java.lang.String relativePosition) throws AuthorOperationException
relativePosition
.
After the operation the caret will be positioned at the end of the inserted XML fragment.
xmlFragment
- The XML fragment.relativeTo
- The node to insert fragment relative to.relativePosition
- The position relative to the node.
Can be one of the constants: AuthorConstants.POSITION_BEFORE
, AuthorConstants.POSITION_AFTER
,
AuthorConstants.POSITION_INSIDE_FIRST
or AuthorConstants.POSITION_INSIDE_LAST
.AuthorOperationException
- If the fragment could not be inserted.SchemaAwareHandlerResult insertXMLFragmentSchemaAware(java.lang.String xmlFragment, int offset) throws AuthorOperationException
<sect1> <title>Section title</title> {caret} <para>para content</para> </sect1>if insert a fragment like:
<emphasis>text</emphasis>
the proposal is to
create a new para
element and insert the fragment inside it. The proposal result will be:
<sect1> <title>Section title</title> <para><emphasis>text</emphasis></para> <para>para content</para> </sect1>
<sect1> <title>Section title</title> {caret} <para>para content</para> </sect1>if insert a fragment like:
<sect1>...section content...</sect1>
the proposal is to
split the parent sect1
element and insert the fragment between the resulted sections. The proposal result will be:
<sect1> <title>Section title</title> </sect1> <sect1>...section content...</sect1> <sect1> <para>para content</para> </sect1>
<sect1> <title>Section title</title> {caret} <para>para content</para> </sect1>if insert a fragment like:
<emphasis>text</emphasis>
the proposals are to
insert the fragment at the end of title
or at beginning of para
element.
<sect1> <title>Section title {caret}</title> </sect1>if insert a fragment like:
<para>fragment <emphasis>content</emphasis></para>
the proposal is to remove the fragment mark-up and insert the text 'fragment content' at caret position.
The proposal result will be:
<sect1> <title>Section title fragment content</title> </sect1>
If the developer specifies an AuthorSchemaAwareEditingHandler
then this handler has priority
for executing the insert operation.
xmlFragment
- The XML fragment to insert.offset
- The insert position, 0 based.AuthorOperationException
- If the fragment could not be inserted.SchemaAwareHandlerResult insertXMLFragmentSchemaAware(java.lang.String xmlFragment, int offset, boolean replaceSelection) throws AuthorOperationException
<sect1> <title>Section title</title> {caret} <para>para content</para> </sect1>if insert a fragment like:
<emphasis>text</emphasis>
the proposal is to
create a new para
element and insert the fragment inside it. The proposal result will be:
<sect1> <title>Section title</title> <para><emphasis>text</emphasis></para> <para>para content</para> </sect1>
<sect1> <title>Section title</title> {caret} <para>para content</para> </sect1>if insert a fragment like:
<sect1>...section content...</sect1>
the proposal is to
split the parent sect1
element and insert the fragment between the resulted sections. The proposal result will be:
<sect1> <title>Section title</title> </sect1> <sect1>...section content...</sect1> <sect1> <para>para content</para> </sect1>
<sect1> <title>Section title</title> {caret} <para>para content</para> </sect1>if insert a fragment like:
<emphasis>text</emphasis>
the proposals are to
insert the fragment at the end of title
or at beginning of para
element.
<sect1> <title>Section title {caret}</title> </sect1>if insert a fragment like:
<para>fragment <emphasis>content</emphasis></para>
the proposal is to remove the fragment mark-up and insert the text 'fragment content' at caret position.
The proposal result will be:
<sect1> <title>Section title fragment content</title> </sect1>
If the developer specifies an AuthorSchemaAwareEditingHandler
then this handler has priority
for executing the insert operation.
xmlFragment
- The XML fragment to insert.offset
- The insert position, 0 based.replaceSelection
- true
to replace the selected Author content with the fragment,
false
to leave the selected content and paste at caret position.AuthorOperationException
- If the fragment could not be inserted.SchemaAwareHandlerResult insertXMLFragmentSchemaAware(java.lang.String xmlFragment, int offset, int actionID, boolean replaceSelection) throws AuthorOperationException
Insert an XML fragment at the given offset in schema aware mode.
The insertion behavior depends on the action type (specified by the
actionID parameter) that triggered it. For more details see the
description of insertXMLFragmentSchemaAware(String, int, boolean)
.
xmlFragment
- The XML fragment to insert.offset
- The insert position, 0 based.actionID
- The action that caused the insertion. One of the constants
in AuthorSchemaAwareEditingHandler
.replaceSelection
- true
to replace the selected Author content with the fragment,
false
to leave the selected content and paste at caret position.AuthorOperationException
- If the fragment could not be inserted.void insertFragment(int insertOffset, AuthorDocumentFragment frag)
AuthorDocumentFragment
at the given offset.
insertOffset
- The offset where the fragment will be inserted, 0 based.frag
- The AuthorDocumentFragment
to be inserted.boolean processContentRange(int startOffset, int endOffset, RangeProcessor rangeProcessor) throws javax.swing.text.BadLocationException, AuthorOperationException
The author content contains the entire XML document text and special marker characters. Each author node points in the content to the start and end marker characters which are used to delimit it's range.
The start and end offsets pointed to by the AuthorNode can be retrieved using the
AuthorNode.getStartOffset()
and AuthorNode.getEndOffset()
.
The image represents part of the document content and red markers represent special control characters which represent the node ranges.
startOffset
- Start offset of the processed range (inclusive).endOffset
- End offset of the processed range (inclusive).rangeProcessor
- The range processor which gets notified to process the
AuthorDocumentFragment
.true
if the modifications were merged back in the Author content.
For example when the selection cannot be replaced (inside a not-editable element) this method
can return false
.javax.swing.text.BadLocationException
AuthorOperationException
SchemaAwareHandlerResult insertFragmentSchemaAware(int insertOffset, AuthorDocumentFragment frag) throws AuthorOperationException
AuthorDocumentFragment
at the given offset in schema aware mode.
A normal insertion is executed when no schema is specified or schema aware feature is disable by the user
(see Preferences / Editor / Pages / Author / Schema aware).
For more details about schema aware solutions see comments from insertXMLFragmentSchemaAware(String, int)
method.
insertOffset
- The offset where the fragment will be inserted, 0 based.frag
- The AuthorDocumentFragment
to be inserted.AuthorOperationException
- If the fragment could not be inserted.void surroundInFragment(java.lang.String xmlFragment, int startOffset, int endOffset) throws AuthorOperationException
xmlFragment
.
If endOffset < startOffset
the xmlFragment
will be inserted at startOffset
.
xmlFragment
- The XML fragment which will surround the given interval.
The first leaf node of the XML fragment will be the parent of the surrounded content.startOffset
- The start offset of the content to be surrounded, 0 based and inclusive.endOffset
- The end offset of the content to be surrounded, 0 based and inclusive.AuthorOperationException
- If the content between start and end offset could not be surrounded.void surroundInFragment(AuthorDocumentFragment xmlFragment, int startOffset, int endOffset) throws AuthorOperationException
xmlFragment
.
If endOffset < startOffset
the xmlFragment
will be inserted at startOffset
.
xmlFragment
- The XML fragment which will surround the given interval.
The first leaf node of the XML fragment will be the parent of the surrounded content.startOffset
- The start offset of the content to be surrounded, 0 based and inclusive.endOffset
- The end offset of the content to be surrounded, 0 based and inclusive.AuthorOperationException
- If the content between start and end offset could not be surrounded.void surroundInText(java.lang.String header, java.lang.String footer, int startOffset, int endOffset) throws AuthorOperationException
header
at startOffset
and
the footer
at endOffset
.
header
- The header to be inserted before the surrounded text.footer
- The footer to be inserted after the surrounded text.startOffset
- The start offset of the text to be surrounded, 0 based.endOffset
- The end offset of the text to be surrounded, 0 based.AuthorOperationException
- If the operation failed.boolean inInlineContext(int offset) throws javax.swing.text.BadLocationException, AuthorOperationException
offset
is inline(as defined in the CSS specs) or not.
The CSS display property is taken into account when determining this state.
For example a text paragraph determines an inline context, and for an offset inside this paragraph the method will returntrue
.
For an offset between two paragraphs (considered to be block level)
the method will return false
.offset
- The offset in the document, zero based.true
if the given offset is inside an inline context.
false
otherwise.javax.swing.text.BadLocationException
- When the offset does not exists in the document content.AuthorOperationException
- If the operation failed.void addAuthorListener(AuthorListener listener)
listener
- The AuthorListener
to be added.void addAuthorPersistentHighlightListener(AuthorPersistentHighlightsListener listener)
AuthorPersistentHighlighter.addHighlight(int, int, java.util.LinkedHashMap)
listener
- The listenerAuthorPersistentHighlight.PersistentHighlightType
,
AuthorPersistentHighlight
void removeAuthorPersistentHighlightListener(AuthorPersistentHighlightsListener listener)
listener
- The listener to remove.void addPersistentHighlightsFilter(AuthorPersistentHighlightsFilter persistentHighlightsFilter)
persistentHighlightsFilter
- The filter to be added.void removeAuthorListener(AuthorListener listener)
listener
- The AuthorListener
to be removed.java.lang.Object[] evaluateXPath(java.lang.String xpathExpression, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers) throws AuthorOperationException
Object
.
Author DOM text nodes, DOM CDATA sections and DOM comment wrappers can be
ignored for performance reasons.
//node()
will return an array with all the Author DOM Node wrappers in the document.
count(//node())
will return an array having a single component representing the number of nodes in the document.
//node(), count(//node())
will return an array containing all the Author DOM Node wrappers in the document and having as last component
the total number of nodes.
You can also use the XPath extension functions oxy:current-selected-element() and oxy:allows-child-element().
xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.ignoreTexts
- If true
DOM text nodes will not be returned.ignoreCData
- If true
DOM CDATA sections will not be returned.ignoreComments
- If true
DOM comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).null
array. If the XPath evaluation fails it will return
an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.java.lang.Object[] evaluateXPath(java.lang.String xpathExpression, AuthorNode contextNode, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers, XPathVersion xpathVersion) throws AuthorOperationException
Object
.
Author DOM text nodes, DOM CDATA sections and DOM comment wrappers can be
ignored for performance reasons.
//node()
will return an array with all the Author DOM Node wrappers in the document.
count(//node())
will return an array having a single component representing the number of nodes in the document.
//node(), count(//node())
will return an array containing all the Author DOM Node wrappers in the document and having as last component
the total number of nodes.
You can also use the XPath extension functions oxy:current-selected-element() and oxy:allows-child-element().
xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.contextNode
- The node in the context of which the relative XPath Expressions will computed.
If null
the context node will be the node at the current caret position.ignoreTexts
- If true
DOM text nodes will not be returned.ignoreCData
- If true
DOM CDATA sections will not be returned.ignoreComments
- If true
DOM comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).xpathVersion
- Used version of XPath.null
array. If the XPath evaluation fails it will return
an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.java.lang.Object[] evaluateXPath(java.lang.String xpathExpression, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments) throws AuthorOperationException
Object
.
Author DOM text nodes, DOM CDATA sections and DOM comment wrappers can be
ignored for performance reasons.
//node()
will return an array with all the Author DOM Node wrappers in the document.
count(//node())
will return an array having a single component representing the number of nodes in the document.
//node(), count(//node())
will return an array containing all the Author DOM Node wrappers in the document and having as last component
the total number of nodes.
If change tracking (insert/remove/comment) markers exist in the document they will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
You can also use the XPath extension functions oxy:current-selected-element() and oxy:allows-child-element().
xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.ignoreTexts
- If true
DOM text nodes will not be returned.ignoreCData
- If true
DOM CDATA sections will not be returned.ignoreComments
- If true
DOM comments will not be returned.null
array. If the XPath evaluation fails it will return
an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.AuthorNode[] findNodesByXPath(java.lang.String xpathExpression, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers) throws AuthorOperationException
AuthorNode
selected
by the given XPath expression.
Author text nodes, Author CDATA section nodes and Author comment nodes
can be ignored for performance reasons.
//node()
will return an array with all the AuthorNode's in the document.
count(//node())
will return an empty array.
If change tracking (insert/remove/comment) markers exist in the document they will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.xpathExpression
- The XPath expression.ignoreTexts
- If true
Author text nodes will not be returned.ignoreCData
- If true
Author CDATA sections will not be returned.ignoreComments
- If true
Author comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).null
array of nodes.
If the evaluation of the XPath expression fails it will return an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.AuthorNode[] findNodesByXPath(java.lang.String xpathExpression, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments) throws AuthorOperationException
AuthorNode
selected
by the given XPath expression.
Author text nodes, Author CDATA section nodes and Author comment nodes
can be ignored for performance reasons.
//node()
will return an array with all the AuthorNode's in the document.
count(//node())
will return an empty array.
If change tracking (insert/remove/comment) markers exist in the document the XPath will be applied over the document as if the change tracking is applied
(All changes processed to processing instructions like when the XML document gets saved on disk).xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.ignoreTexts
- If true
Author text nodes will not be returned.ignoreCData
- If true
Author CDATA sections will not be returned.ignoreComments
- If true
Author comments will not be returned.null
array of nodes.
If the evaluation of the XPath expression fails it will return an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.int getXPathLocationOffset(java.lang.String xpathLocation, java.lang.String relativePosition, boolean processChangeMarkers) throws AuthorOperationException
xpathLocation
- The XPath defining a node in document.relativePosition
- The relative position to the node.
One of the following: AuthorConstants.POSITION_BEFORE
,
AuthorConstants.POSITION_INSIDE_FIRST
, AuthorConstants.POSITION_INSIDE_LAST
or
AuthorConstants.POSITION_AFTER
processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).AuthorOperationException
- If it fails.Please note that this API is not marked as final and it can change in one of the next versions of the application. If you have suggestions, comments about it, please let us know.
int getXPathLocationOffset(java.lang.String xpathLocation, java.lang.String relativePosition) throws AuthorOperationException
xpathLocation
- The XPath defining a node in document.relativePosition
- The relative position to the node.
One of the following: AuthorConstants.POSITION_BEFORE
,
AuthorConstants.POSITION_INSIDE_FIRST
, AuthorConstants.POSITION_INSIDE_LAST
or
AuthorConstants.POSITION_AFTER
AuthorOperationException
- If it fails.void insertMultipleElements(AuthorElement parentElement, java.lang.String[] elementNames, int[] offsets, java.lang.String namespace)
To insert two elements one after another:
String[] fragments = new String[] {"elem1", "elem2"}; insertMultipleElements(parentElement, fragments, new int[] {offset, offset}, null);The result of running the above code will be:
parent elem1 elem2
The author content contains the entire XML document text and special marker characters.
Each author node points in the content to the start and end marker characters which are used to
delimit it's range.
The start and end offsets pointed to by the AuthorNode can be retrieved using the
AuthorNode.getStartOffset() and AuthorNode.getEndOffset()
The image represents part of the document content and red markers represent special control
characters which represent the node ranges.
parentElement
- The parent element that contains all the new inserted
elements.elementNames
- The element names to be inserted.offsets
- The absolute offsets where the elements will be inserted.namespace
- The namespace of the new inserted elements.boolean insertMultipleFragments(AuthorElement parentElement, AuthorDocumentFragment[] fragments, int[] offsets)
To insert two fragment one after another:
AuthorDocumentFragment[] fragments = new AuthorDocumentFragment[] {frag1, frag2}; insertMultipleFragments(parentElement, fragments, new int[] {offset, offset});The result of running the above code will be:
parent frag1 frag2
The author content contains the entire XML document text and special marker characters.
Each author node points in the content to the start and end marker characters which are used to
delimit it's range.
The start and end offsets pointed to by the AuthorNode can be retrieved using the
AuthorNode.getStartOffset() and AuthorNode.getEndOffset()
The image represents part of the document content and red markers represent special control
characters which represent the node ranges.
parentElement
- The parent element that contains all the new inserted
elements.fragments
- The fragments to be inserted.offsets
- The absolute offsets where the fragments will be inserted.
The offset must be given in the original document.true
if the operation succeed.void multipleDelete(AuthorElement parentElement, int[] startOffsets, int[] endOffsets)
parentElement
- The element that contains all the deleted intervals.startOffsets
- The start offset for each interval.
Must be in document order.endOffsets
- The end offset for each interval.
Must be in document order. 0 based and inclusive.void setDoctype(AuthorDocumentType docType)
docType
- The document type information.AuthorDocumentType getDoctype()
null
.AuthorNode getCommonParentNode(AuthorDocument doc, int startOffset, int endOffset) throws javax.swing.text.BadLocationException
doc
- The author document.startOffset
- The start offset.endOffset
- The end offset.null
.javax.swing.text.BadLocationException
java.util.List<AuthorNode> getNodesToSelect(int selectionStart, int selectionEnd) throws javax.swing.text.BadLocationException
selectionStart
- The selection start.selectionEnd
- The selection end exclusive.javax.swing.text.BadLocationException
AuthorNode getCommonAncestor(AuthorNode[] nodes)
nodes
- The array which contains the nodes.null
if the nodes are not from the same document or do not belong to a document.AuthorDocument getAuthorDocumentNode()
null
.void setDocumentFilter(AuthorDocumentFilter authorDocumentFilter)
AuthorDocumentFilter
to be used for altering the document edits.authorDocumentFilter
- The AuthorDocumentFilter
to be used.AuthorDocumentFilter getDocumentFilter()
AuthorDocumentFilter
which is currently set for altering the document edits.AuthorDocumentFilter
which is currently set for altering the document edits or null
if no filter was set.void getChars(int where, int len, javax.swing.text.Segment chars) throws javax.swing.text.BadLocationException
Segment
.where
- The starting position >= 0, where + len <= length()len
- The number of characters to be retrieved >= 0chars
- The Segment
object to return the characters int.ojavax.swing.text.BadLocationException
- If the specified position or length are invalid.AuthorFilteredContent getFilteredContent(int start, int end, AuthorNodesFilter nodesFilter)
AuthorNodesFilter.shouldFilterNode(AuthorNode)
returns true
.
start
- The starting position >= 0.end
- The end position >= 0, inclusivenodesFilter
- Provides information about the Author nodes that should be filtered.AuthorSchemaManager getAuthorSchemaManager()
SchemaAwareHandlerResult insertXMLFragmentSchemaAware(java.lang.String xmlFragment, java.lang.String xpathLocation, java.lang.String relativePosition) throws AuthorOperationException
xpathLocation
and according with the relativePosition
.
Note: if the xpathLocation
is not specified then the XML fragment
will be inserted at caret position and the relativePosition will be ignored.
For more details about schema aware solutions see comments from insertXMLFragmentSchemaAware(String, int)
method.
xmlFragment
- The XML fragment.xpathLocation
- The XPath location.relativePosition
- The position relative to the node identified by the XPath location.
Can be one of the constants: AuthorConstants.POSITION_BEFORE
, AuthorConstants.POSITION_AFTER
,
AuthorConstants.POSITION_INSIDE_FIRST
or AuthorConstants.POSITION_INSIDE_LAST
.AuthorOperationException
- If the fragment could not be inserted.insertXMLFragmentSchemaAware(String, int)
boolean isEditable(AuthorNode node)
node
- The node to test if is editable.void renameElement(AuthorElement contextNode, java.lang.String newName)
contextNode
- The element to rename.newName
- The new qualified name to set to it.TextContentIterator getTextContentIterator(int startOffset, int endOffset)
startOffset
- Start offset, 0 based, inclusive.endOffset
- End offset, 0 based, inclusive.javax.swing.text.Position createPositionInContent(int offset) throws javax.swing.text.BadLocationException
Position
added to a swing Document
.offset
- The offset where to create the positionjavax.swing.text.BadLocationException
void addClipboardFragmentProcessor(ClipboardFragmentProcessor clipboardFragmentProcessor)
AuthorDocumentFragment
objects before they are inserted in the Author.
The processor specified in the ExtensionsBundle
will have maximum priority.clipboardFragmentProcessor
- a processor which can analyze and modify AuthorDocumentFragment
objects before they are inserted in the Author.void removeClipboardFragmentProcessor(ClipboardFragmentProcessor clipboardFragmentProcessor)
AuthorDocumentFragment
objects before they are inserted in the Author.clipboardFragmentProcessor
- a processor which can analyze and modify AuthorDocumentFragment
objects before they are inserted in the Author.void addUniqueAttributesProcessor(UniqueAttributesProcessor uniqueAttributesProcessor)
UniqueAttributesRecognizer
specified in the ExtensionsBundle
will have maximum priority.uniqueAttributesProcessor
- a processor which is asked to automatically generate unique IDs after content has been inserted in the Author.
The processor can also specify which attributes can be copied on split.UniqueAttributesProcessor getUniqueAttributesProcessor()
Get the compound unique attributes processor which can be asked if a certain attribute should get copied on a split.
void removeUniqueAttributesProcessor(UniqueAttributesProcessor uniqueAttributesProcessor)
UniqueAttributesRecognizer
specified in the ExtensionsBundle
will have maximum priority.uniqueAttributesProcessor
- a processor which is asked to automatically generate unique IDs after content has been inserted in the Author.
The processor can also specify which attributes can be copied on split.AuthorNode[] findNodesByXPath(java.lang.String xpathExpression, AuthorNode contextNode, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers) throws AuthorOperationException
AuthorNode
selected
by the given XPath expression.
Author text nodes, Author CDATA section nodes and Author comment nodes
can be ignored for performance reasons.
//node()
will return an array with all the AuthorNode's in the document.
count(//node())
will return an empty array.
If change tracking (insert/remove/comment) markers exist in the document they will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
Note: References (like XInclude) will be transparent for the Xpath execution.
The Xpath will see the referenced nodes as though they belong to the document.xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.contextNode
- The node in the context of which the relative XPath Expressions will computed.
If null
the context node will be the node at the current caret position.ignoreTexts
- If true
Author text nodes will not be returned.ignoreCData
- If true
Author CDATA sections will not be returned.ignoreComments
- If true
Author comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).null
array of nodes.
If the evaluation of the XPath expression fails it will return an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.AuthorNode[] findNodesByXPath(java.lang.String xpathExpression, AuthorNode contextNode, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers, XPathVersion xpathVersion) throws AuthorOperationException
AuthorNode
selected
by the given XPath expression.
Author text nodes, Author CDATA section nodes and Author comment nodes
can be ignored for performance reasons.
//node()
will return an array with all the AuthorNode's in the document.
count(//node())
will return an empty array.
If change tracking (insert/remove/comment) markers exist in the document they will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.contextNode
- The node in the context of which the relative XPath Expressions will computed.
If null
the context node will be the node at the current caret position.ignoreTexts
- If true
Author text nodes will not be returned.ignoreCData
- If true
Author CDATA sections will not be returned.ignoreComments
- If true
Author comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).xpathVersion
- Used version of XPath.null
array of nodes.
If the evaluation of the XPath expression fails it will return an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.AuthorNode[] findNodesByXPath(java.lang.String xpathExpression, AuthorNode contextNode, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers, XPathVersion xpathVersion, boolean transparentReferences) throws AuthorOperationException
AuthorNode
selected
by the given XPath expression.
Author text nodes, Author CDATA section nodes and Author comment nodes
can be ignored for performance reasons.
//node()
will return an array with all the AuthorNode's in the document.
count(//node())
will return an empty array.
If change tracking (insert/remove/comment) markers exist in the document they will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.contextNode
- The node in the context of which the relative XPath Expressions will computed.
If null
the context node will be the node at the current caret position.ignoreTexts
- If true
Author text nodes will not be returned.ignoreCData
- If true
Author CDATA sections will not be returned.ignoreComments
- If true
Author comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).xpathVersion
- Used version of XPath.transparentReferences
- If true
the references (like XInclude, or entities) will be transparent for the Xpath execution.
The Xpath will see the referenced nodes as though they belong to the document.null
array of nodes.
If the evaluation of the XPath expression fails it will return an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.java.lang.Object[] evaluateXPath(java.lang.String xpathExpression, AuthorNode contextNode, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments, boolean processChangeMarkers) throws AuthorOperationException
Object
.
Author DOM text nodes, DOM CDATA sections and DOM comment wrappers can be
ignored for performance reasons.
//node()
will return an array with all the Author DOM Node wrappers in the document.
count(//node())
will return an array having a single component representing the number of nodes in the document.
//node(), count(//node())
will return an array containing all the Author DOM Node wrappers in the document and having as last component
the total number of nodes.
You can also use the XPath extension functions oxy:current-selected-element() and oxy:allows-child-element().
Note: References (like XInclude) will be transparent for the Xpath execution. The Xpath will see the referenced nodes as though they belong to the document.xpathExpression
- The XPath expression. If the XPath expression is relative, it will be computed in the context of the context node.contextNode
- The node in the context of which the relative XPath Expressions will computed.
If null
the context node will be the node at the current caret position.ignoreTexts
- If true
DOM text nodes will not be returned.ignoreCData
- If true
DOM CDATA sections will not be returned.ignoreComments
- If true
DOM comments will not be returned.processChangeMarkers
- If false
the change markers (inserts/deletes/comments) will be ignored
and the XPath will return results as if the insert changes are accepted, the delete changes are rejected and the comment changes are ignored.
If true
the XPath will be applied over the document as if the change markers are applied.
(All changes processed to processing instructions like when the XML document gets saved on disk).null
array. If the XPath evaluation fails it will return
an empty array.AuthorOperationException
- If the XPath expression failed to be evaluated.AuthorDocumentFragment unwrapDocumentFragment(AuthorDocumentFragment fragmentToUnwrap) throws javax.swing.text.BadLocationException
null
if the root is empty), else the given fragment is returned.
fragmentToUnwrap
- The Author document fragment to be unwrapped.null
if the root is empty) or the given fragment.javax.swing.text.BadLocationException
- When the offsets are not between 0 and the
content length, or the startOffset
is greater than the endOffset
.java.lang.String getUnparsedEntityUri(AuthorNode contextNode, java.lang.String entityName)
contextNode
- Context node.entityName
- Unparsed entity name.null
if the entity is undefined.void refreshNodeReferences(AuthorNode node)
Refresh node references recursively. If a node has expanded references on it created using the "ro.sync.ecss.extensions.api.AuthorReferenceResolver" API this method will call again the API to provide a fresh reference content for the node.
node
- The node on which to refresh the references.void setRenderingInfoChangedListener(RenderingInfoChangedListener listener)
Sets the listener to be notified when the rendering info of a node has changed.
The rendering info is represented by the node's styles computed from the associated CSS stylesheet and its content.
listener
- The listener.java.lang.String getXPathExpression(int offset) throws javax.swing.text.BadLocationException
offset
- The offset of the node to get the XPath expression for.javax.swing.text.BadLocationException
- When the offset is outside the valid interval (0 and the
content length).java.lang.String getXPathExpression(int offset, boolean processChanges) throws javax.swing.text.BadLocationException
offset
- The offset of the node to get the XPath expression for.processChanges
- if true
nodes which have been marked as deletion changes are ignored when building the expession.javax.swing.text.BadLocationException
- When the offset is outside the valid interval (0 and the
content length).void disableLayoutUpdate()
enableLayoutUpdate(AuthorNode)
should allways be
called at the end.void enableLayoutUpdate(AuthorNode ancestorOfChanges)
disableLayoutUpdate()
and fires
the required notifications to update the views and styles.ancestorOfChanges
- The node that contains all the structural changes.
If null
the root element will be used instead.boolean split(AuthorNode toSplit, int splitOffset)
toSplit
- The node to splitsplitOffset
- The split offsetPlease note that this API is not marked as final and it can change in one of the next versions of the application. If you have suggestions, comments about it, please let us know.
java.lang.String getFilteredText(int offset, int length) throws javax.swing.text.BadLocationException
offset
- The starting offset >= 0.length
- The number of characters to retrieve >= 0javax.swing.text.BadLocationException
- The range given includes a position
that is not a valid position within the document text content.Please note that this API is not marked as final and it can change in one of the next versions of the application. If you have suggestions, comments about it, please let us know.
© Copyright SyncRO Soft SRL 2002 - 2016. All rights reserved.