Jakarta Commons Cookbook
- Core:BeanUtils,Lang,Collections,logging
- Db:DbUtils,DBCP,Pool
- IO: IO,
- XML vs Bean:betwixt,Digester,JXPath,Jelly
- 模版:EL, JEXL
- 通用:Codec,Id
- Web:FileUpload,httpClient
- 文件系统:VFS
1.apache的commons工程包括了许多方便的工程可以节省开发人员的时间,本书主要介绍了:BeanUtils,Betwixt,CLI,Codec,Collections,Configuretion,Digester,HttpClient,ID,IO,JEXL,JXPath,Lang,
- abbreviate 缩写
- IsEmpty/IsBlank - checks if a String contains text
- Trim/Strip - removes leading and trailing whitespace,strip提供了丰富的截除部分字符串的功能
- Equals - compares two strings null-safe
- startsWith - check if a String starts with a prefix null-safe
- endsWith - check if a String ends with a suffix null-safe
- IndexOf/LastIndexOf/Contains - null-safe index-of checks
- IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut - index-of any of a set of Strings
- ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters
- Substring/Left/Right/Mid - null-safe substring extractions
- SubstringBefore/SubstringAfter/SubstringBetween - substring extraction relative to other strings
- Split/Join - splits a String into an array of substrings and vice versa
- repeat 克隆字符
- Remove/Delete - removes part of a String
- Replace/Overlay - Searches a String and replaces one String with another
- Chomp/Chop - removes the last part of a String
- LeftPad/RightPad/Center/Repeat - pads a String
- UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize - changes the case of a String
- CountMatches - counts the number of occurrences of one String in another
- IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String
- DefaultString - protects against a null input String
- Reverse/ReverseDelimited - reverses a String
- Abbreviate - abbreviates a string using ellipsis
- Difference/indexOfDifference - compares Strings and reports on their differences
- LevenshteinDistance - the number of changes needed to change one String into another
- 中提供了获取bean中普通元素,bean元素,list元素,Map元素的值方法,分别是getSimpleProperty(bean,"name"),getNestedProperty(bean,"ext.balance"),getIndexedProperty(bean,"list[1]"),getMappedProperty(bean,"map(key)"),也可以直接调用getProperty(bean,"ext.list[0].map(key)")组合的形式,被解析的时候根据具体形式再调用上面的具体方法,相应的set方法使用,尤其是JEXL的描述用法很方便
- isReadable/isWritable(bean,"name")可以查看此属性是否可读/可写
- describe方法返回所有get方法可访问的bean元素到一个Map中,key为属性名。BeanMap类通过传入一个bean构造一个map,在此map上用map的基本方法直接操作bean,酷啊。
- MultiKeyMap:多个key共同作用才能对应到一个value
- MultiValueMap:一个key可以对应多个value,get(key)时返回的是一个ArrayList实例
- BidiMap可以通过value来反找key,这个时候key-value都是一一对应的,put的时候如果key不同而value,则后put的key会替换相同value对应的已经存在的key。
-
CaseInsensitiveMap 对key大小写敏感的Map,即大小写不同但是内容相同的key会被认为是同一个key
- countMatches(collection,predicate)计算符合predicate的collection中的元素的个数
- cardinality(ele,collection)计算ele在collection出现的次数
- getCardinalityMap(collection)得到一个map,key为collection中的元素,value为每个元素出现的次数
- union,intersection,disjunction,subtract可以实现两个iterable对象的并集,交集,非交集,不包括集
LazyMap.lazyMap(map,factory) 可以将一个普通的map转化成lazymap,即当get的时候如果map里没有对应的key,则会调用factory里面一次生成value放到map中。
fixedSizeMap(Map)fixedSizeSortedMap(SortedMap)lazyMap(Map,Factory)lazyMap(Map,Transformer)lazySortedMap(SortedMap,Factory)lazySortedMap(SortedMap,Transformer)predicatedMap(Map,Predicate,Predicate)predicatedSortedMap(SortedMap,Predicate,Predicate)transformedMap(Map, Transformer, Transformer)transformedSortedMap(SortedMap, Transformer, Transformer)multiValueMap( Map )multiValueMap( Map, Class )multiValueMap( Map, Factory )
digester.setValidating( false );
//当遇见 catalog 元素的时候,产生一个Catalog对象
digester.addObjectCreate( "catalog", Catalog.class );
//当遇见 catalog 元素下面的book的时候,产生一个Book对象
digester.addObjectCreate( "catalog/book", Book.class );
// 当遇见 catalog 元素下面的book的author时候,调用author属性的Set方法
digester.addBeanPropertySetter( "catalog/book/author", "author" );
digester.addBeanPropertySetter( "catalog/book/title", "title" );
//当再一次遇见 catalog 元素下面的book的时候,调用catalog类的addBook()方法
digester.addSetNext( "catalog/book", "addBook" );
Commons CLI supports different types of options:
- POSIX like options (ie. tar -zxvf foo.tar.gz)
- GNU like long options (ie. du --human-readable --max-depth=1)
- Java like properties (ie. java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo)
- Short options with value attached (ie. gcc -O2 foo.c)
- long options with single hyphen (ie. ant -projecthelp)
- Properties files
- XML documents
- Windows INI files
- Property list files (plist)
- JNDI
- JDBC Datasource
- System properties
- Applet parameters
- Servlet parameters
- Utility classes - with static methods to perform common tasks
- Input - useful Input Stream and Reader implementations
- Output - useful Output Stream and Writer implementations
- Filters - various implementations of file filters
- Comparators - various implementations of java.util.Comparator for files
- File Monitor - a component for monitoring file system events
- closeQuietly - these methods close a stream ignoring nulls and exceptions
- toXxx/read - these methods read data from a stream
- write - these methods write data to a stream
- copy/copyLarge - these methods copy all the data from one stream to another,copy默认buffer是4k
- contentEquals - these methods compare the content of two streams
- writing to a file
- reading from a file
- make a directory including parent directories
- copying files and directories
- deleting files and directories
- converting to and from a URL
- listing files and directories by filter and extension
- comparing file content
- file last changed date
- calculating a checksum
- byteCountToDisplaySize显示human-readable size
- copyFile/Directory/ 复制文件或目录
- copy[url,inputstream]ToFile 复制url链接内容或输入流到文件
- move/deleteDirectory
- touch文件
The blocking I/O model may be more appropriate for data intensive, low latency scenarios, whereas the non-blocking model may be more appropriate for high latency scenarios where raw data throughput is less important than the ability to handle thousands of simultaneous HTTP connections in a resource efficient manner.
Jakarta Commons Cookbook的更多相关文章
- Taxonomy of class loader problems encountered when using Jakarta Commons Logging(转)
Acknowledgments I would like to thank Jacob Kjome for reviewing early drafts of this document. His c ...
- Apache Jakarta Commons 工具集简介
Apache Jakarta Commons 工具集简介[转] Apache Commons包含了很多开源的工具,用于解决平时编程经常会遇到的问题,减少重复劳动.我选了一些比较常用的项目做简单介绍.文 ...
- Commons BeanUtils 中对Map的操作
CSDN学院招募微信小程序讲师啦 程序员简历优化指南! [观点]移动原生App开发 PK HTML 5开发 云端应用征文大赛,秀绝招,赢无人机! Commons BeanUtils 中对Map的操作 ...
- EqualsBuilder和HashCodeBuilder
package com.osc.demo; import java.util.List; import org.apache.commons.lang.builder.EqualsBuilder; i ...
- EqualsBuilder和HashCodeBuilder(重写equal和hashcode)
EqualsBuilder和HashCodeBuilder 自动化hashCode()和equals() 问题产生:当需要自动实现hashCode()和equals()方法 解决方法:使用Equa ...
- java apache commons HttpClient发送get和post请求的学习整理(转)
文章转自:http://blog.csdn.net/ambitiontan/archive/2006/01/06/572171.aspx HttpClient 是我最近想研究的东西,以前想过的一些应用 ...
- 一篇关于apache commons类库的详解
1.1. 开篇 在Java的世界,有很多(成千上万)开源的框架,有成功的,也有不那么成功的,有声名显赫的,也有默默无闻的.在我看来,成功而默默无闻的那些框架值得我们格外的尊敬和关注,Jakarta C ...
- 使用slf4j取代Apache Commons Logging
假如你正在开发应用程序所调用的组件当中已经使用了 JCL(之前叫 Jakarta Commons Logging,JCL) 的,还有一些组建可能直接调用了 java.util.logging,这时你需 ...
- 对象池化技术 org.apache.commons.pool
恰当地使用对象池化技术,可以有效地减少对象生成和初始化时的消耗,提高系统的运行效率.Jakarta Commons Pool组件提供了一整套用于实现对象池化的框架,以及若干种各具特色的对象池实现,可以 ...
随机推荐
- html页面控制字体大小的js代码
dom对象控制显示文章字体大小的js代码 <head> <script type="text/javascript"> function check(siz ...
- zookeeper命名服务
zookeeper概念 zooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,底层组成单元是znode,对于zookeeper来说,所有的功能都是基于znode来实现的,因此有万物皆节点 ...
- 3.Appium运行时出现:Original error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device
参考博客:https://blog.csdn.net/niubitianping/article/details/52624417 1.错误信息:Original error: Android dev ...
- VMware ESX常用命令 和 IP 地址修改
一. VMware ESX Command 1. 看你的esx版本 vmware –v 2. 查看显示ESX硬件,内核,存储,网络等信息 esxcfg-info -a(显示所有相关的信息) esxcf ...
- mkdir -p 多层次目录创建
mkdir的-p选项允许你一次性创建多层次的目录,而不是一次只创建单独的目录.例如,我们要在当前目录创建目录Projects/a/src,使用命令 1 mkdir -p Project/a/src 而 ...
- python 下载图片的方法
a='http://wx1.sinaimg.cn/mw600/006HOayNgy1fqjdi2nxohj32pw3o8x6s.jpg' #图片下载地址 ( 这里改成 文件txt地址)w='/U ...
- [转]Acrylic DNS Proxy 使用方法
本文转自:http://www.cnwyw.net/index.php/acrylic-dns-proxy-ping-bi-guang-gao/ 从开始菜单进行“Edit Configuration ...
- 【UVALive】4094 WonderTeam(神结论)
题目 传送门:QWQ 分析 好神的结论啊 看代码吧(Length只有85) 代码 顺手压了压代码 目前代码长度rk1 vjudge #include <iostream> ?:n ...
- leetcode561
public class Solution { public int ArrayPairSum(int[] nums) { var list = nums.OrderBy(x => x).ToL ...
- 33.使用默认的execAndWait拦截器
转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 当我们进行数据库查询等相关的操作时,如果服务器负荷过重可能不能及时把数据查询 ...