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 private static Set<String>__IGNORE_NAMESPACESThe namespaces in which to ignore the glossary words.private static Set<String>__IGNORE_TAGSThe tags in which to ignore the glossary words.protected Context_contextThe avalon context.protected Map<String,Definition>_definitionsThe word definitions.protected String_glossaryHrefThe glossary page href.protected Map<String,Integer>_ignoredNamespaceStackIgnored namespace stack.private int_inIgnoredTagTrue if we are processing a paragraph, false otherwise.private RenderingContextHandler_renderingContextHandlerprotected AmetysObjectResolver_resolverThe ametys object resolver.protected SiteManager_siteManagerThe site managerprotected URIResolverExtensionPoint_uriResolverThe page URI resolver.static StringROLEThe 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.voidcharacters(char[] ch, int start, int length)voidcontextualize(Context context)voidendElement(String uri, String localName, String qName)voidservice(ServiceManager serviceManager)voidstartDocument()voidstartElement(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
-
__IGNORE_TAGS
private static final Set<String> __IGNORE_TAGS
The tags in which to ignore the glossary words.
-
__IGNORE_NAMESPACES
private static final Set<String> __IGNORE_NAMESPACES
The namespaces in which to ignore the glossary words.
-
_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.
-
_inIgnoredTag
private int _inIgnoredTag
True if we are processing a paragraph, false otherwise.
-
_renderingContextHandler
private RenderingContextHandler _renderingContextHandler
-
-
Constructor Detail
-
DefinitionEnhancementHandler
public DefinitionEnhancementHandler()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
startDocument
public void startDocument() throws SAXException
- 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
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classAbstractEnhancementHandler- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin 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.
-
-