Class CommentEventsCollector


  • public class CommentEventsCollector
    extends java.lang.Object
    Used by the Composer and Emitter to collect comment events so that they can be used at a later point in the process.
    • 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.
      java.util.List<CommentLine> 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • eventSource

        private final java.util.Queue<Event> eventSource
      • expectedCommentTypes

        private final CommentType[] expectedCommentTypes
      • commentLineList

        private java.util.List<CommentLine> commentLineList
    • 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​(java.util.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

      • isEventExpected

        private boolean isEventExpected​(Event event)
        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

        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 java.util.List<CommentLine> 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