org.apache.wicket.markup.parser
Class XmlPullParser

java.lang.Object
  extended by org.apache.wicket.markup.parser.XmlPullParser
All Implemented Interfaces:
IXmlPullParser

public final class XmlPullParser
extends Object
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

Field Summary
static int BODY
          Tag body in between two tags
static int CDATA
          
static int COMMENT
           
static int CONDITIONAL_COMMENT
           
static int NOT_INITIALIZED
          next() must be called at least once for the Type to be valid
static int PROCESSING_INSTRUCTION
          
static int SPECIAL_TAG
          all other tags which look like
static int TAG
          
 
Constructor Summary
XmlPullParser()
          Construct.
 
Method Summary
 MarkupElement getElement()
           
 String getEncoding()
          Return the encoding applied while reading the markup resource.
 CharSequence getInput(int fromPos, int toPos)
          Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analyzed by Wicket.
 CharSequence getInputFromPositionMarker(int toPos)
          Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analyzed by Wicket.
 CharSequence getString()
           
 String getXmlDeclaration()
          Return the XML declaration string, in case if found in the markup.
 int next()
          Move to the next XML element
 MarkupElement nextTag()
           
 void parse(CharSequence string)
          Parse the given string.
 void parse(InputStream in)
          Reads and parses markup from an input stream, using UTF-8 encoding by default when not specified in XML declaration.
 void parse(InputStream inputStream, String encoding)
          Reads and parses markup from an input stream
 void setPositionMarker()
          Set the position marker of the markup at the current position.
 void setPositionMarker(int pos)
          Set the position marker of the markup
protected  void specialTagHandling(String tagText, int openBracketIndex, int closeBracketIndex)
          Handle special tags like or or
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOT_INITIALIZED

public static final int NOT_INITIALIZED
next() must be called at least once for the Type to be valid

See Also:
Constant Field Values

TAG

public static final int TAG

See Also:
Constant Field Values

BODY

public static final int BODY
Tag body in between two tags

See Also:
Constant Field Values

COMMENT

public static final int COMMENT

See Also:
Constant Field Values

CONDITIONAL_COMMENT

public static final int CONDITIONAL_COMMENT

See Also:
Constant Field Values

CDATA

public static final int CDATA

See Also:
Constant Field Values

PROCESSING_INSTRUCTION

public static final int PROCESSING_INSTRUCTION

See Also:
Constant Field Values

SPECIAL_TAG

public static final int SPECIAL_TAG
all other tags which look like

See Also:
Constant Field Values
Constructor Detail

XmlPullParser

public XmlPullParser()
Construct.

Method Detail

getEncoding

public String getEncoding()
Description copied from interface: IXmlPullParser
Return the encoding applied while reading the markup resource. The encoding is determined by analyzing 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 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 CharSequence getInputFromPositionMarker(int toPos)
Description copied from interface: IXmlPullParser
Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analyzed 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 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 analyzed 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)

next

public final int next()
               throws ParseException
Description copied from interface: IXmlPullParser
Move to the next XML element

Specified by:
next in interface IXmlPullParser
Returns:
XXX
Throws:
ParseException

specialTagHandling

protected void specialTagHandling(String tagText,
                                  int openBracketIndex,
                                  int closeBracketIndex)
                           throws ParseException
Handle special tags like or or

Parameters:
tagText -
openBracketIndex -
closeBracketIndex -
Throws:
ParseException

getElement

public final MarkupElement getElement()
Specified by:
getElement in interface IXmlPullParser
Returns:
MarkupElement

getString

public final CharSequence getString()
Returns:
The xml string from the last element

nextTag

public final MarkupElement nextTag()
                            throws ParseException
Returns:
The next XML tag
Throws:
ParseException

parse

public void parse(CharSequence string)
           throws 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:
IOException - Error while reading the resource
ResourceStreamNotFoundException - Resource not found

parse

public void parse(InputStream in)
           throws IOException,
                  ResourceStreamNotFoundException
Reads and parses markup from an input stream, using UTF-8 encoding by default when not specified in XML declaration.

Specified by:
parse in interface IXmlPullParser
Parameters:
in - The input stream to read and parse
Throws:
IOException
ResourceStreamNotFoundException

parse

public void parse(InputStream inputStream,
                  String encoding)
           throws IOException,
                  ResourceStreamNotFoundException
Reads and parses markup from an input stream

Specified by:
parse in interface IXmlPullParser
Parameters:
inputStream - The input stream to read and parse
encoding - The default character encoding of the input
Throws:
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 String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


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