设为首页 加入收藏

TOP

【代码总结● Swing中的一些操作与设置】(二)
2019-09-17 17:56:06 】 浏览:83
Tags:代码 总结 Swing 一些 操作 设置
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
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇再探motan 下一篇【中间件】Redis 实战之主从复制..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目