Class AptParser
- java.lang.Object
-
- org.apache.maven.doxia.parser.AbstractParser
-
- org.apache.maven.doxia.parser.AbstractTextParser
-
- org.apache.maven.doxia.module.apt.AptParser
-
- All Implemented Interfaces:
LogEnabled
,Markup
,TextMarkup
,AptMarkup
,Parser
@Component(role=Parser.class, hint="apt") public class AptParser extends AbstractTextParser implements AptMarkup
The APT parser.
Based on the APTconvert project.- Since:
- 1.0
- Version:
- $Id: AptParser.java 1726913 2016-01-26 22:01:54Z rfscholte $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
line
a line of AptSource.protected Sink
sink
the sink to receive the events.protected java.lang.String
sourceContent
sourceContent.protected static char[]
SPACES
An array of 85 spaces.static int
TAB_WIDTH
Default tab width.protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>>
warnMessages
Map of warn messages with a String as key to describe the error type and a Set as value.-
Fields inherited from interface org.apache.maven.doxia.module.apt.AptMarkup
ANCHOR_END_MARKUP, ANCHOR_START_MARKUP, BACKSLASH, BOLD_END_MARKUP, BOLD_START_MARKUP, BOXED_VERBATIM_END_MARKUP, BOXED_VERBATIM_START_MARKUP, COMMENT, HEADER_START_MARKUP, HORIZONTAL_RULE_MARKUP, ITALIC_END_MARKUP, ITALIC_START_MARKUP, LINK_END_MARKUP, LINK_START_1_MARKUP, LINK_START_2_MARKUP, LIST_END_MARKUP, LIST_START_MARKUP, MONOSPACED_END_MARKUP, MONOSPACED_START_MARKUP, NON_BOXED_VERBATIM_END_MARKUP, NON_BOXED_VERBATIM_START_MARKUP, NON_BREAKING_SPACE_MARKUP, NUMBERING, NUMBERING_LOWER_ALPHA_CHAR, NUMBERING_LOWER_ROMAN_CHAR, NUMBERING_UPPER_ALPHA_CHAR, NUMBERING_UPPER_ROMAN_CHAR, PAGE_BREAK, PAGE_BREAK_MARKUP, PERCENT, SECTION_TITLE_START_MARKUP, TAB, TABLE_CELL_SEPARATOR_MARKUP, TABLE_COL_CENTERED_ALIGNED_MARKUP, TABLE_COL_LEFT_ALIGNED_MARKUP, TABLE_COL_RIGHT_ALIGNED_MARKUP, TABLE_ROW_SEPARATOR_MARKUP, TABLE_ROW_START_MARKUP
-
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
-
Fields inherited from interface org.apache.maven.doxia.markup.TextMarkup
PIPE
-
-
Constructor Summary
Constructors Constructor Description AptParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static char
charAt(java.lang.String string, int length, int i)
Returns the character at position i of the given string.protected void
doTraverseText(java.lang.String text, int begin, int end, Sink sink)
Parse the given text.int
getSourceLineNumber()
Returns the current line number of the Apt source document.java.lang.String
getSourceName()
Returns the name of the Apt source document.protected void
init()
Initialize the parser.protected void
nextLine()
Parse the next line of the Apt source document.void
parse(java.io.Reader source, Sink sink)
Parses the given source model and emits Doxia events into the given sink.void
parse(java.io.Reader source, Sink sink, java.lang.String reference)
Parses the given source model and emits Doxia events into the given sink.protected static java.lang.String
replaceAll(java.lang.String string, java.lang.String oldSub, java.lang.String newSub)
Replace part of a string.protected static int
skipSpace(java.lang.String string, int length, int i)
Skip spaces.-
Methods inherited from class org.apache.maven.doxia.parser.AbstractTextParser
getType
-
Methods inherited from class org.apache.maven.doxia.parser.AbstractParser
doxiaVersion, enableLogging, executeMacro, getBasedir, getLog, getMacroManager, isEmitComments, isSecondParsing, parse, setEmitComments, setSecondParsing
-
-
-
-
Field Detail
-
SPACES
protected static final char[] SPACES
An array of 85 spaces.
-
TAB_WIDTH
public static final int TAB_WIDTH
Default tab width.- See Also:
- Constant Field Values
-
sourceContent
protected java.lang.String sourceContent
sourceContent.
-
sink
protected Sink sink
the sink to receive the events.
-
line
protected java.lang.String line
a line of AptSource.
-
warnMessages
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> warnMessages
Map of warn messages with a String as key to describe the error type and a Set as value. Using to reduce warn messages.
-
-
Method Detail
-
parse
public void parse(java.io.Reader source, Sink sink) throws ParseException
Description copied from interface:Parser
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.
-
parse
public void parse(java.io.Reader source, Sink sink, java.lang.String reference) throws ParseException
Description copied from interface:Parser
Parses the given source model and emits Doxia events into the given sink.- Specified by:
parse
in interfaceParser
- Overrides:
parse
in classAbstractParser
- 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.
-
getSourceName
public java.lang.String getSourceName()
Returns the name of the Apt source document.- Returns:
- the source name.
-
getSourceLineNumber
public int getSourceLineNumber()
Returns the current line number of the Apt source document.- Returns:
- the line number.
-
nextLine
protected void nextLine() throws AptParseException
Parse the next line of the Apt source document.- Throws:
AptParseException
- if something goes wrong.
-
doTraverseText
protected void doTraverseText(java.lang.String text, int begin, int end, Sink sink) throws AptParseException
Parse the given text.- Parameters:
text
- the text to parse.begin
- offset.end
- offset.sink
- the sink to receive the events.- Throws:
AptParseException
- if something goes wrong.
-
charAt
protected static char charAt(java.lang.String string, int length, int i)
Returns the character at position i of the given string.- Parameters:
string
- the string.length
- length.i
- offset.- Returns:
- the character, or '\0' if i > length.
-
skipSpace
protected static int skipSpace(java.lang.String string, int length, int i)
Skip spaces.- Parameters:
string
- string.length
- length.i
- offset.- Returns:
- int.
-
replaceAll
protected static java.lang.String replaceAll(java.lang.String string, java.lang.String oldSub, java.lang.String newSub)
Replace part of a string.- Parameters:
string
- the stringoldSub
- the substring to replacenewSub
- the replacement string- Returns:
- String
-
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.- Overrides:
init
in classAbstractParser
-
-