public enum NoDocumentContext extends Enum<NoDocumentContext> implements DocumentContext
DocumentContext interface.
This context represents a non-existent or uninitialized document context,
hence all its methods return default or null values.
This can be useful as a sentinel value or placeholder to avoid null checks in code that works with document contexts. Using `NoDocumentContext.INSTANCE` denotes a guaranteed uninitialized state for a document context.
| Enum Constant and Description |
|---|
INSTANCE
The singleton instance of the NoDocumentContext
|
NOOP| Modifier and Type | Method and Description |
|---|---|
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 |
isData()
Determines if the
DocumentContext is in an open state. |
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. |
int |
sourceId()
Retrieves the source ID associated with this context.
|
static NoDocumentContext |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static NoDocumentContext[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
Wire |
wire()
Returns the
Wire associated with the Document. |
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfisOpen, rollbackIfNotComplete, rollbackOnClosepublic static final NoDocumentContext INSTANCE
public static NoDocumentContext[] values()
for (NoDocumentContext c : NoDocumentContext.values()) System.out.println(c);
public static NoDocumentContext valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic boolean isMetaData()
DocumentContextDocumentContext is metadata. If it is, true is
returned, otherwise false.isMetaData in interface DocumentContextpublic boolean isPresent()
DocumentContextDocumentContext is present. If it is, true is returned,
otherwise false.isPresent in interface DocumentContextpublic boolean isData()
DocumentContextDocumentContext is in an open state.
This method essentially checks the inverse of the completion status of the context.isData in interface DocumentContexttrue if the context is open (i.e., the NOT_COMPLETE flag is set),
false otherwise.public 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 int sourceId()
SourceContextsourceId in interface SourceContextpublic long index()
SourceContextindex in interface SourceContextpublic boolean isNotComplete()
isNotComplete 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 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 DocumentContextCopyright © 2024. All rights reserved.