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
Fields Modifier and Type Field Description protected Context
_context
The avalon context.protected Map<String,Definition>
_definitions
The word definitions.protected String
_glossaryHref
The glossary page href.protected Map<String,Integer>
_ignoredNamespaceStack
Ignored namespace stack.protected AmetysObjectResolver
_resolver
The ametys object resolver.protected SiteManager
_siteManager
The site managerprotected URIResolverExtensionPoint
_uriResolver
The page URI resolver.static String
ROLE
The Avalon role.-
Fields inherited from class org.ametys.cms.transformation.AbstractEnhancementHandler
_contentHandler, _inUnmodifiableContent, _lexicalHandler, PROCESSING_INSTRUCTION_UNMODIFIABLE
-
-
Constructor Summary
Constructors Constructor Description DefinitionEnhancementHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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
_searchCharacters()
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
startDocument()
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
-
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_siteManager
protected SiteManager _siteManager
The site manager
-
_uriResolver
protected URIResolverExtensionPoint _uriResolver
The page URI resolver.
-
_definitions
protected Map<String,Definition> _definitions
The word definitions.
-
_glossaryHref
protected String _glossaryHref
The glossary page href.
-
_ignoredNamespaceStack
protected Map<String,Integer> _ignoredNamespaceStack
Ignored namespace stack.
-
-
Constructor Detail
-
DefinitionEnhancementHandler
public DefinitionEnhancementHandler()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
startDocument
public void startDocument() throws SAXException
- 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
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classAbstractEnhancementHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classAbstractEnhancementHandler
- Throws:
SAXException
-
_searchCharacters
protected boolean _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
protected Map<String,Definition> _getDefinitions(String siteName, String lang)
Get all the words with definitions to display.- Parameters:
siteName
- the site name.lang
- the language.- Returns:
- an exhaustive set of the words.
-
_getWordsAndDefinitions
protected Map<String,Definition> _getWordsAndDefinitions(String siteName, String lang)
Get all the words with definitions to display.- Parameters:
siteName
- the site name.lang
- the language.- Returns:
- an exhaustive set of the words.
-
_getWordsPattern
protected Pattern _getWordsPattern(Set<String> words)
Get a regexp that matches any of the definition words.- Parameters:
words
- the words.- Returns:
- the pattern.
-
_getGlossaryPageHref
protected String _getGlossaryPageHref(String siteName, String language)
Get the glossary page in a given site and language.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- the glossary page.
-
_getGlossaryPage
protected Page _getGlossaryPage(String siteName, String language)
Get the glossary page in a given site and language.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- the glossary page.
-
-