01.11.2007 - BA1 RMS - Record Management System. 01.11.2007 - BA2 Record Store En Record er et bytearray af vilkårlig størrelse En RecordStore er et antal.

Slides:



Advertisements
Similar presentations
1 Streams and Input/Output Files Part 2. 2 Files and Exceptions When creating files and performing I/O operations on them, the systems generates errors.
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Using Arrays and Collections.
Bruce Scharlau, University of Aberdeen, 2010 Java ME Record Management System Mobile Computing.
Lecture 15 Linked Lists part 2
Chapter 1 Object Oriented Programming 1. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
CSCI2100B Linked List Jeffrey
ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
The List ADT Textbook Sections
Lilian Blot VARIABLE SCOPE EXCEPTIONS FINAL WORD Final Lecture Spring 2014 TPOP 1.
Java ME persistence made easy! by Thiago Rossato Thiago Moreira.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
The Package Statement Group related interfaces and classes together Purpose: encapsulation and reduces name conflicts –private package classes not visible.
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
BA1 MIDP GUI BA2 Displayable hierarki Displayable ScreenCanvas TextBoxAlertFormList GameCanvas.
Formal Language, chapter 4, slide 1Copyright © 2007 by Adam Webber Chapter Four: DFA Applications.
CSC 142 G 1 CSC 142 Conditionals [Reading: chapter 5]
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Department of Computer Science & Engineering
Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = WED; if (today == FRI) cout
Copyright © 2012 Pearson Education, Inc. Chapter 16: Exceptions, Templates, and the Standard Template Library (STL)
Lesson 16 Exceptions Lesson Exceptions1. Murphy’s Law Anything that can go wrong will go wrong Lesson Exceptions2.
Files Files are used to store long term data. –Typically referred to as persistent data. –A file is a group of related records. –A list of friends addresses.
Exception Handling.  What are errors?  What does exception handling allow us to do?  Where are exceptions handled?  What does exception handling facilitate?
Voice Instant Messenger Andrew Miller CS 491B Fall 2006 Professor Sun.
Cosc 4730 Blackberry: Record Store & SQLite. Introduction RecordStore – Comes from JavaME, MIDP 1.0 On some phone who where you may not have a filesystem.
EXCEPTIONS Def: An exception is a run-time error. Examples include: attempting to divide by zero, or manipulate invalid data.
Part-B1 Stacks. Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations.
Part-B1 Stacks. Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations.
Stacks. 2 Outline and Reading The Stack ADT (§2.1.1) Applications of Stacks (§2.1.1) Array-based implementation (§2.1.1) Growable array-based stack (§1.5)
Exceptions. 2 Objectives Introduce C# exception handling –library exception types –custom exceptions Describe keywords used for exception handling –try.
1. Database-systemer, introduktion1 1. Database-systemer Introduktion.
Persistent Storage  Record Stores  mini databases – represent data as byte records  Record Management System (RMS) API  Files and Directories  FileConnection.
Detecting Changes  ItemStateListener interface – detect changes in internal state of an Item  new selection made in a ChoiceGroup  adjusted value of.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Java File Structure.  File class which is defined by java.io does not operate on streams  deals directly with files and the file system  File class.
Mobile Applications with Java ME & BlackBerry. Overview Java ME –Networking –Databases Java ME and the BlackBerry –The BlackBerry wireless device –Converting.
Stack. Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations on the data.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data.
Binary Files, Random Access Files Binary Files The way data is stored in memory is sometimes called the raw binary format. Data can be stored in.
BlackBerry Persistent Storage Models Persistent Storage APIs and Record Management System.
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 4 Pointers and Dynamic Arrays Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
ArrayList Class An ArrayList is an object that contains a sequence of elements that are ordered by position. An ArrayList is an object that contains a.
Java 1.5 The New Java Mike Orsega Central Carolina CC.
Model Checking Lock-Free Binary Search Tree Presented by Joanna Helga.
Enterprise Java v041109Container Managed Relationships1 Container Managed Relationships (CMR) Source: “Enterprise JavaBeans, 3rd Edition”, Richard Monson-Haefel.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 8 CDC andJ2ME Rob Pooley
1 Software 1 Java I/O. 2 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating.
모바일 자바 프로그래밍 MIDP RMS Ps lab 오민경. MIDP RMS  RMS (Record Management System)  MIDP 에서 정의하는 영속성을 지닌 자체 데이터 저장 공간  Record Store 의 집합으로 구성된 아주 간단한 데이터베이스.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
PROG Mobile Java Application Development PROG Mobile Java Application Development Data Storage, Continued.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
1 SWIFT 2.0: New features Dzianis Astravukh AUGUST 5, 2015.
Lecture 7 February 24, Javadoc version and author Tags These go in the comments before named classes. –Put your SS# on a separate line from the.
Unit Testing Part 2: Drivers and Stubs
MIDP Database Programming Using RMS: Jingwu He Csc 3360.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 4 GEORGE KOUTSOGIANNAKIS Copyright: 2016 Illinois Institute of Technology/George Koutsogiannakis 1.
File Input & Output1 Streams & File I/O. Introduction (1) The Java platform includes a number of packages that are concerned with the movement of data.
The Record Store ( ) Frank Ducrest. The Record Store 2 The Record Store provides persistence of data between MIDlet runs not quite a DBMS API.
Java IO Exploring the java.io package and living to talk about it.
Chapter 10: I/O Streams Input Streams Output Streams
Java- I/O, SMS etc N Amanquah.
Lecture 15: More Iterators
Computer Programming Methodology File Input
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Initializing Arrays char [] cArray3 = {'a', 'b', 'c'};
null, true, and false are also reserved.
Files and Streams in Java
Pre-assessment Questions
Presentation transcript:

BA1 RMS - Record Management System

BA2 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)

BA3 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 }...

BA4 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

BA5 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.

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

BA7 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.

BA8 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.

Datamapping BA9

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(); } BA10

Datamapping 3 public void fromByteArray(byte[] data) throws IOException { ByteArrayInputStream bin = new ByteArrayInputStream(data); DataInputStream din = new DataInputStream(bin); fromDataStream(din); din.close(); } public byte[] toByteArray() throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); toDataStream(dout); dout.close(); return bout.toByteArray(); } BA11

Datamapping 4 public void fromDataStream(DataInputStream din) throws IOException { _firstName = din.readUTF(); _lastName = din.readUTF(); _phoneNumber = din.readUTF(); } public void toDataStream(DataOutputStream dout) throws IOException { dout.writeUTF(getFirstName()); dout.writeUTF(getLastName()); dout.writeUTF(getPhoneNumber()); } BA12

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 BA13

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

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; } BA15

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 BA16

BA17 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

BA18