|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.maven.doxia.parser.AbstractParser org.apache.maven.doxia.parser.AbstractXmlParser
public abstract class AbstractXmlParser
An abstract class that defines some convenience methods for XML
parsers.
Nested Class Summary | |
---|---|
static class |
AbstractXmlParser.CachedFileEntityResolver
Implementation of the callback mechanism EntityResolver . |
Field Summary |
---|
Fields inherited from interface org.apache.maven.doxia.markup.XmlMarkup |
---|
BANG, CDATA, DOCTYPE_START, ENTITY_START, XML_NAMESPACE |
Fields inherited from interface org.apache.maven.doxia.markup.Markup |
---|
COLON, EOL, EQUAL, GREATER_THAN, LEFT_CURLY_BRACKET, LEFT_SQUARE_BRACKET, LESS_THAN, MINUS, PLUS, QUOTE, RIGHT_CURLY_BRACKET, RIGHT_SQUARE_BRACKET, SEMICOLON, SLASH, SPACE, STAR |
Fields inherited from interface org.apache.maven.doxia.parser.Parser |
---|
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE |
Constructor Summary | |
---|---|
AbstractXmlParser()
|
Method Summary | |
---|---|
protected SinkEventAttributeSet |
getAttributesFromParser(org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
Converts the attributes of the current start tag of the given parser to a SinkEventAttributeSet. |
protected Map<String,String> |
getLocalEntities()
Return the defined entities in a local doctype. |
protected String |
getText(org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
getText. |
int |
getType()
The parser type value could be Parser.UNKNOWN_TYPE , Parser.TXT_TYPE or
Parser.XML_TYPE . |
protected void |
handleCdsect(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink)
Handles CDATA sections. |
protected void |
handleComment(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink)
Handles comments. |
protected abstract void |
handleEndTag(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink)
Goes through the possible end tags. |
protected void |
handleEntity(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink)
Handles entities. |
protected abstract void |
handleStartTag(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink)
Goes through the possible start tags. |
protected void |
handleText(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink)
Handles text events. |
protected void |
handleUnknown(org.codehaus.plexus.util.xml.pull.XmlPullParser parser,
Sink sink,
int type)
Handles an unkown event. |
protected boolean |
isCollapsibleWhitespace()
isCollapsibleWhitespace. |
protected boolean |
isIgnorableWhitespace()
isIgnorableWhitespace. |
protected boolean |
isTrimmableWhitespace()
isTrimmableWhitespace. |
boolean |
isValidate()
isValidate. |
void |
parse(Reader source,
Sink sink)
Parses the given source model and emits Doxia events into the given sink. |
void |
parse(String string,
Sink sink)
Convenience method to parse an arbitrary string and emit events into the given sink. Convenience method to parse an arbitrary string and emit any xml events into the given sink. |
protected void |
setCollapsibleWhitespace(boolean collapsible)
Specify that text will be collapsed. |
protected void |
setIgnorableWhitespace(boolean ignorable)
Specify that whitespace will be ignored. |
protected void |
setTrimmableWhitespace(boolean trimmable)
Specify that text will be collapsed. |
void |
setValidate(boolean validate)
Specify a flag to validate or not the XML content. |
Methods inherited from class org.apache.maven.doxia.parser.AbstractParser |
---|
doxiaVersion, enableLogging, executeMacro, getBasedir, getLog, getMacroManager, init, isSecondParsing, setSecondParsing |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractXmlParser()
Method Detail |
---|
public void parse(Reader source, Sink sink) throws ParseException
parse
in interface Parser
source
- not null reader that provides the source document.
You could use newReader
methods from ReaderFactory
.sink
- A sink that consumes the Doxia events.
ParseException
- if the model could not be parsed.public void parse(String string, Sink sink) throws ParseException
parse
in class AbstractParser
string
- A string that provides the source input.sink
- A sink that consumes the Doxia events.
ParseException
- if the string could not be parsed.public final int getType()
Parser.UNKNOWN_TYPE
, Parser.TXT_TYPE
or
Parser.XML_TYPE
.
getType
in interface Parser
getType
in class AbstractParser
protected SinkEventAttributeSet getAttributesFromParser(org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
parser
- A parser, not null.
protected abstract void handleStartTag(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, MacroExecutionException
parser
- A parser, not null.sink
- the sink to receive the events.
org.codehaus.plexus.util.xml.pull.XmlPullParserException
- if there's a problem parsing the model
MacroExecutionException
- if there's a problem executing a macroprotected abstract void handleEndTag(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, MacroExecutionException
parser
- A parser, not null.sink
- the sink to receive the events.
org.codehaus.plexus.util.xml.pull.XmlPullParserException
- if there's a problem parsing the model
MacroExecutionException
- if there's a problem executing a macroprotected void handleText(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
This is a default implementation, if the parser points to a non-empty text element, it is emitted as a text event into the specified sink.
parser
- A parser, not null.sink
- the sink to receive the events. Not null.
org.codehaus.plexus.util.xml.pull.XmlPullParserException
- if there's a problem parsing the modelprotected void handleCdsect(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
This is a default implementation, all data are emitted as text events into the specified sink.
parser
- A parser, not null.sink
- the sink to receive the events. Not null.
org.codehaus.plexus.util.xml.pull.XmlPullParserException
- if there's a problem parsing the modelprotected void handleComment(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
This is a default implementation, all data are emitted as comment events into the specified sink.
parser
- A parser, not null.sink
- the sink to receive the events. Not null.
org.codehaus.plexus.util.xml.pull.XmlPullParserException
- if there's a problem parsing the modelprotected void handleEntity(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
This is a default implementation, all entities are resolved and emitted as text events into the specified sink, except:
#160
, nbsp
and #x00A0
are emitted as nonBreakingSpace()
events.
parser
- A parser, not null.sink
- the sink to receive the events. Not null.
org.codehaus.plexus.util.xml.pull.XmlPullParserException
- if there's a problem parsing the modelprotected void handleUnknown(org.codehaus.plexus.util.xml.pull.XmlPullParser parser, Sink sink, int type)
This is a default implementation, all events are emitted as unknown events into the specified sink.
parser
- the parser to get the event from.sink
- the sink to receive the event.type
- the tag event type. This should be one of HtmlMarkup.TAG_TYPE_SIMPLE,
HtmlMarkup.TAG_TYPE_START, HtmlMarkup.TAG_TYPE_END or HtmlMarkup.ENTITY_TYPE.
It will be passed as the first argument of the required parameters to the Sink
Sink.unknown(String, Object[], org.apache.maven.doxia.sink.SinkEventAttributes)
method.protected boolean isIgnorableWhitespace()
isIgnorableWhitespace.
true
if whitespace will be ignored, false
otherwise.setIgnorableWhitespace(boolean)
protected void setIgnorableWhitespace(boolean ignorable)
<tr> <td/> </tr>is equivalent to
<tr><td/></tr>
ignorable
- true
to ignore whitespace, false
otherwise.protected boolean isCollapsibleWhitespace()
isCollapsibleWhitespace.
true
if text will collapse, false
otherwise.setCollapsibleWhitespace(boolean)
protected void setCollapsibleWhitespace(boolean collapsible)
Text Textis equivalent to
Text Text
collapsible
- true
to allow collapsible text, false
otherwise.protected boolean isTrimmableWhitespace()
isTrimmableWhitespace.
true
if text will be trim, false
otherwise.setTrimmableWhitespace(boolean)
protected void setTrimmableWhitespace(boolean trimmable)
<p> Text </p>is equivalent to
<p>Text</p>
trimmable
- true
to allow trimmable text, false
otherwise.protected String getText(org.codehaus.plexus.util.xml.pull.XmlPullParser parser)
getText.
parser
- A parser, not null.
XmlPullParser.getText()
taking care of trimmable or collapsible configuration.XmlPullParser.getText()
,
isCollapsibleWhitespace()
,
isTrimmableWhitespace()
protected Map<String,String> getLocalEntities()
<!DOCTYPE foo [ <!ENTITY bar "Š"> <!ENTITY bar1 "š"> ]>
public boolean isValidate()
isValidate.
true
if XML content will be validate, false
otherwise.public void setValidate(boolean validate)
validate
- the validate to setparse(Reader, Sink)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |