public abstract class AbstractBsonWriter extends java.lang.Object implements BsonWriter, java.io.Closeable
| 限定符和类型 | 类和说明 |
|---|---|
class |
AbstractBsonWriter.Context
The context for the writer.
|
protected class |
AbstractBsonWriter.Mark
Capture the current state of this writer - its
AbstractBsonWriter.Context, AbstractBsonWriter.State, field name and depth. |
static class |
AbstractBsonWriter.State
The state of a writer.
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
AbstractBsonWriter(BsonWriterSettings settings)
Initializes a new instance of the BsonWriter class.
|
protected |
AbstractBsonWriter(BsonWriterSettings settings,
FieldNameValidator validator)
Initializes a new instance of the BsonWriter class.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
checkPreconditions(java.lang.String methodName,
AbstractBsonWriter.State... validStates)
Checks the writer is in the correct state.
|
protected boolean |
checkState(AbstractBsonWriter.State[] validStates)
Checks if this writer's current state is in the list of given states.
|
void |
close() |
protected abstract void |
doWriteBinaryData(BsonBinary value)
Handles the logic of writing a
BsonBinary value |
protected abstract void |
doWriteBoolean(boolean value)
Handles the logic of writing a boolean value
|
protected abstract void |
doWriteDateTime(long value)
Handles the logic of writing a date time value
|
protected abstract void |
doWriteDBPointer(BsonDbPointer value)
Handles the logic of writing a DbPointer value
|
protected abstract void |
doWriteDouble(double value)
Handles the logic of writing a Double value
|
protected abstract void |
doWriteEndArray()
Handles the logic of writing the end of an array
|
protected abstract void |
doWriteEndDocument()
Handles the logic of writing the end of a document
|
protected abstract void |
doWriteInt32(int value)
Handles the logic of writing an int32 value
|
protected abstract void |
doWriteInt64(long value)
Handles the logic of writing an int64 value
|
protected abstract void |
doWriteJavaScript(java.lang.String value)
Handles the logic of writing a JavaScript function
|
protected abstract void |
doWriteJavaScriptWithScope(java.lang.String value)
Handles the logic of writing a scoped JavaScript function
|
protected abstract void |
doWriteMaxKey()
Handles the logic of writing a Max key
|
protected abstract void |
doWriteMinKey()
Handles the logic of writing a Min key
|
protected abstract void |
doWriteNull()
Handles the logic of writing a Null value
|
protected abstract void |
doWriteObjectId(ObjectId value)
Handles the logic of writing an ObjectId
|
protected abstract void |
doWriteRegularExpression(BsonRegularExpression value)
Handles the logic of writing a regular expression
|
protected abstract void |
doWriteStartArray()
Handles the logic to start writing an array
|
protected abstract void |
doWriteStartDocument()
Handles the logic to start writing a document
|
protected abstract void |
doWriteString(java.lang.String value)
Handles the logic of writing a String
|
protected abstract void |
doWriteSymbol(java.lang.String value)
Handles the logic of writing a Symbol
|
protected abstract void |
doWriteTimestamp(BsonTimestamp value)
Handles the logic of writing a timestamp
|
protected abstract void |
doWriteUndefined()
Handles the logic of writing an Undefined value
|
protected AbstractBsonWriter.Context |
getContext()
Get the context, which will indicate which state the writer is in, for example which part of a document it's currently writing.
|
protected java.lang.String |
getName()
The name of the field being written.
|
protected AbstractBsonWriter.State |
getNextState()
Returns the next valid state for this writer.
|
protected AbstractBsonWriter.State |
getState()
Gets the current state of this writer.
|
protected boolean |
isClosed()
Returns whether this writer has been closed.
|
void |
pipe(BsonReader reader)
Reads a single document from a BsonReader and writes it to this.
|
protected void |
setContext(AbstractBsonWriter.Context context)
Set the context, which will indicate which state the writer is in, for example which part of a document it's currently writing.
|
protected void |
setState(AbstractBsonWriter.State state)
Sets the current state of the writer.
|
protected void |
throwInvalidContextType(java.lang.String methodName,
BsonContextType actualContextType,
BsonContextType... validContextTypes)
Throws an InvalidOperationException when the method called is not valid for the current ContextType.
|
protected void |
throwInvalidState(java.lang.String methodName,
AbstractBsonWriter.State... validStates)
Throws a
BsonInvalidOperationException when the method called is not valid for the current state. |
void |
writeBinaryData(BsonBinary binary)
Writes a BSON Binary data element to the writer.
|
void |
writeBinaryData(java.lang.String name,
BsonBinary binary)
Writes a BSON Binary data element to the writer.
|
void |
writeBoolean(boolean value)
Writes a BSON Boolean to the writer.
|
void |
writeBoolean(java.lang.String name,
boolean value)
Writes a BSON Boolean element to the writer.
|
void |
writeDateTime(long value)
Writes a BSON DateTime to the writer.
|
void |
writeDateTime(java.lang.String name,
long value)
Writes a BSON DateTime element to the writer.
|
void |
writeDBPointer(BsonDbPointer value)
Writes a BSON DBPointer to the writer.
|
void |
writeDBPointer(java.lang.String name,
BsonDbPointer value)
Writes a BSON DBPointer element to the writer.
|
void |
writeDouble(double value)
Writes a BSON Double to the writer.
|
void |
writeDouble(java.lang.String name,
double value)
Writes a BSON Double element to the writer.
|
void |
writeEndArray()
Writes the end of a BSON array to the writer.
|
void |
writeEndDocument()
Writes the end of a BSON document to the writer.
|
void |
writeInt32(int value)
Writes a BSON Int32 to the writer.
|
void |
writeInt32(java.lang.String name,
int value)
Writes a BSON Int32 element to the writer.
|
void |
writeInt64(long value)
Writes a BSON Int64 to the writer.
|
void |
writeInt64(java.lang.String name,
long value)
Writes a BSON Int64 element to the writer.
|
void |
writeJavaScript(java.lang.String code)
Writes a BSON JavaScript to the writer.
|
void |
writeJavaScript(java.lang.String name,
java.lang.String code)
Writes a BSON JavaScript element to the writer.
|
void |
writeJavaScriptWithScope(java.lang.String code)
Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).
|
void |
writeJavaScriptWithScope(java.lang.String name,
java.lang.String code)
Writes a BSON JavaScript element to the writer (call WriteStartDocument to start writing the scope).
|
void |
writeMaxKey()
Writes a BSON MaxKey to the writer.
|
void |
writeMaxKey(java.lang.String name)
Writes a BSON MaxKey element to the writer.
|
void |
writeMinKey()
Writes a BSON MinKey to the writer.
|
void |
writeMinKey(java.lang.String name)
Writes a BSON MinKey element to the writer.
|
void |
writeName(java.lang.String name)
Writes the name of an element to the writer.
|
void |
writeNull()
Writes a BSON null to the writer.
|
void |
writeNull(java.lang.String name)
Writes a BSON null element to the writer.
|
void |
writeObjectId(ObjectId objectId)
Writes a BSON ObjectId to the writer.
|
void |
writeObjectId(java.lang.String name,
ObjectId objectId)
Writes a BSON ObjectId element to the writer.
|
void |
writeRegularExpression(BsonRegularExpression regularExpression)
Writes a BSON regular expression to the writer.
|
void |
writeRegularExpression(java.lang.String name,
BsonRegularExpression regularExpression)
Writes a BSON regular expression element to the writer.
|
void |
writeStartArray()
Writes the start of a BSON array to the writer.
|
void |
writeStartArray(java.lang.String name)
Writes the start of a BSON array element to the writer.
|
void |
writeStartDocument()
Writes the start of a BSON document to the writer.
|
void |
writeStartDocument(java.lang.String name)
Writes the start of a BSON document element to the writer.
|
void |
writeString(java.lang.String value)
Writes a BSON String to the writer.
|
void |
writeString(java.lang.String name,
java.lang.String value)
Writes a BSON String element to the writer.
|
void |
writeSymbol(java.lang.String value)
Writes a BSON Symbol to the writer.
|
void |
writeSymbol(java.lang.String name,
java.lang.String value)
Writes a BSON Symbol element to the writer.
|
void |
writeTimestamp(BsonTimestamp value)
Writes a BSON Timestamp to the writer.
|
void |
writeTimestamp(java.lang.String name,
BsonTimestamp value)
Writes a BSON Timestamp element to the writer.
|
void |
writeUndefined()
Writes a BSON undefined to the writer.
|
void |
writeUndefined(java.lang.String name)
Writes a BSON undefined element to the writer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitflushprotected AbstractBsonWriter(BsonWriterSettings settings)
settings - The writer settings.protected AbstractBsonWriter(BsonWriterSettings settings, FieldNameValidator validator)
settings - The writer settings.validator - the field name validatorprotected java.lang.String getName()
protected boolean isClosed()
close() method has been called.protected void setState(AbstractBsonWriter.State state)
state - the state to set this writer to.protected AbstractBsonWriter.State getState()
protected AbstractBsonWriter.Context getContext()
protected void setContext(AbstractBsonWriter.Context context)
context - the new context for this writerprotected abstract void doWriteStartDocument()
protected abstract void doWriteEndDocument()
protected abstract void doWriteStartArray()
protected abstract void doWriteEndArray()
protected abstract void doWriteBinaryData(BsonBinary value)
BsonBinary valuevalue - the BsonBinary value to writeprotected abstract void doWriteBoolean(boolean value)
value - the boolean value to writeprotected abstract void doWriteDateTime(long value)
value - the long value to writeprotected abstract void doWriteDBPointer(BsonDbPointer value)
value - the BsonDbPointer value to writeprotected abstract void doWriteDouble(double value)
value - the double value to writeprotected abstract void doWriteInt32(int value)
value - the int value to writeprotected abstract void doWriteInt64(long value)
value - the long value to writeprotected abstract void doWriteJavaScript(java.lang.String value)
value - the String value to writeprotected abstract void doWriteJavaScriptWithScope(java.lang.String value)
value - the boolean value to writeprotected abstract void doWriteMaxKey()
protected abstract void doWriteMinKey()
protected abstract void doWriteNull()
protected abstract void doWriteObjectId(ObjectId value)
value - the ObjectId value to writeprotected abstract void doWriteRegularExpression(BsonRegularExpression value)
value - the BsonRegularExpression value to writeprotected abstract void doWriteString(java.lang.String value)
value - the String value to writeprotected abstract void doWriteSymbol(java.lang.String value)
value - the boolean value to writeprotected abstract void doWriteTimestamp(BsonTimestamp value)
value - the BsonTimestamp value to writeprotected abstract void doWriteUndefined()
public void writeStartDocument(java.lang.String name)
BsonWriterwriteStartDocument 在接口中 BsonWritername - The name of the element.public void writeStartDocument()
BsonWriterwriteStartDocument 在接口中 BsonWriterpublic void writeEndDocument()
BsonWriterwriteEndDocument 在接口中 BsonWriterpublic void writeStartArray(java.lang.String name)
BsonWriterwriteStartArray 在接口中 BsonWritername - The name of the element.public void writeStartArray()
BsonWriterwriteStartArray 在接口中 BsonWriterpublic void writeEndArray()
BsonWriterwriteEndArray 在接口中 BsonWriterpublic void writeBinaryData(java.lang.String name,
BsonBinary binary)
BsonWriterwriteBinaryData 在接口中 BsonWritername - The name of the element.binary - The Binary data value.public void writeBinaryData(BsonBinary binary)
BsonWriterwriteBinaryData 在接口中 BsonWriterbinary - The Binary data.public void writeBoolean(java.lang.String name,
boolean value)
BsonWriterwriteBoolean 在接口中 BsonWritername - The name of the element.value - The Boolean value.public void writeBoolean(boolean value)
BsonWriterwriteBoolean 在接口中 BsonWritervalue - The Boolean value.public void writeDateTime(java.lang.String name,
long value)
BsonWriterwriteDateTime 在接口中 BsonWritername - The name of the element.value - The number of milliseconds since the Unix epoch.public void writeDateTime(long value)
BsonWriterwriteDateTime 在接口中 BsonWritervalue - The number of milliseconds since the Unix epoch.public void writeDBPointer(java.lang.String name,
BsonDbPointer value)
BsonWriterwriteDBPointer 在接口中 BsonWritername - The name of the element.value - The DBPointer to writepublic void writeDBPointer(BsonDbPointer value)
BsonWriterwriteDBPointer 在接口中 BsonWritervalue - The DBPointer to writepublic void writeDouble(java.lang.String name,
double value)
BsonWriterwriteDouble 在接口中 BsonWritername - The name of the element.value - The Double value.public void writeDouble(double value)
BsonWriterwriteDouble 在接口中 BsonWritervalue - The Double value.public void writeInt32(java.lang.String name,
int value)
BsonWriterwriteInt32 在接口中 BsonWritername - The name of the element.value - The Int32 value.public void writeInt32(int value)
BsonWriterwriteInt32 在接口中 BsonWritervalue - The Int32 value.public void writeInt64(java.lang.String name,
long value)
BsonWriterwriteInt64 在接口中 BsonWritername - The name of the element.value - The Int64 value.public void writeInt64(long value)
BsonWriterwriteInt64 在接口中 BsonWritervalue - The Int64 value.public void writeJavaScript(java.lang.String name,
java.lang.String code)
BsonWriterwriteJavaScript 在接口中 BsonWritername - The name of the element.code - The JavaScript code.public void writeJavaScript(java.lang.String code)
BsonWriterwriteJavaScript 在接口中 BsonWritercode - The JavaScript code.public void writeJavaScriptWithScope(java.lang.String name,
java.lang.String code)
BsonWriterwriteJavaScriptWithScope 在接口中 BsonWritername - The name of the element.code - The JavaScript code.public void writeJavaScriptWithScope(java.lang.String code)
BsonWriterwriteJavaScriptWithScope 在接口中 BsonWritercode - The JavaScript code.public void writeMaxKey(java.lang.String name)
BsonWriterwriteMaxKey 在接口中 BsonWritername - The name of the element.public void writeMaxKey()
BsonWriterwriteMaxKey 在接口中 BsonWriterpublic void writeMinKey(java.lang.String name)
BsonWriterwriteMinKey 在接口中 BsonWritername - The name of the element.public void writeMinKey()
BsonWriterwriteMinKey 在接口中 BsonWriterpublic void writeName(java.lang.String name)
BsonWriterwriteName 在接口中 BsonWritername - The name of the element.public void writeNull(java.lang.String name)
BsonWriterwriteNull 在接口中 BsonWritername - The name of the element.public void writeNull()
BsonWriterwriteNull 在接口中 BsonWriterpublic void writeObjectId(java.lang.String name,
ObjectId objectId)
BsonWriterwriteObjectId 在接口中 BsonWritername - The name of the element.objectId - The ObjectId value.public void writeObjectId(ObjectId objectId)
BsonWriterwriteObjectId 在接口中 BsonWriterobjectId - The ObjectId value.public void writeRegularExpression(java.lang.String name,
BsonRegularExpression regularExpression)
BsonWriterwriteRegularExpression 在接口中 BsonWritername - The name of the element.regularExpression - The RegularExpression value.public void writeRegularExpression(BsonRegularExpression regularExpression)
BsonWriterwriteRegularExpression 在接口中 BsonWriterregularExpression - the regular expression to write.public void writeString(java.lang.String name,
java.lang.String value)
BsonWriterwriteString 在接口中 BsonWritername - The name of the element.value - The String value.public void writeString(java.lang.String value)
BsonWriterwriteString 在接口中 BsonWritervalue - The String value.public void writeSymbol(java.lang.String name,
java.lang.String value)
BsonWriterwriteSymbol 在接口中 BsonWritername - The name of the element.value - The symbol.public void writeSymbol(java.lang.String value)
BsonWriterwriteSymbol 在接口中 BsonWritervalue - The symbol.public void writeTimestamp(java.lang.String name,
BsonTimestamp value)
BsonWriterwriteTimestamp 在接口中 BsonWritername - The name of the element.value - The combined timestamp/increment value.public void writeTimestamp(BsonTimestamp value)
BsonWriterwriteTimestamp 在接口中 BsonWritervalue - The combined timestamp/increment value.public void writeUndefined(java.lang.String name)
BsonWriterwriteUndefined 在接口中 BsonWritername - The name of the element.public void writeUndefined()
BsonWriterwriteUndefined 在接口中 BsonWriterprotected AbstractBsonWriter.State getNextState()
AbstractBsonWriter.State.VALUE to AbstractBsonWriter.State.NAME once a value
is written.Stateprotected boolean checkState(AbstractBsonWriter.State[] validStates)
validStates - an array of States to compare this writer's state to.protected void checkPreconditions(java.lang.String methodName,
AbstractBsonWriter.State... validStates)
IllegalStateException if the writer is closed. Throws BsonInvalidOperationException
if the method is trying to do something that is not permitted in the current state.methodName - the name of the method being performed that checks are being performed forvalidStates - the list of valid states for this operationthrowInvalidState(String, org.bson.AbstractBsonWriter.State...)protected void throwInvalidContextType(java.lang.String methodName,
BsonContextType actualContextType,
BsonContextType... validContextTypes)
methodName - The name of the method.actualContextType - The actual ContextType.validContextTypes - The valid ContextTypes.BsonInvalidOperationException - when the method called is not valid for the current ContextType.protected void throwInvalidState(java.lang.String methodName,
AbstractBsonWriter.State... validStates)
BsonInvalidOperationException when the method called is not valid for the current state.methodName - The name of the method.validStates - The valid states.BsonInvalidOperationException - when the method called is not valid for the current state.public void close()
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseablepublic void pipe(BsonReader reader)
BsonWriterpipe 在接口中 BsonWriterreader - The source.