Package gnu.java.zrtp.zidfile
Class ZidFile
- java.lang.Object
-
- gnu.java.zrtp.zidfile.ZidFile
-
public class ZidFile extends Object
- Author:
- Werner Dittmann <Werner.Dittmann@t-online.de>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the ZID file.static ZidFilegetInstance()Get the an instance of ZIDFile.ZidRecordgetRecord(byte[] zid)Get a ZID record from the active ZID file.byte[]getZid()Get the ZID associated with this ZID file.booleanisOpen()Check if ZIDFile has an active (open) file.intopen(String name)Open the named ZID file and return a ZID file class.intsaveRecord(ZidRecord zidRecord)Save a ZID record into the active ZID file.
-
-
-
Method Detail
-
getInstance
public static ZidFile getInstance()
Get the an instance of ZIDFile. This method just creates an instance an store a pointer to it in a static variable. The ZIDFile is a singleton, thus only one ZID file can be open at one time.- Returns:
- A pointer to the global ZIDFile singleton instance.
-
open
public int open(String name)
Open the named ZID file and return a ZID file class. This static function either opens an existing ZID file or creates a new ZID file with the given name. The ZIDFile is a singleton, thus only one ZID file can be open at one time. To open another ZID file you must close the active ZID file first.- Parameters:
name- The name of the ZID file to open or create- Returns:
- 1 if file could be opened/created, 0 if the ZID instance already has an open file, -1 if open/creation of file failed.
-
isOpen
public boolean isOpen()
Check if ZIDFile has an active (open) file.- Returns:
- True if ZIDFile has an active file, false otherwise
-
close
public void close()
Close the ZID file. Closes the ZID file, and prepares to open a new ZID file.
-
getRecord
public ZidRecord getRecord(byte[] zid)
Get a ZID record from the active ZID file. The method get the identifier data from the ZID record parameter, locates the record in the ZID file and fills in the RS1, RS2, and other data. If no matching record exists in the ZID file the method creates it and fills it with default values.- Parameters:
zid- contains the identifier data. The method returns the record.- Returns:
- The existing or created ZID record or null in case of I/O problems.
-
saveRecord
public int saveRecord(ZidRecord zidRecord)
Save a ZID record into the active ZID file. This method saves the content of a ZID record into the ZID file. Before you can save the ZID record you must have performed a getRecord() first.- Parameters:
zidRecord- The ZID record to save.- Returns:
- 1 on success
-
getZid
public byte[] getZid()
Get the ZID associated with this ZID file.- Returns:
- Pointer to the ZID
-
-