Package org.apache.maven.doxia.index
Class IndexingSink
- java.lang.Object
-
- org.apache.maven.doxia.sink.impl.AbstractSink
-
- org.apache.maven.doxia.sink.impl.SinkWrapper
-
- org.apache.maven.doxia.index.IndexingSink
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,Markup
,org.apache.maven.doxia.sink.Sink
- Direct Known Subclasses:
CreateAnchorsForIndexEntries
public class IndexingSink extends SinkWrapper
A sink wrapper for populating an index tree for particular elements in a document. Currently this only generatesIndexEntry
objects for sections.- Author:
- Trygve Laugstøl, Vincent Siveton
-
-
Field Summary
-
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.sink.Sink
JUSTIFY_CENTER, JUSTIFY_LEFT, JUSTIFY_RIGHT, NUMBERING_DECIMAL, NUMBERING_LOWER_ALPHA, NUMBERING_LOWER_ROMAN, NUMBERING_UPPER_ALPHA, NUMBERING_UPPER_ROMAN, SECTION_LEVEL_1, SECTION_LEVEL_2, SECTION_LEVEL_3, SECTION_LEVEL_4, SECTION_LEVEL_5, SECTION_LEVEL_6
-
-
Constructor Summary
Constructors Constructor Description IndexingSink(IndexEntry rootEntry)
Deprecated.legacy constructor, useIndexingSink(Sink)
withSinkAdapter
as argument and callgetRootEntry()
to retrieve the index tree afterwards.IndexingSink(org.apache.maven.doxia.sink.Sink delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
anchor(java.lang.String name, org.apache.maven.doxia.sink.SinkEventAttributes attributes)
void
close()
IndexEntry
getRootEntry()
This should only be called once the sink is closed.java.lang.String
getTitle()
Getter for the fieldtitle
.protected void
onIndexEntry(IndexEntry entry)
Called at the beginning of each entry (once all metadata about it is collected).IndexEntry
peek()
peek.void
pop()
Removes the IndexEntry at the top of this stack.void
push(IndexEntry entry)
Pushes an IndexEntry onto the top of this stack.void
section(int level, org.apache.maven.doxia.sink.SinkEventAttributes attributes)
void
section_(int level)
void
sectionTitle_(int level)
void
text(java.lang.String text, org.apache.maven.doxia.sink.SinkEventAttributes attributes)
void
title(org.apache.maven.doxia.sink.SinkEventAttributes attributes)
void
title_()
-
Methods inherited from class org.apache.maven.doxia.sink.impl.SinkWrapper
address, address_, anchor_, article, article_, author, author_, blockquote, blockquote_, body, body_, bold, bold_, comment, content, content_, data, data_, date, date_, definedTerm, definedTerm_, definition, definition_, definitionList, definitionList_, definitionListItem, definitionListItem_, division, division_, figure, figure_, figureCaption, figureCaption_, figureGraphics, flush, footer, footer_, getDocumentLocator, getWrappedSink, head, head_, header, header_, horizontalRule, inline, inline_, italic, italic_, lineBreak, lineBreakOpportunity, link, link_, list, list_, listItem, listItem_, monospaced, monospaced_, navigation, navigation_, nonBreakingSpace, numberedList, numberedList_, numberedListItem, numberedListItem_, pageBreak, paragraph, paragraph_, rawText, sectionTitle, setDocumentLocator, setWrappedSink, sidebar, sidebar_, table, table_, tableCaption, tableCaption_, tableCell, tableCell_, tableHeaderCell, tableHeaderCell_, tableRow, tableRow_, tableRows, tableRows_, time, time_, unknown, verbatim, verbatim_
-
Methods inherited from class org.apache.maven.doxia.sink.impl.AbstractSink
address, anchor, article, author, blockquote, body, content, data, date, definedTerm, definition, definitionList, definitionListItem, division, figure, figureCaption, figureGraphics, footer, formatLocation, getLocationLogPrefix, head, header, horizontalRule, init, inline, lineBreak, lineBreakOpportunity, link, list, listItem, navigation, numberedList, numberedListItem, paragraph, section1, section1_, section2, section2_, section3, section3_, section4, section4_, section5, section5_, section6, section6_, sectionTitle, sectionTitle_, sectionTitle1, sectionTitle1_, sectionTitle2, sectionTitle2_, sectionTitle3, sectionTitle3_, sectionTitle4, sectionTitle4_, sectionTitle5, sectionTitle5_, sectionTitle6, sectionTitle6_, sidebar, table, tableCaption, tableCell, tableHeaderCell, tableRow, tableRows, text, time, title, unifyEOLs, verbatim
-
-
-
-
Constructor Detail
-
IndexingSink
@Deprecated public IndexingSink(IndexEntry rootEntry)
Deprecated.legacy constructor, useIndexingSink(Sink)
withSinkAdapter
as argument and callgetRootEntry()
to retrieve the index tree afterwards.
-
IndexingSink
public IndexingSink(org.apache.maven.doxia.sink.Sink delegate)
-
-
Method Detail
-
getRootEntry
public IndexEntry getRootEntry()
This should only be called once the sink is closed. Before that the tree might not be complete.- Returns:
- the tree of entries starting from the root
- Throws:
java.lang.IllegalStateException
- in case the sink was not closed yet
-
getTitle
public java.lang.String getTitle()
- Returns:
- the title
-
title
public void title(org.apache.maven.doxia.sink.SinkEventAttributes attributes)
- Specified by:
title
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
title
in classSinkWrapper
-
title_
public void title_()
- Specified by:
title_
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
title_
in classSinkWrapper
-
section
public void section(int level, org.apache.maven.doxia.sink.SinkEventAttributes attributes)
- Specified by:
section
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
section
in classSinkWrapper
-
section_
public void section_(int level)
- Specified by:
section_
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
section_
in classSinkWrapper
-
sectionTitle_
public void sectionTitle_(int level)
- Specified by:
sectionTitle_
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
sectionTitle_
in classSinkWrapper
-
text
public void text(java.lang.String text, org.apache.maven.doxia.sink.SinkEventAttributes attributes)
- Specified by:
text
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
text
in classSinkWrapper
-
anchor
public void anchor(java.lang.String name, org.apache.maven.doxia.sink.SinkEventAttributes attributes)
- Specified by:
anchor
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
anchor
in classSinkWrapper
-
onIndexEntry
protected void onIndexEntry(IndexEntry entry)
Called at the beginning of each entry (once all metadata about it is collected). The events for the metadata are buffered and only flushed after this method was called.- Parameters:
entry
- the newly collected entry
-
push
public void push(IndexEntry entry)
Pushes an IndexEntry onto the top of this stack.- Parameters:
entry
- to put.
-
pop
public void pop()
Removes the IndexEntry at the top of this stack.
-
peek
public IndexEntry peek()
peek.
- Returns:
- Looks at the IndexEntry at the top of this stack.
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceorg.apache.maven.doxia.sink.Sink
- Overrides:
close
in classSinkWrapper
-
-