Package org.snakeyaml.engine.v2.comments
Class CommentEventsCollector
java.lang.Object
org.snakeyaml.engine.v2.comments.CommentEventsCollector
Used by the Composer and Emitter to collect comment events so that they can be used at a later
point in the process.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCommentEventsCollector
(Queue<Event> eventSource, CommentType... expectedCommentTypes) Constructor used to collect events emitted by the Serializer.CommentEventsCollector
(Parser parser, CommentType... expectedCommentTypes) Constructor used to collect comment events emitted by a Parser. -
Method Summary
Modifier and TypeMethodDescriptionCollect all events of the expected type (set during construction) starting with the top event on the event source.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.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.consume()
Return the events collected and reset the collector.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.
-
Field Details
-
eventSource
-
expectedCommentTypes
-
commentLineList
-
-
Constructor Details
-
CommentEventsCollector
Constructor used to collect comment events emitted by a Parser.- Parameters:
parser
- the event source.expectedCommentTypes
- the comment types expected. Any comment types not included are not collected.
-
CommentEventsCollector
Constructor used to collect events emitted by the Serializer.- Parameters:
eventSource
- the event source.expectedCommentTypes
- the comment types expected. Any comment types not included are not collected.
-
-
Method Details
-
isEventExpected
Determine if the event is a comment of one of the expected types set during construction.- Parameters:
event
- the event to test.- Returns:
true
if the events is a comment of the expected type; Otherwise, false.
-
collectEvents
Collect all events of the expected type (set during construction) starting with the top event on the event source. Collection stops as soon as a non comment or comment of the unexpected type is encountered.- Returns:
- this object.
-
collectEvents
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. Collection stops as soon as a non comment or comment of the unexpected type is encountered.- Parameters:
event
- the first event to attempt to collect.- Returns:
- the event provided as an argument, if it is not collected; Otherwise,
null
-
collectEventsAndPoll
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. Collection stops as soon as a non comment or comment of the unexpected type is encountered.- Parameters:
event
- the first event to attempt to collect.- Returns:
- the event provided as an argument, if it is not collected; Otherwise, the first event that is not collected.
-
consume
Return the events collected and reset the collector.- Returns:
- the events collected.
-
isEmpty
public boolean isEmpty()Test if the collector contains any collected events.- Returns:
true
if it does; Otherwise,false
-