Class DefaultUniqueAttributesRecognizer
java.lang.Object
ro.sync.ecss.extensions.commons.id.DefaultUniqueAttributesRecognizer
- All Implemented Interfaces:
AuthorExtensionStateListener
,ClipboardFragmentProcessor
,Extension
,UniqueAttributesProcessor
,UniqueAttributesRecognizer
- Direct Known Subclasses:
DITAUniqueAttributesRecognizer
,DocBookUniqueAttributesRecognizer
,TEIP5UniqueAttributesRecognizer
,XHTMLUniqueAttributesRecognizer
@API(type=INTERNAL,
src=PUBLIC)
public class DefaultUniqueAttributesRecognizer
extends Object
implements UniqueAttributesRecognizer, ClipboardFragmentProcessor
Default unique attributes recognizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthorAccess
The author accessprotected String
The ID attribute qname -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DefaultUniqueAttributesRecognizer
(String idAttrQname) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activated
(AuthorAccess authorAccess) Method called when the Author extension was activated.void
assignUniqueIDs
(int startOffset, int endOffset, boolean forceGeneration) Assigns unique IDs between a start and an end offset in the document.boolean
copyAttributeOnSplit
(String attrQName, AuthorElement element) Checks if the attribute specified by QName can be considered as a valid attribute to copy when the element is split.void
deactivated
(AuthorAccess authorAccess) Method called when the Author extension was deactivated.protected String
generateUniqueIDFor
(String idGenerationPattern, AuthorElement element) Generate an unique ID for an elementprotected GenerateIDElementsInfo
protected String
Get the name of the XML resource from which to load the default options.protected String
getGenerateIDAttributeQName
(AuthorElement element, String[] elemsWithAutoGeneration, boolean forceGeneration) boolean
protected boolean
preserveIDsWhenPastingBetweenResources
(int fragmentPurpose) Check if we should preserve IDs when pasting between resources.void
process
(ClipboardFragmentInformation fragmentInformation) Process a fragment in the clipboard before inserting it in the document.
-
Field Details
-
idAttrQname
The ID attribute qname -
authorAccess
The author access
-
-
Constructor Details
-
DefaultUniqueAttributesRecognizer
public DefaultUniqueAttributesRecognizer()Default constructor. -
DefaultUniqueAttributesRecognizer
Constructor.- Parameters:
idAttrQname
- The ID attribute qname
-
-
Method Details
-
copyAttributeOnSplit
Description copied from interface:UniqueAttributesProcessor
Checks if the attribute specified by QName can be considered as a valid attribute to copy when the element is split.- Specified by:
copyAttributeOnSplit
in interfaceUniqueAttributesProcessor
- Parameters:
attrQName
- The attribute qualified name.element
- The element.- Returns:
true
if the attribute should be copied when Split is performed.- See Also:
-
activated
Description copied from interface:AuthorExtensionStateListener
Method called when the Author extension was activated. This event is triggered when the Author extension where this listener is defined was activated in relation with a document opened in Author page. Listeners likeAuthorMouseListener
orAuthorListener
can be added at this point.- Specified by:
activated
in interfaceAuthorExtensionStateListener
- Parameters:
authorAccess
- TheAuthorAccess
of the Author page where the listener was activated.- See Also:
-
deactivated
Description copied from interface:AuthorExtensionStateListener
Method called when the Author extension was deactivated. This event is triggered when another Author extension corresponding to the the current document opened in Author page was activated, the user switches to another editor page or the editor is closed.- Specified by:
deactivated
in interfaceAuthorExtensionStateListener
- Parameters:
authorAccess
- TheAuthorAccess
of the Author page where the listener was deactivated.- See Also:
-
getDefaultOptions
- Returns:
- The default generation options
-
getDefaultOptionsXMLResourceName
Get the name of the XML resource from which to load the default options.- Returns:
- the name of the XML resource from which to load the default options.
-
isAutoIDGenerationActive
public boolean isAutoIDGenerationActive()- Specified by:
isAutoIDGenerationActive
in interfaceUniqueAttributesRecognizer
- Returns:
- true if auto generation is active and we have elements for which to generate.
-
getGenerateIDAttributeQName
protected String getGenerateIDAttributeQName(AuthorElement element, String[] elemsWithAutoGeneration, boolean forceGeneration) - Parameters:
element
- The current element.elemsWithAutoGeneration
- The array of elements for which generation is activatedforceGeneration
- Force ID generation if there is no selection.- Returns:
- The name of the attribute for which to generate the ID or null (default behavior).
-
generateUniqueIDFor
Generate an unique ID for an element- Parameters:
idGenerationPattern
- The pattern for id generation.element
- The element- Returns:
- The unique ID
-
assignUniqueIDs
public void assignUniqueIDs(int startOffset, int endOffset, boolean forceGeneration) Description copied from interface:UniqueAttributesProcessor
Assigns unique IDs between a start and an end offset in the document.- Specified by:
assignUniqueIDs
in interfaceUniqueAttributesProcessor
- Parameters:
startOffset
- Start offset.endOffset
- End offset.forceGeneration
-true
to generate ID even if the ID generation pattern list does not match.- See Also:
-
getGenerateIDElementsInfo
- Returns:
- Returns the autoGenerateElementsInfo.
-
process
Description copied from interface:ClipboardFragmentProcessor
Process a fragment in the clipboard before inserting it in the document.- Specified by:
process
in interfaceClipboardFragmentProcessor
- Parameters:
fragmentInformation
- Information about a fragment in the clipboard.- See Also:
-
preserveIDsWhenPastingBetweenResources
protected boolean preserveIDsWhenPastingBetweenResources(int fragmentPurpose) Check if we should preserve IDs when pasting between resources.- Parameters:
fragmentPurpose
- The fragment purpose. On of theAuthorSchemaAwareEditingHandler
purposes.- Returns:
true
if we should preserve IDs when pasting between resources. By default the base method returnstrue
.
-
getDescription
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
-