Package org.apache.maven.doxia.parser
Class AbstractParser
java.lang.Object
org.apache.maven.doxia.parser.AbstractParser
- All Implemented Interfaces:
LogEnabled
,Parser
- Direct Known Subclasses:
AbstractTextParser
,AbstractXmlParser
An abstract base class that defines some convenience methods for parsers.
Provides a macro mechanism to give dynamic functionalities for the parsing.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private boolean
Emit Doxia comment events when parsing comments?private Log
Log instance.private MacroManager
private boolean
Indicates that a second parsing is required.Fields inherited from interface org.apache.maven.doxia.parser.Parser
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static String
The current Doxia version.void
enableLogging
(Log log) Enable aDoxia
logger for thisDoxia
component.void
executeMacro
(String macroId, MacroRequest request, Sink sink) Execute a macro on the given sink.protected File
Deprecated.this does not work in multi-module builds, see DOXIA-373protected Log
getLog()
Returns the current logger for this parser.protected MacroManager
Gets the currentMacroManager
.int
getType()
protected void
init()
Initialize the parser.boolean
isEmitComments.protected boolean
Indicates if we are currently parsing a second time.void
Parses the given source model and emits Doxia events into the given sink.void
Convenience method to parse an arbitrary string and emit events into the given sink.void
Convenience method to parse an arbitrary string and emit events into the given sink.void
setEmitComments
(boolean emitComments) When comments are found in source markup, emit comment Doxia events or just ignore?void
setSecondParsing
(boolean second) SetsecondParsing
to true, if we need a second parsing.
-
Field Details
-
secondParsing
private boolean secondParsingIndicates that a second parsing is required. -
macroManager
-
logger
Log instance. -
emitComments
private boolean emitCommentsEmit Doxia comment events when parsing comments? -
DOXIA_VERSION
-
-
Constructor Details
-
AbstractParser
public AbstractParser()
-
-
Method Details
-
getType
public int getType() -
setEmitComments
public void setEmitComments(boolean emitComments) When comments are found in source markup, emit comment Doxia events or just ignore?- Specified by:
setEmitComments
in interfaceParser
- Parameters:
emitComments
-true
(default value) to emit comment Doxia events
-
isEmitComments
public boolean isEmitComments()isEmitComments.
- Specified by:
isEmitComments
in interfaceParser
- Returns:
- a boolean
-
executeMacro
public void executeMacro(String macroId, MacroRequest request, Sink sink) throws MacroExecutionException, MacroNotFoundException Execute a macro on the given sink.- Parameters:
macroId
- an id to lookup the macrorequest
- the corresponding MacroRequestsink
- the sink to receive the events- Throws:
MacroExecutionException
- if an error occurred during executionMacroNotFoundException
- if the macro could not be found
-
getBasedir
Deprecated.this does not work in multi-module builds, see DOXIA-373Returns the current base directory.- Returns:
- the base directory
-
parse
Convenience method to parse an arbitrary string and emit events into the given sink.- Parameters:
string
- a string that provides the source inputsink
- a sink that consumes the Doxia events- Throws:
ParseException
- if the string could not be parsed- Since:
- 1.1
-
parse
Convenience method to parse an arbitrary string and emit events into the given sink.- Parameters:
string
- a string that provides the source inputsink
- a sink that consumes the Doxia eventsreference
- a string containing the reference to the source of the input string (e.g. filename)- Throws:
ParseException
- if the string could not be parsed- Since:
- 1.10
-
parse
Parses the given source model and emits Doxia events into the given sink.- Specified by:
parse
in interfaceParser
- Parameters:
source
- not null reader that provides the source document. You could usenewReader
methods fromReaderFactory
.sink
- A sink that consumes the Doxia events.- Throws:
ParseException
- if the model could not be parsed.
-
setSecondParsing
public void setSecondParsing(boolean second) SetsecondParsing
to true, if we need a second parsing.- Parameters:
second
- true for second parsing
-
isSecondParsing
protected boolean isSecondParsing()Indicates if we are currently parsing a second time.- Returns:
- true if we are currently parsing a second time
- Since:
- 1.1
-
enableLogging
Enable aDoxia
logger for thisDoxia
component.- Specified by:
enableLogging
in interfaceLogEnabled
- Parameters:
log
- a Log.
-
getLog
Returns the current logger for this parser. If no logger has been configured yet, a new SystemStreamLog is returned.- Returns:
- Log
- Since:
- 1.1
-
getMacroManager
Gets the currentMacroManager
.- Returns:
- the current
MacroManager
- Since:
- 1.1
-
init
protected void init()Initialize the parser. This is called first byparse(java.io.Reader, org.apache.maven.doxia.sink.Sink)
and can be used to set the parser into a clear state so it can be re-used.- Since:
- 1.1.2
-
doxiaVersion
The current Doxia version.- Returns:
- the current Doxia version as a String
- Since:
- 1.2
-