Top Description Fields Constructors Methods
org.yaml.snakeyaml.comments

public Class CommentEventsCollector

extends Object
Class Inheritance
Imports
java.util.AbstractQueue, .ArrayList, .Iterator, .List, .Queue, org.yaml.snakeyaml.events.CommentEvent, .Event, org.yaml.snakeyaml.parser.Parser

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

Modifier and TypeField and Description
private List<CommentLine>
private final Queue<Event>
private final CommentType[]

Constructor Summary

AccessConstructor and Description
public
CommentEventsCollector(final Parser
the event source.
parser
,
CommentType...
the comment types expected. Any comment types not included are not collected.
expectedCommentTypes
)

Constructor used to collect comment events emitted by a Parser.

public
CommentEventsCollector(Queue<Event>
the event source.
eventSource
,
CommentType...
the comment types expected. Any comment types not included are not collected.
expectedCommentTypes
)

Constructor used to collect events emitted by the Serializer.

Method Summary

Modifier and TypeMethod and Description
public CommentEventsCollector

Returns:

this object.
collectEvents
()

Collect all events of the expected type (set during construction) starting with the top event on the event source.

public Event

Returns:

the event provided as an argument, if it is not collected; Otherwise, null
collectEvents
(Event
the first event to attempt to collect.
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.

public Event

Returns:

the event provided as an argument, if it is not collected; Otherwise, the first event that is not collected.
collectEventsAndPoll
(Event
the first event to attempt to collect.
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.

public List<CommentLine>

Returns:

the events collected.
consume
()

Return the events collected and reset the colletor.

public boolean

Returns:

true if it does; Otherwise, false
isEmpty
()

Test if the collector contains any collected events.

private boolean

Returns:

true if the events is a comment of the expected type; Otherwise, false.
isEventExpected
(Event
the event to test.
event
)

Determine if the event is a comment of one of the expected types set during construction.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

commentLineListback to summary
private List<CommentLine> commentLineList
eventSourceback to summary
private final Queue<Event> eventSource
expectedCommentTypesback to summary
private final CommentType[] expectedCommentTypes

Constructor Detail

CommentEventsCollectorback to summary
public CommentEventsCollector(final Parser parser, CommentType... expectedCommentTypes)

Constructor used to collect comment events emitted by a Parser.

Parameters
parser:Parser

the event source.

expectedCommentTypes:CommentType[]

the comment types expected. Any comment types not included are not collected.

CommentEventsCollectorback to summary
public CommentEventsCollector(Queue<Event> eventSource, CommentType... expectedCommentTypes)

Constructor used to collect events emitted by the Serializer.

Parameters
eventSource:Queue<Event>

the event source.

expectedCommentTypes:CommentType[]

the comment types expected. Any comment types not included are not collected.

Method Detail

collectEventsback to summary
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:CommentEventsCollector

this object.

collectEventsback to summary
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:Event

the first event to attempt to collect.

Returns:Event

the event provided as an argument, if it is not collected; Otherwise, null

collectEventsAndPollback to summary
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:Event

the first event to attempt to collect.

Returns:Event

the event provided as an argument, if it is not collected; Otherwise, the first event that is not collected.

consumeback to summary
public List<CommentLine> consume()

Return the events collected and reset the colletor.

Returns:List<CommentLine>

the events collected.

isEmptyback to summary
public boolean isEmpty()

Test if the collector contains any collected events.

Returns:boolean

true if it does; Otherwise, false

isEventExpectedback to summary
private boolean isEventExpected(Event event)

Determine if the event is a comment of one of the expected types set during construction.

Parameters
event:Event

the event to test.

Returns:boolean

true if the events is a comment of the expected type; Otherwise, false.