📄 employee.java
字号:
/*
* Created on Mar 10, 2009
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package Emp;
import java.util.Hashtable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author VietHung Romano
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Employee {
private String empNo;
private String empName;
private String date;
private String month;
private String year;
private String birthDate;
private String address;
private String phone;
private String email;
private String job;
private String salary;
private String result;
private Hashtable<String, String> errors;
public Employee() {
empName = "";
year = "";
address = "";
phone = "";
email = "";
job = "";
salary = "";
errors = new Hashtable<String, String>();
}
public String getEmpNo() {
return empNo;
}
public void setEmpNo(String empNo) {
this.empNo = empNo;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
/**
* @return Returns the date.
*/
public String getDate() {
return date;
}
/**
* @param date
* The date to set.
*/
public void setDate(String date) {
this.date = date;
}
/**
* @return Returns the month.
*/
public String getMonth() {
return month;
}
/**
* @param month
* The month to set.
*/
public void setMonth(String month) {
this.month = month;
}
/**
* @return Returns the year.
*/
public String getYear() {
return year;
}
/**
* @param year
* The year to set.
*/
public void setYear(String year) {
this.year = year;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getSalary() {
return salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
public String getResult() {
return result;
}
/**
* @param result
* The result to set.
*/
public void setResult(String result) {
this.result = result;
}
/**
* @return Returns the email.
*/
public String getEmail() {
return email;
}
/**
* @param email
* The email to set.
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return Returns the result.
*/
/*
* @param _empName check if Employee Name is Empty
*/
public boolean isEmpName(String _empName) {
if (_empName.equals("")) {
errors.put("empName", "Please enter your name!");
empName = "";
return false;
}
return true;
}
public boolean isYear(String _year) {
if (_year.equals("")) {
errors.put("year", "Please enter year!");
return false;
}
return true;
}
/*
* @param _address Check if Address is empty @author VietHung Romano
*
* TODO To change the template for this generated type comment go to Window
* - Preferences - Java - Code Style - Code Templates
*/
public boolean isAddress(String _address) {
if (_address.equals("")) {
errors.put("address", "Please enter your address!");
return false;
}
return true;
}
/*
* @param _phone Check if Phone is valid : xxx-xxxxxxx @author VietHung
* Romano
*
* TODO To change the template for this generated type comment go to Window
* - Preferences - Java - Code Style - Code Templates
*/
public boolean isPhone(String _phone) {
String regex = "\\d{3}-\\d{7}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(_phone);
if (!matcher.matches()) {
errors.put("phone", "Please enter a valid phone number!");
return false;
}
return true;
}
/*
* @param _email check if email is valid @author VietHung Romano
*
* TODO To change the template for this generated type comment go to Window
* - Preferences - Java - Code Style - Code Templates
*/
public boolean isEmail(String _email) {
String regex = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(_email);
if (!matcher.matches()) {
errors.put("email", "Please enter a valid e-mail address!");
return false;
}
return true;
}
/*
* @param _job check if job is empty @author VietHung Romano
*
* TODO To change the template for this generated type comment go to Window
* - Preferences - Java - Code Style - Code Templates
*/
public boolean isJob(String _job) {
if (_job.equals("")) {
errors.put("job", "Please enter your job!");
return false;
}
return true;
}
public boolean isSalary(String _salary) {
if (_salary.equals("")) {
errors.put("salary", "Please enter your salary!");
return false;
}
return true;
}
public String getErrorMsg(String s) {
String errorMsg = (String) errors.get(s.trim());
return (errorMsg == null) ? "" : errorMsg;
}
private static final long serialVersionUID = 3359229824352097500L;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -