org.apache.maven.doxia.parser
Class AbstractParser

java.lang.Object
  extended by org.apache.maven.doxia.parser.AbstractParser
All Implemented Interfaces:
LogEnabled, Parser
Direct Known Subclasses:
AbstractTextParser, AbstractXmlParser

public abstract class AbstractParser
extends 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 1094965 2011-04-19 09:30:13Z ltheussl $
Author:
Jason van Zyl
Plexus component

Field Summary
 
Fields inherited from interface org.apache.maven.doxia.parser.Parser
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE
 
Constructor Summary
AbstractParser()
           
 
Method Summary
protected static String doxiaVersion()
          The current Doxia version.
 void enableLogging(Log log)
          
 void executeMacro(String macroId, MacroRequest request, Sink sink)
          Execute a macro on the given sink.
protected  File getBasedir()
          Deprecated. this does not work in multi-module builds, see DOXIA-373
protected  Log getLog()
          Returns the current logger for this parser.
protected  MacroManager getMacroManager()
          Gets the current MacroManager.
 int getType()
          The parser type value could be Parser.UNKNOWN_TYPE, Parser.TXT_TYPE or Parser.XML_TYPE.
protected  void init()
          Initialize the parser.
protected  boolean isSecondParsing()
          Indicates if we are currently parsing a second time.
 void parse(String string, Sink sink)
          Convenience method to parse an arbitrary string and emit events into the given sink.
 void setSecondParsing(boolean second)
          Set secondParsing to true, if we need a second parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.doxia.parser.Parser
parse
 

Constructor Detail

AbstractParser

public AbstractParser()
Method Detail

getType

public int getType()
The parser type value could be Parser.UNKNOWN_TYPE, Parser.TXT_TYPE or Parser.XML_TYPE.

Specified by:
getType in interface Parser
Returns:
the type of Parser

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 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 File getBasedir()
Deprecated. this does not work in multi-module builds, see DOXIA-373

Returns the current base directory.

Returns:
The base directory.

parse

public void parse(String string,
                  Sink sink)
           throws ParseException
Convenience 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

setSecondParsing

public void setSecondParsing(boolean second)
Set secondParsing 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

public void enableLogging(Log log)

Specified by:
enableLogging in interface LogEnabled

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 current MacroManager.

Returns:
The current MacroManager.
Since:
1.1

init

protected void init()
Initialize the parser. This is called first by Parser.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 String doxiaVersion()
The current Doxia version.

Returns:
the current Doxia version as a String.
Since:
1.2


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.