INNER CODE UNIT · Java
readEndDocument
mongodb/mongo-java-driver · bson/src/main/org/bson/AbstractBsonReader.java:342
public void readEndDocument() {
if (isClosed()) {
throw new IllegalStateException("BsonReader is closed");
}
if (getContext().getContextType() != BsonContextType.DOCUMENT && getContext().getContextType() != BsonContextType.SCOPE_DOCUMENT) {
throwInvalidContextType("readEndDocument",
getContext().getContextType(), BsonContextType.DOCUMENT, BsonContextType.SCOPE_DOCUMENT);
}
if (getState() == State.TYPE) {
readBsonType(); // will set state to EndOfDocument if at end of document
}
if (getState() != State.END_OF_DOCUMENT) {
throwInvalidState("readEndDocument", State.END_OF_DOCUMENT);
}
doReadEndDocument();
setStateOnEnd();