Serch in RMS
Hi all.
I'm using in my project a RMS database. This database has 2 columns:
1.- A word.
2.- A number.
All works fine, but when I try to do a search I have a small problem. For ejample:
Column 1 - Column 2
Hello- 654
Peter- 23545
In- 5234
Indian- 134123
- I want to search "In", and the functuons must to return me "5234". BUT NO!! the function returns me "134123 " and this number is of "Indian".
This is a part of my code:
if (rs.getNumRecords() > 0){
Filtro search = new Filtro(tfFind);
RecordEnumeration re = rs.enumerateRecords(search, null, false);
if (re.numRecords() > 0){
ByteArrayInputStream bais;
DataInputStream dis;
byte[] registro =new byte[50];
try{
bais = new ByteArrayInputStream(registro);
dis = new DataInputStream(bais);
rs.getRecord(re.nextRecordId(),registro,0);
if (opcion==1)
siMatch = new String(dis.readUTF());
else {
dis.readUTF();
siMatch = new String(dis.readUTF());
}
dis.close();
bais.close();
Filtro It's a function that only returns if the word is in the RMS.
Any help?
Kind regards,
[1235 byte] By [
Kuntera] at [2007-10-2 5:27:32]

Ok, sorry. Here all code:
public String buscar(String tfFind){
siMatch=null;
try{
if (rs.getNumRecords() > 0){
Filtro search = new Filtro (tfFind);
RecordEnumeration re = rs.enumerateRecords(search, null, false);
if (re.numRecords() > 0){
ByteArrayInputStream bais;
DataInputStream dis;
byte[] registro =new byte[50];
try{
bais = new ByteArrayInputStream(registro);
dis = new DataInputStream(bais);
rs.getRecord(re.nextRecordId(),registro,0);
if (opcion==1)//Read the word
siMatch = new String(dis.readUTF());
else {//Read the number
dis.readUTF();
siMatch = new String(dis.readUTF());
}
dis.close();
bais.close();
}
catch(Exception e) {}
}
else {
System.out.println("NO EXISTS");
}
siMatch=palabraNoEncontrada;
}
re.destroy();
}
}
catch (Exception e){
db("Buscar -- " + e.toString());
}
return siMatch;
}
class SearchFilter implements RecordFilter
{
private String searchText = null;
public Filtro (String searchText)
{
// Este es el texto a buscar
this.searchText = searchText.toLowerCase();
}
public boolean matches(byte[] candidate)
{
String str = new String(candidate).toLowerCase();
// Encuentra el registro
if (searchText != null && str.indexOf(searchText) != -1)
return true;
else
return false;
}
}