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组件提供了一整套用于实现对象池化的框架,以及若干种各具特色的对象池实现,可以 ...
随机推荐
- 【转】pycharm的一些快捷键
最近在学着用GA来做游戏的自动化,然后有用到pycharm来做一些脚本的编辑和试调.然后在试调时进行多行注释一行一行来感觉有点儿麻烦,然后就想着pycharm有没有多行注释的快捷方式.. 然后在网上查 ...
- WinForm获取当前路径汇总
Winform获取应用程序的当前路径的方法集合汇总,值得收藏备用 具体如下, //获取当前进程的完整路径,包含文件名(进程名). string str = this.GetType().Assembl ...
- test20181024 nan
题意 nan 问题描述 我们有一个序列,现在他里面有三个数1,2,2.我们从第三个数开始考虑: 第三个数是2,所以我们在序列后面写2个3,变成1,2,2,3,3. 第四个数是3,所以我们在序列后面写3 ...
- Testng优势
选择Testng的理由: 1.可指定执行顺序, dependsOnMethods 属性来应对测试的依赖性问题. 2.·参数化1:轻轻松松从XML中得到参数 @BeforeClass public vo ...
- ringojs 基于jvm 的javascript 平台试用
ringojs 是一个基于jvm 的javascript 平台,支持commonjs 模块模式 安装 下载包配置环境变量,或者使用docker,测试使用docker dockerfile deb 包安 ...
- hibernate enum映射详解
hibernate enum映射详解 在这里介绍注解的形式,如果想要了解XML配置的方式,可以自行查找相关资料. 例如以下Entity @Entity @Table(name = "t_us ...
- Git核心概念
Git作为流行的分布式版本管理系统,用好它要理解下面几个核心的概念. 1.Git保寸的是文件完整快照,而不是差异变化或者文件补丁.每次提交若文件有变化则会指向上一个版本的指针而不重复生成副本. Git ...
- oracle之 RAC 11G ASM下控制文件多路复用
如果数据库仅有一组control file文件,需要添加一组或者多组,保证一组文件损坏或者丢失导致数据库宕机. -- 环境说明SQL> select * from v$version;BANNE ...
- 常见的加密和解密算法—MD5
一.MD5加密概述 Message Digest Algorithm MD5(中文名为消息摘要算法第五版)为计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护.该算法的文件号为RFC 13 ...
- rm 递归删除目录下某一类型文件
命令:find -name "*.js.map" | xargs rm -f 解释:find -name "*.js.map" 可以查到当前目录下(包括子目录, ...