public abstract class AbstractValidatingReplyCallback extends Object implements ReplyCallback
Reply message
into a different type of result.| Modifier and Type | Field and Description |
|---|---|
static String |
ERROR_CODE_FIELD
The fields that may contain the error code.
|
static List<String> |
ERROR_MESSAGE_FIELDS
The fields that may contain the error message.
|
| Constructor and Description |
|---|
AbstractValidatingReplyCallback()
Creates a new AbstractValidatingReplyCallback.
|
| Modifier and Type | Method and Description |
|---|---|
protected MongoDbException |
asError(Reply reply)
Creates an exception from the
Reply. |
protected MongoDbException |
asError(Reply reply,
boolean knownError)
Creates an exception from the
Reply. |
protected MongoDbException |
asError(Reply reply,
int okValue,
int errorNumber,
boolean knownDurabilityError,
String errorMessage,
Message message)
Creates an exception from the parsed reply fields.
|
protected MongoDbException |
asError(Reply reply,
int okValue,
int errorNumber,
String errorMessage)
Creates an exception from the parsed reply fields.
|
protected String |
asString(Element errorMessageElem)
Converts the
Element to a string. |
void |
callback(Reply result)
Called when the MongoDB operation has completed with the result of the
operation.
|
protected void |
checkForError(Reply reply)
Checks for a non-flag error in the reply.
|
abstract void |
exception(Throwable thrown)
Called when the operation fails due to an exception.
|
protected abstract void |
handle(Reply reply)
Called once the
Reply has been validated. |
protected int |
toInt(Element element)
Converts a
NumericElementinto an int value. |
protected void |
verify(Reply reply)
Checks the reply for an error message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisLightWeightpublic static final String ERROR_CODE_FIELD
public AbstractValidatingReplyCallback()
public void callback(Reply result)
callback in interface Callback<Reply>result - The result of the operation.Callback.callback(V)public abstract void exception(Throwable thrown)
protected MongoDbException asError(Reply reply)
Reply.reply - The raw reply.protected MongoDbException asError(Reply reply, boolean knownError)
Reply.reply - The raw reply.knownError - If true then the reply is assumed to be an error reply.protected final MongoDbException asError(Reply reply, int okValue, int errorNumber, boolean knownDurabilityError, String errorMessage, Message message)
reply - The raw reply.okValue - The 'ok' field.errorNumber - The 'errno' field.knownDurabilityError - Set to true when we know the error is a durability failure.errorMessage - The 'errmsg' field.message - The message that triggered the error, if known.protected MongoDbException asError(Reply reply, int okValue, int errorNumber, String errorMessage)
reply - The raw reply.okValue - The 'ok' field.errorNumber - The 'errno' field.errorMessage - The 'errmsg' field.protected String asString(Element errorMessageElem)
Element to a string. If a StringElement the
value of the element is returned. In all other cases the toString()
result for the element is returned.errorMessageElem - The element to convert to a string.Element's string value.protected void checkForError(Reply reply) throws MongoDbException
reply - The reply to check.MongoDbException - On an error represented in the reply.protected abstract void handle(Reply reply)
Reply has been validated.reply - The Reply to be handled.protected int toInt(Element element)
NumericElementinto an int value. If not a
NumericElement then -1 is returned.element - The element to convert.protected void verify(Reply reply) throws MongoDbException
reply - The Reply to verify is successful.MongoDbException - On a failure message in the reply.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.