alueOf(pwdField.getPassword()).trim();
自己写的一些判断的工具类
package pers.jason.market.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** * 工具包 * @author Administrator * */
public final class Util {
/** * 判断字符串是否为空 * @param str * @return */
public static boolean isEmpty(String str) {
return null == str || "" .equals(str.trim()) ? true : false;
}
/** * 判断字符串是否为整数 * @Title : isNumber * @Description: * @param str * @return * @return boolean * @author Anderson * @data 2018-8-23 下午10:05:06 */
public static boolean isInt (String str){
Pattern pattern = Pattern.compile("[0-9]+");
Matcher isNum = pattern.matcher(str);
if( !isNum.matches() ){
return false;
}
return true;
}
/** * 判断是否为小数 * @Title : isDouble * @Description: * @param str * @return * @return boolean * @author Anderson * @data 2018-8-23 下午10:59:04 */
public static boolean isDouble (String str){
String [] num = str.split("\\.");
if(num.length == 2 && isInt(num[0]) && isInt(num[1]) ){
return true;
}
return false;
}
/** * * @Title : isDolores * @Description:判断是否为美元 * @param str * @return * @return boolean * @author Anderson * @data 2018-8-27 上午11:38:26 */
public static boolean isDolores(String str){
if("$".equals(str)){
return true;
}else
return false;
}
/** * * @Title : isRMB * @Description: 判断是否为人民币 * @param str * @return * @return boolean * @author Anderson * @data 2018-8-27 下午12:33:11 */
public static boolean isRMB(String str){
if("¥".equals(str)){
return true;
}
return false;
}
}
object.properties 配置文件(对象属性)
Transaction=pers.jason.market.transaction.impl.TransactionImpl
UserDao=pers.jason.market.dao.impl.UserDaoImpl
UserService=pers.jason.market.service.impl.UserServiceImpl
AccountDao=pers.jason.market.dao.impl.AccountDaoImpl
AccountService=pers.jason.market.service.impl.AccountServiceImpl
SupplierDao=pers.jason.market.dao.impl.SupplierDaoImpl
SupplierService=pers.jason.market.service.impl.SupplierServiceImpl
SupplierGroupDao=pers.jason.market.dao.impl.SupplierGroupDaoImpl
SupplierGroupService=pers.jason.market.service.impl.SupplierGroupServiceImpl
GoodsGroupDao=pers.jason.market.dao.impl.GoodsGroupDaoImpl
GoodsGroupService=pers.jason.market.service.impl.GoodsGroupServiceImpl
等号左边是接口,等号右边是其对应的实现类所在的包及实现类本身
之所以要写这个,是因为要写对象工厂
对象工厂
package pers.jason.market.object.factoy;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/** * * @Title ObjectFactory.java * @description TODO 对象工厂 * @time 2018-8-20 下午3:11:19 * @author Anderson * @version 1.0 ok */
public final class ObjectFactory {
private static Map<String, Object> objectMap = new HashMap<String,Object>();
static {
Properties properties = new Properties();
try {
properties.load(new FileInputStream("Object.properties"));
Enumeration<?> enumeration =properties.keys();
while(enumeration.hasMoreElements()) {
String key = (String)enumeration.nextElement();
String value = properties.getProperty(key);
objectMap.put(key, Class.forName(valu