Package org.apache.wicket.markup
Class AbstractMarkupParser
- java.lang.Object
-
- org.apache.wicket.markup.AbstractMarkupParser
-
- Direct Known Subclasses:
MarkupParser
public abstract class AbstractMarkupParser extends Object
This is a base MarkupParser specifically for (X)HTML. It makes use of a streaming XML parser to read the markup and IMarkupFilters to remove comments, identify Wicket relevant tags, apply html specific treatments etc.. Please see WicketMarkupParser for a parser preconfigured for Wicket.The result will be an Markup object, which is basically a list, containing Wicket relevant tags and RawMarkup.
- Author:
- Jonathan Locke, Juergen Donnerstag
- See Also:
IMarkupFilter
,MarkupFactory
,MarkupSettings
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
CONDITIONAL_COMMENT_OPENING
Opening a conditional comment section, which is NOT treated as a comment section
-
Constructor Summary
Constructors Constructor Description AbstractMarkupParser(String markup)
Constructor.AbstractMarkupParser(MarkupResourceStream resource)
Constructor.AbstractMarkupParser(IXmlPullParser xmlParser, MarkupResourceStream resource)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
compressWhitespace(String rawMarkup)
Remove whitespace from the raw markupList<IMarkupFilter>
getMarkupFilters()
protected MarkupResourceStream
getMarkupResourceStream()
Applications which subclass initFilterChain() might also wish to access the markup resource stream.protected CharSequence
handleRawText(String rawMarkup)
protected abstract List<IMarkupFilter>
initializeMarkupFilters(Markup markup)
Create a new markup filter chain and initialize with all default filters required.Markup
parse()
Reads and parses markup from a file.protected void
postProcess(Markup markup)
void
setWicketNamespace(String namespace)
In case you want to analyze markup which BY DEFAULT does not use "wicket" to find relevant tags.String
toString()
-
-
-
Field Detail
-
CONDITIONAL_COMMENT_OPENING
public static final Pattern CONDITIONAL_COMMENT_OPENING
Opening a conditional comment section, which is NOT treated as a comment section
-
-
Constructor Detail
-
AbstractMarkupParser
public AbstractMarkupParser(MarkupResourceStream resource)
Constructor.- Parameters:
resource
- The markup resource (file)
-
AbstractMarkupParser
public AbstractMarkupParser(String markup)
Constructor. Usually for testing purposes only- Parameters:
markup
- The markup resource.
-
AbstractMarkupParser
public AbstractMarkupParser(IXmlPullParser xmlParser, MarkupResourceStream resource)
Constructor.- Parameters:
xmlParser
- The streaming xml parser to read and parse the markupresource
- The markup resource (file)
-
-
Method Detail
-
getMarkupFilters
public List<IMarkupFilter> getMarkupFilters()
- Returns:
- Gets the list of markup filters
-
setWicketNamespace
public final void setWicketNamespace(String namespace)
In case you want to analyze markup which BY DEFAULT does not use "wicket" to find relevant tags.- Parameters:
namespace
-
-
getMarkupResourceStream
protected MarkupResourceStream getMarkupResourceStream()
Applications which subclass initFilterChain() might also wish to access the markup resource stream.- Returns:
- The markup resource stream
-
initializeMarkupFilters
protected abstract List<IMarkupFilter> initializeMarkupFilters(Markup markup)
Create a new markup filter chain and initialize with all default filters required.- Parameters:
markup
-- Returns:
- The list of markup filters to be considered by the markup parser
-
parse
public final Markup parse() throws IOException, ResourceStreamNotFoundException
Reads and parses markup from a file.- Returns:
- The markup
- Throws:
IOException
ResourceStreamNotFoundException
-
postProcess
protected void postProcess(Markup markup)
- Parameters:
markup
-
-
handleRawText
protected CharSequence handleRawText(String rawMarkup)
- Parameters:
rawMarkup
-- Returns:
- The modified raw markup
-
compressWhitespace
protected String compressWhitespace(String rawMarkup)
Remove whitespace from the raw markup- Parameters:
rawMarkup
-- Returns:
- rawMarkup
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
-