@Component(role=Parser.class, hint="apt") public class AptParser extends AbstractTextParser implements AptMarkup
Modifier and Type | Class and Description |
---|---|
private class |
AptParser.Block
A block of an apt source document.
|
private class |
AptParser.Comment
A Comment Block.
|
private class |
AptParser.DefinitionListItem
A DefinitionListItem Block.
|
private class |
AptParser.Figure
A Figure Block.
|
private class |
AptParser.HorizontalRule
A HorizontalRule Block.
|
private class |
AptParser.ListBreak
A ListBreak Block.
|
private class |
AptParser.ListItem
A ListItem Block.
|
private class |
AptParser.MacroBlock
A MacroBlock Block.
|
private class |
AptParser.NumberedListItem
A NumberedListItem Block.
|
private class |
AptParser.PageBreak
A PageBreak Block.
|
private class |
AptParser.Paragraph
A Paragraph Block.
|
private class |
AptParser.Section
A Section Block.
|
private class |
AptParser.Section1
A Section1 Block.
|
private class |
AptParser.Section2
A Section2 Block.
|
class |
AptParser.Section3
A Section3 Block.
|
private class |
AptParser.Section4
A Section4 Block.
|
private class |
AptParser.Section5
A Section5 Block.
|
private class |
AptParser.Table
A Table Block.
|
private class |
AptParser.Title
A Title Block.
|
private class |
AptParser.Verbatim
A Verbatim Block.
|
Modifier and Type | Field and Description |
---|---|
private AptParser.Block |
block
a block of AptSource.
|
private java.lang.String |
blockFileName
blockFileName.
|
private int |
blockLineNumber
blockLineNumber.
|
private static int |
COMMENT_BLOCK
Comment event id.
|
private static int |
DEFINITION_LIST_ITEM
Definition list event id
|
private static int |
FIGURE
Figure event id
|
private static int |
HORIZONTAL_RULE
Horizontal rule event id
|
protected java.lang.String |
line
a line of AptSource.
|
private static int |
LIST_BREAK
List break event id
|
private static int |
LIST_ITEM
List event id
|
private static int |
MACRO
Macro event id
|
private static int |
NUMBER_OF_SPACES |
private static int |
NUMBERED_LIST_ITEM
Numbered list event id
|
private static int |
PARAGRAPH
Paragraph event id
|
private static int |
PG_BREAK
Page break event id
|
private static int |
SECTION1
Section 1 event id
|
private static int |
SECTION2
Section 2 event id
|
private static int |
SECTION3
Section 3 event id
|
private static int |
SECTION4
Section 4 event id
|
private static int |
SECTION5
Section 5 event id
|
protected Sink |
sink
the sink to receive the events.
|
private AptSource |
source
the AptSource.
|
protected java.lang.String |
sourceContent
sourceContent.
|
protected static char[] |
SPACES
An array of 85 spaces.
|
static int |
TAB_WIDTH
Default tab width.
|
private static int |
TABLE
Table event id
|
private static int |
TITLE
Title event id
|
private static java.lang.String[] |
TYPE_NAMES
String representations of event ids
|
private static int |
VERBATIM
Verbatim event id
|
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.
|
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
PIPE
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
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPE
Constructor and Description |
---|
AptParser() |
Modifier and Type | Method and Description |
---|---|
protected static char |
charAt(java.lang.String string,
int length,
int i)
Returns the character at position i of the given string.
|
private java.lang.String |
doGetTraversedLink(java.lang.String text,
int begin,
int end)
Parse the given text.
|
protected void |
doTraverseText(java.lang.String text,
int begin,
int end,
Sink sink)
Parse the given text.
|
private void |
expectedBlock(int type)
Checks that the current block is of the expected type.
|
private static void |
flushTraversed(java.lang.StringBuilder buffer,
Sink sink)
Emits the text so far parsed into the given sink.
|
int |
getSourceLineNumber()
Returns the current line number of the Apt source document.
|
java.lang.String |
getSourceName()
Returns the name of the Apt source document.
|
private java.lang.String |
getTraversedAnchor(java.lang.String text,
int begin,
int end)
Parse the given text.
|
private java.lang.String |
getTraversedLink(java.lang.String text,
int begin,
int end)
Parse the given text.
|
protected void |
init()
Initialize the parser.
|
private static boolean |
isHexChar(char c)
Determine if c is an hex character.
|
private static boolean |
isOctalChar(char c)
Determine if c is an octal character.
|
private void |
logMessage(java.lang.String key,
java.lang.String msg)
If debug mode is enabled, log the
msg as is, otherwise add unique msg in warnMessages . |
private void |
logWarnings() |
private void |
nextBlock()
Parse the next block of the Apt source document.
|
private void |
nextBlock(boolean firstBlock)
Parse the next block of the Apt source document.
|
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.
|
private static int |
skipTraversedLinkAnchor(java.lang.String text,
int begin,
int end,
java.lang.StringBuilder linkAnchor)
Parse the given text.
|
private void |
traverseBody()
Parse the body of the Apt source document.
|
private void |
traverseDefinitionList()
Parse a definition list of the Apt source document.
|
private void |
traverseHead()
Parse the head of the Apt source document.
|
private void |
traverseList()
Parse a list of the Apt source document.
|
private void |
traverseNumberedList()
Parse a numbered list of the Apt source document.
|
private void |
traverseSection(int level)
Parse a section of the Apt source document.
|
private void |
traverseSectionBlocks()
Parse the section blocks of the Apt source document.
|
getType
doxiaVersion, enableLogging, executeMacro, getBasedir, getLog, getMacroManager, isEmitComments, isSecondParsing, parse, setEmitComments, setSecondParsing
private static final int TITLE
private static final int SECTION1
private static final int SECTION2
private static final int SECTION3
private static final int SECTION4
private static final int SECTION5
private static final int PARAGRAPH
private static final int VERBATIM
private static final int FIGURE
private static final int TABLE
private static final int LIST_ITEM
private static final int NUMBERED_LIST_ITEM
private static final int DEFINITION_LIST_ITEM
private static final int HORIZONTAL_RULE
private static final int PG_BREAK
private static final int LIST_BREAK
private static final int MACRO
private static final int COMMENT_BLOCK
private static final java.lang.String[] TYPE_NAMES
protected static final char[] SPACES
public static final int TAB_WIDTH
private AptSource source
private AptParser.Block block
private java.lang.String blockFileName
private int blockLineNumber
protected java.lang.String sourceContent
protected Sink sink
protected java.lang.String line
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> warnMessages
private static final int NUMBER_OF_SPACES
public void parse(java.io.Reader source, Sink sink) throws ParseException
Parser
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(java.io.Reader source, Sink sink, java.lang.String reference) throws ParseException
Parser
parse
in interface Parser
parse
in class AbstractParser
source
- not null reader that provides the source document.
You could use newReader
methods from ReaderFactory
.sink
- A sink that consumes the Doxia events.reference
- the referenceParseException
- if the model could not be parsed.public java.lang.String getSourceName()
public int getSourceLineNumber()
protected void nextLine() throws AptParseException
AptParseException
- if something goes wrong.protected void doTraverseText(java.lang.String text, int begin, int end, Sink sink) throws AptParseException
text
- the text to parse.begin
- offset.end
- offset.sink
- the sink to receive the events.AptParseException
- if something goes wrong.protected static char charAt(java.lang.String string, int length, int i)
string
- the string.length
- length.i
- offset.protected static int skipSpace(java.lang.String string, int length, int i)
string
- string.length
- length.i
- offset.protected static java.lang.String replaceAll(java.lang.String string, java.lang.String oldSub, java.lang.String newSub)
string
- the stringoldSub
- the substring to replacenewSub
- the replacement stringprotected void init()
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.init
in class AbstractParser
private void traverseHead() throws AptParseException
AptParseException
- if something goes wrong.private void traverseBody() throws AptParseException
AptParseException
- if something goes wrong.private void traverseSection(int level) throws AptParseException
level
- The section level.AptParseException
- if something goes wrong.private void traverseSectionBlocks() throws AptParseException
AptParseException
- if something goes wrong.private void traverseList() throws AptParseException
AptParseException
- if something goes wrong.private void traverseNumberedList() throws AptParseException
AptParseException
- if something goes wrong.private void traverseDefinitionList() throws AptParseException
AptParseException
- if something goes wrong.private void nextBlock() throws AptParseException
AptParseException
- if something goes wrong.private void nextBlock(boolean firstBlock) throws AptParseException
firstBlock
- True if this is the first block of the Apt source document.AptParseException
- if something goes wrong.private void expectedBlock(int type) throws AptParseException
type
- the expected type.AptParseException
- if something goes wrong.private static boolean isOctalChar(char c)
c
- the character.private static boolean isHexChar(char c)
c
- the character.private static void flushTraversed(java.lang.StringBuilder buffer, Sink sink)
buffer
- A StringBuilder that contains the text to be flushed.sink
- The sink to receive the text.private static int skipTraversedLinkAnchor(java.lang.String text, int begin, int end, java.lang.StringBuilder linkAnchor) throws AptParseException
text
- the text to parse.begin
- offset.end
- offset.linkAnchor
- a StringBuilder.AptParseException
- if something goes wrong.private java.lang.String getTraversedLink(java.lang.String text, int begin, int end) throws AptParseException
text
- the text to parse.begin
- offset.end
- offset.AptParseException
- if something goes wrong.private java.lang.String getTraversedAnchor(java.lang.String text, int begin, int end) throws AptParseException
text
- the text to parse.begin
- offset.end
- offset.AptParseException
- if something goes wrong.private java.lang.String doGetTraversedLink(java.lang.String text, int begin, int end) throws AptParseException
text
- the text to parse.begin
- offset.end
- offset.AptParseException
- if something goes wrong.private void logMessage(java.lang.String key, java.lang.String msg)
msg
as is, otherwise add unique msg in warnMessages
.key
- not nullmsg
- not nullparse(Reader, Sink)
private void logWarnings()