Search in sources :

Example 1 with HasNextDelimitedRecordEvent

use of org.ballerinalang.nativeimpl.io.events.records.HasNextDelimitedRecordEvent in project ballerina by ballerina-lang.

the class HasNextTextRecord method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(Context context, CallableUnitCallback callback) {
    BStruct channel = (BStruct) context.getRefArgument(TXT_RECORD_CHANNEL_INDEX);
    if (channel.getNativeData(IOConstants.TXT_RECORD_CHANNEL_NAME) != null) {
        DelimitedRecordChannel textRecordChannel = (DelimitedRecordChannel) channel.getNativeData(IOConstants.TXT_RECORD_CHANNEL_NAME);
        EventContext eventContext = new EventContext(context, callback);
        HasNextDelimitedRecordEvent hasNextEvent = new HasNextDelimitedRecordEvent(textRecordChannel, eventContext);
        CompletableFuture<EventResult> event = EventManager.getInstance().publish(hasNextEvent);
        event.thenApply(HasNextTextRecord::response);
    }
}
Also used : EventContext(org.ballerinalang.nativeimpl.io.events.EventContext) BStruct(org.ballerinalang.model.values.BStruct) EventResult(org.ballerinalang.nativeimpl.io.events.EventResult) HasNextDelimitedRecordEvent(org.ballerinalang.nativeimpl.io.events.records.HasNextDelimitedRecordEvent) DelimitedRecordChannel(org.ballerinalang.nativeimpl.io.channels.base.DelimitedRecordChannel)

Aggregations

BStruct (org.ballerinalang.model.values.BStruct)1 DelimitedRecordChannel (org.ballerinalang.nativeimpl.io.channels.base.DelimitedRecordChannel)1 EventContext (org.ballerinalang.nativeimpl.io.events.EventContext)1 EventResult (org.ballerinalang.nativeimpl.io.events.EventResult)1 HasNextDelimitedRecordEvent (org.ballerinalang.nativeimpl.io.events.records.HasNextDelimitedRecordEvent)1