Class DefinitionEnhancementHandler
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.transformation.AbstractEnhancementHandler
org.ametys.plugins.glossary.transformation.DefinitionEnhancementHandler
- All Implemented Interfaces:
Component,Contextualizable,LogEnabled,Serviceable,ContentHandler,LexicalHandler
public class DefinitionEnhancementHandler
extends AbstractEnhancementHandler
implements Component, Serviceable, Contextualizable
Definition enhancement handler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContextThe avalon context.protected Map<String,Definition> The word definitions.protected StringThe glossary page href.Ignored namespace stack.protected AmetysObjectResolverThe ametys object resolver.protected SiteManagerThe site managerprotected URIResolverExtensionPointThe page URI resolver.static final StringThe Avalon role.Fields inherited from class org.ametys.cms.transformation.AbstractEnhancementHandler
_contentHandler, _inUnmodifiableContent, _lexicalHandler, PROCESSING_INSTRUCTION_UNMODIFIABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_charactersWithDefinitions(char[] ch, int start, int length, Content content) SAX characters, generating definition tags on words that are present in the glossary.protected Map<String,Definition> _getDefinitions(String siteName, String lang) Get all the words with definitions to display.protected Page_getGlossaryPage(String siteName, String language) Get the glossary page in a given site and language.protected String_getGlossaryPageHref(String siteName, String language) Get the glossary page in a given site and language.protected Map<String,Definition> _getWordsAndDefinitions(String siteName, String lang) Get all the words with definitions to display.protected Pattern_getWordsPattern(Set<String> words) Get a regexp that matches any of the definition words.protected booleanTest if the currently processed characters have to be searched for glossary words or ignored.voidcharacters(char[] ch, int start, int length) voidcontextualize(Context context) voidendElement(String uri, String localName, String qName) voidservice(ServiceManager serviceManager) voidvoidstartElement(String uri, String localName, String qName, Attributes atts) Methods inherited from class org.ametys.cms.transformation.AbstractEnhancementHandler
comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, saxError, setContentHandler, setDocumentLocator, setLexicalHandler, skippedEntity, startCDATA, startDTD, startEntity, startPrefixMappingMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
ROLE
The Avalon role. -
_resolver
The ametys object resolver. -
_siteManager
The site manager -
_uriResolver
The page URI resolver. -
_context
The avalon context. -
_definitions
The word definitions. -
_glossaryHref
The glossary page href. -
_ignoredNamespaceStack
Ignored namespace stack.
-
-
Constructor Details
-
DefinitionEnhancementHandler
public DefinitionEnhancementHandler()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classAbstractEnhancementHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classAbstractEnhancementHandler- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classAbstractEnhancementHandler- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classAbstractEnhancementHandler- Throws:
SAXException
-
_searchCharacters
Test if the currently processed characters have to be searched for glossary words or ignored.- Returns:
- true to search the characters for glossary words, false to ignore.
-
_charactersWithDefinitions
protected void _charactersWithDefinitions(char[] ch, int start, int length, Content content) throws SAXException SAX characters, generating definition tags on words that are present in the glossary.- Parameters:
ch- the characters from the XML document.start- the start position in the array.length- the number of characters to read from the array.content- the content.- Throws:
SAXException- if an error occurs generating the XML.
-
_getDefinitions
Get all the words with definitions to display.- Parameters:
siteName- the site name.lang- the language.- Returns:
- an exhaustive set of the words.
-
_getWordsAndDefinitions
Get all the words with definitions to display.- Parameters:
siteName- the site name.lang- the language.- Returns:
- an exhaustive set of the words.
-
_getWordsPattern
Get a regexp that matches any of the definition words.- Parameters:
words- the words.- Returns:
- the pattern.
-
_getGlossaryPageHref
Get the glossary page in a given site and language.- Parameters:
siteName- the site name.language- the language.- Returns:
- the glossary page.
-
_getGlossaryPage
Get the glossary page in a given site and language.- Parameters:
siteName- the site name.language- the language.- Returns:
- the glossary page.
-