public class IfxBSONObject
extends java.lang.Object
implements java.sql.SQLData, java.util.Map<java.lang.String,java.lang.Object>, org.bson.BSONObject
SQLData interface necessary
to read and write BSON data with the Informix JDBC driver and the supporting
API's for users to create/read/manipulate BSON documents
This class is a split between the Raw BSON document (data stays as a byte array)
and an editble document (data is| Modifier and Type | Field and Description |
|---|---|
protected org.bson.Document |
bsonObject
The decoded BSON object.
|
protected org.bson.RawBsonDocument |
rawDocument |
static org.bson.codecs.configuration.CodecRegistry |
REGISTRY |
| Constructor and Description |
|---|
IfxBSONObject()
A no-arg constructor is required for SQLData to work.
|
IfxBSONObject(byte[] bytes)
Constructs a new object from the specified BSON-encoded byte array.
|
IfxBSONObject(byte[] bytes,
boolean copyBytes)
Constructs a new object from the specified BSON-encoded byte array.
|
IfxBSONObject(byte[] bytes,
boolean copyBytes,
org.bson.json.JsonMode jsonFormat)
Constructs a new object from the specified BSON-encoded byte array.
|
IfxBSONObject(byte[] bytes,
org.bson.json.JsonMode jsonFormat)
Constructs a new object from the specified BSON-encoded byte array.
|
IfxBSONObject(org.bson.Document bsonObject)
Constructs a new object from the specified
BSONObject. |
IfxBSONObject(org.bson.RawBsonDocument document) |
IfxBSONObject(java.lang.String key,
java.lang.Object value)
Constructs a new object with an initial key/value pair
|
| Modifier and Type | Method and Description |
|---|---|
IfxBSONObject |
append(java.lang.String key,
java.lang.Object value)
Append the key/value pair to this document
Similar to {
put(String, Object) but this method returns the class reference
to make multiple appends easier to write |
void |
clear() |
boolean |
containsField(java.lang.String s) |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsKey(java.lang.String s) |
boolean |
containsValue(java.lang.Object value) |
protected void |
ensureBsonObject() |
static IfxBSONObject |
ensureIfxBSONObject(java.lang.Object o)
Ensures that the specified object is an
IfxBSONObject. |
void |
ensureRawDocument() |
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> |
entrySet() |
boolean |
equals(java.lang.Object o) |
java.lang.Object |
get(java.lang.Object key) |
java.lang.Object |
get(java.lang.String key) |
boolean |
getBoolean(java.lang.String key)
Returns the boolean value of the key in the document
|
byte[] |
getBytes() |
org.bson.Document |
getDocument()
Return the Map version of the Bson document
This version takes more memory but is completely manipulatable as you would a Map
This returns a reference to the document object contained in this object.
|
IfxBSONObject |
getDocument(java.lang.String key)
Returns a subdocument from this document
|
double |
getDouble(java.lang.String key)
Returns the double value of the key in the document
|
java.lang.String |
getFirstKey()
Return the first key from the document
|
int |
getInt(java.lang.String key)
Returns the int value of the key in the document
|
org.bson.json.JsonMode |
getJsonFormat() |
long |
getLong(java.lang.String key)
Returns the long value of the key in the document
|
org.bson.RawBsonDocument |
getRawDocument()
Return the reference to the raw document
If you get this object, this is a reference only, if you decided to modify this object later or the raw document
take care as they can become out of sync.
|
java.lang.String |
getSQLTypeName() |
java.lang.String |
getString(java.lang.String key)
Returns the string value of the key in the document
|
int |
hashCode() |
boolean |
isEmpty() |
boolean |
isRawDocument()
Returns whether we are currently a raw document or a fully exploded java map
|
java.util.Set<java.lang.String> |
keySet() |
static IfxBSONObject |
parse(java.lang.String json) |
java.lang.Object |
put(java.lang.String key,
java.lang.Object v) |
void |
putAll(org.bson.BSONObject o) |
void |
putAll(java.util.Map m) |
void |
readSQL(java.sql.SQLInput stream,
java.lang.String typeName) |
java.lang.Object |
remove(java.lang.Object key) |
java.lang.Object |
removeField(java.lang.String key) |
void |
setBSONObject(org.bson.BSONObject bsonObject) |
void |
setBytes(byte[] bytes)
Assigns the BSON-encoded byte array representation of a document.
|
void |
setDocument(org.bson.Document bsonObject)
Assigns the BSONObject this object represents.
|
IfxBSONObject |
setJsonFormat(org.bson.json.JsonMode mode) |
void |
setRawDocument(org.bson.RawBsonDocument doc) |
int |
size() |
java.lang.String |
toJson()
Returns a compact form of JSON
Does not have a pretty-print or any extraneous whitespace
|
java.util.Map<java.lang.String,java.lang.Object> |
toMap() |
java.lang.String |
toString() |
java.util.Collection<java.lang.Object> |
values() |
void |
writeSQL(java.sql.SQLOutput stream) |
public static final org.bson.codecs.configuration.CodecRegistry REGISTRY
protected org.bson.RawBsonDocument rawDocument
protected org.bson.Document bsonObject
public IfxBSONObject()
public IfxBSONObject(java.lang.String key,
java.lang.Object value)
key - String keyvalue - Object valuepublic IfxBSONObject(byte[] bytes)
bytes - the BSON-encoded documentpublic IfxBSONObject(org.bson.RawBsonDocument document)
public IfxBSONObject(byte[] bytes,
boolean copyBytes)
bytes - the BSON-encoded documentcopyBytes - if true the byte array is copiedpublic IfxBSONObject(byte[] bytes,
boolean copyBytes,
org.bson.json.JsonMode jsonFormat)
bytes - the BSON-encoded documentcopyBytes - if true the byte array is copiedjsonFormat - the JsonMode used to serialize the BSON objectpublic IfxBSONObject(byte[] bytes,
org.bson.json.JsonMode jsonFormat)
bytes - the BSON-encoded documentjsonFormat - the JsonMode used to serialize the BSON objectpublic IfxBSONObject(org.bson.Document bsonObject)
BSONObject. It is
generally preferable to use the method
ensureIfxBSONObject(Object) as it inspects the
object to see if it is already of type IfxBSONObject.bsonObject - public static IfxBSONObject parse(java.lang.String json)
public java.lang.String getSQLTypeName()
throws java.sql.SQLException
getSQLTypeName in interface java.sql.SQLDatajava.sql.SQLExceptionpublic void readSQL(java.sql.SQLInput stream,
java.lang.String typeName)
throws java.sql.SQLException
readSQL in interface java.sql.SQLDatajava.sql.SQLExceptionpublic void writeSQL(java.sql.SQLOutput stream)
throws java.sql.SQLException
writeSQL in interface java.sql.SQLDatajava.sql.SQLExceptionpublic void ensureRawDocument()
protected void ensureBsonObject()
public byte[] getBytes()
public void setBytes(byte[] bytes)
null.bytes - the BSON-encoded byte array representation of a documentpublic void setRawDocument(org.bson.RawBsonDocument doc)
public void setDocument(org.bson.Document bsonObject)
null.bsonObject - the documentjava.lang.NullPointerException - if the bsonObject is nullpublic void setBSONObject(org.bson.BSONObject bsonObject)
public static IfxBSONObject ensureIfxBSONObject(java.lang.Object o)
IfxBSONObject. If the
object is already of type IfxBSONObject, the object is simply
cast and returned. If the object implements the BSONObject
interface, the appropriate constructor is called and the new object is
returned.o - java.lang.NullPointerException - if the specified object is nulljava.lang.IllegalArgumentException - if the object is not of type IfxBSONObject and does
not implement the interface BSONObjectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toJson()
public java.lang.Object put(java.lang.String key,
java.lang.Object v)
put in interface java.util.Map<java.lang.String,java.lang.Object>put in interface org.bson.BSONObjectpublic java.util.Map<java.lang.String,java.lang.Object> toMap()
toMap in interface org.bson.BSONObjectpublic boolean containsKey(java.lang.String s)
containsKey in interface org.bson.BSONObjectpublic boolean containsField(java.lang.String s)
containsField in interface org.bson.BSONObjectpublic java.util.Set<java.lang.String> keySet()
keySet in interface java.util.Map<java.lang.String,java.lang.Object>keySet in interface org.bson.BSONObjectpublic int hashCode()
hashCode in interface java.util.Map<java.lang.String,java.lang.Object>hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in interface java.util.Map<java.lang.String,java.lang.Object>equals in class java.lang.Objectpublic int size()
size in interface java.util.Map<java.lang.String,java.lang.Object>public boolean isEmpty()
isEmpty in interface java.util.Map<java.lang.String,java.lang.Object>public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<java.lang.String,java.lang.Object>public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<java.lang.String,java.lang.Object>public java.lang.Object get(java.lang.Object key)
get in interface java.util.Map<java.lang.String,java.lang.Object>public java.lang.Object get(java.lang.String key)
get in interface org.bson.BSONObjectpublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Map<java.lang.String,java.lang.Object>public java.util.Collection<java.lang.Object> values()
values in interface java.util.Map<java.lang.String,java.lang.Object>public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
entrySet in interface java.util.Map<java.lang.String,java.lang.Object>public void putAll(java.util.Map m)
putAll in interface java.util.Map<java.lang.String,java.lang.Object>putAll in interface org.bson.BSONObjectpublic org.bson.Document getDocument()
public IfxBSONObject getDocument(java.lang.String key)
key - field to search forpublic org.bson.RawBsonDocument getRawDocument()
public IfxBSONObject append(java.lang.String key, java.lang.Object value)
put(String, Object) but this method returns the class reference
to make multiple appends easier to writekey - Key to setvalue - Object to setpublic int getInt(java.lang.String key)
key - Key to lookuppublic long getLong(java.lang.String key)
key - Key to lookuppublic double getDouble(java.lang.String key)
key - Key to lookuppublic java.lang.String getString(java.lang.String key)
key - Key to lookuppublic boolean getBoolean(java.lang.String key)
key - Key to lookuppublic boolean isRawDocument()
true if we are are a raw documentpublic java.lang.String getFirstKey()
public void putAll(org.bson.BSONObject o)
putAll in interface org.bson.BSONObjectpublic java.lang.Object removeField(java.lang.String key)
removeField in interface org.bson.BSONObjectpublic void clear()
clear in interface java.util.Map<java.lang.String,java.lang.Object>public IfxBSONObject setJsonFormat(org.bson.json.JsonMode mode)
public org.bson.json.JsonMode getJsonFormat()