Java Doc for StringUtils.java in  » J2EE » panther » org » lateralnz » common » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » panther » org.lateralnz.common.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.lateralnz.common.util.StringUtils

StringUtils
final public class StringUtils implements Constants(Code)
common string utility functions
author:
   J R Briggs




Method Summary
final public static  intcountOccurrences(String s, char c)
    
final public static  intcountOccurrences(StringBuffer sb, char c)
    
final public static  Stringdegzip(byte[] b)
    
final public static  Stringescape(String s)
    
final public static  ListfindRegex(String s, String pattern)
    
final public static  Stringformat(String pattern, Object[] arguments)
    
final public static  Stringformat(String pattern, String argument)
    
final public static  StringfromArray(String[] s, String delim)
    
final public static  StringfromArray(String[] s, String delim, int start, int len)
    
final public static  StringfromList(List l, String delim)
    
final public static  StringfromMap(Map map, char delim)
     create a string based upon the contents of a map.
final public static  StringgetFromDelimitedString(String s, String delim, int index)
    
final public static  PatterngetPattern(String pattern)
    
public static  StringgetRandomString(int len)
    
final public static  StringgetTagValue(String s, String tagStart, String tagEnd)
     given a string and the start and end of a tag return the contents of the tag.
final public static  byte[]gzip(String s)
    
final public static  booleanisEmpty(String s)
    
final public static  booleanisEmpty(Object o)
    
final public static  booleanisEqual(String s1, String s2)
    
final public static  StringisNull(String s, String replacement)
    
final public static  booleanisNumeric(String s)
    
final public static  Stringlpad(String text, char pad, int length)
    
final public static  booleanmatches(String s, String pattern)
    
final public static  StringreadFrom(Reader r)
    
final public static  StringreadFrom(Reader r, int size)
    
final public static  StringreadFromFile(String filename)
    
final public static  Stringremove(String s, String chars)
     remove all occurences of a list of characters from a string.
final public static  voidreplace(StringBuffer sb, String oldstr, String newstr)
    
final public static  Stringreplace(String s, String oldstr, String newstr)
    
final public static  StringreplaceChars(String s, String chars, char newChar)
    
final public static  StringreplaceTag(String s, String tagStart, String tagEnd, String replace)
     replace all references to a 'tag' within a string.
final public static  Stringrpad(String text, char pad, int length)
    
final public static  ListsplitRegex(String s, String pattern)
    
final public static  Stringstrip(String s, String chars)
    
final public static  StringstripLTSpaces(String s)
    
final public static  String[]toArray(String s, String delim)
    
final public static  String[]toArray(String s, String delim, boolean returnDelims)
    
final public static  StringtoDirectory(String filename)
     makes sure that a directory filename ends with the file separator.
final public static  StringtoHTML(String s)
    
final public static  StringtoHTML(String s, boolean includeBR)
     convert a string into an 'HTML-ready' string, handling special characters.
final public static  StringtoHex(byte b)
    
final public static  StringtoHex(byte[] b)
    
final public static  ListtoList(String s, String delim, List list)
    
final public static  ListtoList(String s, String delim)
    
final public static  StringtoMD5Digest(String s)
    
final public static  MaptoMap(String s, String delim)
     turn a string into a map of param=value objects based upon a delimiter.
final public static  voidtoMap(Map m, String s, String delim)
    
final public static  StringtoSHADigest(String s)
    
final public static  Stringunencode(String s)
    
final public static  Stringunescape(String s)
    



Method Detail
countOccurrences
final public static int countOccurrences(String s, char c)(Code)
count the occurrences of a character in a string



countOccurrences
final public static int countOccurrences(StringBuffer sb, char c)(Code)



degzip
final public static String degzip(byte[] b) throws IOException(Code)



escape
final public static String escape(String s)(Code)
escape a string



findRegex
final public static List findRegex(String s, String pattern)(Code)
return a list of regular expression groups given a string and a regex grouping pattern



format
final public static String format(String pattern, Object[] arguments)(Code)
a quick and dirty wrapper over MessageFormat.format, so we don't need to import it into JSPs as well as org.lateralnz.util.*



format
final public static String format(String pattern, String argument)(Code)
a wrapper for MessageFormat.format that takes a single argument rather than an array



fromArray
final public static String fromArray(String[] s, String delim)(Code)



fromArray
final public static String fromArray(String[] s, String delim, int start, int len)(Code)
turn an array of strings into a single delimited string
Parameters:
  s - the array of strings to use
Parameters:
  delim - the delimiter to use between each value
Parameters:
  start - the start position of the array
Parameters:
  len - the number of elements to use from the array



fromList
final public static String fromList(List l, String delim)(Code)
turn a list of strings into a single delimited string



fromMap
final public static String fromMap(Map map, char delim)(Code)
create a string based upon the contents of a map. The string will be constructed as key=value[DELIM]key=value[DELIM]..., where [DELIM] is specified in the call to this method. For example: fromMap(m, ',') would return: key1=value1,key2=value2,key3=value3,etc



getFromDelimitedString
final public static String getFromDelimitedString(String s, String delim, int index)(Code)
parse a delimited string returning the element at the specified index
Parameters:
  s - the string to parse
Parameters:
  delim - the delimiters
Parameters:
  index - the index value to return



getPattern
final public static Pattern getPattern(String pattern) throws PatternSyntaxException(Code)



getRandomString
public static String getRandomString(int len)(Code)
create a random string of a specified length



getTagValue
final public static String getTagValue(String s, String tagStart, String tagEnd)(Code)
given a string and the start and end of a tag return the contents of the tag. For example, given the string: "hello this <!-- is a test -->" and a tag start of "<!--" and a tag end of "-->", this method should return " is a test "



gzip
final public static byte[] gzip(String s) throws IOException(Code)



isEmpty
final public static boolean isEmpty(String s)(Code)
return true if a string is null or empty (in other words equals(\"\"))



isEmpty
final public static boolean isEmpty(Object o)(Code)
return true if an object is null, or it is a string and empty



isEqual
final public static boolean isEqual(String s1, String s2)(Code)
check for equality between two strings, taking nulls into account



isNull
final public static String isNull(String s, String replacement)(Code)
if a string is null, then return the specified replacement
Parameters:
  s - the string to check for null
Parameters:
  replacement - the string to return if s is null



isNumeric
final public static boolean isNumeric(String s)(Code)
Check if a string is numeric (digit chars only)



lpad
final public static String lpad(String text, char pad, int length)(Code)
left pad a string with a certain character so that it equals the specified length



matches
final public static boolean matches(String s, String pattern) throws PatternSyntaxException(Code)
return true if a particular string matches the regular expression
Parameters:
  s - the string to check
Parameters:
  pattern - the regular expression to look for



readFrom
final public static String readFrom(Reader r)(Code)
read the contents of the specified reader



readFrom
final public static String readFrom(Reader r, int size)(Code)
read the contents of the specified reader up to the specified size



readFromFile
final public static String readFromFile(String filename)(Code)
read the contents of a file and return as a string



remove
final public static String remove(String s, String chars)(Code)
remove all occurences of a list of characters from a string. for example:
 remove("This is a test", " ");
 
should return "Thisisatest".
Parameters:
  s - the string to remove characters from
Parameters:
  chars - the list of characters to remove



replace
final public static void replace(StringBuffer sb, String oldstr, String newstr)(Code)
replace all references of a string in a stringbuffer with the contents of a replacement string



replace
final public static String replace(String s, String oldstr, String newstr)(Code)
replace all occurrences of a string with the contents of another string
Parameters:
  s - the string to search
Parameters:
  oldstr - the string pattern to look for
Parameters:
  newstr - the string pattern to replace with



replaceChars
final public static String replaceChars(String s, String chars, char newChar)(Code)



replaceTag
final public static String replaceTag(String s, String tagStart, String tagEnd, String replace)(Code)
replace all references to a 'tag' within a string. A tag is a section of text defined with a start string and and end string. For example:
 replaceTag("this is a test  blah blah", "", "");
 
Would be expected to return "this is a test blah blah"



rpad
final public static String rpad(String text, char pad, int length)(Code)
right pad a string with a character so that the length is the same as that specified by the length param



splitRegex
final public static List splitRegex(String s, String pattern) throws PatternSyntaxException(Code)
split a string based upon a regular expression pattern For example: splitRegex("a,b,c,d,e", ",") would return a list containing a, b, c, d, and e as the elements



strip
final public static String strip(String s, String chars)(Code)
strip all occurrences of characters in a string from a specified string
Parameters:
  s - the string to search
Parameters:
  chars - a string of characters to remove from s



stripLTSpaces
final public static String stripLTSpaces(String s)(Code)
strip leading a trailing spaces from a string based upon line delimiters



toArray
final public static String[] toArray(String s, String delim)(Code)
turn a string into an array of strings (delimiters are not returned as part of the array)
Parameters:
  s - the string to convert
Parameters:
  delim - the delimiters to use in conversion



toArray
final public static String[] toArray(String s, String delim, boolean returnDelims)(Code)
turn a string into a string array based upon a delimiter
Parameters:
  s - the string to convert
Parameters:
  delim - the delimiters to use in conversion
Parameters:
  returnDelimiters - if true, then delimiters are included in the array



toDirectory
final public static String toDirectory(String filename)(Code)
makes sure that a directory filename ends with the file separator. eg: /usr/local/lib becomes /usr/local/lib/



toHTML
final public static String toHTML(String s)(Code)
convert a string into an 'HTML-ready' string, handling special characters and newlines



toHTML
final public static String toHTML(String s, boolean includeBR)(Code)
convert a string into an 'HTML-ready' string, handling special characters. This will convert newlines to html breaks if specified



toHex
final public static String toHex(byte b)(Code)



toHex
final public static String toHex(byte[] b)(Code)



toList
final public static List toList(String s, String delim, List list)(Code)
chop a string up into tokens based upon the delimiter and add the tokens to a list



toList
final public static List toList(String s, String delim)(Code)
turn a string into a list based upon a delimiter



toMD5Digest
final public static String toMD5Digest(String s) throws Exception(Code)
return an MD5 digest of a specified string



toMap
final public static Map toMap(String s, String delim)(Code)
turn a string into a map of param=value objects based upon a delimiter. The string should be something like: "a=100,b=hello,c=a203" where the delimiter is obviously ","



toMap
final public static void toMap(Map m, String s, String delim)(Code)
turn a string into a map of param=value objects based upon a delimiter and using the specified map object for the result



toSHADigest
final public static String toSHADigest(String s) throws Exception(Code)



unencode
final public static String unencode(String s) throws NumberFormatException(Code)
unencode a string containing html escape codes (in the form &#...;)



unescape
final public static String unescape(String s)(Code)
take a string that contains escaped values \\n \\t \\r and returns it with the actual escape codes (\n, \t, \r)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.