Package com.avsystem.anjay
Class AnjayServerObject
- java.lang.Object
-
- com.avsystem.anjay.AnjayServerObject
-
public final class AnjayServerObject extends java.lang.ObjectDefault implementation of LwM2M Server Object (/1).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnjayServerObject.InstanceInstance of LwM2M Server Object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddInstance(AnjayServerObject.Instance instance)Adds new Instance of Server Object and returns newly created Instance ID.intaddInstance(AnjayServerObject.Instance instance, int preferredIid)Overload ofaddInstance(Instance), but allows to specify preferred Instance ID.static AnjayServerObjectinstall(Anjay anjay)Installs the Server Object in an Anjay instance.booleanisModified()voidpersist(java.io.OutputStream outputStream)Dumps Server Object Instances into theoutputStream.voidpurge()Removes all instances of Server Object leaving it in an empty state.voidrestore(java.io.InputStream inputStream)Attempts to restore Server Object Instances from specifiedinputStream.
-
-
-
Method Detail
-
install
public static AnjayServerObject install(Anjay anjay) throws java.lang.Exception
Installs the Server Object in an Anjay instance.- Parameters:
anjay- Anjay instance for which the Server Object is installed.- Returns:
- Server object which may be used to manage its instances.
- Throws:
java.lang.Exception- In case of error.
-
addInstance
public int addInstance(AnjayServerObject.Instance instance) throws java.lang.Exception
Adds new Instance of Server Object and returns newly created Instance ID.- Parameters:
instance- Server Instance to insert.- Returns:
- ID of the added instance.
- Throws:
java.lang.Exception- If instance can't be added.
-
addInstance
public int addInstance(AnjayServerObject.Instance instance, int preferredIid) throws java.lang.Exception
Overload ofaddInstance(Instance), but allows to specify preferred Instance ID.Note: if
preferredIidis set toAnjay.ID_INVALIDthen the Instance ID is generated automatically.- Parameters:
instance- Server Instance to insert.preferredIid- Preferred Instance ID to be set.- Returns:
- ID of the added instance.
- Throws:
java.lang.Exception- If instance can't be added.
-
purge
public void purge()
Removes all instances of Server Object leaving it in an empty state.
-
persist
public void persist(java.io.OutputStream outputStream) throws java.lang.ExceptionDumps Server Object Instances into theoutputStream.- Parameters:
outputStream- Stream to write to.- Throws:
java.lang.Exception- If instances can't be persisted.
-
restore
public void restore(java.io.InputStream inputStream) throws java.lang.ExceptionAttempts to restore Server Object Instances from specifiedinputStream.Note: if restore fails, then Server Object will be left untouched, on success though all Instances stored within the Object will be purged.
- Parameters:
inputStream- Stream to read from.- Throws:
java.lang.Exception- If instances can't be restored.
-
-