|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.codehaus.jackson.JsonGenerator
org.codehaus.jackson.impl.JsonGeneratorBase
de.undercouch.bson4jackson.BsonGenerator
public class BsonGenerator
Writes BSON code to the provided output stream
| Nested Class Summary | |
|---|---|
static class |
BsonGenerator.Feature
Defines toggable features |
| Field Summary | |
|---|---|
protected int |
_bsonFeatures
Bit flag composed of bits that indicate which BsonGenerator.Features are enabled. |
protected DynamicOutputBuffer |
_buffer
Since a BSON document's header must include the size of the whole document in bytes, we have to buffer the whole document first, before we can write it to the output stream. |
protected java.util.Deque<de.undercouch.bson4jackson.BsonGenerator.DocumentInfo> |
_documents
Saves information about documents (the main document and embedded ones) |
protected java.io.OutputStream |
_out
The output stream to write to |
protected int |
_typeMarker
Saves the position of the type marker for the object currently begin written |
protected boolean |
nextObjectIsEmbeddedInValue
Indicates that the next object to be encountered is actually embedded inside a value, and not a complete value itself. |
| Fields inherited from class org.codehaus.jackson.impl.JsonGeneratorBase |
|---|
_cfgNumbersAsStrings, _closed, _features, _objectCodec, _writeContext |
| Fields inherited from class org.codehaus.jackson.JsonGenerator |
|---|
_cfgPrettyPrinter |
| Constructor Summary | |
|---|---|
BsonGenerator(int jsonFeatures,
int bsonFeatures,
java.io.OutputStream out)
Creates a new generator |
|
| Method Summary | |
|---|---|
protected void |
_releaseBuffers()
|
protected void |
_verifyValueWrite(java.lang.String typeMsg)
|
protected void |
_writeArrayFieldNameIfNeeded()
If the generator is currently processing an array, this method writes the field name of the current element (which is just the position of the element in the array) |
protected int |
_writeCString(java.lang.String string)
Write a BSON cstring structure (a null terminated string) |
protected void |
_writeStartObject(boolean array)
Creates a new embedded document or array |
protected int |
_writeString(java.lang.String string)
Write a BSON string structure (a null terminated string prependend by the length of the string) |
void |
close()
|
protected java.lang.String |
flagsToRegexOptions(int flags)
Converts a a Java flags word into a BSON options pattern |
void |
flush()
|
protected void |
flushBuffer()
Tries to flush the output buffer if streaming is enabled. |
protected int |
getAndIncCurrentArrayPos()
Retrieves and then increases the current position in the array currently being generated |
protected boolean |
isArray()
|
protected boolean |
isEnabled(BsonGenerator.Feature f)
Checks if a generator feature is enabled |
protected void |
putHeader(int pos)
Writes the BSON document header to the output buffer at the given position. |
protected void |
reserveHeader()
Reserves bytes for the BSON document header |
void |
writeBinary(org.codehaus.jackson.Base64Variant b64variant,
byte[] data,
int offset,
int len)
|
void |
writeBinary(org.codehaus.jackson.Base64Variant b64variant,
byte subType,
byte[] data,
int offset,
int len)
Similar to writeBinary(Base64Variant, byte, byte[], int, int),
but with the possibility to specify a binary subtype (see
BsonConstants). |
void |
writeBoolean(boolean state)
|
void |
writeDateTime(java.util.Date date)
Write a BSON date time |
void |
writeEndArray()
|
void |
writeEndObject()
|
void |
writeFieldName(java.lang.String name)
|
void |
writeJavaScript(JavaScript javaScript,
org.codehaus.jackson.map.SerializerProvider provider)
Write a BSON JavaScript object |
void |
writeNull()
|
void |
writeNumber(java.math.BigDecimal dec)
|
void |
writeNumber(java.math.BigInteger v)
|
void |
writeNumber(double d)
|
void |
writeNumber(float f)
|
void |
writeNumber(int v)
|
void |
writeNumber(long v)
|
void |
writeNumber(java.lang.String encodedValue)
|
void |
writeObjectId(ObjectId objectId)
Write a BSON ObjectId |
void |
writeRaw(char c)
|
void |
writeRaw(char[] text,
int offset,
int len)
|
void |
writeRaw(java.lang.String text)
|
void |
writeRaw(java.lang.String text,
int offset,
int len)
|
void |
writeRawUTF8String(byte[] text,
int offset,
int length)
|
void |
writeRegex(java.util.regex.Pattern pattern)
Write a BSON regex |
void |
writeStartArray()
|
void |
writeStartObject()
|
void |
writeString(char[] text,
int offset,
int len)
|
void |
writeString(java.lang.String text)
|
void |
writeSymbol(Symbol symbol)
Write a BSON Symbol object |
void |
writeTimestamp(Timestamp timestamp)
Write a MongoDB timestamp |
void |
writeUTF8String(byte[] text,
int offset,
int length)
|
| Methods inherited from class org.codehaus.jackson.impl.JsonGeneratorBase |
|---|
_cantHappen, _reportError, _reportUnsupportedOperation, _throwInternal, _writeEndArray, _writeEndObject, _writeSimpleObject, _writeStartArray, _writeStartObject, copyCurrentEvent, copyCurrentStructure, disable, enable, getCodec, getOutputContext, isClosed, isEnabled, setCodec, useDefaultPrettyPrinter, version, writeObject, writeRawValue, writeRawValue, writeRawValue, writeTree |
| Methods inherited from class org.codehaus.jackson.JsonGenerator |
|---|
configure, disableFeature, enableFeature, isFeatureEnabled, setFeature, setPrettyPrinter, writeArrayFieldStart, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeFieldName, writeFieldName, writeNullField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeString, writeStringField |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final int _bsonFeatures
BsonGenerator.Features are enabled.
protected final java.io.OutputStream _out
protected final DynamicOutputBuffer _buffer
protected int _typeMarker
protected java.util.Deque<de.undercouch.bson4jackson.BsonGenerator.DocumentInfo> _documents
protected boolean nextObjectIsEmbeddedInValue
| Constructor Detail |
|---|
public BsonGenerator(int jsonFeatures,
int bsonFeatures,
java.io.OutputStream out)
jsonFeatures - bit flag composed of bits that indicate which
JsonGenerator.Features are enabled.bsonFeatures - bit flag composed of bits that indicate which
BsonGenerator.Features are enabled.out - the output stream to write to| Method Detail |
|---|
protected boolean isEnabled(BsonGenerator.Feature f)
f - the feature
protected boolean isArray()
protected int getAndIncCurrentArrayPos()
protected void reserveHeader()
protected void putHeader(int pos)
pos - the position where to write the header
public void flush()
throws java.io.IOException
flush in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOExceptionprotected void _releaseBuffers()
_releaseBuffers in class org.codehaus.jackson.impl.JsonGeneratorBase
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOException
public void writeStartArray()
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeStartArray in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeEndArray()
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeEndArray in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeStartObject()
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeStartObject in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOException
org.codehaus.jackson.JsonGenerationException
protected void _writeStartObject(boolean array)
throws java.io.IOException
array - true if the embedded object is an array
java.io.IOException - if the document could not be created
public void writeEndObject()
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeEndObject in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOException
org.codehaus.jackson.JsonGenerationException
protected void _writeArrayFieldNameIfNeeded()
throws java.io.IOException
java.io.IOException - if the field name could not be written
public void writeFieldName(java.lang.String name)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeFieldName in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
protected void _verifyValueWrite(java.lang.String typeMsg)
throws java.io.IOException
_verifyValueWrite in class org.codehaus.jackson.impl.JsonGeneratorBasejava.io.IOException
protected void flushBuffer()
throws java.io.IOException
java.io.IOException - if flushing failed
public void writeString(java.lang.String text)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeString in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeString(char[] text,
int offset,
int len)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeString in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeRaw(java.lang.String text)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeRaw in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeRaw(java.lang.String text,
int offset,
int len)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeRaw in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeRaw(char[] text,
int offset,
int len)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeRaw in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeRaw(char c)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeRaw in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeBinary(org.codehaus.jackson.Base64Variant b64variant,
byte[] data,
int offset,
int len)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeBinary in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeBinary(org.codehaus.jackson.Base64Variant b64variant,
byte subType,
byte[] data,
int offset,
int len)
throws java.io.IOException
writeBinary(Base64Variant, byte, byte[], int, int),
but with the possibility to specify a binary subtype (see
BsonConstants).
b64variant - base64 variant to use (will be ignored for BSON)subType - the binary subtypedata - the binary data to writeoffset - the offset of the first byte to writelen - the number of bytes to write
java.io.IOException - if the binary data could not be written
public void writeNumber(int v)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNumber(long v)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNumber(java.math.BigInteger v)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNumber(double d)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNumber(float f)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNumber(java.math.BigDecimal dec)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNumber(java.lang.String encodedValue)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException,
java.lang.UnsupportedOperationException
writeNumber in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
java.lang.UnsupportedOperationException
public void writeBoolean(boolean state)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeBoolean in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeNull()
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeNull in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeRawUTF8String(byte[] text,
int offset,
int length)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeRawUTF8String in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeUTF8String(byte[] text,
int offset,
int length)
throws java.io.IOException,
org.codehaus.jackson.JsonGenerationException
writeUTF8String in class org.codehaus.jackson.JsonGeneratorjava.io.IOException
org.codehaus.jackson.JsonGenerationException
public void writeDateTime(java.util.Date date)
throws java.io.IOException
date - The date to write
java.io.IOException - If an error occurred in the stream while writing
public void writeObjectId(ObjectId objectId)
throws java.io.IOException
objectId - The objectId to write
java.io.IOException - If an error occurred in the stream while writingprotected java.lang.String flagsToRegexOptions(int flags)
flags - the Java flags
public void writeRegex(java.util.regex.Pattern pattern)
throws java.io.IOException
pattern - The regex to write
java.io.IOException - If an error occurred in the stream while writing
public void writeTimestamp(Timestamp timestamp)
throws java.io.IOException
timestamp - The timestamp to write
java.io.IOException - If an error occurred in the stream while writing
public void writeJavaScript(JavaScript javaScript,
org.codehaus.jackson.map.SerializerProvider provider)
throws java.io.IOException
javaScript - The javaScript to writeprovider - The serializer provider, for serializing the scope
java.io.IOException - If an error occurred in the stream while writing
public void writeSymbol(Symbol symbol)
throws java.io.IOException
symbol - The symbol to write
java.io.IOException - If an error occurred in the stream while writingprotected int _writeString(java.lang.String string)
string - The string to write
protected int _writeCString(java.lang.String string)
string - The string to write
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||