Package org.apache.wicket.markup.parser
Class AbstractMarkupFilter
- java.lang.Object
-
- org.apache.wicket.markup.parser.AbstractMarkupFilter
-
- All Implemented Interfaces:
IMarkupFilter
- Direct Known Subclasses:
AutoLabelTagHandler
,EnclosureHandler
,HeadForceTagIdHandler
,HtmlHandler
,HtmlHeaderSectionHandler
,HtmlProblemFinder
,InlineEnclosureHandler
,OpenCloseTagExpander
,RelativePathPrefixHandler
,RootMarkupFilter
,StyleAndScriptIdentifier
,WicketContainerTagHandler
,WicketLinkTagHandler
,WicketMessageTagHandler
,WicketNamespaceHandler
,WicketRemoveTagHandler
,WicketTagIdentifier
public abstract class AbstractMarkupFilter extends Object implements IMarkupFilter
Base class for markup filters- Author:
- Jonathan Locke, Juergen Donnerstag
-
-
Field Summary
Fields Modifier and Type Field Description protected static MetaDataKey<Map<String,AtomicInteger>>
REQUEST_COUNTER_KEY
A key for a request-relative map of counters.
-
Constructor Summary
Constructors Constructor Description AbstractMarkupFilter()
Construct.AbstractMarkupFilter(MarkupResourceStream markupResourceStream)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected MarkupResourceStream
getMarkupResourceStream()
IMarkupFilter
getNextFilter()
IMarkupFilters are usually chained with the last filter retrieving the elements from the XML parser.protected int
getRequestUniqueId()
Returns an id using the request-relative counter associated with the underlyingMarkupResourceStream
's owner container (seeMarkupResourceStream.getContainerInfo()
).protected String
getWicketNamespace()
Extracts the markup namespace from the MarkupResourceStream passed at creation time.protected String
getWicketNamespace(MarkupStream markupStream)
Extracts the markup namespace from the passed MarkupStream if available, or from the MarkupResourceStream passed at creation time.MarkupElement
nextElement()
Get the next xml element from the markup.protected abstract MarkupElement
onComponentTag(ComponentTag tag)
Invoked when a ComponentTag was found.protected MarkupElement
onSpecialTag(HtmlSpecialTag tag)
Invoked when a tags (e.g.void
postProcess(Markup markup)
Called after all filters have been processed.void
setNextFilter(IMarkupFilter parent)
Set new parent.
-
-
-
Field Detail
-
REQUEST_COUNTER_KEY
protected static final MetaDataKey<Map<String,AtomicInteger>> REQUEST_COUNTER_KEY
A key for a request-relative map of counters. As map keys we use the class name of theMarkupResourceStream
's owner container (seeMarkupResourceStream.getContainerInfo()
), meaning that each container has its own counter. The counters are used bygetRequestUniqueId()
to get unique ids for markup tags.
-
-
Constructor Detail
-
AbstractMarkupFilter
public AbstractMarkupFilter()
Construct.
-
AbstractMarkupFilter
public AbstractMarkupFilter(MarkupResourceStream markupResourceStream)
-
-
Method Detail
-
getNextFilter
public IMarkupFilter getNextFilter()
Description copied from interface:IMarkupFilter
IMarkupFilters are usually chained with the last filter retrieving the elements from the XML parser.- Specified by:
getNextFilter
in interfaceIMarkupFilter
- Returns:
- The next MarkupFilter in the chain
-
setNextFilter
public void setNextFilter(IMarkupFilter parent)
Set new parent.- Specified by:
setNextFilter
in interfaceIMarkupFilter
- Parameters:
parent
- The parent of this component The next element in the chain
-
nextElement
public MarkupElement nextElement() throws ParseException
Get the next xml element from the markup. If eof, than retun null. Ignore raw markup. Invoke nextTag(tag) if a tag was found.- Specified by:
nextElement
in interfaceIMarkupFilter
- Returns:
- Return the next eligible MarkupElement. Null, if no more found.
- Throws:
ParseException
-
onComponentTag
protected abstract MarkupElement onComponentTag(ComponentTag tag) throws ParseException
Invoked when a ComponentTag was found.By default this method is also called for WicketTags.
- Parameters:
tag
-- Returns:
- Usually the same as the tag attribute
- Throws:
ParseException
-
onSpecialTag
protected MarkupElement onSpecialTag(HtmlSpecialTag tag) throws ParseException
Invoked when a tags (e.g. DOCTYPE, PROCESSING_INSTRUCTIION, etc. which have been identified as special tags by the xml parser.- Parameters:
tag
-- Returns:
- Usually the same as the tag attribute
- Throws:
ParseException
-
postProcess
public void postProcess(Markup markup)
Description copied from interface:IMarkupFilter
Called after all filters have been processed.- Specified by:
postProcess
in interfaceIMarkupFilter
-
getMarkupResourceStream
protected MarkupResourceStream getMarkupResourceStream()
-
getWicketNamespace
protected String getWicketNamespace()
Extracts the markup namespace from the MarkupResourceStream passed at creation time.There are two versions of this method because most IMarkupFilter's have dual personality -
IMarkupFilter
(one instance per MarkupParser) andIComponentResolver
(one instance per application).- Returns:
- the namespace of the loaded markup
-
getWicketNamespace
protected String getWicketNamespace(MarkupStream markupStream)
Extracts the markup namespace from the passed MarkupStream if available, or from the MarkupResourceStream passed at creation time.There are two versions of this method because most IMarkupFilter's have dual personality -
IMarkupFilter
(one instance per MarkupParser) andIComponentResolver
(one instance per application).- Parameters:
markupStream
- the markup stream- Returns:
- namespace extracted from the markup
-
getRequestUniqueId
protected int getRequestUniqueId()
Returns an id using the request-relative counter associated with the underlyingMarkupResourceStream
's owner container (seeMarkupResourceStream.getContainerInfo()
). This can be useful for autocomponent tags that need to get a tag id.- Returns:
- the request-relative id
-
-