wicket.markup.parser
Class XmlPullParser

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

public final class XmlPullParser
extends AbstractMarkupFilter
implements IXmlPullParser

A fairly shallow markup pull parser which parses a markup string of a given type of markup (for example, html, xml, vxml or wml) into ComponentTag and RawMarkup tokens.

Author:
Jonathan Locke, Juergen Donnerstag

Constructor Summary
XmlPullParser()
          Construct.
 
Method Summary
 java.lang.String getEncoding()
          Return the encoding applied while reading the markup resource.
 java.lang.CharSequence getInput(int fromPos, int toPos)
          Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analysed by Wicket.
 java.lang.CharSequence getInputFromPositionMarker(int toPos)
          Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analysed by Wicket.
 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, java.lang.String encoding)
          Reads and parses markup from a resource such as file.
 void setPositionMarker()
          Set the position marker of the markup at the current position.
 void setPositionMarker(int pos)
          Set the position marker of the markup
 java.lang.String toString()
           
 
Methods inherited from class wicket.markup.parser.AbstractMarkupFilter
getParent, nextComponentTag, 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()
Description copied from interface: IXmlPullParser
Return the encoding applied while reading the markup resource. The encoding is determined by analysing the <?xml version=".." encoding=".." ?> tag.

Specified by:
getEncoding in interface IXmlPullParser
Returns:
if null, JVM defaults have been used.
See Also:
IXmlPullParser.getEncoding()

getXmlDeclaration

public java.lang.String getXmlDeclaration()
Description copied from interface: IXmlPullParser
Return the XML declaration string, in case if found in the markup.

Specified by:
getXmlDeclaration in interface IXmlPullParser
Returns:
Null, if not found.
See Also:
IXmlPullParser.getXmlDeclaration()

getInputFromPositionMarker

public final java.lang.CharSequence getInputFromPositionMarker(int toPos)
Description copied from interface: IXmlPullParser
Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analysed by Wicket. The method getInputFromPositionMarker() is used to access the raw markup.

Specified by:
getInputFromPositionMarker in interface IXmlPullParser
Parameters:
toPos - To position
Returns:
The raw markup in between the position marker and toPos
See Also:
IXmlPullParser.getInputFromPositionMarker(int)

getInput

public final java.lang.CharSequence getInput(int fromPos,
                                             int toPos)
Description copied from interface: IXmlPullParser
Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analysed by Wicket. The getInputSubsequence() method is used to access the raw markup.

Specified by:
getInput in interface IXmlPullParser
Parameters:
fromPos - From position
toPos - To position
Returns:
The raw markup in between fromPos and toPos
See Also:
IXmlPullParser.getInput(int, int)

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,
                  java.lang.String encoding)
           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
encoding - The default character encoding of the input
Throws:
java.io.IOException
ResourceStreamNotFoundException

setPositionMarker

public final void setPositionMarker()
Description copied from interface: IXmlPullParser
Set the position marker of the markup at the current position.

Specified by:
setPositionMarker in interface IXmlPullParser
See Also:
IXmlPullParser.setPositionMarker()

setPositionMarker

public final void setPositionMarker(int pos)
Description copied from interface: IXmlPullParser
Set the position marker of the markup

Specified by:
setPositionMarker in interface IXmlPullParser
See Also:
IXmlPullParser.setPositionMarker(int)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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