public class DynamicRealmObject extends RealmObject
Constructor and Description |
---|
DynamicRealmObject(RealmObject obj)
Creates a dynamic Realm object based on a existing object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
byte[] |
getBlob(java.lang.String fieldName)
Returns the
byte[] value for a given field. |
boolean |
getBoolean(java.lang.String fieldName)
Returns the
boolean value for a given field. |
byte |
getByte(java.lang.String fieldName)
Returns the
byte value for a given field. |
java.util.Date |
getDate(java.lang.String fieldName)
Returns the
Date value for a given field. |
double |
getDouble(java.lang.String fieldName)
Returns the
double value for a given field. |
java.lang.String[] |
getFieldNames()
Returns the list of field names on this object.
|
float |
getFloat(java.lang.String fieldName)
Returns the
float value for a given field. |
int |
getInt(java.lang.String fieldName)
Returns the
int value for a given field. |
DynamicRealmList |
getList(java.lang.String fieldName)
Returns the
RealmList of objects being linked to from this field. |
long |
getLong(java.lang.String fieldName)
Returns the
long value for a given field. |
DynamicRealmObject |
getObject(java.lang.String fieldName)
Returns the object being linked to from this field.
|
short |
getShort(java.lang.String fieldName)
Returns the
short value for a given field. |
java.lang.String |
getString(java.lang.String fieldName)
Returns the
String value for a given field. |
java.lang.String |
getType()
Return the type of object.
|
boolean |
hasField(java.lang.String fieldName)
Checks whether an object has the given field or not.
|
int |
hashCode() |
boolean |
isNull(java.lang.String fieldName)
Checks if the value of a given field is
null . |
void |
removeFromRealm()
Deletes this object from the Realm.
|
void |
setBlob(java.lang.String fieldName,
byte[] value)
Sets the binary value of the given field.
|
void |
setBoolean(java.lang.String fieldName,
boolean value)
Sets the
boolean value of the given field. |
void |
setByte(java.lang.String fieldName,
byte value)
Sets the
byte value of the given field. |
void |
setDate(java.lang.String fieldName,
java.util.Date value)
Sets the
Date value of the given field. |
void |
setDouble(java.lang.String fieldName,
double value)
Sets the
double value of the given field. |
void |
setFloat(java.lang.String fieldName,
float value)
Sets the
float value of the given field. |
void |
setInt(java.lang.String fieldName,
int value)
Sets the
int value of the given field. |
void |
setList(java.lang.String fieldName,
DynamicRealmList list)
Sets the reference to a
DynamicRealmList on the given field. |
void |
setLong(java.lang.String fieldName,
long value)
Sets the
long value of the given field. |
void |
setObject(java.lang.String fieldName,
DynamicRealmObject value)
Sets a reference to another object on the given field.
|
void |
setShort(java.lang.String fieldName,
short value)
Sets the
short value of the given field. |
void |
setString(java.lang.String fieldName,
java.lang.String value)
Sets the
String value of the given field. |
java.lang.String |
toString() |
addChangeListener, isLoaded, isValid, load, removeChangeListener, removeChangeListeners
public DynamicRealmObject(RealmObject obj)
obj
- the Realm object to convert to a dynamic object. Only objects managed by Realm can be used.java.lang.IllegalArgumentException
- if object isn't managed by a Realm.public boolean getBoolean(java.lang.String fieldName)
boolean
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain booleans.public int getInt(java.lang.String fieldName)
int
value for a given field.fieldName
- the name of field.Integer.MAX_VALUE
will wrap.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.public short getShort(java.lang.String fieldName)
short
value for a given field.fieldName
- the name of field.Short.MAX_VALUE
will wrap.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.public long getLong(java.lang.String fieldName)
long
value for a given field.fieldName
- the name of field.Long.MAX_VALUE
will wrap.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.public byte getByte(java.lang.String fieldName)
byte
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain integers.public float getFloat(java.lang.String fieldName)
float
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain floats.public double getDouble(java.lang.String fieldName)
double
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain doubles.public byte[] getBlob(java.lang.String fieldName)
byte[]
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain binary data.public java.lang.String getString(java.lang.String fieldName)
String
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain Strings.public java.util.Date getDate(java.lang.String fieldName)
Date
value for a given field.fieldName
- the name of field.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain Dates.public DynamicRealmObject getObject(java.lang.String fieldName)
fieldName
- Name of field.DynamicRealmObject
representation of the linked object or null
if no object is
linked.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain links to other objects.public DynamicRealmList getList(java.lang.String fieldName)
RealmList
of objects being linked to from this field. This list is returned
as a DynamicRealmList
.fieldName
- the name of field.DynamicRealmList
representation of the RealmList.java.lang.IllegalArgumentException
- if field name doesn't exists or it doesn't contain a list of links.public boolean isNull(java.lang.String fieldName)
null
.fieldName
- the name of field.true
if field value is null, false
otherwise.java.lang.IllegalArgumentException
- if field name doesn't exists.public boolean hasField(java.lang.String fieldName)
fieldName
- the field name to check.true
if the object has a field with the given name, false
otherwise.public java.lang.String[] getFieldNames()
public void setBoolean(java.lang.String fieldName, boolean value)
boolean
value of the given field.fieldName
- the field name to update.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a boolean field.public void setShort(java.lang.String fieldName, short value)
short
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setInt(java.lang.String fieldName, int value)
int
value of the given field.fieldName
- the field name to update.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setLong(java.lang.String fieldName, long value)
long
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setByte(java.lang.String fieldName, byte value)
byte
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setFloat(java.lang.String fieldName, float value)
float
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't an integer field.public void setDouble(java.lang.String fieldName, double value)
double
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a double field.public void setString(java.lang.String fieldName, java.lang.String value)
String
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a String field.public void setBlob(java.lang.String fieldName, byte[] value)
fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a binary field.public void setDate(java.lang.String fieldName, java.util.Date value)
Date
value of the given field.fieldName
- the field name.value
- the value to insert.java.lang.IllegalArgumentException
- if field name doesn't exists or isn't a Date field.public void setObject(java.lang.String fieldName, DynamicRealmObject value)
fieldName
- the field name.value
- the object to link to.java.lang.IllegalArgumentException
- if field name doesn't exists, it doesn't link to other Realm objects, or the
type of DynamicRealmObject doesn't match.public void setList(java.lang.String fieldName, DynamicRealmList list)
DynamicRealmList
on the given field.fieldName
- the field name.list
- the list of references.java.lang.IllegalArgumentException
- if field name doesn't exists, it doesn't contain a list of links or the type of
the object represented by the DynamicRealmObject doesn't match.public void removeFromRealm()
IllegalStateException
.removeFromRealm
in class RealmObject
public java.lang.String getType()
RealmObject
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object