Class DocumentWriter

  • All Implemented Interfaces:
    org.bson.BsonWriter

    public class DocumentWriter
    extends Object
    implements org.bson.BsonWriter
    Utility to write out to a Document
    Developer note.
    This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Constructor Detail

      • DocumentWriter

        public DocumentWriter​(Mapper mapper)
        Creates a new Writer
        Parameters:
        mapper - the mapper to use
      • DocumentWriter

        public DocumentWriter​(Mapper mapper,
                              org.bson.Document seed)
        Creates a new Writer with a seeded Document
        Parameters:
        mapper - the mapper to use
        seed - the seed Document
    • Method Detail

      • encode

        public DocumentWriter encode​(org.bson.codecs.configuration.CodecRegistry codecRegistry,
                                     Object value,
                                     org.bson.codecs.EncoderContext encoderContext)
        Encodes a value in to this Writer
        Parameters:
        codecRegistry - the registry to use
        value - the value to encode
        encoderContext - the context
        Returns:
        this
      • flush

        public void flush()
        Specified by:
        flush in interface org.bson.BsonWriter
      • getDocument

        public org.bson.Document getDocument()
        Returns:
        the root, or output, of this writer. usually a Document.
      • state

        public dev.morphia.mapping.codec.writer.WriteState state()
      • writeBinaryData

        public void writeBinaryData​(org.bson.BsonBinary binary)
        Specified by:
        writeBinaryData in interface org.bson.BsonWriter
      • writeBinaryData

        public void writeBinaryData​(String name,
                                    org.bson.BsonBinary binary)
        Specified by:
        writeBinaryData in interface org.bson.BsonWriter
      • writeBoolean

        public void writeBoolean​(boolean value)
        Specified by:
        writeBoolean in interface org.bson.BsonWriter
      • writeBoolean

        public void writeBoolean​(String name,
                                 boolean value)
        Specified by:
        writeBoolean in interface org.bson.BsonWriter
      • writeDateTime

        public void writeDateTime​(long value)
        Specified by:
        writeDateTime in interface org.bson.BsonWriter
      • writeDateTime

        public void writeDateTime​(String name,
                                  long value)
        Specified by:
        writeDateTime in interface org.bson.BsonWriter
      • writeDBPointer

        public void writeDBPointer​(org.bson.BsonDbPointer value)
        Specified by:
        writeDBPointer in interface org.bson.BsonWriter
      • writeDBPointer

        public void writeDBPointer​(String name,
                                   org.bson.BsonDbPointer value)
        Specified by:
        writeDBPointer in interface org.bson.BsonWriter
      • writeDouble

        public void writeDouble​(double value)
        Specified by:
        writeDouble in interface org.bson.BsonWriter
      • writeDouble

        public void writeDouble​(String name,
                                double value)
        Specified by:
        writeDouble in interface org.bson.BsonWriter
      • writeEndArray

        public void writeEndArray()
        Specified by:
        writeEndArray in interface org.bson.BsonWriter
      • writeEndDocument

        public void writeEndDocument()
        Specified by:
        writeEndDocument in interface org.bson.BsonWriter
      • writeInt32

        public void writeInt32​(int value)
        Specified by:
        writeInt32 in interface org.bson.BsonWriter
      • writeInt32

        public void writeInt32​(String name,
                               int value)
        Specified by:
        writeInt32 in interface org.bson.BsonWriter
      • writeInt64

        public void writeInt64​(long value)
        Specified by:
        writeInt64 in interface org.bson.BsonWriter
      • writeInt64

        public void writeInt64​(String name,
                               long value)
        Specified by:
        writeInt64 in interface org.bson.BsonWriter
      • writeDecimal128

        public void writeDecimal128​(org.bson.types.Decimal128 value)
        Specified by:
        writeDecimal128 in interface org.bson.BsonWriter
      • writeDecimal128

        public void writeDecimal128​(String name,
                                    org.bson.types.Decimal128 value)
        Specified by:
        writeDecimal128 in interface org.bson.BsonWriter
      • writeJavaScript

        public void writeJavaScript​(String code)
        Specified by:
        writeJavaScript in interface org.bson.BsonWriter
      • writeMaxKey

        public void writeMaxKey​(String name)
        Specified by:
        writeMaxKey in interface org.bson.BsonWriter
      • writeJavaScript

        public void writeJavaScript​(String name,
                                    String code)
        Specified by:
        writeJavaScript in interface org.bson.BsonWriter
      • writeMinKey

        public void writeMinKey​(String name)
        Specified by:
        writeMinKey in interface org.bson.BsonWriter
      • writeJavaScriptWithScope

        public void writeJavaScriptWithScope​(String code)
        Specified by:
        writeJavaScriptWithScope in interface org.bson.BsonWriter
      • writeJavaScriptWithScope

        public void writeJavaScriptWithScope​(String name,
                                             String code)
        Specified by:
        writeJavaScriptWithScope in interface org.bson.BsonWriter
      • writeMaxKey

        public void writeMaxKey()
        Specified by:
        writeMaxKey in interface org.bson.BsonWriter
      • writeMinKey

        public void writeMinKey()
        Specified by:
        writeMinKey in interface org.bson.BsonWriter
      • writeName

        public void writeName​(String name)
        Specified by:
        writeName in interface org.bson.BsonWriter
      • writeNull

        public void writeNull()
        Specified by:
        writeNull in interface org.bson.BsonWriter
      • writeNull

        public void writeNull​(String name)
        Specified by:
        writeNull in interface org.bson.BsonWriter
      • writeObjectId

        public void writeObjectId​(org.bson.types.ObjectId objectId)
        Specified by:
        writeObjectId in interface org.bson.BsonWriter
      • writeStartArray

        public void writeStartArray​(String name)
        Specified by:
        writeStartArray in interface org.bson.BsonWriter
      • writeObjectId

        public void writeObjectId​(String name,
                                  org.bson.types.ObjectId objectId)
        Specified by:
        writeObjectId in interface org.bson.BsonWriter
      • writeRegularExpression

        public void writeRegularExpression​(org.bson.BsonRegularExpression regularExpression)
        Specified by:
        writeRegularExpression in interface org.bson.BsonWriter
      • writeRegularExpression

        public void writeRegularExpression​(String name,
                                           org.bson.BsonRegularExpression regularExpression)
        Specified by:
        writeRegularExpression in interface org.bson.BsonWriter
      • writeStartArray

        public void writeStartArray()
        Specified by:
        writeStartArray in interface org.bson.BsonWriter
      • writeStartDocument

        public void writeStartDocument()
        Specified by:
        writeStartDocument in interface org.bson.BsonWriter
      • writeSymbol

        public void writeSymbol​(String name,
                                String value)
        Specified by:
        writeSymbol in interface org.bson.BsonWriter
      • writeStartDocument

        public void writeStartDocument​(String name)
        Specified by:
        writeStartDocument in interface org.bson.BsonWriter
      • writeString

        public void writeString​(String value)
        Specified by:
        writeString in interface org.bson.BsonWriter
      • writeString

        public void writeString​(String name,
                                String value)
        Specified by:
        writeString in interface org.bson.BsonWriter
      • writeUndefined

        public void writeUndefined​(String name)
        Specified by:
        writeUndefined in interface org.bson.BsonWriter
      • pipe

        public void pipe​(org.bson.BsonReader reader)
        Specified by:
        pipe in interface org.bson.BsonWriter
      • writeSymbol

        public void writeSymbol​(String value)
        Specified by:
        writeSymbol in interface org.bson.BsonWriter
      • writeTimestamp

        public void writeTimestamp​(org.bson.BsonTimestamp value)
        Specified by:
        writeTimestamp in interface org.bson.BsonWriter
      • writeTimestamp

        public void writeTimestamp​(String name,
                                   org.bson.BsonTimestamp value)
        Specified by:
        writeTimestamp in interface org.bson.BsonWriter
      • writeUndefined

        public void writeUndefined()
        Specified by:
        writeUndefined in interface org.bson.BsonWriter