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 class
PushStream.StreamMessage
-
Constructor Summary
Constructors Constructor Description PushStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(CommandHandler handler)
Registers a listeningCommandHandler
to the stream.void
close()
Closes this stream.List<Command>
getCommands()
Returns theList
of commands that were written into this stream.List<PushStream.StreamMessage>
getWarnings()
void
signalError(String message)
Signal an error to the attachedCommandHandler
.void
warn(PushStream.StreamMessage warning)
void
write(Command command)
-
-
-
Method Detail
-
addHandler
public void addHandler(CommandHandler handler)
Description copied from interface:CommandStream
Registers a listeningCommandHandler
to the stream. TheCommandHandler
will be notified for every newCommand
pushed to this stream.- Specified by:
addHandler
in interfaceCommandStream
- Parameters:
handler
- the handler to attach to this stream
-
getCommands
public List<Command> getCommands()
Description copied from interface:CommandStream
Returns theList
of commands that were written into this stream.- Specified by:
getCommands
in 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)
-
-