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 java.lang.Object implements IMarkupFilter
Base class for markup filters- Author:
- Jonathan Locke, Juergen Donnerstag
-
-
Field Summary
Fields Modifier and Type Field Description protected static MetaDataKey<java.util.Map<java.lang.String,java.util.concurrent.atomic.AtomicInteger>>REQUEST_COUNTER_KEYA 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 MarkupResourceStreamgetMarkupResourceStream()IMarkupFiltergetNextFilter()IMarkupFilters are usually chained with the last filter retrieving the elements from the XML parser.protected intgetRequestUniqueId()Returns an id using the request-relative counter associated with the underlyingMarkupResourceStream's owner container (seeMarkupResourceStream.getContainerInfo()).protected java.lang.StringgetWicketNamespace()Extracts the markup namespace from the MarkupResourceStream passed at creation time.protected java.lang.StringgetWicketNamespace(MarkupStream markupStream)Extracts the markup namespace from the passed MarkupStream if available, or from the MarkupResourceStream passed at creation time.MarkupElementnextElement()Get the next xml element from the markup.protected abstract MarkupElementonComponentTag(ComponentTag tag)Invoked when a ComponentTag was found.protected MarkupElementonSpecialTag(HtmlSpecialTag tag)Invoked when a tags (e.g.voidpostProcess(Markup markup)Called after all filters have been processed.voidsetNextFilter(IMarkupFilter parent)Set new parent.
-
-
-
Field Detail
-
REQUEST_COUNTER_KEY
protected static final MetaDataKey<java.util.Map<java.lang.String,java.util.concurrent.atomic.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:IMarkupFilterIMarkupFilters are usually chained with the last filter retrieving the elements from the XML parser.- Specified by:
getNextFilterin interfaceIMarkupFilter- Returns:
- The next MarkupFilter in the chain
-
setNextFilter
public void setNextFilter(IMarkupFilter parent)
Set new parent.- Specified by:
setNextFilterin interfaceIMarkupFilter- Parameters:
parent- The parent of this component The next element in the chain
-
nextElement
public MarkupElement nextElement() throws java.text.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:
nextElementin interfaceIMarkupFilter- Returns:
- Return the next eligible MarkupElement. Null, if no more found.
- Throws:
java.text.ParseException
-
onComponentTag
protected abstract MarkupElement onComponentTag(ComponentTag tag) throws java.text.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:
java.text.ParseException
-
onSpecialTag
protected MarkupElement onSpecialTag(HtmlSpecialTag tag) throws java.text.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:
java.text.ParseException
-
postProcess
public void postProcess(Markup markup)
Description copied from interface:IMarkupFilterCalled after all filters have been processed.- Specified by:
postProcessin interfaceIMarkupFilter
-
getMarkupResourceStream
protected MarkupResourceStream getMarkupResourceStream()
-
getWicketNamespace
protected java.lang.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 java.lang.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
-
-