SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à Interface Record filter

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
 

Similaire à Interface Record filter (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...
 

Plus 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
 

Dernier

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Dernier (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Interface Record filter

  • 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

Notes de l'éditeur

  1. http://improvejava.blogspot.in