@API(type=INTERNAL,
src=PUBLIC)
public class CommonsOperationsUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CommonsOperationsUtil.ConversionElementHelper
Interface used to check the elements that will be converted in other elements
(table cells or list entries)
|
static class |
CommonsOperationsUtil.SelectedFragmentInfo
Class containing the new fragment and info about it.
|
Constructor and Description |
---|
CommonsOperationsUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
buildFreshPrefix(NamespaceContext namespaceContext)
Generates a prefix that is not yet bound to a namespace.
|
static java.net.URL |
expandAndResolvePath(AuthorAccess authorAccess,
java.lang.String path)
Resolves a path relative to the framework directory.
|
static java.lang.String |
getLocalName(java.lang.String qName)
Get the local name from an qualified element or attribute name.
|
static java.lang.String |
getPrefix(java.lang.String qName)
Get the proxy from an qualified element or attribute name.
|
static java.util.List<CommonsOperationsUtil.SelectedFragmentInfo> |
getSelectedFragmentsForConversions(AuthorAccess authorAccess,
CommonsOperationsUtil.ConversionElementHelper helper)
Get selected content fragments to be converted to cell or list entries fragments.
|
static java.net.URL |
locateResourceInClasspath(AuthorAccess authorAccess,
java.lang.String resourceFileName)
Locate a certain resource in the classpath using its file name.
|
static java.util.List<javax.swing.text.Position> |
removeCurrentSelection(AuthorAccess authorAccess)
Remove current selection from Author.
|
static void |
removeEmptyElements(AuthorAccess authorAccess,
java.util.List<javax.swing.text.Position> emptyElementsPositions)
Remove empty elements.
|
static void |
removeUnwantedAttributes(java.lang.String[] skippedAttributes,
AuthorDocumentFragment fragment,
AuthorDocumentController controller)
Remove unwanted attributes.
|
static java.lang.String |
setAttributeValue(AuthorDocumentController ctrl,
AuthorElement targetElement,
javax.xml.namespace.QName attributeQName,
java.lang.String value,
boolean removeIfEmpty)
Sets an attribute value.
|
static java.lang.String |
setAttributeValue(AuthorDocumentController ctrl,
AuthorElement targetElement,
javax.xml.namespace.QName attributeQName,
java.lang.String value,
java.lang.String normalizedValue,
boolean removeIfEmpty)
Sets an attribute value.
|
static void |
surroundWithFragment(AuthorAccess authorAccess,
boolean schemaAware,
java.lang.String xmlFragment)
Surround selection with fragment.
|
static int |
surroundWithFragment(AuthorAccess authorAccess,
java.lang.String xmlFragment,
int start,
int end)
Surround the content between start and end offset with the given fragment.
|
static void |
unwrapTags(AuthorAccess authorAccess,
AuthorNode nodeToUnwrap)
Unwrap node tags.
|
public static void unwrapTags(AuthorAccess authorAccess, AuthorNode nodeToUnwrap) throws javax.swing.text.BadLocationException
authorAccess
- The Author access.nodeToUnwrap
- The node to unwrap.javax.swing.text.BadLocationException
public static void surroundWithFragment(AuthorAccess authorAccess, boolean schemaAware, java.lang.String xmlFragment) throws AuthorOperationException
authorAccess
- Author access.schemaAware
- true
for schema aware operationxmlFragment
- The xml fragmentAuthorOperationException
public static int surroundWithFragment(AuthorAccess authorAccess, java.lang.String xmlFragment, int start, int end) throws AuthorOperationException
authorAccess
- Author access.xmlFragment
- The xml fragmentstart
- The start offset. Inclusive.end
- The end offset. Inclusive.AuthorOperationException
public static java.lang.String setAttributeValue(AuthorDocumentController ctrl, AuthorElement targetElement, javax.xml.namespace.QName attributeQName, java.lang.String value, boolean removeIfEmpty)
null
the attribute will
be removed from the element. If the value is the empty string and removeIfEmpty
is true
the attribute will also be removed.ctrl
- Attribute controller.targetElement
- The target element.attributeQName
- Attribute to edit.value
- Current value. Illegal characters in the value WILL NOT be escaped.removeIfEmpty
- true
to remove the attribute when an empty
value is set.public static java.lang.String setAttributeValue(AuthorDocumentController ctrl, AuthorElement targetElement, javax.xml.namespace.QName attributeQName, java.lang.String value, java.lang.String normalizedValue, boolean removeIfEmpty)
null
the attribute will
be removed from the element. If the value is the empty string and removeIfEmpty
is true
the attribute will also be removed.ctrl
- Attribute controller.targetElement
- The target element.attributeQName
- Attribute to edit.value
- Current value. Illegal characters in the value WILL NOT be escaped. All entities
must be already escaped in this value. For example: ab"c&$
normalizedValue
- The value with normalized whitespaces and expanded entities. For example: ab"c&$
removeIfEmpty
- true
to remove the attribute when an empty
value is set.public static java.lang.String buildFreshPrefix(NamespaceContext namespaceContext)
namespaceContext
- Namespace context.public static java.net.URL locateResourceInClasspath(AuthorAccess authorAccess, java.lang.String resourceFileName)
authorAccess
- Author access.resourceFileName
- The resource file name.null
.public static java.net.URL expandAndResolvePath(AuthorAccess authorAccess, java.lang.String path)
authorAccess
- Author access.path
- The path to resolve. Can be a file path, an URL path or a path relative
to the framework directory. Editor variables are also accepted. The path is
also passed through the catalog mappings.public static java.lang.String getPrefix(java.lang.String qName)
qName
- q namepublic static java.lang.String getLocalName(java.lang.String qName)
qName
- q namepublic static void removeUnwantedAttributes(java.lang.String[] skippedAttributes, AuthorDocumentFragment fragment, AuthorDocumentController controller)
skippedAttributes
- The attributes to be deleted.fragment
- The author document fragment to be cleared.controller
- The author document controller.public static java.util.List<javax.swing.text.Position> removeCurrentSelection(AuthorAccess authorAccess)
authorAccess
- Author access.public static java.util.List<CommonsOperationsUtil.SelectedFragmentInfo> getSelectedFragmentsForConversions(AuthorAccess authorAccess, CommonsOperationsUtil.ConversionElementHelper helper) throws AuthorOperationException
authorAccess
- The author access.helper
- Used to check if the elements from selection can be converted
in other elements (table cells or list entries)AuthorOperationException
public static void removeEmptyElements(AuthorAccess authorAccess, java.util.List<javax.swing.text.Position> emptyElementsPositions)
authorAccess
- The Author access.emptyElementsPositions
- Positions for empty elements© Copyright SyncRO Soft SRL 2002 - 2016. All rights reserved.