public class CommentEventsCollector
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<CommentLine> |
commentLineList |
private java.util.Queue<Event> |
eventSource |
private CommentType[] |
expectedCommentTypes |
Constructor and Description |
---|
CommentEventsCollector(Parser parser,
CommentType... expectedCommentTypes)
Constructor used to collect comment events emitted by a Parser.
|
CommentEventsCollector(java.util.Queue<Event> eventSource,
CommentType... expectedCommentTypes)
Constructor used to collect events emitted by the Serializer.
|
Modifier and Type | Method and Description |
---|---|
CommentEventsCollector |
collectEvents()
Collect all events of the expected type (set during construction) starting with the top event
on the event source.
|
Event |
collectEvents(Event event)
Collect all events of the expected type (set during construction) starting with event provided
as an argument and continuing with the top event on the event source.
|
Event |
collectEventsAndPoll(Event event)
Collect all events of the expected type (set during construction) starting with event provided
as an argument and continuing with the top event on the event source.
|
java.util.List<CommentLine> |
consume()
Return the events collected and reset the colletor.
|
boolean |
isEmpty()
Test if the collector contains any collected events.
|
private boolean |
isEventExpected(Event event)
Determine if the event is a comment of one of the expected types set during construction.
|
private java.util.List<CommentLine> commentLineList
private final java.util.Queue<Event> eventSource
private final CommentType[] expectedCommentTypes
public CommentEventsCollector(Parser parser, CommentType... expectedCommentTypes)
parser
- the event source.expectedCommentTypes
- the comment types expected. Any comment types not included are not
collected.public CommentEventsCollector(java.util.Queue<Event> eventSource, CommentType... expectedCommentTypes)
eventSource
- the event source.expectedCommentTypes
- the comment types expected. Any comment types not included are not
collected.private boolean isEventExpected(Event event)
event
- the event to test.true
if the events is a comment of the expected type; Otherwise, false.public CommentEventsCollector collectEvents()
public Event collectEvents(Event event)
event
- the first event to attempt to collect.null
public Event collectEventsAndPoll(Event event)
event
- the first event to attempt to collect.public java.util.List<CommentLine> consume()
public boolean isEmpty()
true
if it does; Otherwise, false