📄 contact.java
字号:
/**
* Class : short description
* @author Michele 'Miccar' Cardinale miccar@gmail.com
* @author Natale Vinto ebballon@interfree.it
* @version 1.0
*/
/*
* goText : text messaging over GPRS
* Copyright (C) 2006 Natale Vinto <ebballon@interfree.it>
* OpenJLab Group www.openjlab.org
* Copyright (C) 2006 Michele Cardinale 'Miccar' <miccar@gmail.com>
* www.miccar.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
import javax.microedition.rms.*;
import java.util.*;
public class Contact{
static String RN="_contacts";
public final static int MAX_MEM_CONTACTS=30;
String contactString;
String name;
String number;
String email;
public Contact(String contactString) {
this.contactString=contactString;
this.name=utils.getTag(contactString, "na");
this.number=utils.getTag(contactString, "nu");
this.email=utils.getTag(contactString, "em");
}
public String getName(){
return this.name;
}
public String getNumber(){
return this.number;
}
public String getEmail(){
return this.email;
}
public boolean isGroup(){
if(this.number.indexOf(";")>0)
return true;
else
return false;
}
public int set(String na,String nu,String em){
String string="<na>"+na+"</na>";
string+="<nu>"+nu+"</nu>";
string+="<em>"+em+"</em>";
int id=this.getRmsId();
if(!this.getName().equals(na)){
if(Contact.existContactName(na))
return -2;
}
return modContact(string, id);
}
public int getRmsId(){
RecordStore rs=null;
try{
rs=RecordStore.openRecordStore(RN, true);
RecordEnumeration e=rs.enumerateRecords(new RSUtils().new FilterByString(this.contactString),null,true);
if(e.hasNextElement()){
return e.nextRecordId();
} else {
return -1;
}
} catch (Exception e){
return -2;
} finally {
try{
rs.closeRecordStore();
} catch (Exception e){}
}
}
public static int insert(String na,String nu,String em){
// -3: superata la soglia di contatti salvabili.
// -2: nominativo gia' presente
// -1: errore inserimento (vedi insContact)
// 0 : la stringa passata non pu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -