📄 studentbean.java
字号:
package bean;
import dao.DataAccess;
import dao.Status;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StudentBean {
private Status status;
private DataAccess studentDAO;
private String number = "";
private String name = "";
private String email = "";
public StudentBean() {
status = new Status();
studentDAO = new DataAccess();
}
public void setNumber(String id){
if((id == null)||(id.length()==0)||(id.length()>9)){
status.addException(new Exception("Please input your number(8 bit)"));
}else{
number = id;
}
}
public String getNumber(){
return number;
}
public void setName ( String value ) {
if ((value == null)||(value.length()==0)) {
status.addException(new Exception("Please input your name"));
}else{
name = value;
}
}
public String getName(){
return name;
}
public void setEmail ( String value ) {
if ((value == null)||(value.length()==0)) {
status.addException(new Exception("Please input your email address"));
}else{
if(verifyEmail(value)){
email = value;
}else{
status.addException(new Exception(
"The email address is not improperly formated"));
}
}
}
public String getEmail(){
return email;
}
public boolean wasSuccessful() {
return status.isSuccessful();
}
public Status getStatus(){
return status;
}
public void processRequest(){
if(wasSuccessful()){
try{
studentDAO.insert(number,name,email);
}catch(Exception ex){
status.addException(ex);
}
}
}
public boolean search(){
boolean flag=studentDAO.search(this.number);
//System.out.println(this.number);
return flag;
}
public boolean verifyEmail(String email){
boolean result = true;
if(email.indexOf('@')==-1){
result = false;
}
int dotIdx = email.lastIndexOf('.');
if(dotIdx == -1){
result = false;
}else{
String str = email.substring(dotIdx+1);
if(str.equals("com")||str.equals("edu")||str.equals("org")||str.equals("net")){
result = true;
}
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -