Class AbstractTagHandler
- java.lang.Object
-
- com.day.cq.wcm.designimporter.parser.taghandlers.AbstractTagHandler
-
- All Implemented Interfaces:
HTMLContentProvider
,PageComponentProvider
,TagHandler
- Direct Known Subclasses:
CanvasComponentTagHandler
,DefaultComponentTagHandler
,DefaultTagHandler
,HeadTagHandler
,ImageComponentTagHandler
,NonScriptTagHandler
,ParsysComponentTagHandler
,TextComponentTagHandler
,TitleComponentTagHandler
,TitleTagHandler
public abstract class AbstractTagHandler extends java.lang.Object implements TagHandler, PageComponentProvider, HTMLContentProvider
The abstract class that pulls up all the common tag handling functionality.The tag handlers usually attempt to delegate all the SAX events to nested handlers if they exist. If there aren't any nested handlers, the incoming SAX events are used to either populate the html markup/css/script buffers or generate CQ page components(via component provider subclasses).
Nested handlers are created when an element matching a tag handler registration rule is encountered. Then on, all the SAX events are directed to the instantiated nested handler until end of nested tag is encountered. Once that happens, the nested tag handler is asked for whatever content/components it has culled out. After that, the nested tag handler is popped out for GC.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NAME_HINT_PROPERTY_KEY
-
Constructor Summary
Constructors Constructor Description AbstractTagHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginHandling(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
Callback to signal the start of handling giving the tag handler a chance for running intialization routines.void
characters(char[] ch, int start, int length)
Callback to signal the encounter of character content within tags.void
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
Callback to signal the encounter of a tag end.void
endHandling(java.lang.String uri, java.lang.String localName, java.lang.String qName)
Callback to signal the end of handling giving the tag handler a chance for finalizing things.java.lang.Object
getContent(HTMLContentType htmlContentType)
Gets the content of the typeHTMLContentType
java.util.List<PageComponent>
getPageComponents()
The list of page components that this provider provides.void
setDesignImporterContext(DesignImporterContext designImporterContext)
Sets the design importer contextvoid
setPageBuilder(PageBuilder pageBuilder)
Setter for injecting the page builder which is used for building page components.void
setTagHandlerProvider(TagHandlerProvider tagHandlerProvider)
void
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
Callback to signal the encounter of a tag start.boolean
supportsContent(HTMLContentType htmlContentType)
Indicates whether the passedHTMLContentType
is supported or not
-
-
-
Field Detail
-
NAME_HINT_PROPERTY_KEY
public static final java.lang.String NAME_HINT_PROPERTY_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
beginHandling
public void beginHandling(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws DesignImportException
Description copied from interface:TagHandler
Callback to signal the start of handling giving the tag handler a chance for running intialization routines.TagHandler
s are registered against tag+attribute combination and are invoked by theHTMLContentHandler
as and when it encounters a tag matching the tag attribute combination the tag handler is registered with.- Specified by:
beginHandling
in interfaceTagHandler
- Throws:
DesignImportException
-
characters
public void characters(char[] ch, int start, int length) throws DesignImportException
Description copied from interface:TagHandler
Callback to signal the encounter of character content within tags.- Specified by:
characters
in interfaceTagHandler
- Throws:
DesignImportException
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws DesignImportException
Description copied from interface:TagHandler
Callback to signal the encounter of a tag end.- Specified by:
endElement
in interfaceTagHandler
- Throws:
DesignImportException
-
endHandling
public void endHandling(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws DesignImportException
Description copied from interface:TagHandler
Callback to signal the end of handling giving the tag handler a chance for finalizing things.This is arguably the last callback a tag handler receives. After this, the current tag handler is popped out from the chain and the subsequent Tika events are directed to preceding tag handlers.
- Specified by:
endHandling
in interfaceTagHandler
- Throws:
DesignImportException
-
getContent
public java.lang.Object getContent(HTMLContentType htmlContentType)
Description copied from interface:HTMLContentProvider
Gets the content of the typeHTMLContentType
- Specified by:
getContent
in interfaceHTMLContentProvider
- Returns:
-
getPageComponents
public java.util.List<PageComponent> getPageComponents()
Description copied from interface:PageComponentProvider
The list of page components that this provider provides.- Specified by:
getPageComponents
in interfacePageComponentProvider
- Returns:
- The list of page components
-
setDesignImporterContext
public void setDesignImporterContext(DesignImporterContext designImporterContext)
Description copied from interface:TagHandler
Sets the design importer context- Specified by:
setDesignImporterContext
in interfaceTagHandler
-
setPageBuilder
public void setPageBuilder(PageBuilder pageBuilder)
Description copied from interface:PageComponentProvider
Setter for injecting the page builder which is used for building page components.- Specified by:
setPageBuilder
in interfacePageComponentProvider
-
setTagHandlerProvider
public void setTagHandlerProvider(TagHandlerProvider tagHandlerProvider)
- Specified by:
setTagHandlerProvider
in interfaceTagHandler
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws DesignImportException
Description copied from interface:TagHandler
Callback to signal the encounter of a tag start.Once a tag handler begins handling, it receives the start tag events for all the nested tags within the purview of the tag this tag handler is registered against.
- Specified by:
startElement
in interfaceTagHandler
- Throws:
DesignImportException
-
supportsContent
public boolean supportsContent(HTMLContentType htmlContentType)
Description copied from interface:HTMLContentProvider
Indicates whether the passedHTMLContentType
is supported or not- Specified by:
supportsContent
in interfaceHTMLContentProvider
- Returns:
-
-