SlideShare uma empresa Scribd logo
1 de 18
Interface RecordFilter

Interface RecordFilter
• javax.microedition.rms
• public interface RecordFilter

Interface RecordFilter
• This interface is used to searching in the recordstore.
• Searching is also called as ‘Filtering’.
• It specifies which records should be included in
enumeration
• Returns true if the candidate record is selected by the
RecordFilter.
For example:
• RecordFilter f = new DateRecordFilter(); // class
implements RecordFilter if
(f.matches(recordStore.getRecord(theRecordID)) == true)
DoSomethingUseful(theRecordID);
Interface RecordFilter
Searching Records:
• Here, if records matches a search criteria are
copied into the RecordEnumeration and
unmatched records are not included in the
RecordEnumeration.

Interface RecordFilter
• Record Searching(Filtering) is performed by
using interface RecordFilter interface.
• RecordFilter interface requires two
parameters: (1) match() (2) filterclose()

Interface RecordFilter
Match()
• It is a member method of Filter class
• It is used to read columns from the record and
uses logical operators to verify whether they
are matching the search key or not.
• It contains the searching logic

Interface RecordFilter
Logic for searching
Step 1
• Create a filter class by implementing RecordFilter
• Filter class should contain the logic for comparing
records and search criteria
Step 2:
• Create an object of Filter class and create a
record enumeration using its object:
ie: MyFilter mf=new MyFilter(“searchKey”);
Rec_enum=rec.enumerateRecords(filter,null,false);
Interface RecordFilter
• The enumerateRecords() method calls methods
defined in the Filter class.
Step 3:
• Execute loop record enumeration and copy each record
to a variable.
Step 4:
• Display the data in dialog box
Step 5:
• If any errors occurs display them
Step 6:
• Close and remove RecordEnumeration and record store
Interface RecordFilter
filterClose()
• It is used to free the resources

Interface RecordFilter
•
•
•
•
•
•
•
•
•
•
•
•
•

//searching program and exception handling
import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class SearchEx extends MIDlet implements CommandListener
{
private Display d;
private Alert a;
private Form f;
private Command exit;
private Command start;
private RecordStore rec = null;

•

private RecordEnumeration r = null;

•
•
•
•
•
•
•
•
•
•
•
•
•
•

private Filter fil = null;
private boolean b;
public SearchEx ()
{
d = Display.getDisplay(this);
b=false;
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
f = new Form("Mixed RecordEnumeration", null);
f.addCommand(exit);
f.addCommand(start);
f.setCommandListener(this);
}

Interface RecordFilter
•
•
•
•
•
•
•
•
•
•
•
•
•
•

public void startApp()
{
d.setCurrent(f);
}
public void pauseApp()
{
}
public void destroyApp( boolean un ) throws MIDletStateChangeException
{
if(un==false)
{
throw new MIDletStateChangeException();
}
}
Interface RecordFilter
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

public void commandAction(Command c, Displayable dd)
{
if (c == exit)
{
try
{
if(b==false)
{
StringItem s=new StringItem(null,"please press exit once again");
f.append(s);
destroyApp(false);
}
else
{
destroyApp(true);
notifyDestroyed();
}
}//end of try
catch(MIDletStateChangeException e)
{
b=true;
}
}

Interface RecordFilter
•
•
•
•
•
•
•
•
•
•
•
•
•
•

else if (c == start)
{
try
{
rec = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
a = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
Interface RecordFilter
•
•

try
{

•
•
•
•
•
•
•
•
•
•
•
•
•

String s[] = {"Sita", "Rama", "Anand"};
for (int x = 0 ; x < 3; x++)
{
byte[] by = s[x].getBytes();
rec.addRecord(by, 0,by.length);
}//x,by are lost
}//s is lost
catch ( Exception error)
{
a = new Alert("Error Writing",error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
Interface RecordFilter
•
•
•
•
•
•

try
{
fil = new Filter("Rama");//searching element
r = rec.enumerateRecords(fil, null, false);//Record Enumeration is constructed,search element
//is stored in recordenumeration r
if (r.numRecords() > 0)//It returns no.of records in the RecordEnumeration

•
•
•
•
•
•
•
•
•
•
•
•
•
•

{
String s = new String(r.nextRecord());
a = new Alert("Reading", s,null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
}
catch (Exception error)
{
a = new Alert("Error Reading",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}

Interface RecordFilter
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

try
{
rec.closeRecordStore();
}
catch (Exception error)
{
a = new Alert("Error Closing",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
if (RecordStore.listRecordStores() != null)
{
try
{
RecordStore.deleteRecordStore("myRecordStore");
r.destroy();
fil.filterClose();
}
catch (Exception error)
{
a = new Alert("Error Removing",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
}
}
}
}

Interface RecordFilter
RecordFilter
•
•
•

//Filter is user defined class
class Filter implements RecordFilter
{

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

private String key = null;
private ByteArrayInputStream bai = null;
private DataInputStream dis = null;
//this constructor is called when enumerateRecords() method is called
public Filter(String key)
{
this.key = key.toLowerCase();
}
//matches() is called automatically after constructor
public boolean matches(byte[] by)
{
String s = new String(by).toLowerCase();//converted into string form frm byte, converted into lowercase
if (s!= null && s.indexOf(key) != -1)//Returns the index within this string of the first
//occurrence of the specified substring.
return true;
else
return false;
}

Interface RecordFilter
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

public void filterClose()
{
try
{
if (bai != null)
{
bai.close();
}
if (dis != null)
{
dis.close();
}
}
catch ( Exception error)
{
}
}
}

Interface RecordFilter

Mais conteúdo relacionado

Destaque

Byte arrayoutputstream
Byte arrayoutputstreamByte arrayoutputstream
Byte arrayoutputstreammyrajendra
 
Interface record comparator
Interface record comparatorInterface record comparator
Interface record comparatormyrajendra
 
Interface record enumeration
Interface record enumerationInterface record enumeration
Interface record enumerationmyrajendra
 
Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Eventsmuthusvm
 
Session6 J2ME High Level User Interface(HLUI) part1
Session6 J2ME High Level User Interface(HLUI) part1Session6 J2ME High Level User Interface(HLUI) part1
Session6 J2ME High Level User Interface(HLUI) part1muthusvm
 

Destaque (9)

Byte arrayoutputstream
Byte arrayoutputstreamByte arrayoutputstream
Byte arrayoutputstream
 
M rec enum
M rec enumM rec enum
M rec enum
 
Interface record comparator
Interface record comparatorInterface record comparator
Interface record comparator
 
Interface record enumeration
Interface record enumerationInterface record enumeration
Interface record enumeration
 
J2 me 1
J2 me 1J2 me 1
J2 me 1
 
Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Events
 
Wr ex2
Wr ex2Wr ex2
Wr ex2
 
Record store
Record storeRecord store
Record store
 
Session6 J2ME High Level User Interface(HLUI) part1
Session6 J2ME High Level User Interface(HLUI) part1Session6 J2ME High Level User Interface(HLUI) part1
Session6 J2ME High Level User Interface(HLUI) part1
 

Semelhante a RecordFilter Interface for Searching Records in Java ME

PROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfPROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfezonesolutions
 
SeaJUG March 2004 - Groovy
SeaJUG March 2004 - GroovySeaJUG March 2004 - Groovy
SeaJUG March 2004 - GroovyTed Leung
 
Deep Dumpster Diving
Deep Dumpster DivingDeep Dumpster Diving
Deep Dumpster DivingRonnBlack
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Trisha Gee
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityGeorgePeterBanyard
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code SmellsMario Sangiorgio
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)Subhas Kumar Ghosh
 
The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31Mahmoud Samir Fayed
 
Session10 J2ME Record Management System
Session10 J2ME Record Management SystemSession10 J2ME Record Management System
Session10 J2ME Record Management Systemmuthusvm
 
Java 8 - Lambdas and much more
Java 8 - Lambdas and much moreJava 8 - Lambdas and much more
Java 8 - Lambdas and much moreAlin Pandichi
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Data Con LA
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
MongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all togetherMongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all togetherScott Hernandez
 
Replication Internals: Fitting Everything Together
Replication Internals: Fitting Everything TogetherReplication Internals: Fitting Everything Together
Replication Internals: Fitting Everything TogetherMongoDB
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureNicolas Corrarello
 
First Failure Data Capture for your enterprise application with WebSphere App...
First Failure Data Capture for your enterprise application with WebSphere App...First Failure Data Capture for your enterprise application with WebSphere App...
First Failure Data Capture for your enterprise application with WebSphere App...Rohit Kelapure
 

Semelhante a RecordFilter Interface for Searching Records in Java ME (20)

Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
JavaZone 2014 - goto java;
JavaZone 2014 - goto java;JavaZone 2014 - goto java;
JavaZone 2014 - goto java;
 
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfPROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
 
SeaJUG March 2004 - Groovy
SeaJUG March 2004 - GroovySeaJUG March 2004 - Groovy
SeaJUG March 2004 - Groovy
 
Deep Dumpster Diving
Deep Dumpster DivingDeep Dumpster Diving
Deep Dumpster Diving
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
 
The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31
 
Session10 J2ME Record Management System
Session10 J2ME Record Management SystemSession10 J2ME Record Management System
Session10 J2ME Record Management System
 
Java 8 - Lambdas and much more
Java 8 - Lambdas and much moreJava 8 - Lambdas and much more
Java 8 - Lambdas and much more
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
Java 8
Java 8Java 8
Java 8
 
MongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all togetherMongoDB 2.8 Replication Internals: Fitting it all together
MongoDB 2.8 Replication Internals: Fitting it all together
 
Replication Internals: Fitting Everything Together
Replication Internals: Fitting Everything TogetherReplication Internals: Fitting Everything Together
Replication Internals: Fitting Everything Together
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
First Failure Data Capture for your enterprise application with WebSphere App...
First Failure Data Capture for your enterprise application with WebSphere App...First Failure Data Capture for your enterprise application with WebSphere App...
First Failure Data Capture for your enterprise application with WebSphere App...
 

Mais de myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Último

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Último (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

RecordFilter Interface for Searching Records in Java ME

  • 2. • javax.microedition.rms • public interface RecordFilter Interface RecordFilter
  • 3. • This interface is used to searching in the recordstore. • Searching is also called as ‘Filtering’. • It specifies which records should be included in enumeration • Returns true if the candidate record is selected by the RecordFilter. For example: • RecordFilter f = new DateRecordFilter(); // class implements RecordFilter if (f.matches(recordStore.getRecord(theRecordID)) == true) DoSomethingUseful(theRecordID); Interface RecordFilter
  • 4. Searching Records: • Here, if records matches a search criteria are copied into the RecordEnumeration and unmatched records are not included in the RecordEnumeration. Interface RecordFilter
  • 5. • Record Searching(Filtering) is performed by using interface RecordFilter interface. • RecordFilter interface requires two parameters: (1) match() (2) filterclose() Interface RecordFilter
  • 6. Match() • It is a member method of Filter class • It is used to read columns from the record and uses logical operators to verify whether they are matching the search key or not. • It contains the searching logic Interface RecordFilter
  • 7. Logic for searching Step 1 • Create a filter class by implementing RecordFilter • Filter class should contain the logic for comparing records and search criteria Step 2: • Create an object of Filter class and create a record enumeration using its object: ie: MyFilter mf=new MyFilter(“searchKey”); Rec_enum=rec.enumerateRecords(filter,null,false); Interface RecordFilter
  • 8. • The enumerateRecords() method calls methods defined in the Filter class. Step 3: • Execute loop record enumeration and copy each record to a variable. Step 4: • Display the data in dialog box Step 5: • If any errors occurs display them Step 6: • Close and remove RecordEnumeration and record store Interface RecordFilter
  • 9. filterClose() • It is used to free the resources Interface RecordFilter
  • 10. • • • • • • • • • • • • • //searching program and exception handling import javax.microedition.rms.*; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.io.*; public class SearchEx extends MIDlet implements CommandListener { private Display d; private Alert a; private Form f; private Command exit; private Command start; private RecordStore rec = null; • private RecordEnumeration r = null; • • • • • • • • • • • • • • private Filter fil = null; private boolean b; public SearchEx () { d = Display.getDisplay(this); b=false; exit = new Command("Exit", Command.SCREEN, 1); start = new Command("Start", Command.SCREEN, 1); f = new Form("Mixed RecordEnumeration", null); f.addCommand(exit); f.addCommand(start); f.setCommandListener(this); } Interface RecordFilter
  • 11. • • • • • • • • • • • • • • public void startApp() { d.setCurrent(f); } public void pauseApp() { } public void destroyApp( boolean un ) throws MIDletStateChangeException { if(un==false) { throw new MIDletStateChangeException(); } } Interface RecordFilter
  • 12. • • • • • • • • • • • • • • • • • • • • • • • • public void commandAction(Command c, Displayable dd) { if (c == exit) { try { if(b==false) { StringItem s=new StringItem(null,"please press exit once again"); f.append(s); destroyApp(false); } else { destroyApp(true); notifyDestroyed(); } }//end of try catch(MIDletStateChangeException e) { b=true; } } Interface RecordFilter
  • 13. • • • • • • • • • • • • • • else if (c == start) { try { rec = RecordStore.openRecordStore( "myRecordStore", true ); } catch (Exception error) { a = new Alert("Error Creating", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a); } Interface RecordFilter
  • 14. • • try { • • • • • • • • • • • • • String s[] = {"Sita", "Rama", "Anand"}; for (int x = 0 ; x < 3; x++) { byte[] by = s[x].getBytes(); rec.addRecord(by, 0,by.length); }//x,by are lost }//s is lost catch ( Exception error) { a = new Alert("Error Writing",error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a); } Interface RecordFilter
  • 15. • • • • • • try { fil = new Filter("Rama");//searching element r = rec.enumerateRecords(fil, null, false);//Record Enumeration is constructed,search element //is stored in recordenumeration r if (r.numRecords() > 0)//It returns no.of records in the RecordEnumeration • • • • • • • • • • • • • • { String s = new String(r.nextRecord()); a = new Alert("Reading", s,null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a); } } catch (Exception error) { a = new Alert("Error Reading", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a); } Interface RecordFilter
  • 16. • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • try { rec.closeRecordStore(); } catch (Exception error) { a = new Alert("Error Closing", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a); } if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore("myRecordStore"); r.destroy(); fil.filterClose(); } catch (Exception error) { a = new Alert("Error Removing", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a); } } } } } Interface RecordFilter
  • 17. RecordFilter • • • //Filter is user defined class class Filter implements RecordFilter { • • • • • • • • • • • • • • • • • • private String key = null; private ByteArrayInputStream bai = null; private DataInputStream dis = null; //this constructor is called when enumerateRecords() method is called public Filter(String key) { this.key = key.toLowerCase(); } //matches() is called automatically after constructor public boolean matches(byte[] by) { String s = new String(by).toLowerCase();//converted into string form frm byte, converted into lowercase if (s!= null && s.indexOf(key) != -1)//Returns the index within this string of the first //occurrence of the specified substring. return true; else return false; } Interface RecordFilter
  • 18. • • • • • • • • • • • • • • • • • • public void filterClose() { try { if (bai != null) { bai.close(); } if (dis != null) { dis.close(); } } catch ( Exception error) { } } } Interface RecordFilter

Notas do Editor

  1. http://improvejava.blogspot.in