spring 工具類簡介01

spring給咱們提供了不少的工具類, 應該在咱們的平常工做中很好的利用起來. 它能夠大大的減輕咱們的平時編寫代碼的長度. 因咱們只想用spring的工具類, 

而不想把一個大大的spring工程給引入進來. 下面是我從spring3.0.5裏抽取出來的工具類. 

在最後給出我提取出來的spring代碼打成的jar包 

spring的裏的resouce的概念, 在咱們處理io時頗有用. 具體信息請參考spring手冊 

內置的resouce類型 

  1. UrlResource
  2. ClassPathResource
  3. FileSystemResource
  4. ServletContextResource
  5. InputStreamResource
  6. ByteArrayResource
  7. EncodedResource 也就是Resource加上encoding, 能夠認爲是有編碼的資源
  8. VfsResource(在jboss裏常常用到, 相應還有 工具類 VfsUtils)
  9. org.springframework.util.xml.ResourceUtils 用於處理表達資源字符串前綴描述資源的工具. 如: "classpath:". 
    有 getURL, getFile, isFileURL, isJarURL, extractJarFileURL 


工具類 

  1. org.springframework.core.annotation.AnnotationUtils   處理註解
  2. org.springframework.core.io.support.PathMatchingResourcePatternResolver  用 於處理 ant 匹配風格(com/*.jsp, com/**/*.jsp),找出全部的資源, 結合上面的resource的概念一塊兒使用,對於遍歷文件頗有用. 具體請詳細查看javadoc
  3. org.springframework.core.io.support.PropertiesLoaderUtils 加載Properties資源工具類,和Resource結合
  4. org.springframework.core.BridgeMethodResolver  橋接方法分析器.  關於橋接方法請參考: http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.4.5
  5. org.springframework.core.GenericTypeResolver  範型分析器, 在用於對範型方法, 參數分析.
  6. org.springframework.core.NestedExceptionUtils


xml工具 
  1. org.springframework.util.xml.AbstractStaxContentHandler
  2. org.springframework.util.xml.AbstractStaxXMLReader
  3. org.springframework.util.xml.AbstractXMLReader
  4. org.springframework.util.xml.AbstractXMLStreamReader
  5. org.springframework.util.xml.DomUtils
  6. org.springframework.util.xml.SimpleNamespaceContext
  7. org.springframework.util.xml.SimpleSaxErrorHandler
  8. org.springframework.util.xml.SimpleTransformErrorListener
  9. org.springframework.util.xml.StaxUtils
  10. org.springframework.util.xml.TransformerUtils



其它工具集 
  1. org.springframework.util.xml.AntPathMatcherant風格的處理
  2. org.springframework.util.xml.AntPathStringMatcher
  3. org.springframework.util.xml.Assert斷言,在咱們的參數判斷時應該常常用
  4. org.springframework.util.xml.CachingMapDecorator
  5. org.springframework.util.xml.ClassUtils用於Class的處理
  6. org.springframework.util.xml.CollectionUtils用於處理集合的工具
  7. org.springframework.util.xml.CommonsLogWriter
  8. org.springframework.util.xml.CompositeIterator
  9. org.springframework.util.xml.ConcurrencyThrottleSupport
  10. org.springframework.util.xml.CustomizableThreadCreator
  11. org.springframework.util.xml.DefaultPropertiesPersister
  12. org.springframework.util.xml.DigestUtils摘要處理, 這裏有用於md5處理信息的
  13. org.springframework.util.xml.FileCopyUtils文件的拷貝處理, 結合Resource的概念一塊兒來處理, 真的是很方便
  14. org.springframework.util.xml.FileSystemUtils
  15. org.springframework.util.xml.LinkedCaseInsensitiveMap
    key值不區分大小寫的LinkedMap
  16. org.springframework.util.xml.LinkedMultiValueMap一個key能夠存放多個值的LinkedMap
  17. org.springframework.util.xml.Log4jConfigurer一個log4j的啓動加載指定配製文件的工具類
  18. org.springframework.util.xml.NumberUtils處理數字的工具類, 有parseNumber 能夠把字符串處理成咱們指定的數字格式, 還支持format格式, convertNumberToTargetClass 能夠實現Number類型的轉化. 
  19. org.springframework.util.xml.ObjectUtils有不少處理null object的方法. 如nullSafeHashCode, nullSafeEquals, isArray, containsElement, addObjectToArray, 等有用的方法
  20. org.springframework.util.xml.PatternMatchUtilsspring裏用於處理簡單的匹配. 如 Spring's typical "xxx*", "*xxx" and "*xxx*" pattern styles
  21. org.springframework.util.xml.PropertyPlaceholderHelper用於處理佔位符的替換
  22. org.springframework.util.xml.ReflectionUtils反映經常使用工具方法. 有 findField, setField, getField, findMethod, invokeMethod等有用的方法
  23. org.springframework.util.xml.SerializationUtils用於java的序列化與反序列化. serialize與deserialize方法
  24. org.springframework.util.xml.StopWatch一個很好的用於記錄執行時間的工具類, 且能夠用於任務分階段的測試時間. 最後支持一個很好看的打印格式. 這個類應該常常用
  25. org.springframework.util.xml.StringUtils
  26. org.springframework.util.xml.SystemPropertyUtils
  27. org.springframework.util.xml.TypeUtils用於類型相容的判斷. isAssignable
  28. org.springframework.util.xml.WeakReferenceMonitor弱引用的監控 


和web相關的工具 

  1. org.springframework.web.util.CookieGenerator
  2. org.springframework.web.util.HtmlCharacterEntityDecoder
  3. org.springframework.web.util.HtmlCharacterEntityReferences
  4. org.springframework.web.util.HtmlUtils
  5. org.springframework.web.util.HttpUrlTemplate
    這個類用於用字符串模板構建url, 它會自動處理url裏的漢字及其它相關的編碼. 在讀取別人提供的url資源時, 應該常常用 
    String url = "http://localhost/myapp/{name}/{id}"
  6. org.springframework.web.util.JavaScriptUtils
  7. org.springframework.web.util.Log4jConfigListener
    用listener的方式來配製log4j在web環境下的初始化
  8. org.springframework.web.util.UriTemplate
  9. org.springframework.web.util.UriUtils處理uri裏特殊字符的編碼
  10. org.springframework.web.util.WebUtils
  11. org.springframework.web.util.
相關文章
相關標籤/搜索