Package org.apache.wicket.markup.parser
Class XmlPullParser
- java.lang.Object
-
- 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.wicket.markup.parser.IXmlPullParser
IXmlPullParser.HttpTagType
-
-
Constructor Summary
Constructors Constructor Description XmlPullParser()
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharSequence
getDoctype()
Gets the <!DOCTYPE ...> tag if found in the markupXmlTag
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()
IXmlPullParser.HttpTagType
next()
Move to the next XML elementXmlTag
nextTag()
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
parse(CharSequence string)
Parse the given string.void
setPositionMarker()
Set the position marker of the markup at the current position.void
setPositionMarker(int pos)
Set the position marker of the markupprotected void
specialTagHandling(String tagText, int openBracketIndex, int closeBracketIndex)
Handle special tags like <!-- --> or <![CDATA[..]]> or <?xml>String
toString()
-
-
-
Field Detail
-
STYLE
public static final String STYLE
- See Also:
- Constant Field Values
-
SCRIPT
public static final String SCRIPT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XmlPullParser
public XmlPullParser()
Construct.
-
-
Method Detail
-
getEncoding
public final 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 interfaceIXmlPullParser
- Returns:
- if null, JVM defaults have been used.
-
getDoctype
public final CharSequence getDoctype()
Description copied from interface:IXmlPullParser
Gets the <!DOCTYPE ...> tag if found in the markup- Specified by:
getDoctype
in interfaceIXmlPullParser
- Returns:
- Null, if not found
-
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 interfaceIXmlPullParser
- Parameters:
toPos
- To position- Returns:
- The raw markup in between the position marker and toPos
-
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 interfaceIXmlPullParser
- Parameters:
fromPos
- From positiontoPos
- To position- Returns:
- The raw markup in between fromPos and toPos
-
next
public final IXmlPullParser.HttpTagType next() throws ParseException
Description copied from interface:IXmlPullParser
Move to the next XML element- Specified by:
next
in interfaceIXmlPullParser
- Returns:
- XXX
- Throws:
ParseException
-
specialTagHandling
protected void specialTagHandling(String tagText, int openBracketIndex, int closeBracketIndex) throws ParseException
Handle special tags like <!-- --> or <![CDATA[..]]> or <?xml>- Parameters:
tagText
-openBracketIndex
-closeBracketIndex
-- Throws:
ParseException
-
getElement
public final XmlTag getElement()
- Specified by:
getElement
in interfaceIXmlPullParser
- Returns:
- MarkupElement
-
getString
public final CharSequence getString()
- Specified by:
getString
in interfaceIXmlPullParser
- Returns:
- The xml string from the last element
-
nextTag
public final XmlTag nextTag() throws ParseException
- Returns:
- The next XML tag
- Throws:
ParseException
-
parse
public void parse(CharSequence string) throws IOException
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 interfaceIXmlPullParser
- Parameters:
string
- The input string- Throws:
IOException
- Error while reading the resource
-
parse
public void parse(InputStream in) throws IOException
Reads and parses markup from an input stream, using UTF-8 encoding by default when not specified in XML declaration.- Specified by:
parse
in interfaceIXmlPullParser
- Parameters:
in
- The input stream to read and parse- Throws:
IOException
- See Also:
parse(InputStream, String)
-
parse
public void parse(InputStream inputStream, String encoding) throws IOException
Reads and parses markup from an input stream.Note: The input is closed after parsing.
- Specified by:
parse
in interfaceIXmlPullParser
- Parameters:
inputStream
- The input stream to read and parseencoding
- The default character encoding of the input- Throws:
IOException
-
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 interfaceIXmlPullParser
-
setPositionMarker
public final void setPositionMarker(int pos)
Description copied from interface:IXmlPullParser
Set the position marker of the markup- Specified by:
setPositionMarker
in interfaceIXmlPullParser
-
-