Package org.yaml.snakeyaml.comments
Class CommentEventsCollector
- java.lang.Object
-
- org.yaml.snakeyaml.comments.CommentEventsCollector
-
public class CommentEventsCollector extends Object
Used by the Composer and Emitter to collect comment events so that they can be used at a later point in the process.
-
-
Constructor Summary
Constructors Constructor Description CommentEventsCollector(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
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.List<CommentLine>
consume()
Return the events collected and reset the colletor.boolean
isEmpty()
Test if the collector contains any collected events.
-
-
-
Constructor Detail
-
CommentEventsCollector
public CommentEventsCollector(Parser parser, CommentType... expectedCommentTypes)
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
public CommentEventsCollector(Queue<Event> eventSource, CommentType... expectedCommentTypes)
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 Detail
-
collectEvents
public CommentEventsCollector 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
public 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. 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
public 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. 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
public List<CommentLine> consume()
Return the events collected and reset the colletor.- Returns:
- the events collected.
-
isEmpty
public boolean isEmpty()
Test if the collector contains any collected events.- Returns:
true
if it does; Otherwise,false
-
-