- java.lang.Object
-
- swim.codec.Output<T>
-
- swim.codec.OutputBuffer<T>
-
public abstract class OutputBuffer<T> extends Output<T>
Non-blocking token stream buffer.
-
-
Constructor Summary
Constructors Constructor Description OutputBuffer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract byte[]
array()
abstract int
arrayOffset()
abstract int
capacity()
OutputBuffer<T>
clone()
Returns an implementation-defined branch of the token stream.OutputBuffer<T>
debug(Object object)
Writes the code points of the developer-readableDebug
string of the givenobject
.OutputBuffer<T>
display(Object object)
Writes the code points of the human-readableDisplay
string of the givenobject
.static <T> OutputBuffer<T>
done()
Returns anOutputBuffer
in the done state, that binds anull
result.static <T> OutputBuffer<T>
done(OutputSettings settings)
Returns anOutputBuffer
in the done state, with the givensettings
.static <T> OutputBuffer<T>
done(T value)
Returns anOutputBuffer
in the done state, that binds the givenvalue
.static <T> OutputBuffer<T>
done(T value, OutputSettings settings)
Returns anOutputBuffer
in the done state, that binds the givenvalue
, with the givensettings
.static <T> OutputBuffer<T>
error(Throwable error)
Returns anOutputBuffer
in the error state, with the given outputerror
.static <T> OutputBuffer<T>
error(Throwable error, OutputSettings settings)
Returns anOutputBuffer
in the error state, with the given outputerror
andsettings
.OutputBuffer<T>
flush()
Writes any internally buffered state to the underlying output stream.OutputBuffer<T>
fork(Object condition)
Returns anOutput
equivalent to thisOutput
, but whose behavior may be altered by the given out-of-bandcondition
.static <T> OutputBuffer<T>
full()
Returns anOutputBuffer
in the full state, that binds anull
result.static <T> OutputBuffer<T>
full(OutputSettings settings)
Returns anOutputBuffer
in the full state, with the givensettings
.static <T> OutputBuffer<T>
full(T value)
Returns anOutputBuffer
in the full state, that binds the givenvalue
.static <T> OutputBuffer<T>
full(T value, OutputSettings settings)
Returns anOutputBuffer
in the full state, that binds the givenvalue
, with the givensettings
.abstract int
get(int index)
abstract boolean
has(int index)
abstract int
index()
abstract OutputBuffer<T>
index(int index)
abstract OutputBuffer<T>
isPart(boolean isPart)
Returns a partialOutput
equivalent to thisOutput
, ifisPart
istrue
; returns a finalOutput
equivalent to thisOutput
ifisPart
isfalse
.abstract int
limit()
abstract OutputBuffer<T>
limit(int limit)
abstract OutputBuffer<T>
move(int fromIndex, int toIndex, int length)
abstract int
remaining()
abstract void
set(int index, int token)
abstract OutputBuffer<T>
settings(OutputSettings settings)
Updates thesettings
associated with thisOutput
.abstract OutputBuffer<T>
step(int offset)
abstract OutputBuffer<T>
write(int token)
Writes a singletoken
to the stream, if thisOutput
is in the cont state.OutputBuffer<T>
write(String string)
Writes the code points of the givenstring
.abstract int
write(ReadableByteChannel channel)
OutputBuffer<T>
writeln()
Writes the code points of thesettings
'line separator
.OutputBuffer<T>
writeln(String string)
Writes the code points of the givenstring
, followed by the code points of thesettings
'line separator
.
-
-
-
Method Detail
-
isPart
public abstract OutputBuffer<T> isPart(boolean isPart)
Description copied from class:Output
Returns a partialOutput
equivalent to thisOutput
, ifisPart
istrue
; returns a finalOutput
equivalent to thisOutput
ifisPart
isfalse
. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
index
public abstract int index()
-
index
public abstract OutputBuffer<T> index(int index)
-
limit
public abstract int limit()
-
limit
public abstract OutputBuffer<T> limit(int limit)
-
capacity
public abstract int capacity()
-
remaining
public abstract int remaining()
-
array
public abstract byte[] array()
-
arrayOffset
public abstract int arrayOffset()
-
has
public abstract boolean has(int index)
-
get
public abstract int get(int index)
-
set
public abstract void set(int index, int token)
-
write
public abstract int write(ReadableByteChannel channel) throws IOException
- Throws:
IOException
-
write
public abstract OutputBuffer<T> write(int token)
Description copied from class:Output
Writes a singletoken
to the stream, if thisOutput
is in the cont state. Returns anOutput
in the error state if thisOutput
is not in the cont state. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
write
public OutputBuffer<T> write(String string)
Description copied from class:Output
Writes the code points of the givenstring
. Assumes this is a UnicodeOutput
with sufficient capacity. Returns anOutput
in the error state if thisOutput
exits the cont state before the fullstring
has been writtem. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
writeln
public OutputBuffer<T> writeln(String string)
Description copied from class:Output
Writes the code points of the givenstring
, followed by the code points of thesettings
'line separator
. Assumes this is a UnicodeOutput
with sufficient capacity. Returns anOutput
in the error state if thisOutput
exits the cont state before the fullstring
and line separator has been written. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
writeln
public OutputBuffer<T> writeln()
Description copied from class:Output
Writes the code points of thesettings
'line separator
. Assumes this is a UnicodeOutput
with sufficient capacity. Returns anOutput
in the error state if thisOutput
exits the cont state before the full line separator has been written. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
display
public OutputBuffer<T> display(Object object)
Description copied from class:Output
Writes the code points of the human-readableDisplay
string of the givenobject
. Assumes this is a UnicodeOutput
with sufficient capacity. Returns anOutput
in the error state if thisOutput
exits the contt state before the full display string has been written. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
debug
public OutputBuffer<T> debug(Object object)
Description copied from class:Output
Writes the code points of the developer-readableDebug
string of the givenobject
. Assumes this is a UnicodeOutput
with sufficient capacity. Returns anOutput
in the error state if thisOutput
exits the contt state before the full debug string has been written. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
move
public abstract OutputBuffer<T> move(int fromIndex, int toIndex, int length)
-
step
public abstract OutputBuffer<T> step(int offset)
-
flush
public OutputBuffer<T> flush()
Description copied from class:Output
Writes any internally buffered state to the underlying output stream.
-
fork
public OutputBuffer<T> fork(Object condition)
Description copied from class:Output
Returns anOutput
equivalent to thisOutput
, but whose behavior may be altered by the given out-of-bandcondition
. The caller's reference tothis
Output
should be replaced by the returnedOutput
.
-
settings
public abstract OutputBuffer<T> settings(OutputSettings settings)
Description copied from class:Output
Updates thesettings
associated with thisOutput
.
-
clone
public OutputBuffer<T> clone()
Description copied from class:Output
Returns an implementation-defined branch of the token stream.
-
full
public static <T> OutputBuffer<T> full()
Returns anOutputBuffer
in the full state, that binds anull
result.
-
full
public static <T> OutputBuffer<T> full(OutputSettings settings)
Returns anOutputBuffer
in the full state, with the givensettings
.
-
full
public static <T> OutputBuffer<T> full(T value)
Returns anOutputBuffer
in the full state, that binds the givenvalue
.
-
full
public static <T> OutputBuffer<T> full(T value, OutputSettings settings)
Returns anOutputBuffer
in the full state, that binds the givenvalue
, with the givensettings
.
-
done
public static <T> OutputBuffer<T> done()
Returns anOutputBuffer
in the done state, that binds anull
result.
-
done
public static <T> OutputBuffer<T> done(OutputSettings settings)
Returns anOutputBuffer
in the done state, with the givensettings
.
-
done
public static <T> OutputBuffer<T> done(T value)
Returns anOutputBuffer
in the done state, that binds the givenvalue
.
-
done
public static <T> OutputBuffer<T> done(T value, OutputSettings settings)
Returns anOutputBuffer
in the done state, that binds the givenvalue
, with the givensettings
.
-
error
public static <T> OutputBuffer<T> error(Throwable error)
Returns anOutputBuffer
in the error state, with the given outputerror
.
-
error
public static <T> OutputBuffer<T> error(Throwable error, OutputSettings settings)
Returns anOutputBuffer
in the error state, with the given outputerror
andsettings
.
-
-