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,MarkdownParser
public abstract class AbstractParser extends java.lang.Object implements Parser
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
- Version:
- $Id: AbstractParser.java 1726913 2016-01-26 22:01:54Z rfscholte $
- Author:
- Jason van Zyl
-
-
Field Summary
-
Fields inherited from interface org.apache.maven.doxia.parser.Parser
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE
-
-
Constructor Summary
Constructors Constructor Description AbstractParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static java.lang.StringdoxiaVersion()The current Doxia version.voidenableLogging(Log log)Enable aDoxialogger for thisDoxiacomponent.voidexecuteMacro(java.lang.String macroId, MacroRequest request, Sink sink)Execute a macro on the given sink.protected java.io.FilegetBasedir()Deprecated.this does not work in multi-module builds, see DOXIA-373protected LoggetLog()Returns the current logger for this parser.protected MacroManagergetMacroManager()Gets the currentMacroManager.intgetType()protected voidinit()Initialize the parser.booleanisEmitComments()Does the parser emit Doxia comments event when comments found in source?protected booleanisSecondParsing()Indicates if we are currently parsing a second time.voidparse(java.io.Reader source, Sink sink, java.lang.String reference)Parses the given source model and emits Doxia events into the given sink.voidparse(java.lang.String string, Sink sink)Convenience method to parse an arbitrary string and emit events into the given sink.voidsetEmitComments(boolean emitComments)When comments are found in source markup, emit comment Doxia events or just ignore?voidsetSecondParsing(boolean second)SetsecondParsingto true, if we need a second parsing.
-
-
-
Method Detail
-
setEmitComments
public void setEmitComments(boolean emitComments)
Description copied from interface:ParserWhen comments are found in source markup, emit comment Doxia events or just ignore?- Specified by:
setEmitCommentsin interfaceParser- Parameters:
emitComments-true(default value) to emit comment Doxia events
-
isEmitComments
public boolean isEmitComments()
Description copied from interface:ParserDoes the parser emit Doxia comments event when comments found in source?- Specified by:
isEmitCommentsin interfaceParser- Returns:
true(default value) if comment Doxia events are emitted
-
executeMacro
public void executeMacro(java.lang.String macroId, MacroRequest request, Sink sink) throws MacroExecutionException, MacroNotFoundExceptionExecute a macro on the given sink.- Parameters:
macroId- An id to lookup the macro.request- The corresponding MacroRequest.sink- The sink to receive the events.- Throws:
MacroExecutionException- if an error occurred during execution.MacroNotFoundException- if the macro could not be found.
-
getBasedir
protected java.io.File getBasedir()
Deprecated.this does not work in multi-module builds, see DOXIA-373Returns the current base directory.- Returns:
- The base directory.
-
parse
public void parse(java.lang.String string, Sink sink) throws ParseExceptionConvenience method to parse an arbitrary string and emit events into the given sink.- Parameters:
string- A string that provides the source input.sink- A sink that consumes the Doxia events.- Throws:
ParseException- if the string could not be parsed.- Since:
- 1.1
-
parse
public void parse(java.io.Reader source, Sink sink, java.lang.String reference) throws ParseExceptionDescription copied from interface:ParserParses the given source model and emits Doxia events into the given sink.- Specified by:
parsein interfaceParser- Parameters:
source- not null reader that provides the source document. You could usenewReadermethods fromReaderFactory.sink- A sink that consumes the Doxia events.- Throws:
ParseException- if the model could not be parsed.
-
setSecondParsing
public void setSecondParsing(boolean second)
SetsecondParsingto 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
public void enableLogging(Log log)
Enable aDoxialogger for thisDoxiacomponent.- Specified by:
enableLoggingin interfaceLogEnabled- Parameters:
log- a Log.
-
getLog
protected 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
protected MacroManager getMacroManager()
Gets the currentMacroManager.- Returns:
- The current
MacroManager. - Since:
- 1.1
-
init
protected void init()
Initialize the parser. This is called first byParser.parse(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
protected static java.lang.String doxiaVersion()
The current Doxia version.- Returns:
- the current Doxia version as a String.
- Since:
- 1.2
-
-