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

## Class PushStream

- java.lang.Object
- - org.apache.sling.scripting.sightly.impl.compiler.PushStream

All Implemented Interfaces:
  `CommandStream`

    public final class PushStream
    extends Object
    implements CommandStream

A stream that can be written into.

### Nested Class Summary

Nested Classes
`static class` `PushStream.StreamMessage`

### Constructor Summary

Constructors
`PushStream()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addHandler​(CommandHandler handler)` Registers a listening `CommandHandler` to the stream.
`void` `close()` Closes this stream.
`List<Command>` `getCommands()` Returns the `List` of commands that were written into this stream.
`List<PushStream.StreamMessage>` `getWarnings()`
`void` `signalError​(String message)` Signal an error to the attached `CommandHandler`.
`void` `warn​(PushStream.StreamMessage warning)`
`void` `write​(Command command)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PushStream

    public PushStream()

### Method Detail

#### addHandler

    public void addHandler​(CommandHandler handler)

Description copied from interface: `CommandStream`
Registers a listening `CommandHandler` to the stream. The `CommandHandler` will be notified for every new `Command` pushed to this stream.

Specified by:
  `addHandler` in interface `CommandStream`
Parameters:
  `handler` - the handler to attach to this stream

#### getCommands

    public List<Command> getCommands()

Description copied from interface: `CommandStream`
Returns the `List` of commands that were written into this stream.

Specified by:
  `getCommands` in interface `CommandStream`
Returns:
  the commands written into this stream

#### getWarnings

    public List<PushStream.StreamMessage> getWarnings()

#### write

    public void write​(Command command)

#### signalError

    public void signalError​(String message)

Signal an error to the attached `CommandHandler`.

Parameters:
  `message` - the error message
Throws:
  `UnsupportedOperationException` - if the stream has been closed

#### close

    public void close()

Closes this stream. Once the stream has been closed no other methods can be called on the stream any more.

Throws:
  `UnsupportedOperationException` - if the stream has already been closed

#### warn

    public void warn​(PushStream.StreamMessage warning)