Class 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 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