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.
Based on the APTconvert project.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classA block of an apt source document.private classA Comment Block.private classA DefinitionListItem Block.private classA Figure Block.private classA HorizontalRule Block.private classA ListBreak Block.private classA ListItem Block.private classA MacroBlock Block.private classA NumberedListItem Block.private classA PageBreak Block.private classA Paragraph Block.private classA Section Block.private classA Section1 Block.private classA Section2 Block.classA Section3 Block.private classA Section4 Block.private classA Section5 Block.private classA Table Block.private classA Title Block.private classA Verbatim Block. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AptParser.Blocka block of AptSource.private StringblockFileName.private intblockLineNumber.private static final intComment event id.private static final intDefinition list event idprivate static final intFigure event idprivate static final intHorizontal rule event idprotected Stringa line of AptSource.private static final intList break event idprivate static final intList event idprivate static final intMacro event idprivate static final intprivate static final intNumbered list event idprivate static final intParagraph event idprivate static final intPage break event idprivate static final intSection 1 event idprivate static final intSection 2 event idprivate static final intSection 3 event idprivate static final intSection 4 event idprivate static final intSection 5 event idprotected Sinkthe sink to receive the events.private AptSourcethe AptSource.protected StringsourceContent.protected static final char[]An array of 85 spaces.static final intDefault tab width.private static final intTable event idprivate static final intTitle event idprivate static final String[]String representations of event idsprivate static final intVerbatim event idMap 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_MARKUPFields 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, STARFields inherited from interface org.apache.maven.doxia.parser.Parser
ROLE, TXT_TYPE, UNKNOWN_TYPE, XML_TYPEFields inherited from interface org.apache.maven.doxia.markup.TextMarkup
PIPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static charReturns the character at position i of the given string.private StringdoGetTraversedLink(String text, int begin, int end) Parse the given text.protected voiddoTraverseText(String text, int begin, int end, Sink sink) Parse the given text.private voidexpectedBlock(int type) Checks that the current block is of the expected type.private static voidflushTraversed(StringBuilder buffer, Sink sink) Emits the text so far parsed into the given sink.intReturns the current line number of the Apt source document.Returns the name of the Apt source document.private StringgetTraversedAnchor(String text, int begin, int end) Parse the given text.private StringgetTraversedLink(String text, int begin, int end) Parse the given text.protected voidinit()Initialize the parser.private static booleanisHexChar(char c) Determine if c is an hex character.private static booleanisOctalChar(char c) Determine if c is an octal character.private voidlogMessage(String key, String msg) If debug mode is enabled, log themsgas is, otherwise add unique msg inwarnMessages.private voidprivate voidParse the next block of the Apt source document.private voidnextBlock(boolean firstBlock) Parse the next block of the Apt source document.protected voidnextLine()Parse the next line of the Apt source document.voidParses the given source model and emits Doxia events into the given sink.voidParses the given source model and emits Doxia events into the given sink.protected static StringreplaceAll(String string, String oldSub, String newSub) Replace part of a string.protected static intSkip spaces.private static intskipTraversedLinkAnchor(String text, int begin, int end, StringBuilder linkAnchor) Parse the given text.private voidParse the body of the Apt source document.private voidParse a definition list of the Apt source document.private voidParse the head of the Apt source document.private voidParse a list of the Apt source document.private voidParse a numbered list of the Apt source document.private voidtraverseSection(int level) Parse a section of the Apt source document.private voidParse the section blocks of the Apt source document.Methods inherited from class org.apache.maven.doxia.parser.AbstractTextParser
getTypeMethods inherited from class org.apache.maven.doxia.parser.AbstractParser
doxiaVersion, enableLogging, executeMacro, getBasedir, getLog, getMacroManager, isEmitComments, isSecondParsing, parse, parse, setEmitComments, setSecondParsing
-
Field Details
-
TITLE
private static final int TITLETitle event id- See Also:
-
SECTION1
private static final int SECTION1Section 1 event id- See Also:
-
SECTION2
private static final int SECTION2Section 2 event id- See Also:
-
SECTION3
private static final int SECTION3Section 3 event id- See Also:
-
SECTION4
private static final int SECTION4Section 4 event id- See Also:
-
SECTION5
private static final int SECTION5Section 5 event id- See Also:
-
PARAGRAPH
private static final int PARAGRAPHParagraph event id- See Also:
-
VERBATIM
private static final int VERBATIMVerbatim event id- See Also:
-
FIGURE
private static final int FIGUREFigure event id- See Also:
-
TABLE
private static final int TABLETable event id- See Also:
-
LIST_ITEM
private static final int LIST_ITEMList event id- See Also:
-
NUMBERED_LIST_ITEM
private static final int NUMBERED_LIST_ITEMNumbered list event id- See Also:
-
DEFINITION_LIST_ITEM
private static final int DEFINITION_LIST_ITEMDefinition list event id- See Also:
-
HORIZONTAL_RULE
private static final int HORIZONTAL_RULEHorizontal rule event id- See Also:
-
PG_BREAK
private static final int PG_BREAKPage break event id- See Also:
-
LIST_BREAK
private static final int LIST_BREAKList break event id- See Also:
-
MACRO
private static final int MACROMacro event id- See Also:
-
COMMENT_BLOCK
private static final int COMMENT_BLOCKComment event id.- See Also:
-
TYPE_NAMES
String representations of event ids -
SPACES
protected static final char[] SPACESAn array of 85 spaces. -
TAB_WIDTH
public static final int TAB_WIDTHDefault tab width.- See Also:
-
source
the AptSource. -
block
a block of AptSource. -
blockFileName
blockFileName. -
blockLineNumber
private int blockLineNumberblockLineNumber. -
sourceContent
sourceContent. -
sink
the sink to receive the events. -
line
a line of AptSource. -
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. -
NUMBER_OF_SPACES
private static final int NUMBER_OF_SPACES- See Also:
-
-
Constructor Details
-
AptParser
public AptParser()
-
-
Method Details
-
parse
Parses the given source model and emits Doxia events into the given sink.- Specified by:
parsein interfaceParser- Overrides:
parsein classAbstractParser- 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.
-
parse
Parses 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.reference- the reference- Throws:
ParseException- if the model could not be parsed.
-
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
Parse the next line of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
doTraverseText
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
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
Skip spaces.- Parameters:
string- string.length- length.i- offset.- Returns:
- int.
-
replaceAll
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 byAbstractParser.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:
initin classAbstractParser
-
traverseHead
Parse the head of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
traverseBody
Parse the body of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
traverseSection
Parse a section of the Apt source document.- Parameters:
level- The section level.- Throws:
AptParseException- if something goes wrong.
-
traverseSectionBlocks
Parse the section blocks of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
traverseList
Parse a list of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
traverseNumberedList
Parse a numbered list of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
traverseDefinitionList
Parse a definition list of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
nextBlock
Parse the next block of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
nextBlock
Parse the next block of the Apt source document.- Parameters:
firstBlock- True if this is the first block of the Apt source document.- Throws:
AptParseException- if something goes wrong.
-
expectedBlock
Checks that the current block is of the expected type.- Parameters:
type- the expected type.- Throws:
AptParseException- if something goes wrong.
-
isOctalChar
private static boolean isOctalChar(char c) Determine if c is an octal character.- Parameters:
c- the character.- Returns:
- boolean
-
isHexChar
private static boolean isHexChar(char c) Determine if c is an hex character.- Parameters:
c- the character.- Returns:
- boolean
-
flushTraversed
Emits the text so far parsed into the given sink.- Parameters:
buffer- A StringBuilder that contains the text to be flushed.sink- The sink to receive the text.
-
skipTraversedLinkAnchor
private static int skipTraversedLinkAnchor(String text, int begin, int end, StringBuilder linkAnchor) throws AptParseException Parse the given text.- Parameters:
text- the text to parse.begin- offset.end- offset.linkAnchor- a StringBuilder.- Returns:
- int
- Throws:
AptParseException- if something goes wrong.
-
getTraversedLink
Parse the given text.- Parameters:
text- the text to parse.begin- offset.end- offset.- Returns:
- String
- Throws:
AptParseException- if something goes wrong.
-
getTraversedAnchor
Parse the given text.- Parameters:
text- the text to parse.begin- offset.end- offset.- Returns:
- String
- Throws:
AptParseException- if something goes wrong.
-
doGetTraversedLink
Parse the given text.- Parameters:
text- the text to parse.begin- offset.end- offset.- Returns:
- String
- Throws:
AptParseException- if something goes wrong.
-
logMessage
If debug mode is enabled, log themsgas is, otherwise add unique msg inwarnMessages.- Parameters:
key- not nullmsg- not null- Since:
- 1.1.1
- See Also:
-
logWarnings
private void logWarnings()- Since:
- 1.1.2
-