public class TextWriteDocumentContext extends Object implements WriteDocumentContext
WriteDocumentContext for text-based wire representations.
This class manages and tracks the state of the document being written and contains functionalities
for starting a new write transaction in the document.
While writing, it can be ensured that meta-data is correctly specified, and the position of the write operation is recorded.
| Modifier and Type | Field and Description |
|---|---|
protected int |
count |
protected long |
position |
protected Wire |
wire |
NOOP| Constructor and Description |
|---|
TextWriteDocumentContext(Wire wire)
Constructs a new context for the specified wire.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
chainedElement()
Returns
true if this WriteDocumentContext is a
chained element. |
void |
chainedElement(boolean chainedElement)
Marks this
WriteDocumentContext as a chained element. |
void |
close()
Closes the
DocumentContext and releases any held resources. |
long |
index()
Obtains the index of the last read operation from this source context.
|
boolean |
isEmpty()
Checks if the writing context is empty.
|
boolean |
isMetaData()
Checks it the
DocumentContext is metadata. |
boolean |
isNotComplete() |
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. |
void |
rollbackIfNotComplete()
Call this if any incomplete message should be rolled back at this point, it it wasn't complete by now.
|
void |
rollbackOnClose()
Invoked to signal an error condition in the current context.
|
int |
sourceId()
Retrieves the source ID associated with this context.
|
void |
start(boolean metaData)
Starts a new write transaction in the document.
|
Wire |
wire()
Returns the
Wire associated with the Document. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisData, isOpenprotected Wire wire
protected int count
protected long position
public TextWriteDocumentContext(Wire wire)
wire - The wire instance to be used for writingpublic void start(boolean metaData)
start in interface WriteDocumentContextmetaData - Indicates if the data being written is meta-datapublic boolean isEmpty()
WriteDocumentContextisEmpty in interface WriteDocumentContexttrue if the context is empty; otherwise, false.public boolean isMetaData()
DocumentContextDocumentContext is metadata. If it is, true is
returned, otherwise false.isMetaData in interface DocumentContextpublic void close()
DocumentContextDocumentContext 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 Closeableclose in interface AutoCloseableclose in interface DocumentContextpublic void rollbackIfNotComplete()
DocumentContextrollbackIfNotComplete in interface DocumentContextpublic void rollbackOnClose()
DocumentContextrollbackOnClose in interface DocumentContextpublic void reset()
DocumentContextDocumentContext 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.reset in interface DocumentContextpublic boolean chainedElement()
WriteDocumentContexttrue if this WriteDocumentContext is a
chained element.chainedElement in interface WriteDocumentContexttrue if this WriteDocumentContext is a
chained element; otherwise, false.public void chainedElement(boolean chainedElement)
WriteDocumentContextWriteDocumentContext as a chained element.chainedElement in interface WriteDocumentContextchainedElement - A boolean value indicating if the context
is a chained element.public boolean isPresent()
DocumentContextDocumentContext is present. If it is, true is returned,
otherwise false.isPresent in interface DocumentContextpublic Wire wire()
DocumentContextWire associated with the Document. It is possible that
null is returned, depending on the implementation.wire in interface DocumentContextWire associated with the Document.public long index()
SourceContextindex in interface SourceContextpublic int sourceId()
SourceContextsourceId in interface SourceContextpublic boolean isNotComplete()
isNotComplete in interface DocumentContextCopyright © 2024. All rights reserved.