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 java.lang.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 java.lang.CharSequencegetDoctype()Gets the <!DOCTYPE ...> tag if found in the markupXmlTaggetElement()java.lang.StringgetEncoding()Return the encoding applied while reading the markup resource.java.lang.CharSequencegetInput(int fromPos, int toPos)Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analyzed by Wicket.java.lang.CharSequencegetInputFromPositionMarker(int toPos)Wicket dissects the markup into Wicket relevant tags and raw markup, which is not further analyzed by Wicket.java.lang.CharSequencegetString()IXmlPullParser.HttpTagTypenext()Move to the next XML elementXmlTagnextTag()voidparse(java.io.InputStream in)Reads and parses markup from an input stream, using UTF-8 encoding by default when not specified in XML declaration.voidparse(java.io.InputStream inputStream, java.lang.String encoding)Reads and parses markup from an input stream.voidparse(java.lang.CharSequence string)Parse the given string.voidsetPositionMarker()Set the position marker of the markup at the current position.voidsetPositionMarker(int pos)Set the position marker of the markupprotected voidspecialTagHandling(java.lang.String tagText, int openBracketIndex, int closeBracketIndex)Handle special tags like or orjava.lang.StringtoString()
-
-
-
Field Detail
-
STYLE
public static final java.lang.String STYLE
- See Also:
- Constant Field Values
-
SCRIPT
public static final java.lang.String SCRIPT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getEncoding
public final java.lang.String getEncoding()
Description copied from interface:IXmlPullParserReturn the encoding applied while reading the markup resource. The encoding is determined by analyzing the <?xml version=".." encoding=".." ?> tag.- Specified by:
getEncodingin interfaceIXmlPullParser- Returns:
- if null, JVM defaults have been used.
-
getDoctype
public final java.lang.CharSequence getDoctype()
Description copied from interface:IXmlPullParserGets the <!DOCTYPE ...> tag if found in the markup- Specified by:
getDoctypein interfaceIXmlPullParser- Returns:
- Null, if not found
-
getInputFromPositionMarker
public final java.lang.CharSequence getInputFromPositionMarker(int toPos)
Description copied from interface:IXmlPullParserWicket 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:
getInputFromPositionMarkerin interfaceIXmlPullParser- Parameters:
toPos- To position- Returns:
- The raw markup in between the position marker and toPos
-
getInput
public final java.lang.CharSequence getInput(int fromPos, int toPos)Description copied from interface:IXmlPullParserWicket 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:
getInputin interfaceIXmlPullParser- Parameters:
fromPos- From positiontoPos- To position- Returns:
- The raw markup in between fromPos and toPos
-
next
public final IXmlPullParser.HttpTagType next() throws java.text.ParseException
Description copied from interface:IXmlPullParserMove to the next XML element- Specified by:
nextin interfaceIXmlPullParser- Returns:
- XXX
- Throws:
java.text.ParseException
-
specialTagHandling
protected void specialTagHandling(java.lang.String tagText, int openBracketIndex, int closeBracketIndex) throws java.text.ParseExceptionHandle special tags like or or- Parameters:
tagText-openBracketIndex-closeBracketIndex-- Throws:
java.text.ParseException
-
getElement
public final XmlTag getElement()
- Specified by:
getElementin interfaceIXmlPullParser- Returns:
- MarkupElement
-
getString
public final java.lang.CharSequence getString()
- Specified by:
getStringin interfaceIXmlPullParser- Returns:
- The xml string from the last element
-
nextTag
public final XmlTag nextTag() throws java.text.ParseException
- Returns:
- The next XML tag
- Throws:
java.text.ParseException
-
parse
public void parse(java.lang.CharSequence string) throws java.io.IOExceptionParse the given string.Note: xml character encoding is NOT applied. It is assumed the input provided does have the correct encoding already.
- Specified by:
parsein interfaceIXmlPullParser- Parameters:
string- The input string- Throws:
java.io.IOException- Error while reading the resource
-
parse
public void parse(java.io.InputStream in) throws java.io.IOExceptionReads and parses markup from an input stream, using UTF-8 encoding by default when not specified in XML declaration.- Specified by:
parsein interfaceIXmlPullParser- Parameters:
in- The input stream to read and parse- Throws:
java.io.IOException
-
parse
public void parse(java.io.InputStream inputStream, java.lang.String encoding) throws java.io.IOExceptionReads and parses markup from an input stream.Note: The input is closed after parsing.
- Specified by:
parsein interfaceIXmlPullParser- Parameters:
inputStream- The input stream to read and parseencoding- The default character encoding of the input- Throws:
java.io.IOException
-
setPositionMarker
public final void setPositionMarker()
Description copied from interface:IXmlPullParserSet the position marker of the markup at the current position.- Specified by:
setPositionMarkerin interfaceIXmlPullParser
-
setPositionMarker
public final void setPositionMarker(int pos)
Description copied from interface:IXmlPullParserSet the position marker of the markup- Specified by:
setPositionMarkerin interfaceIXmlPullParser
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-