org.apache.wicket.markup
Class MarkupParser

java.lang.Object
  extended by org.apache.wicket.markup.MarkupParser

public class MarkupParser
extends Object

This is a Wicket 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..

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, IMarkupParserFactory, IMarkupSettings, MarkupResourceData

Field Summary
static Pattern CONDITIONAL_COMMENT_OPENING
          Opening a conditional comment section, which is NOT treated as a comment section
 
Constructor Summary
MarkupParser(IXmlPullParser xmlParser, MarkupResourceStream resource)
          Constructor.
MarkupParser(MarkupResourceStream resource)
          Constructor.
MarkupParser(String markup)
          Constructor.
 
Method Summary
 void appendMarkupFilter(IMarkupFilter filter)
          Append a new filter to the list of already pre-configured markup filters.
 void appendMarkupFilter(IMarkupFilter filter, Class<? extends IMarkupFilter> beforeFilter)
          Append a new filter to the list of already pre-configured markup filters.
protected  String compressWhitespace(String rawMarkup)
          Remove whitespace from the raw markup
protected  MarkupResourceStream getMarkupResourceStream()
          Applications which subclass initFilterChain() might also wish to access the markup resource stream.
 ComponentTag getNextTag()
          Get the next tag from the markup file
protected  void initFilterChain()
          Deprecated. since 1.3
 Markup parse()
          Reads and parses markup from a file.
 void setWicketNamespace(String namespace)
          In case you want to analyze markup which BY DEFAULT does not use "wicket" to find relevant tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

MarkupParser

public MarkupParser(MarkupResourceStream resource)
Constructor.

Parameters:
resource - The markup resource (file)

MarkupParser

public MarkupParser(String markup)
Constructor. Usually for testing purposes only

Parameters:
markup - The markup resource.

MarkupParser

public MarkupParser(IXmlPullParser xmlParser,
                    MarkupResourceStream resource)
Constructor.

Parameters:
xmlParser - The streaming xml parser to read and parse the markup
resource - The markup resource (file)
Method Detail

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

initFilterChain

@Deprecated
protected void initFilterChain()
Deprecated. since 1.3

By default don't do anything. Subclasses may append additional markup filters if required.

See Also:
appendMarkupFilter(IMarkupFilter)

appendMarkupFilter

public final void appendMarkupFilter(IMarkupFilter filter)
Append a new filter to the list of already pre-configured markup filters.

Parameters:
filter - The filter to be appended

appendMarkupFilter

public final void appendMarkupFilter(IMarkupFilter filter,
                                     Class<? extends IMarkupFilter> beforeFilter)
Append a new filter to the list of already pre-configured markup filters. Add the new filter before the "beforeFilter" which is identified by its class.

Parameters:
filter - The filter to be appended
beforeFilter - The filter will be added before the beforeFilter. If beforeFilter == null or beforeFilter not found than append to the end

parse

public final Markup parse()
                   throws IOException,
                          ResourceStreamNotFoundException
Reads and parses markup from a file.

Returns:
The markup
Throws:
IOException
ResourceStreamNotFoundException

getNextTag

public ComponentTag getNextTag()
                        throws ParseException
Get the next tag from the markup file

Returns:
The next tag
Throws:
ParseException

compressWhitespace

protected String compressWhitespace(String rawMarkup)
Remove whitespace from the raw markup

Parameters:
rawMarkup -
Returns:
rawMarkup


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.