Advisercn-ROS RMS矩阵

时间:2024.5.4

AdvisercnROSRMS矩阵

AdvisercnROSRMS矩阵

New Concept Consulting

ROS/RMS矩阵

ROS/RMS矩阵(Return Of Sales/Relative Market Share,简称ROS/RMS Matrix) ROS/RMS矩阵也称做销售回报和相对市场份额矩阵,主要是用来分析企业的不同业务单元或产品的发展战略。这个模型认为,企业某个业务单元或产品在市场上的销售额应该与其在市场中的相对份额成正比,并且该业务单元或产品的销售额越高,该业务单元或产品为企业所提供的销售回报就应该越高。

如下图,企业的某种业务单元或产品的销售额在由低向高不断增加,其相对市场份额和销售回报也在一个“通道”内由低向高不断增加。如果该业务单元或产品的销售额增加,而其对企业的销售回报或相对市场份额降低,那么企业就不应该在这个时候进入其他领域,应该着重改善这个业务单元或产品的经营状况。

AdvisercnROSRMS矩阵

远见顾问(Advisercn)--- 利润战略专家! 第 1 页 共 1 页


第二篇:RMS_20xx0401


Sharing Record Storesin MIDlet Suites April 1, 2006

Technical Article

Sharing Record Stores in MIDlet Suites

By Motocoder Staff

In the first part of this article, we introduce the RMS (Record Management Store), including some new features provided in MIDP 2.0. Then, we will focus on how to share the RS (Record Store) in different MIDlet Suites. The sample code at the end of this document will help the developer better understand the API. RMS Introduction

The MIDP specification provides a mechanism called the Record Management Store (RMS) to store application data. RMS is an important persistent storage subsystem of J2ME. Considering that support is still limited for file systems today, RMS is the first choice for most J2ME developers when

implementing local data storage. The RMS can be used to store data directly on a device for offline browsing and for storing other application-related data. These APIs are found in the package javax.microedition.rms.

RMS implements the mechanism of records and record stores. In MIDP 1.0, RMS is described as a simple record-oriented database. A record store consists of a collection of records that remain persistent after the MIDlet exits. The records can be any data, such as text files and pictures that can be encoded into byte arrays. Record stores are referenced by name, which may consist of up to 32 case-sensitive characters.

The implementation of RMS in MIDP 2.0 is somewhat different from that in MIDP 1.0. In MIDP 1.0, only the record stores of the MIDlets packaged together within the same MIDlet Suite can be shared. However in MIDP 2.0, record stores of different MIDlet Suites can be shared through a new access mode to a RecordStore class.

In the next section, we will talk about how to share an RS in different MIDlet Suites.

Sharing an RS in different MIDlet Suites

This section will introduce the new feature of sharing an RS in different MIDlet Suites in MIDP 2.0.

RMS space in a MIDlet

Figure1: RMS space in a MIDlet

During runtime, other MIDlets can access the record store from inside the same MIDlet suite or others if

RMS20xx0401

the parameters are set correctly.

Figure 2: A RMS can be accessed by several MIDlet Suites

How to share a record store

The MIDP 2.0 RMS package provides persistent, record-based storage for MIDlets. The MIDP 2.0 specification adds a highly useful capability: One MIDlet suite can share a record store with others, granting them read-only or read-write access, depending on application requirements. By centralizing common data at a single location, a shared record store can simplify management, reduce on-device storage requirements, and avoid the synchronization problems that can arise when data is duplicated in multiple record stores.[5]

The record store doesn't create an instance by new an object. In fact, RecordStore provides a set of static methods openRecordStore to get instances:

? openRecordStore (String recordStoreName, boolean createIfNecessary)

? openRecordStore (String recordStoreName, boolean createIfNecessary, int

authmode, boolean writable)

RMS20xx0401

? openRecordStore (String recordStoreName, String vendorName, String

SuiteName)

The first method opens a record store with the given name recordStoreName. If there is no record store of that name, and createIfNecessary equals true, then this method will create one. Otherwise, it will throw an exception.

The parameter “authmode” in the second method specifies the authorization mode that decides whether this record store can be accessed by other MIDlet Suites, and the last parameter in this method specifies whether the record store is writable.

Using the first method means that only the MIDlet in the same MIDlet Suite can access this record store. It has the same effect as using the second method, as illustrated below:

openRecordStore (String recordStoreName, boolean createIfNecessary,

RecordStore.AUTHMODE_PRIVATE, false)

MIDP 2.0 also provides the third method specifically for MIDlet Suites to access the record stores in other MIDlet Suites. This method has 3 parameters: the name of the record store, the name of the vendor of this MIDlet, and the name of the MIDlet Suite. It should be noted that if the record store it wants to access is set to AUTHMODE_PRIVATE, invoking this method will throw an exception.

Note: Only the owning MIDlet suite may change the authmode and writable characteristics. There is no method to query the current settings of these attributes.

Samples

In the attached sample code, there are two MIDlet Suites, one called SharingRSinMIDletsI and the other one is called SharingRSinMIDletsII. In SharingRSinMIDletsI, we create two record stores: “private record” and “public record.” The “private record” record store can only be accessed by the midlet in the same MIDlet Suite (SharingRSinMIDletsI MIDlet Suite), and the “public record” record store can be shared by other MIDlet Suites.

Code:

<SharingRSinMIDletsI>

There are two classes in the SharingRSinMIDletsI MIDlet Suite. The RSOperation class specifies operations such as creating a record store, adding records into a record store and other RMS operations. RSSharingDemoI is the MIDlet class.

RSOperation.java

------------------------

package com.carol.demoI;

import javax.microedition.rms.InvalidRecordIDException;

import javax.microedition.rms.RecordStore;

import javax.microedition.rms.RecordStoreException;

import javax.microedition.rms.RecordStoreFullException;

import javax.microedition.rms.RecordStoreNotFoundException;

import javax.microedition.rms.RecordStoreNotOpenException;

/**

* Specify the operation of the record stores

*

* @author carol

* @version 0.1

*/

public class RSOperation {

private static RecordStore privateRS = null; public static RecordStore publicRS = null; // Create record stores public static void create(String str){ if (str.equals("private")&&(privateRS == null)){//a record store that can’t be shared try {

privateRS = RecordStore.openRecordStore("private record", true); System.out.println("create private rs");

System.out.println(privateRS.getName());

} catch (RecordStoreFullException e) {

System.err.println("Create Address Book Error:");

e.printStackTrace();

} catch (RecordStoreNotFoundException e) {

System.err.println("Create Address Book Error:");

e.printStackTrace();

} catch (RecordStoreException e) {

System.err.println("Create Address Book Error:");

e.printStackTrace();

} else if (str.equals("public")&&(publicRS == null)){// a record store that can be shared

publicRS = RecordStore.openRecordStore("public record", true,

RecordStore.AUTHMODE_ANY, true);

System.out.println("create public rs");

} catch (RecordStoreFullException e) {

System.err.println("Create Address Book Error:");

e.printStackTrace();

} catch (RecordStoreNotFoundException e) {

System.err.println("Create Address Book Error:");

e.printStackTrace();

} catch (RecordStoreException e) {

System.err.println("Create Address Book Error:");

e.printStackTrace();

byte[] tmpdatas = (strName+":").getBytes(); // convert the string to byte[]

byte[] datas = new byte[tmpdatas.length+4]; //convert the int to byte[] public static void addRecord(String str, String strName, int iNumber) { } else { } System.out.println("The"+str+" address book has already exist!"); } } try { } // Add records ---- Phone Book example

for (int i=0; i<tmpdatas.length;i++){

datas[i]=tmpdatas[i];

} datas[tmpdatas.length]= (byte)(0xff&(iNumber >> 24)); datas[tmpdatas.length+1]= (byte)(0xff&(iNumber >> 16)); datas[tmpdatas.length+2]= (byte)(0xff&(iNumber >> 8)); datas[tmpdatas.length+3]= (byte)(0xff&(iNumber >> 0));

if (str.equals("private")){

System.out.println("private add");

try {

privateRS.addRecord(datas, 0, datas.length);

} } catch (RecordStoreNotOpenException e) { } catch (RecordStoreFullException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); e.printStackTrace();

else if (str.equals("public")){

System.out.println("public add");

try {

publicRS.addRecord(datas, 0, datas.length);

} } catch (RecordStoreNotOpenException e) { } catch (RecordStoreFullException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); e.printStackTrace(); }

// Get records public static String getRecord(String str, int recordId) { byte[] datas = null; String result = null;

if (str.equals("private")){

try {

datas = privateRS.getRecord(recordId); System.out.println("get private data");

} } catch (RecordStoreNotOpenException e) { } catch (InvalidRecordIDException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); e.printStackTrace();

else if (str.equals("public")){

try {

datas = publicRS.getRecord(recordId); System.out.println("get public data");

if (datas != null) {

byte[] tmpByte = new byte[datas.length-4]; for (int i=0; i<tmpByte.length;i++){ tmpByte[i]= datas[i];

} } catch (RecordStoreNotOpenException e) { } catch (InvalidRecordIDException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); e.printStackTrace();

} // byte[] to int result = new String(tmpByte);

int tmpInt;

tmpInt = (datas[datas.length-4]&0x0000ff);

tmpInt = (tmpInt<<8)+(datas[datas.length-3]&0x0000ff); tmpInt = (tmpInt<<8)+(datas[datas.length-2]&0x0000ff); tmpInt = (tmpInt<<8)+(datas[datas.length-1]&0x0000ff);

result = result + String.valueOf(tmpInt);

System.out.println("result--"+result);

}

return result;

}

// Close the Record Store public static void close(){

try {

privateRS.closeRecordStore();

publicRS.closeRecordStore();

public RSOperation(String str){ } catch (RecordStoreNotOpenException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); }

}

}

RSSharingDemoI

----------------------

package com.carol.demoI;

import javax.microedition.lcdui.Display;

import javax.microedition.lcdui.Form;

import javax.microedition.midlet.MIDlet;

import javax.microedition.midlet.MIDletStateChangeException;

/**

* This is an example of

* Sharing RS in Different MIDlets

*

* @author carol

* @version 0.1

*/

public class RSSharingDemoI extends MIDlet {

public RSSharingDemoI() {

display = Display.getDisplay(this); }

protected void startApp(){ String strPrivateRecordName = "private"; private Display display;

String strPublicRecordName = "public"; Form f = new Form("Record Store Sharing Test");

RSOperation.create(strPrivateRecordName);

RSOperation.create(strPublicRecordName);

String[][] privateDatas = new String[][] {

{"Amy","123456"},

{"Ben","223456"},

{"Coral","323456"},

{"Denni","423456"}};

String[][] publicDatas = new String[][] {

{"Amy","100000"},

{"Ben","200000"},

{"Coral","300000"},

{"Denni","400000"}};

for (int i=0; i<4; i++){

Integer.parseInt(privateDatas[i][1]));

RSOperation.addRecord(strPublicRecordName,publicDatas[i][0],

Integer.parseInt(publicDatas[i][1]));

} RSOperation.addRecord(strPrivateRecordName,privateDatas[i][0],

f.append("get private records:"+"\n");

f.append("1st records--"+RSOperation.getRecord(strPrivateRecordName,1)+"\n"); f.append("2nd records--"+RSOperation.getRecord(strPrivateRecordName,2)+"\n");

f.append("3rd records--"+RSOperation.getRecord(strPrivateRecordName,3)+"\n"); f.append("4th records--"+RSOperation.getRecord(strPrivateRecordName,4)+"\n"); f.append("\n===================\n\n");

f.append("get public records:"+"\n");

f.append("1st records--"+RSOperation.getRecord(strPublicRecordName,1)+"\n"); f.append("2nd records--"+RSOperation.getRecord(strPublicRecordName,2)+"\n");

f.append("3rd records--"+RSOperation.getRecord(strPublicRecordName,3)+"\n"); f.append("4th records--"+RSOperation.getRecord(strPublicRecordName,4)+"\n");

display.setCurrent(f);

RSOperation.close();

}

}

}

<SharingRSinMIDletsII>

There are two classes in the SharingRSinMIDletsII MIDlet Suite. RSOperation class specifies RMS operations, and RSSharingDemoII is the MIDlet class.

RSOperation.java } protected void pauseApp() { protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

---------------------

package com.carol.demoII;

import javax.microedition.rms.InvalidRecordIDException;

import javax.microedition.rms.RecordStore;

import javax.microedition.rms.RecordStoreException;

import javax.microedition.rms.RecordStoreFullException;

import javax.microedition.rms.RecordStoreNotFoundException;

import javax.microedition.rms.RecordStoreNotOpenException;

/**

* Specify the operation of the record stores

*

* @author carol

* @version 0.1

*/

public class RSOperation {

private static RecordStore rs = null; public class RSOperation { private static RecordStore rs = null; public static String create(String recordStoreName, String suiteName) { String vendorName, String info = "info";

try {

rs = RecordStore.openRecordStore(recordStoreName, vendorName,

suiteName ); } catch (RecordStoreNotFoundException e) { info = "Error:Please run the SharinRSinMIDletI MIDlet Suite first."; System.out.println("== Please run the SharinRSinMIDletI MIDlet Suite first."); e.printStackTrace(); System.out.println("==================================="); System.out.println("======================="); } catch (RecordStoreException e) { } catch (SecurityException e){ info = "Error: this RecordStore can not be shared"; e.printStackTrace();

System.out.println(info);

}

return info;

}

byte[] tmpdatas = (strName+":").getBytes();

byte[] datas = new byte[tmpdatas.length+4]; // Add records public static void addRecord(String strName, int iNumber) {

for (int i=0; i<tmpdatas.length;i++){

datas[i]=tmpdatas[i];

} datas[tmpdatas.length]= (byte)(0xff&(iNumber >> 24)); datas[tmpdatas.length+1]= (byte)(0xff&(iNumber >> 16)); datas[tmpdatas.length+2]= (byte)(0xff&(iNumber >> 8)); datas[tmpdatas.length+3]= (byte)(0xff&(iNumber >> 0));

try {

rs.addRecord(datas, 0, datas.length);

}

// Get records } catch (RecordStoreNotOpenException e) { } catch (RecordStoreFullException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); e.printStackTrace();

public static String getRecord(int recordId) { byte[] datas = null; String result = null;

try {

datas = rs.getRecord(recordId);

System.out.println(rs.getNextRecordID());

System.out.println("get private data");

if (datas != null) {

byte[] tmpByte = new byte[datas.length-4];

for (int i=0; i<tmpByte.length;i++){

tmpByte[i]= datas[i];

} result = new String(tmpByte);

int tmpInt;

tmpInt = (datas[datas.length-4]&0x0000ff);

tmpInt = (tmpInt<<8)+(datas[datas.length-3]&0x0000ff); tmpInt = (tmpInt<<8)+(datas[datas.length-2]&0x0000ff); tmpInt = (tmpInt<<8)+(datas[datas.length-1]&0x0000ff);

result = result + String.valueOf(tmpInt);

System.out.println("result--"+result);

} } catch (RecordStoreNotOpenException e) { } catch (InvalidRecordIDException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); e.printStackTrace();

return result;

}

// Close the Record Store public static void close(){

try {

rs.closeRecordStore();

}

RSSharingDemoII.java } catch (RecordStoreNotOpenException e) { } catch (RecordStoreException e) { } e.printStackTrace(); e.printStackTrace(); } public RSOperation(String str){ }

----------------------------

package com.carol.demoII;

import javax.microedition.lcdui.Display;

import javax.microedition.lcdui.Form;

import javax.microedition.midlet.MIDlet;

import javax.microedition.midlet.MIDletStateChangeException;

/**

* This is an example of

* Sharing RS in Different MIDlets

*

* @author carol

* @version 0.1

*/

public class RSSharingDemoII extends MIDlet {

public RSSharingDemoII() {

display = Display.getDisplay(this);

}

protected void startApp(){ Form f = new Form("Record Store Sharing Test"); f.append("get records from the RecordStore \"public record\" of"+

" SharingRSinMIDletsI MIDlet Suite:"+"\n");

f.append("-------------------\n");

String info = RSOperation.create("public record",

"Midlet Suite Vendor",

"SharingRSinMIDletsI Midlet Suite");

// open the RS successfully

if (info.equals("info")){

RSOperation.addRecord("Grace",70000);

f.append("1st records--"+RSOperation.getRecord(1)+"\n"); f.append("2nd records--"+RSOperation.getRecord(2)+"\n"); f.append("3rd records--"+RSOperation.getRecord(3)+"\n"); f.append("4th records--"+RSOperation.getRecord(4)+"\n"); f.append("5th records--"+RSOperation.getRecord(5)+"\n");

} else { private Display display;

f.append(info);

info = RSOperation.create("private record",

"Midlet Suite Vendor",

"SharingRSinMIDletsI Midlet Suite");

f.append("=====================================\n"); f.append("get records from the RecordStore \"private record\" of"+

" SharingRSinMIDletsI MIDlet Suite:"+"\n");

f.append("-------------------\n");

f.append(info);

}

Below is the Running result of the sample: protected void destroyApp(boolean arg0) throws MIDletStateChangeException { } protected void pauseApp() { } display.setCurrent(f); RSOperation.close(); } }

RMS20xx0401

Figure 3: A running result of the sample – RSSharingDemoI (left), RSSharingDemoII

(right)

References

[1] Programming Wireless Devices with the Java 2 Platform Micro Edition, Second Edition (Book).

[2] MIDP Database Programming Using RMS: a Persistent Storage for MIDlets, By Qusay Mahmoud,

[3] Working With The RMS, by John Muchow,

[4] J2ME record management store, by Soma Ghosh, Entigo

[5] Sharing Data Between MIDlet Suites, by Richard Marejka,

更多相关推荐:
Pride and Prejudice读后感

20xx20xx学年第一学期英国文学课程期末考试试卷HappyLoveisGraspedbyWomenThemselvesPrideandPrejudicethemasterpieceofJaneAustenp...

Pride and Prejudice读后感

PrideandPrejudice1SummaryPrideandPrejudiceisamasterpieceofJaneAusten16December177518July1817whoisanoutstandingEngli...

Pride and Prejudice读后感

BookReportofPrideandPrejudiceRecentlyIreadthroughPrideandPrejudicewhichwrittenbyawellknownEnglishwriterJaneAustenAu...

Pride and Prejudice读后感

PrideandPrejudicePrideandPrejudiceisawellknownBritishwriterJaneAustensrepresentativedescribedthePrideDarcyandPrejud...

Pride and Prejudice读后感

ThePrideandPrejudiceThePrideandPrejudiceiswrittenbyGeorgeAustenThestoryismainlyabout4marriagesintheUKin18thThemosti...

Pride and Prejudice读后感

ImpressionsofPrideandPrejudicePrideandPrejudiceisJaneAusten39smasterpieceThewriterssharpobservationofsociallivesmak...

Pride and Prejudice 读后感

PrideandPrejudiceLastweekIwatchedamoviecalledPrideandPrejudiceIfoundthatIhavealonqingtobethemajoractorElizabethWhyH...

pride and prejudice傲慢与偏见读后感

PrideandPrejudiceinmyeyesPrideandPrejudiceisabookwrittenbyJaneAustenItmainlyshowsalovestoryinBritishinthe18centuryb...

pride_and_prejudice_傲慢与偏见读后感_英文

PrideandPrejudiceWhenIfirstknowthisbookbywatchingthemovielongbeforeIjustconsideredittobealovestoryButnowafterreadin...

傲慢与偏见Pride and Prejudice英文名著读后感

PrideandPrejudiceHumansWeaknessesquotItisatruthuniversallyacknowledgedthatasinglemaninpossessionofagoodfortunemustb...

book review of Pride and prejudic傲慢与偏见读后感

BookReviewofPrideandPrejudicePrideandPrejudiceisunquestionablyaclassicromanticstorythathaskidnappedgenerationafterg...

Book review of Pride and Prejudice 傲慢与偏见读后感

BookreviewofPrideandPrejudicePrideandPrejudiceisastoryofloveandmarriagesTherearemanyyoungpeopleinthisstorysuchasDar...

pride and prejudice 读后感(45篇)