Commons包

作者: 明月_48cd | 来源:发表于2017-09-06 16:19 被阅读0次

    1.Commons Lang

    1.1 org.apache.commons.lang.ClassUtils;


    1.2 org.apache.commons.lang.ArrayUtils;
    //判断基本数据类型或者对象数组中是否包含这个元素
    ArrayUtils.contains();
    1.3 org.apache.commons.lang.ObjectUtils;
    //ObjectUtils的toString方法
    public static String toString(Object obj) {
    return obj == null ? "" : obj.toString();
    }

    org.apache.commons.lang.StringUtils;
    //ObjectUtils的方法isBlank,null或者无内容或者有内容但是是一堆空格都返回true
    public static boolean isBlank(String str) {
    int strLen;
    if (str == null || (strLen = str.length()) == 0) {
    return true;
    }
    for (int i = 0; i < strLen; i++) {
    if ((Character.isWhitespace(str.charAt(i)) == false)) {
    return false;
    }
    }
    return true;
    }

    org.apache.commons.lang.math.NumberUtils;
    NumberUtils.inNumber(String) 他会正确判断出给定的字符串是否是合法的数值?????
    而 StringUtils.isNumeric(String 只能判断一个字符串是否是由纯数字字符组成

    org.apache.commons.chain.Chain;
    /**saveOrUpdateChain 保存责任链*/
    @Autowired
    @Qualifier("saveOrUpdateChain")
    private Chain saveOrUpdateChain;

    org.apache.commons.chain.Command;
    org.apache.commons.chain.Context;

    org.apache.commons.collections.CollectionUtils;
    //在集合为null以及没有内容的情况下均返回true
    CollectionUtils.isEmpty(jzBeanList);

    org.apache.commons.lang.ClassUtils;


    org.apache.commons.lang.ArrayUtils;
    //判断基本数据类型或者对象数组中是否包含这个元素
    ArrayUtils.contains();
    org.apache.commons.lang.ObjectUtils;
    //ObjectUtils的toString方法
    public static String toString(Object obj) {
    return obj == null ? "" : obj.toString();
    }

    org.apache.commons.lang.StringUtils;
    //ObjectUtils的方法isBlank,null或者无内容或者有内容但是是一堆空格都返回true
    public static boolean isBlank(String str) {
    int strLen;
    if (str == null || (strLen = str.length()) == 0) {
    return true;
    }
    for (int i = 0; i < strLen; i++) {
    if ((Character.isWhitespace(str.charAt(i)) == false)) {
    return false;
    }
    }
    return true;
    }

    org.apache.commons.lang.math.NumberUtils;
    NumberUtils.inNumber(String) 他会正确判断出给定的字符串是否是合法的数值?????
    而 StringUtils.isNumeric(String 只能判断一个字符串是否是由纯数字字符组成

    org.apache.commons.logging.Log;
    org.apache.commons.logging.LogFactory;
    /**
    * logger
    */
    private Log logger = LogFactory.getLog(this.getClass());

    org.apache.commons.io.IOUtils;
    //长用此类去关闭流
    IOUtils.closeQuietly(is);

    org.apache.commons.io.input.ClosedInputStream; ?????
    public void close() throws IOException {
    IOUtils.closeQuietly(in);
    in = new ClosedInputStream();
    }

    org.apache.commons.io.FilenameUtils;
    //获取文件的后缀
    String suffix = FilenameUtils.getExtension(tmpName);

    org.apache.commons.beanutils.PropertyUtils;
    //把后者的属性赋给前者
    PropertyUtils.copyProperties(treeNode, treeNodeDubbo);

    org.apache.commons.codec.binary.Base64;
    Base64类最主要的两个静态方法是:Base64.encodeBase64(byte[]byteArray),用于对字节数组中指定的内容进行执行Base64编码;
    Base64.decodeBase64(byte[]byteArray),用于对字节数组中指定的内容执行Base64解码。
    另外,Base64还有一个静态方法Base64.isArrayByteBase64(byte[] byteArray),用于检测指定的字节数组是否可通过Base64测试(
    即是否包含了经过Base64编码的数据)。

    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.methods.GetMethod;
    import org.apache.commons.httpclient.methods.PostMethod;
    org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
    org.apache.commons.httpclient.params.HttpMethodParams;
    org.apache.commons.httpclient.HttpStatus;
    org.apache.commons.httpclient.HttpException;
    Commons-HttpClient 提供了可以工作于HTTP协议客户端的一个框架.

    org.apache.commons.lang.time.DateFormatUtils;
    org.apache.commons.collections.map.CaseInsensitiveMap;
    //获得request中的header 由于header是不区分大小写的,所有返回的headers是CaseInsensitiveMap
    Map<String, String> headers = new CaseInsensitiveMap();

    org.apache.commons.collections.MapUtils;
    MapUtils.isEmpty(ctb.getIndexMap());
    //MapUtils的isEmpty 方法
    public static boolean isEmpty(Map map) {
    return (map == null || map.isEmpty());
    }

    org.apache.commons.collections.map.LRUMap;
    //用于构建缓存或者连接池
    private static final LRUMap EVENT_MAP = new LRUMap(100);

    org.apache.commons.collections.map.ListOrderedMap;
    //将一个HashMap初始化成一个有序的Map
    Map<String, List<String>> dsrMcSsdwMap = ListOrderedMap.decorate(new HashMap<String, List<String>>());

    相关文章

      网友评论

        本文标题:Commons包

        本文链接:https://www.haomeiwen.com/subject/qwdsjxtx.html