SlideServe
Menu
Préférences
© SlideServe · v2026

RMS - Record Management System

aviva avatar
16 diapositives · 396 Views · Aug 20, 2014

RMS - Record Management System. Record Store. En Record er et bytearray af vilkårlig størrelse En RecordStore er et antal Records nummerede 1, 2, 3, ... Når en ny Record indsættes anvendes næste endnu ikke anvendte index (ingen genbrug af indexværdier). Oprette en RecordStore. ...

RMS - Record Management System - slide 1
01 / 16RMS - Record Management System
1 / 17

Télécharger la présentation

RMS - Record Management System
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. RMS - Record Management System

  2. Record Store • En Record er et bytearray af vilkårlig størrelse • En RecordStore er et antal Records nummerede 1, 2, 3, ... • Når en ny Record indsættes anvendes næste endnu ikke anvendte index (ingen genbrug af indexværdier)

  3. Oprette en RecordStore ... // Create a record store RecordStore rs = null; try { rs = RecordStore.openRecordStore( "myrs", true ); } catch( RecordStoreException e ){ // couldn't open it or create it } ...

  4. Indsætte og opdatere Records // Indsætte en ny Record byte[] data = new byte[]{0, 1, 2, 3 }; int recordID; recordID = rs.addRecord(data, 0, data.length); // Opdatere en eksisterende Record int recordID = ...; // some record ID byte[] data = new byte[]{ 0, 10, 20, 30}; rs.setRecord(recordID, data, 1, 2); // replaces all data in record with 10, 20

  5. Læse og fjerne Records ... int recordID = .... // some record ID byte[] data = rs.getRecord(recordID); ... ... int recordID = ...; // some record ID rs.deleteRecord(recordID); ... Once a record is deleted, any attempt to use it throws an InvalidRecordIDException.

  6. Slette en RecordStore ... try { RecordStore.deleteRecordStore("myrs"); } catch(RecordStoreNotFoundException e){ // no such record store } catch(RecordStoreException e){ // somebody has it open } ...

  7. Flere RecordStore operationer • getLastModified() returns the time of the last modification • getName() returns the name of the record store. • getNumRecords() returns the number of records in the record store. • getSize() returns the total size of the record store, in bytes. • getSizeAvailable() returns the number of bytes available for growth. • getVersion() returns the version number of the record store.

  8. RMS Exceptions • InvalidRecordIDException is thrown when an operation cannot be performed because the record ID is invalid. • RecordStoreFullException is thrown when no more space is available in the record store. • RecordStoreNotFoundException is thrown when the application tries to open a non-existent record store. • RecordStoreNotOpenException is thrown when an application tries to access a record store that has already been closed. • RecordStoreException is the superclass of the other four, and is thrown for general errors they don't cover.

  9. Datamapping 1

  10. Datamapping 2 public void fromByteArray(byte[] data) throws IOException { ByteArrayInputStream bin = new ByteArrayInputStream(data); DataInputStream din = new DataInputStream(bin); _firstName = din.readUTF(); _lastName = din.readUTF(); _phoneNumber = din.readUTF(); din.close(); } public byte[] toByteArray() throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); dout.writeUTF(getFirstName()); dout.writeUTF(getLastName()); dout.writeUTF(getPhoneNumber()); dout.close(); return bout.toByteArray(); }

  11. Enumerations 1 RecordStore rs = ... // an open record store RecordEnumeration enum = rs.enumerateRecords( filter, comperator, tracking_updates ); ... // use the enumeration here enum.destroy(); // always clean it up! enum.hasNextElement() enum.nextRecordId() enum.nextRecord() osv Rækkefølgen i enum er udefineret

  12. Enumerations 2 RecordFilter public class MyFilter implements RecordFilter { public boolean matches( byte[] recordData ) { ... // matching code here } }

  13. Enumerations 3 RecordComparator public class MyComparator implements RecordComparator { public int compare(byte[] r1, byte[] r2){ int salary1 = getSalary(r1); int salary2 = getSalary(r2); if(salary1 < salary2){ return PRECEDES; } else if(salary1 == salary2){ return EQUIVALENT; } else { return FOLLOWS; } } }

  14. Alternativer • RMS • Filsystem (FileConnection API) • PIM (Personal Information Management API) RMS er tilgængelig på de fleste apparater Filesystem og PIM er ikke så tilgængelige som RMS, og kræver endvidere certificering

  15. Afsluttende bemærkninger • Alle RMS operationer er trådsikre • Attributten MIDlet-Data-Size (minimumsværdi) bør sættes i såvel jad som manifest filer • Det vil være rart at kunne arbejde på "objektniveau" • Der er behov for at kunne søge effektivt i en RecordStore