public class IfxBSONObject
extends IfxUDT
implements java.sql.SQLData, java.util.Map<java.lang.String,java.lang.Object>
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 Document |
bsonObject
The decoded BSON object.
|
protected RawBsonDocument |
rawDocument |
| 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(Document bsonObject)
Constructs a new object from the specified
BSONObject. |
IfxBSONObject(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 |
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. |
protected 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() |
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
|
long |
getLong(java.lang.String key)
Returns the long value of the key in the document
|
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() |
java.lang.Object |
put(java.lang.String key,
java.lang.Object v) |
void |
putAll(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(Document bsonObject)
Assigns the BSONObject this object represents.
|
void |
setRawDocument(RawBsonDocument doc) |
int |
size() |
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) |
protected RawBsonDocument rawDocument
protected 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(RawBsonDocument document)
public IfxBSONObject(byte[] bytes,
boolean copyBytes)
bytes - the BSON-encoded documentcopyBytes - if true the byte array is copiedpublic IfxBSONObject(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 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.SQLExceptionprotected 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(RawBsonDocument doc)
public void setDocument(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()
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>public java.util.Map<java.lang.String,java.lang.Object> toMap()
public boolean containsKey(java.lang.String s)
public boolean containsField(java.lang.String s)
public java.util.Set<java.lang.String> keySet()
keySet in interface java.util.Map<java.lang.String,java.lang.Object>public int hashCode()
hashCode in interface java.util.Map<java.lang.String,java.lang.Object>public boolean equals(java.lang.Object o)
equals in interface java.util.Map<java.lang.String,java.lang.Object>public 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)
public 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>public Document getDocument()
public IfxBSONObject getDocument(java.lang.String key)
key - field to search forpublic 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(BSONObject o)
putAll in interface java.util.Map<java.lang.String,java.lang.Object>public java.lang.Object removeField(java.lang.String key)