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 Modifier and Type Class Description static classPushStream.StreamMessage
-
Constructor Summary
Constructors Constructor Description PushStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(CommandHandler handler)Registers a listeningCommandHandlerto the stream.voidclose()Closes this stream.List<Command>getCommands()Returns theListof commands that were written into this stream.List<PushStream.StreamMessage>getWarnings()voidsignalError(String message)Signal an error to the attachedCommandHandler.voidwarn(PushStream.StreamMessage warning)voidwrite(Command command)
-
-
-
Method Detail
-
addHandler
public void addHandler(CommandHandler handler)
Description copied from interface:CommandStreamRegisters a listeningCommandHandlerto the stream. TheCommandHandlerwill be notified for every newCommandpushed to this stream.- Specified by:
addHandlerin interfaceCommandStream- Parameters:
handler- the handler to attach to this stream
-
getCommands
public List<Command> getCommands()
Description copied from interface:CommandStreamReturns theListof commands that were written into this stream.- Specified by:
getCommandsin interfaceCommandStream- 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 attachedCommandHandler.- 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)
-
-