saveObject

saveObject ( string name , object _objectValue , int|default:1 _saveAllXiterations , string _pathFile ) : boolean

Save an object. It will be reloaded in the next analysis with loadOrCreateObject. It is useful for long analysis where it can have an interruption.
Returns true if the object is saved.
It is recommanded to synchronize the object if you use multithreads.
Object to save must be serializable and contains just serializable objets. If you create your own class, use the structure "class MyClass implements Serializable { ... }"

Example


profilesToCheck=loadOrCreateObject("profilesToCheck",[])
profilesToCheck.each{profile->

...
profilesToCheck.add(newProfile)
saveObject("profilesToCheck",profilesToCheck)
}


See also

loadOrCreateObject
loadAllObjects
saveAllObjects
isGlobalVariableExists

Parameters

name

name of the object saved with saveObject

_objectValue (optional)

If no saved object exists, the object is created with this value. If there is no this argument, the value of the global variable with this name is taken. If null, the value is set to null.

_saveAllXiterations (optional)

Allows to skip this function sometimes (it can accelerate the iteration, because it not save each time)

_pathFile (optional)

You can indicate a special path on your disk for this object. Else it is saved in the folder savedObject of Grimport Crawler.