Class IndexingSink
- All Implemented Interfaces:
AutoCloseable
,Markup
,Sink
- Direct Known Subclasses:
CreateAnchorsForIndexEntries
IndexEntry
objects for sections.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Istrue
if the sink is currently populating entry data (i.e.private boolean
Istrue
once the sink has been closed.private boolean
private final IndexEntry
private final Stack
<IndexEntry> The stack.private IndexEntry.Type
The current type.private final Map
<String, AtomicInteger> A map containing all used ids of index entries as key and how often they are used as value (0-based, i.e.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
ConstructorsModifierConstructorDescriptionIndexingSink
(IndexEntry rootEntry) Deprecated.private
IndexingSink
(IndexEntry rootEntry, Sink delegate) Default constructor.IndexingSink
(Sink delegate) -
Method Summary
Modifier and TypeMethodDescriptionvoid
anchor
(String name, SinkEventAttributes attributes) Starts an element which defines an anchor.void
close()
Close the writer or the stream, if needed.This should only be called once the sink is closed.getTitle()
Getter for the fieldtitle
.(package private) String
getUniqueId
(String id) Converts the given id into a unique one by potentially suffixing it with an index value.(package private) void
protected void
onIndexEntry
(IndexEntry entry) Called at the beginning of each entry (once all metadata about it is collected).private boolean
parseAnchor
(String name) 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.private void
pushNewEntry
(IndexEntry.Type type) Creates and pushes a new IndexEntry onto the top of this stack.void
section
(int level, SinkEventAttributes attributes) Start a new section at the given level.void
section_
(int level) Ends a section at the given level.void
sectionTitle_
(int level) Ends a section title at the given level.private void
setEntryId
(IndexEntry entry, String id) void
text
(String text, SinkEventAttributes attributes) Adds a text.void
title
(SinkEventAttributes attributes) Starts the title element.void
title_()
Ends the title element.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
-
Field Details
-
type
The current type. -
stack
The stack. -
usedIds
A map containing all used ids of index entries as key and how often they are used as value (0-based, i.e. 0 means used 1 time).AtomicInteger
is only used here as it implements a mutable integer (not for its atomicity). -
rootEntry
-
isComplete
private boolean isCompleteIstrue
once the sink has been closed. -
isTitle
private boolean isTitle -
hasOpenEntry
private boolean hasOpenEntryIstrue
if the sink is currently populating entry data (i.e. metadata about the current entry is not completely captured yet)
-
-
Constructor Details
-
IndexingSink
Deprecated.legacy constructor, useIndexingSink(Sink)
withSinkAdapter
as argument and callgetRootEntry()
to retrieve the index tree afterwards. -
IndexingSink
-
IndexingSink
Default constructor.
-
-
Method Details
-
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:
IllegalStateException
- in case the sink was not closed yet
-
getTitle
- Returns:
- the title
-
title
Description copied from interface:Sink
Starts the title element. This is used to identify the document.Supported attributes are the
base attributes
.- Specified by:
title
in interfaceSink
- Overrides:
title
in classSinkWrapper
- Parameters:
attributes
- A set ofSinkEventAttributes
, may benull
.- See Also:
-
title_
public void title_()Description copied from interface:Sink
Ends the title element.- Specified by:
title_
in interfaceSink
- Overrides:
title_
in classSinkWrapper
-
section
Description copied from interface:Sink
Start a new section at the given level.Sections with higher level have to be entirely contained within sections of lower level.
Supported attributes are the
base attributes
.- Specified by:
section
in interfaceSink
- Overrides:
section
in classSinkWrapper
- Parameters:
level
- the section level (must be a value between 1 and 6).attributes
- A set ofSinkEventAttributes
, may benull
.
-
section_
public void section_(int level) Description copied from interface:Sink
Ends a section at the given level. -
sectionTitle_
public void sectionTitle_(int level) Description copied from interface:Sink
Ends a section title at the given level.- Specified by:
sectionTitle_
in interfaceSink
- Overrides:
sectionTitle_
in classSinkWrapper
- Parameters:
level
- the section title level (must be a value between 1 and 6).
-
text
Description copied from interface:Sink
Adds a text.The
text
parameter should contain only real content, ie any ignorable/collapsable whitespace/EOLs or other pretty-printing should be removed/normalized by a parser.If
text
contains any variants of line terminators, they should be normalized to the System EOL by an implementing Sink.Supported attributes are the
base attributes
plusSEMANTICS
(values "emphasis", "strong", "small", "line-through", "citation", "quote", "definition", "abbreviation", "italic", "bold", "monospaced", "variable", "sample", "keyboard", "superscript", "subscript", "annotation", "highlight", "ruby", "rubyBase", "rubyText", "rubyTextContainer", "rubyParentheses", "bidirectionalIsolation", "bidirectionalOverride", "phrase", "insert", "delete").The following attributes are deprecated:
VALIGN
(values "sub", "sup"),DECORATION
(values "underline", "overline", "line-through"),STYLE
(values "italic", "bold", "monospaced").- Specified by:
text
in interfaceSink
- Overrides:
text
in classSinkWrapper
- Parameters:
text
- The text to write.attributes
- A set ofSinkEventAttributes
, may benull
.
-
anchor
Description copied from interface:Sink
Starts an element which defines an anchor.The
name
parameter has to be a valid SGML NAME token. According to the HTML 4.01 specification section 6.2 SGML basic types:ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Supported attributes are the
base attributes
. IfNAME
is specified in the SinkEventAttributes, it will be overwritten by thename
parameter.- Specified by:
anchor
in interfaceSink
- Overrides:
anchor
in classSinkWrapper
- Parameters:
name
- the name of the anchor. This has to be a valid SGML NAME token.attributes
- A set ofSinkEventAttributes
, may benull
.
-
parseAnchor
-
setEntryId
-
getUniqueId
Converts the given id into a unique one by potentially suffixing it with an index value.- Parameters:
id
-- Returns:
- the unique id
-
indexEntryComplete
void indexEntryComplete() -
onIndexEntry
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
-
pushNewEntry
Creates and pushes a new IndexEntry onto the top of this stack. -
push
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
peek.
- Returns:
- Looks at the IndexEntry at the top of this stack.
-
close
public void close()Description copied from interface:Sink
Close the writer or the stream, if needed. Closing a previously-closed Sink has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSink
- Overrides:
close
in classSinkWrapper
-
IndexingSink(Sink)
withSinkAdapter
as argument and callgetRootEntry()
to retrieve the index tree afterwards.