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
Modifier and TypeFieldDescriptionprotected Context
The avalon context.protected Map<String,
Definition> The word definitions.protected String
The glossary page href.Ignored namespace stack.protected AmetysObjectResolver
The ametys object resolver.protected SiteManager
The site managerprotected URIResolverExtensionPoint
The page URI resolver.static final String
The Avalon role.Fields inherited from class org.ametys.cms.transformation.AbstractEnhancementHandler
_contentHandler, _inUnmodifiableContent, _lexicalHandler, PROCESSING_INSTRUCTION_UNMODIFIABLE
-
Constructor Summary
-
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 boolean
Test if the currently processed characters have to be searched for glossary words or ignored.void
characters
(char[] ch, int start, int length) void
contextualize
(Context context) void
endElement
(String uri, String localName, String qName) void
service
(ServiceManager serviceManager) void
void
startElement
(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, startPrefixMapping
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classAbstractEnhancementHandler
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classAbstractEnhancementHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classAbstractEnhancementHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in 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.
-