Package org.apache.sling.scripting.sightly.compiler.commands

## Interface CommandStream

All Known Implementing Classes:
  `PushStream`

    @ProviderType
    public interface CommandStream

This interface defines a stream to which `Command`s are pushed during the compilation of a HTL script by the `SightlyCompiler`. Depending on how a consumer wants to use the stream there are several options:

- if the stream needs to be consumed immediately then a `CommandHandler` can be attached to the stream; the stream, in turn, will notify the handler for every command that has been pushed;
- if the stream can be consumed after the actual compilation there's no need to attach a `CommandHandler`, as the `Command`s that were written to the stream can be replayed in the exact order in which they have been pushed.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `addHandler​(CommandHandler handler)` Registers a listening `CommandHandler` to the stream.
`List<Command>` `getCommands()` Returns the `List` of commands that were written into this stream.

### Method Detail

#### addHandler

    void addHandler​(CommandHandler handler)

Registers a listening `CommandHandler` to the stream. The `CommandHandler` will be notified for every new `Command` pushed to this stream.

Parameters:
  `handler` - the handler to attach to this stream

#### getCommands

    List<Command> getCommands()

Returns the `List` of commands that were written into this stream.

Returns:
  the commands written into this stream