public abstract class IOFolding extends Object
Client usage:
InputOutput io = ...; if (!IOFolding.isSupported(io)) { throw new Exception("Folding is not supported"); } io.getOut().println("First Line - start of fold"); FoldHandle fold = IOFolding.startFold(io, true); io.getOut().println(" Fold Content 1"); io.getOut().println(" The first line of nested fold"); FoldHandle nestedFold = fold.startFold(true); io.getOut().println(" Nested fold content 1"); nestedFold.finish(); io.getOut().println(" Fold Content 2"); fold.finish(); io.getOut().println("Text outside of the fold.");
How to support IOFolding
in own IOProvider
implementation:
InputOutput
provided by IOProvider
has to implement
Lookup.Provider
IOFolding
and implement its abstract methodsIOFolding.FoldHandleDefinition
IOFolding
to Lookup
provided by
InputOutput
Modifier and Type | Class and Description |
---|---|
protected static class |
IOFolding.FoldHandleDefinition
An SPI for creating custom FoldHandle implementations.
|
Constructor and Description |
---|
IOFolding() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isSupported(InputOutput io)
Check whether an
InputOutput supports folding. |
protected abstract IOFolding.FoldHandleDefinition |
startFold(boolean expanded)
Create a fold handle definition for the current last line in the output
window.
|
static FoldHandle |
startFold(InputOutput io,
boolean expanded)
Create a fold handle for the current last line in the output window.
|
public static boolean isSupported(@NonNull InputOutput io)
InputOutput
supports folding.io
- The InputOutput to check.IOFolding.startFold(InputOutput, boolean)
can be used with
io
, false otherwise.@NonNull protected abstract IOFolding.FoldHandleDefinition startFold(boolean expanded)
expanded
- Initial state of the fold.IllegalStateException
- if the last fold hasn't been finished yet.@CheckReturnValue @NonNull public static FoldHandle startFold(@NonNull InputOutput io, boolean expanded)
io
- InputOutput to create the fold in.expanded
- Initial state of the fold.IllegalStateException
- if the last fold hasn't been finished yet.UnsupportedOperationException
- if folding is not supported by the
InputOutput object.