public interface DocumentContext extends Closeable, SourceContext
Implementations must ensure proper handling of resources and consistency of the document state.
| Modifier and Type | Field and Description |
|---|---|
static DocumentContext |
NOOP |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
DocumentContext and releases any held resources. |
default boolean |
isData()
Determines if the
DocumentContext is in an open state. |
boolean |
isMetaData()
Checks it the
DocumentContext is metadata. |
boolean |
isNotComplete() |
default boolean |
isOpen() |
boolean |
isPresent()
Checks if the
DocumentContext is present. |
void |
reset()
Cleans up the
DocumentContext by invoking the close method, then discarding
any lingering state associated with it. |
default void |
rollbackIfNotComplete()
Call this if any incomplete message should be rolled back at this point, it it wasn't complete by now.
|
default void |
rollbackOnClose()
Invoked to signal an error condition in the current context.
|
@Nullable Wire |
wire()
Returns the
Wire associated with the Document. |
index, sourceIdstatic final DocumentContext NOOP
boolean isMetaData()
DocumentContext is metadata. If it is, true is
returned, otherwise false.boolean isPresent()
DocumentContext is present. If it is, true is returned,
otherwise false.default boolean isData()
DocumentContext is in an open state.
This method essentially checks the inverse of the completion status of the context.true if the context is open (i.e., the NOT_COMPLETE flag is set),
false otherwise.@Nullable @Nullable Wire wire()
Wire associated with the Document. It is possible that
null is returned, depending on the implementation.Wire associated with the Document.boolean isNotComplete()
default boolean isOpen()
default void rollbackOnClose()
default void rollbackIfNotComplete()
void close()
DocumentContext and releases any held resources.
It is crucial to ensure that this method is invoked after the context's operations are completed
to prevent any potential resource leaks or data corruption.close in interface AutoCloseableclose in interface Closeablevoid reset()
DocumentContext by invoking the close method, then discarding
any lingering state associated with it. This provides a way to ensure the context
is in a fresh state and free of any residual data or settings.Copyright © 2024. All rights reserved.