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组件提供了一整套用于实现对象池化的框架,以及若干种各具特色的对象池实现,可以 ...
随机推荐
- centOS上安装MySQL5.7
在centos上安装mysql,前提得有sudo的权限.没有的话先去跟管理员申请一个. STEP 1 - 安装MySQL 首先打开浏览器访问下 https://dev.mysql.com/downlo ...
- ARM汇编返回指令
[ 588.756226] task: ffff000008a22f80 task.stack: ffff000008a10000 [ 588.762153] PC is at vb2_buffer_ ...
- streamsets 错误记录处理
我们可以在stage 级别,或者piepline 级别进行error 处理配置 pipeline的错误记录处理 discard(丢踢) send response to Origin pipeline ...
- HDU1735 字数统计
版权声明:长风原创 https://blog.csdn.net/u012846486/article/details/28011667 字数统计 Time Limit: 1000/2000 MS (J ...
- HDU 3179 二叉搜索树(树的建立)
二叉搜索树 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- 设置修改CentOS系统时间和时区
1.yum install ntp,安装时间服务ntpdate time-a.nist.gov && hwclock -w (跟网络同步时间,并且写入主板BIos) 2.chkconf ...
- ubuntu sudo apt-get update与sudo apt-get upgrade的作用及区别,以及python pip的安装
在UBUNTU下,我们维护一个源列表,源列表里面都是一些网址信息,这每一条网址就是一个源,这个地址指向的数据标识着这台源服务器上有哪些软件可以安装使用.编辑源命令: sudo gedit /etc/a ...
- 并发服务器和HTTP协议
单进程服务器 1. 完成一个简单的TCP服务器 from socket import * serSocket = socket(AF_INET, SOCK_STREAM) # 重复使用绑定的信息 se ...
- [代码][deque容器练习]打分案例
案例要求: //打分案例(sort算法排序)//创建5个选手(姓名.得分),十个评委对五个选手进行打分//得分规则:去除最高分,去除最低分,取出平均分//按得分对5个选手进行排名 源代码: //打分案 ...
- python类静态变量
python的类静态变量直接定义在类中即可,不需要修饰符,如: 1 class Test: stc_attr = 1 def __init__(self,attr1,attr2): self.attr ...