Package org.bson
Class AbstractBsonReader
- java.lang.Object
-
- org.bson.AbstractBsonReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BsonReader
- Direct Known Subclasses:
BsonBinaryReader,BsonDocumentReader,JsonReader
public abstract class AbstractBsonReader extends java.lang.Object implements BsonReader
Abstract base class for BsonReader implementations.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractBsonReader.StateThe state of a reader.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the reader.BsonTypegetCurrentBsonType()java.lang.StringgetCurrentName()Gets the most recently read name.AbstractBsonReader.StategetState()intpeekBinarySize()Peeks the size of the binary data that the reader is positioned at.bytepeekBinarySubType()Peeks the subtype of the binary data that the reader is positioned at.BsonBinaryreadBinaryData()Reads BSON Binary data from the reader.BsonBinaryreadBinaryData(java.lang.String name)Reads a BSON Binary data element from the reader.booleanreadBoolean()Reads a BSON Boolean from the reader.booleanreadBoolean(java.lang.String name)Reads a BSON Boolean element from the reader.abstract BsonTypereadBsonType()Reads a BSONType from the reader.longreadDateTime()Reads a BSON DateTime from the reader.longreadDateTime(java.lang.String name)Reads a BSON DateTime element from the reader.BsonDbPointerreadDBPointer()Reads a BSON DBPointer from the reader.BsonDbPointerreadDBPointer(java.lang.String name)Reads a BSON DBPointer element from the reader.Decimal128readDecimal128()Reads a BSON Decimal128 from the reader.Decimal128readDecimal128(java.lang.String name)Reads a BSON Decimal128 element from the reader.doublereadDouble()Reads a BSON Double from the reader.doublereadDouble(java.lang.String name)Reads a BSON Double element from the reader.voidreadEndArray()Reads the end of a BSON array from the reader.voidreadEndDocument()Reads the end of a BSON document from the reader.intreadInt32()Reads a BSON Int32 from the reader.intreadInt32(java.lang.String name)Reads a BSON Int32 element from the reader.longreadInt64()Reads a BSON Int64 from the reader.longreadInt64(java.lang.String name)Reads a BSON Int64 element from the reader.java.lang.StringreadJavaScript()Reads a BSON JavaScript from the reader.java.lang.StringreadJavaScript(java.lang.String name)Reads a BSON JavaScript element from the reader.java.lang.StringreadJavaScriptWithScope()Reads a BSON JavaScript with scope from the reader (call readStartDocument next to read the scope).java.lang.StringreadJavaScriptWithScope(java.lang.String name)Reads a BSON JavaScript with scope element from the reader (call readStartDocument next to read the scope).voidreadMaxKey()Reads a BSON MaxKey from the reader.voidreadMaxKey(java.lang.String name)Reads a BSON MaxKey element from the reader.voidreadMinKey()Reads a BSON MinKey from the reader.voidreadMinKey(java.lang.String name)Reads a BSON MinKey element from the reader.java.lang.StringreadName()Reads the name of an element from the reader.voidreadName(java.lang.String name)Reads the name of an element from the reader.voidreadNull()Reads a BSON null from the reader.voidreadNull(java.lang.String name)Reads a BSON null element from the reader.ObjectIdreadObjectId()Reads a BSON ObjectId from the reader.ObjectIdreadObjectId(java.lang.String name)Reads a BSON ObjectId element from the reader.BsonRegularExpressionreadRegularExpression()Reads a BSON regular expression from the reader.BsonRegularExpressionreadRegularExpression(java.lang.String name)Reads a BSON regular expression element from the reader.voidreadStartArray()Reads the start of a BSON array.voidreadStartDocument()Reads the start of a BSON document.java.lang.StringreadString()Reads a BSON String from the reader.java.lang.StringreadString(java.lang.String name)Reads a BSON string element from the reader.java.lang.StringreadSymbol()Reads a BSON symbol from the reader.java.lang.StringreadSymbol(java.lang.String name)Reads a BSON symbol element from the reader.BsonTimestampreadTimestamp()Reads a BSON timestamp from the reader.BsonTimestampreadTimestamp(java.lang.String name)Reads a BSON timestamp element from the reader.voidreadUndefined()Reads a BSON undefined from the reader.voidreadUndefined(java.lang.String name)Reads a BSON undefined element from the reader.voidskipName()Skips the name (reader must be positioned on a name).voidskipValue()Skips the value (reader must be positioned on a value).-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bson.BsonReader
getMark, mark, reset
-
-
-
-
Method Detail
-
getCurrentBsonType
public BsonType getCurrentBsonType()
- Specified by:
getCurrentBsonTypein interfaceBsonReader- Returns:
- The current BsonType.
-
getCurrentName
public java.lang.String getCurrentName()
Description copied from interface:BsonReaderGets the most recently read name.- Specified by:
getCurrentNamein interfaceBsonReader- Returns:
- the most recently read name
-
getState
public AbstractBsonReader.State getState()
- Returns:
- The current state of the reader.
-
close
public void close()
Closes the reader.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceBsonReader- Specified by:
closein interfacejava.io.Closeable
-
readBinaryData
public BsonBinary readBinaryData()
Description copied from interface:BsonReaderReads BSON Binary data from the reader.- Specified by:
readBinaryDatain interfaceBsonReader- Returns:
- A Binary.
-
peekBinarySubType
public byte peekBinarySubType()
Description copied from interface:BsonReaderPeeks the subtype of the binary data that the reader is positioned at. This operation is not permitted if the mark is already set.- Specified by:
peekBinarySubTypein interfaceBsonReader- Returns:
- the subtype
- See Also:
BsonReader.mark()
-
peekBinarySize
public int peekBinarySize()
Description copied from interface:BsonReaderPeeks the size of the binary data that the reader is positioned at. This operation is not permitted if the mark is already set.- Specified by:
peekBinarySizein interfaceBsonReader- Returns:
- the size of the binary data
- See Also:
BsonReader.mark()
-
readBoolean
public boolean readBoolean()
Description copied from interface:BsonReaderReads a BSON Boolean from the reader.- Specified by:
readBooleanin interfaceBsonReader- Returns:
- A Boolean.
-
readBsonType
public abstract BsonType readBsonType()
Description copied from interface:BsonReaderReads a BSONType from the reader.- Specified by:
readBsonTypein interfaceBsonReader- Returns:
- A BSONType.
-
readDateTime
public long readDateTime()
Description copied from interface:BsonReaderReads a BSON DateTime from the reader.- Specified by:
readDateTimein interfaceBsonReader- Returns:
- The number of milliseconds since the Unix epoch.
-
readDouble
public double readDouble()
Description copied from interface:BsonReaderReads a BSON Double from the reader.- Specified by:
readDoublein interfaceBsonReader- Returns:
- A Double.
-
readEndArray
public void readEndArray()
Description copied from interface:BsonReaderReads the end of a BSON array from the reader.- Specified by:
readEndArrayin interfaceBsonReader
-
readEndDocument
public void readEndDocument()
Description copied from interface:BsonReaderReads the end of a BSON document from the reader.- Specified by:
readEndDocumentin interfaceBsonReader
-
readInt32
public int readInt32()
Description copied from interface:BsonReaderReads a BSON Int32 from the reader.- Specified by:
readInt32in interfaceBsonReader- Returns:
- An Int32.
-
readInt64
public long readInt64()
Description copied from interface:BsonReaderReads a BSON Int64 from the reader.- Specified by:
readInt64in interfaceBsonReader- Returns:
- An Int64.
-
readDecimal128
public Decimal128 readDecimal128()
Description copied from interface:BsonReaderReads a BSON Decimal128 from the reader.- Specified by:
readDecimal128in interfaceBsonReader- Returns:
- A Decimal128
-
readJavaScript
public java.lang.String readJavaScript()
Description copied from interface:BsonReaderReads a BSON JavaScript from the reader.- Specified by:
readJavaScriptin interfaceBsonReader- Returns:
- A string.
-
readJavaScriptWithScope
public java.lang.String readJavaScriptWithScope()
Description copied from interface:BsonReaderReads a BSON JavaScript with scope from the reader (call readStartDocument next to read the scope).- Specified by:
readJavaScriptWithScopein interfaceBsonReader- Returns:
- A string.
-
readMaxKey
public void readMaxKey()
Description copied from interface:BsonReaderReads a BSON MaxKey from the reader.- Specified by:
readMaxKeyin interfaceBsonReader
-
readMinKey
public void readMinKey()
Description copied from interface:BsonReaderReads a BSON MinKey from the reader.- Specified by:
readMinKeyin interfaceBsonReader
-
readNull
public void readNull()
Description copied from interface:BsonReaderReads a BSON null from the reader.- Specified by:
readNullin interfaceBsonReader
-
readObjectId
public ObjectId readObjectId()
Description copied from interface:BsonReaderReads a BSON ObjectId from the reader.- Specified by:
readObjectIdin interfaceBsonReader- Returns:
- the
ObjectIdvalue
-
readRegularExpression
public BsonRegularExpression readRegularExpression()
Description copied from interface:BsonReaderReads a BSON regular expression from the reader.- Specified by:
readRegularExpressionin interfaceBsonReader- Returns:
- A regular expression.
-
readDBPointer
public BsonDbPointer readDBPointer()
Description copied from interface:BsonReaderReads a BSON DBPointer from the reader.- Specified by:
readDBPointerin interfaceBsonReader- Returns:
- A DBPointer.
-
readStartArray
public void readStartArray()
Description copied from interface:BsonReaderReads the start of a BSON array.- Specified by:
readStartArrayin interfaceBsonReader
-
readStartDocument
public void readStartDocument()
Description copied from interface:BsonReaderReads the start of a BSON document.- Specified by:
readStartDocumentin interfaceBsonReader
-
readString
public java.lang.String readString()
Description copied from interface:BsonReaderReads a BSON String from the reader.- Specified by:
readStringin interfaceBsonReader- Returns:
- A String.
-
readSymbol
public java.lang.String readSymbol()
Description copied from interface:BsonReaderReads a BSON symbol from the reader.- Specified by:
readSymbolin interfaceBsonReader- Returns:
- A string.
-
readTimestamp
public BsonTimestamp readTimestamp()
Description copied from interface:BsonReaderReads a BSON timestamp from the reader.- Specified by:
readTimestampin interfaceBsonReader- Returns:
- The combined timestamp/increment.
-
readUndefined
public void readUndefined()
Description copied from interface:BsonReaderReads a BSON undefined from the reader.- Specified by:
readUndefinedin interfaceBsonReader
-
skipName
public void skipName()
Description copied from interface:BsonReaderSkips the name (reader must be positioned on a name).- Specified by:
skipNamein interfaceBsonReader
-
skipValue
public void skipValue()
Description copied from interface:BsonReaderSkips the value (reader must be positioned on a value).- Specified by:
skipValuein interfaceBsonReader
-
readBinaryData
public BsonBinary readBinaryData(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON Binary data element from the reader.- Specified by:
readBinaryDatain interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A Binary.
-
readBoolean
public boolean readBoolean(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON Boolean element from the reader.- Specified by:
readBooleanin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A Boolean.
-
readDateTime
public long readDateTime(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON DateTime element from the reader.- Specified by:
readDateTimein interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- The number of milliseconds since the Unix epoch.
-
readDouble
public double readDouble(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON Double element from the reader.- Specified by:
readDoublein interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A Double.
-
readInt32
public int readInt32(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON Int32 element from the reader.- Specified by:
readInt32in interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- An Int32.
-
readInt64
public long readInt64(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON Int64 element from the reader.- Specified by:
readInt64in interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- An Int64.
-
readDecimal128
public Decimal128 readDecimal128(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON Decimal128 element from the reader.- Specified by:
readDecimal128in interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A Decimal128
-
readJavaScript
public java.lang.String readJavaScript(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON JavaScript element from the reader.- Specified by:
readJavaScriptin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A string.
-
readJavaScriptWithScope
public java.lang.String readJavaScriptWithScope(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON JavaScript with scope element from the reader (call readStartDocument next to read the scope).- Specified by:
readJavaScriptWithScopein interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A string.
-
readMaxKey
public void readMaxKey(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON MaxKey element from the reader.- Specified by:
readMaxKeyin interfaceBsonReader- Parameters:
name- The name of the element.
-
readMinKey
public void readMinKey(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON MinKey element from the reader.- Specified by:
readMinKeyin interfaceBsonReader- Parameters:
name- The name of the element.
-
readName
public java.lang.String readName()
Description copied from interface:BsonReaderReads the name of an element from the reader.- Specified by:
readNamein interfaceBsonReader- Returns:
- The name of the element.
-
readName
public void readName(java.lang.String name)
Description copied from interface:BsonReaderReads the name of an element from the reader.- Specified by:
readNamein interfaceBsonReader- Parameters:
name- The name of the element.
-
readNull
public void readNull(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON null element from the reader.- Specified by:
readNullin interfaceBsonReader- Parameters:
name- The name of the element.
-
readObjectId
public ObjectId readObjectId(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON ObjectId element from the reader.- Specified by:
readObjectIdin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- ObjectId.
-
readRegularExpression
public BsonRegularExpression readRegularExpression(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON regular expression element from the reader.- Specified by:
readRegularExpressionin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A regular expression.
-
readDBPointer
public BsonDbPointer readDBPointer(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON DBPointer element from the reader.- Specified by:
readDBPointerin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A DBPointer.
-
readString
public java.lang.String readString(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON string element from the reader.- Specified by:
readStringin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A String.
-
readSymbol
public java.lang.String readSymbol(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON symbol element from the reader.- Specified by:
readSymbolin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- A string.
-
readTimestamp
public BsonTimestamp readTimestamp(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON timestamp element from the reader.- Specified by:
readTimestampin interfaceBsonReader- Parameters:
name- The name of the element.- Returns:
- The combined timestamp/increment.
-
readUndefined
public void readUndefined(java.lang.String name)
Description copied from interface:BsonReaderReads a BSON undefined element from the reader.- Specified by:
readUndefinedin interfaceBsonReader- Parameters:
name- The name of the element.
-
-