wicket.markup.parser
Class XmlPullParser

java.lang.Object
  extended bywicket.markup.parser.AbstractMarkupFilter
      extended bywicket.markup.parser.XmlPullParser
All Implemented Interfaces:
IMarkupFilter, IXmlPullParser

public final class XmlPullParser
extends AbstractMarkupFilter
implements IXmlPullParser

A fairly shallow markup pull or streaming parser. Parses a markup string of a given type of markup (for example, html, xml, vxml or wml) into Tag and RawMarkup tokens. IMarkupFilters may be used to handle markup specifics like identifying Wicket components or HTML which is not 100% xml compliant.

Author:
Jonathan Locke

Constructor Summary
XmlPullParser()
          Construct.
 
Method Summary
 java.lang.String getEncoding()
          Return the encoding used while reading the markup file.
 java.lang.CharSequence getInputFromPositionMarker(int toPos)
          Get the character sequence from the position marker to toPos.
 java.lang.CharSequence getInputSubsequence(int fromPos, int toPos)
          Get the character sequence in between both positions.
 java.lang.String getXmlDeclaration()
          Return the XML declaration string, in case if found in the markup.
 MarkupElement nextTag()
          Gets the next tag from the input string.
 void parse(java.lang.CharSequence string)
          Parse the given string.
 void parse(IResourceStream resource)
          Reads and parses markup from a resource such as file.
 void setPositionMarker()
          Remember the current position in markup
 void setStripComments(boolean stripComments)
          Set whether to strip components.
 java.lang.String toString()
           
 
Methods inherited from class wicket.markup.parser.AbstractMarkupFilter
getParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wicket.markup.parser.IMarkupFilter
getParent, setParent
 

Constructor Detail

XmlPullParser

public XmlPullParser()
Construct.

Method Detail

getEncoding

public java.lang.String getEncoding()
Return the encoding used while reading the markup file.

Specified by:
getEncoding in interface IXmlPullParser
Returns:
if null, than JVM default

getXmlDeclaration

public java.lang.String getXmlDeclaration()
Return the XML declaration string, in case if found in the markup.

Specified by:
getXmlDeclaration in interface IXmlPullParser
Returns:
Null, if not found.

getInputFromPositionMarker

public final java.lang.CharSequence getInputFromPositionMarker(int toPos)
Get the character sequence from the position marker to toPos.

Specified by:
getInputFromPositionMarker in interface IXmlPullParser
Parameters:
toPos - index of first character not included
Returns:
Raw markup (a string) in between these two positions.

getInputSubsequence

public final java.lang.CharSequence getInputSubsequence(int fromPos,
                                                        int toPos)
Get the character sequence in between both positions.

Specified by:
getInputSubsequence in interface IXmlPullParser
Parameters:
fromPos - first index
toPos - second index
Returns:
the string (raw markup) in between both positions

nextTag

public final MarkupElement nextTag()
                            throws java.text.ParseException
Gets the next tag from the input string.

Specified by:
nextTag in interface IMarkupFilter
Returns:
The extracted tag (will always be of type XmlTag).
Throws:
java.text.ParseException

parse

public void parse(java.lang.CharSequence string)
           throws java.io.IOException,
                  ResourceStreamNotFoundException
Parse the given string.

Note: xml character encoding is NOT applied. It is assumed the input provided does have the correct encoding already.

Specified by:
parse in interface IXmlPullParser
Parameters:
string - The input string
Throws:
java.io.IOException - Error while reading the resource
ResourceStreamNotFoundException - Resource not found

parse

public void parse(IResourceStream resource)
           throws java.io.IOException,
                  ResourceStreamNotFoundException
Reads and parses markup from a resource such as file.

Specified by:
parse in interface IXmlPullParser
Parameters:
resource - The resource to read and parse
Throws:
java.io.IOException
ResourceStreamNotFoundException

setPositionMarker

public final void setPositionMarker()
Remember the current position in markup

Specified by:
setPositionMarker in interface IXmlPullParser

setStripComments

public void setStripComments(boolean stripComments)
Set whether to strip components.

Specified by:
setStripComments in interface IXmlPullParser
Parameters:
stripComments - whether to strip components.

toString

public java.lang.String toString()
Returns:
The markup to be parsed


Copyright © 2004-2005 Wicket developers. All Rights Reserved.