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 AuthorAccessThe author accessprotected StringThe ID attribute qname -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DefaultUniqueAttributesRecognizer(String idAttrQname) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivated(AuthorAccess authorAccess) Method called when the Author extension was activated.voidassignUniqueIDs(int startOffset, int endOffset, boolean forceGeneration) Assigns unique IDs between a start and an end offset in the document.booleancopyAttributeOnSplit(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.voiddeactivated(AuthorAccess authorAccess) Method called when the Author extension was deactivated.protected StringgenerateUniqueIDFor(String idGenerationPattern, AuthorElement element) Generate an unique ID for an elementprotected GenerateIDElementsInfoprotected StringGet the name of the XML resource from which to load the default options.protected StringgetGenerateIDAttributeQName(AuthorElement element, String[] elemsWithAutoGeneration, boolean forceGeneration) booleanprotected booleanpreserveIDsWhenPastingBetweenResources(int fragmentPurpose) Check if we should preserve IDs when pasting between resources.voidprocess(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:UniqueAttributesProcessorChecks if the attribute specified by QName can be considered as a valid attribute to copy when the element is split.- Specified by:
copyAttributeOnSplitin interfaceUniqueAttributesProcessor- Parameters:
attrQName- The attribute qualified name.element- The element.- Returns:
trueif the attribute should be copied when Split is performed.- See Also:
-
activated
Description copied from interface:AuthorExtensionStateListenerMethod 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 likeAuthorMouseListenerorAuthorListenercan be added at this point.- Specified by:
activatedin interfaceAuthorExtensionStateListener- Parameters:
authorAccess- TheAuthorAccessof the Author page where the listener was activated.- See Also:
-
deactivated
Description copied from interface:AuthorExtensionStateListenerMethod 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:
deactivatedin interfaceAuthorExtensionStateListener- Parameters:
authorAccess- TheAuthorAccessof 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:
isAutoIDGenerationActivein 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:UniqueAttributesProcessorAssigns unique IDs between a start and an end offset in the document.- Specified by:
assignUniqueIDsin interfaceUniqueAttributesProcessor- Parameters:
startOffset- Start offset.endOffset- End offset.forceGeneration-trueto generate ID even if the ID generation pattern list does not match.- See Also:
-
getGenerateIDElementsInfo
- Returns:
- Returns the autoGenerateElementsInfo.
-
process
Description copied from interface:ClipboardFragmentProcessorProcess a fragment in the clipboard before inserting it in the document.- Specified by:
processin 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 theAuthorSchemaAwareEditingHandlerpurposes.- Returns:
trueif we should preserve IDs when pasting between resources. By default the base method returnstrue.
-
getDescription
- Specified by:
getDescriptionin interfaceExtension- Returns:
- The description of the extension.
- See Also:
-