Java Doc for StringUtils.java in  » Report » datavision-1.1.0 » jimm » 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 » Report » datavision 1.1.0 » jimm.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jimm.util.StringUtils

StringUtils
public class StringUtils (Code)
Globally available utility classes, mostly for string manipulation.
author:
   Jim Menard, jimm@io.com


Field Summary
final protected static  intDEFAULT_MAX_MESSAGE_WIDTH
    


Method Summary
public static  StringescapeHTML(String str)
     Returns a string with HTML special characters replaced by their entity equivalents.
public static  StringescapeXML(String str)
     Returns a string with XML special characters replaced by their entity equivalents.
public static  intfindBreakAfter(String line, int start)
     Returns the index of the first whitespace character or '-' in line that is at or after start.
public static  intfindBreakBefore(String line, int start)
     Returns the index of the first whitespace character or '-' in line that is at or before start.
public static  Stringjoin(Collection c, String joinWith)
     Returns a string consisting of all members of a collection separated by the specified string.
public static  StringnewlinesToXHTMLBreaks(String str)
     Returns a new string where all newlines ("\n", "\r", or "\r\n") have been replaced by "\n" plus XHTML break tags ("\n<br />").
public static  StringnullOrTrimmed(String str)
     Returns str with leading and trailing spaces trimmed or, if str is null, returns null.
public static  StringreplaceDelimited(String start, String end, Replacer r, String s)
     Returns a new string with all strings delimited by start and end replaced by whatever is generated by the Replacer r.
public static  StringreplaceDelimited(String exceptAfter, String start, String end, Replacer r, String s)
     Returns a new string with all strings delimited by start and end (but not immediately preceeded by exceptAfter) replaced by whatever is generated by the Replacer r.
public static  Listsplit(String str, String delim)
     Returns a list of substrings created by splitting the given string at the given delimiter.
public static  ListsplitIntoLines(String str)
     Returns an array of strings, one for each line in the string.
public static  voidsplitUp(StringBuffer buf, String str)
     Appends a string to a string buffer, adding extra newlines so the message is not too wide.
public static  voidsplitUp(StringBuffer buf, String str, int maxWidth)
     Appends a string to a string buffer, adding extra newlines so the message is not too wide.
public static  StringunescapeXML(String str)
     Returns a string with XML entities replaced by their normal characters.
public static  Listwrap(String str, FontMetrics fm, int maxWidth)
     Returns an array of strings, one for each line in the string after it has been wrapped to fit lines of maxWidth.
public static  voidwrapLineInto(String line, List list, FontMetrics fm, int maxWidth)
     Given a line of text and font metrics information, wrap the line and add the new line(s) to list.

Field Detail
DEFAULT_MAX_MESSAGE_WIDTH
final protected static int DEFAULT_MAX_MESSAGE_WIDTH(Code)





Method Detail
escapeHTML
public static String escapeHTML(String str)(Code)
Returns a string with HTML special characters replaced by their entity equivalents.
Parameters:
  str - the string to escape a new string without HTML special characters



escapeXML
public static String escapeXML(String str)(Code)
Returns a string with XML special characters replaced by their entity equivalents.
Parameters:
  str - the string to escape a new string without XML special characters



findBreakAfter
public static int findBreakAfter(String line, int start)(Code)
Returns the index of the first whitespace character or '-' in line that is at or after start. Returns -1 if no such character is found.
Parameters:
  line - a string
Parameters:
  start - where to star looking



findBreakBefore
public static int findBreakBefore(String line, int start)(Code)
Returns the index of the first whitespace character or '-' in line that is at or before start. Returns -1 if no such character is found.
Parameters:
  line - a string
Parameters:
  start - where to star looking



join
public static String join(Collection c, String joinWith)(Code)
Returns a string consisting of all members of a collection separated by the specified string. The toString method of each collection member is called to convert it to a string.
Parameters:
  c - a collection of objects
Parameters:
  joinWith - the string that will separate each member of the collection



newlinesToXHTMLBreaks
public static String newlinesToXHTMLBreaks(String str)(Code)
Returns a new string where all newlines ("\n", "\r", or "\r\n") have been replaced by "\n" plus XHTML break tags ("\n<br />").

We don't call splitIntoLines because that method does not tell us if the string ended with a newline or not.
Parameters:
  str - any string a new string with all newlines replaced by"\n<br />"




nullOrTrimmed
public static String nullOrTrimmed(String str)(Code)
Returns str with leading and trailing spaces trimmed or, if str is null, returns null. str trimmed or null



replaceDelimited
public static String replaceDelimited(String start, String end, Replacer r, String s)(Code)
Returns a new string with all strings delimited by start and end replaced by whatever is generated by the Replacer r. The delimiters themselves are not part of the returned string.

If the Replacer ever returns null, we return null.
Parameters:
  start - the delimiter start (for example, "{@")
Parameters:
  end - the delimiter end (for example, "}")
Parameters:
  r - the replacer; takes the text between start andend and returns the replacement text
Parameters:
  s - the string we're munging a new string munged by the replacer, or null ifthe replacer ever returns null




replaceDelimited
public static String replaceDelimited(String exceptAfter, String start, String end, Replacer r, String s)(Code)
Returns a new string with all strings delimited by start and end (but not immediately preceeded by exceptAfter) replaced by whatever is generated by the Replacer r. The delimiters themselves are not part of the returned string.

If the Replacer ever returns null, we return null.
Parameters:
  exceptAfter - ignore start if it appears immediatelyafter this string; may be null
Parameters:
  start - the delimiter start (for example, "{@")
Parameters:
  end - the delimiter end (for example, "}")
Parameters:
  r - the replacer; takes the text between start andend and returns the replacement text
Parameters:
  s - the string we're munging a new string munged by the replacer, or null ifthe replacer ever returns null




split
public static List split(String str, String delim)(Code)
Returns a list of substrings created by splitting the given string at the given delimiter. The return value will be null if the string is null, else it will be a non-empty list of strings. If delim is null or is not found in the string, the list will contain one element: the original string.

This isn't the same thing as using a tokenizer. delim is a literal string, not a set of characters any of which may be a delimiter.
Parameters:
  str - the string we're splitting
Parameters:
  delim - the delimter string




splitIntoLines
public static List splitIntoLines(String str)(Code)
Returns an array of strings, one for each line in the string. Lines end with any of cr, lf, or cr lf. A line ending at the end of the string will not output a further, empty string.

This code assumes str is not null.
Parameters:
  str - the string to split a non-empty list of strings




splitUp
public static void splitUp(StringBuffer buf, String str)(Code)
Appends a string to a string buffer, adding extra newlines so the message is not too wide. Max width is not guaranteed; if there is no space in a line before DEFAULT_MAX_MESSAGE_WIDTH then the next one after it will be used insetead. Each line will be trimmed before and after it's added, so some whitespace may be goofed up. This is used for error message wrapping, so it's not critical that whitespace be preserved.

TODO Looks for space, not all whitespace. This should probably change.
Parameters:
  buf - the string buffer
Parameters:
  str - the string




splitUp
public static void splitUp(StringBuffer buf, String str, int maxWidth)(Code)
Appends a string to a string buffer, adding extra newlines so the message is not too wide. Max width is not guaranteed; if there is no space in a line before maxWidth then the next one after it will be used instead. Each line will be trimmed before and after it's added, so some whitespace may be goofed up. This is used for error message wrapping, so it's not critical that whitespace be preserved.

TODO Looks for space, not all whitespace. This should probably change.
Parameters:
  buf - the string buffer
Parameters:
  str - the string
Parameters:
  maxWidth - maximum number of chars in each line




unescapeXML
public static String unescapeXML(String str)(Code)
Returns a string with XML entities replaced by their normal characters.
Parameters:
  str - the string to un-escape a new normal string



wrap
public static List wrap(String str, FontMetrics fm, int maxWidth)(Code)
Returns an array of strings, one for each line in the string after it has been wrapped to fit lines of maxWidth. Lines end with any of cr, lf, or cr lf. A line ending at the end of the string will not output a further, empty string.

This code assumes str is not null.
Parameters:
  str - the string to split
Parameters:
  fm - needed for string width calculations
Parameters:
  maxWidth - the max line width, in points a non-empty list of strings




wrapLineInto
public static void wrapLineInto(String line, List list, FontMetrics fm, int maxWidth)(Code)
Given a line of text and font metrics information, wrap the line and add the new line(s) to list.
Parameters:
  line - a line of text
Parameters:
  list - an output list of strings
Parameters:
  fm - font metrics
Parameters:
  maxWidth - maximum width of the line(s)



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.