Java Doc for StringHelper.java in  » J2EE » Jaffa » org » jaffa » 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 » Jaffa » org.jaffa.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jaffa.util.StringHelper

StringHelper
public class StringHelper (Code)
Utility Class for Common String Manipulation routines.
author:
   PaulE
version:
   1.0

Inner Class :public static class Line



Method Summary
public static  StringaddCommentWithStamp(String originalComment, String additionalComment, boolean lifo, String userId)
     This is a helper for combining old and additional comments. A stamp containing the userId and current time will be inserted before the additional comment. The additional comment will be inserted before the old comment if 'lifo' is true, otherwise it'll be appended. If the input userId is null, then the userId will be obtained from the SecurityManager.
Parameters:
  originalComment - The original comment.
Parameters:
  additionalComment - The additional comment.
Parameters:
  lifo - This determines if the additional comment is inserted before or appended after the old comment.
Parameters:
  userId - The userId.
public static  StringaddHTMLLineBreak(String s, int lineLimit)
     This method will add HTML line breaks in the input String at the specified limits.
public static  StringconvertFromHTML(String s)
     Convert a string that has XML (and HTML) entities in it, into a regular string It will convert the following...
public static  StringconvertToHTML(String s)
     Convert a regular string into an XML (and HTML) based string It will convert the following...
public static  ArrayListconvertToList(String commaList)
    
public static  StringfindEol(String input)
     Returns the EOL character for the input String, if any. The EOL character can be '\r', '\n' or '\r\n'. the EOL character for the input String.
public static  StringformatDescription(Object field, String layout, String domainClassWithPackage, String domainField, boolean toHtml)
     This method is invoked in cases where 'description' field is appended to a 'code' field. This method formats the input dexcriptionField based on the passed layout. The layout can be passed directly or can be determined from the parameters domainClassWithPackage and domainField, through the appropriate FieldMetaData object. It then truncates the formatted String to the input limit.
public static  StringformatDescription(Object field, String layout, String domainClassWithPackage, String domainField, boolean toHtml, String beginMarker, String endMarker)
     This method is invoked in cases where 'description' field is appended to a 'code' field. This method formats the input dexcriptionField based on the passed layout. The layout can be passed directly or can be determined from the parameters domainClassWithPackage and domainField, through the appropriate FieldMetaData object. It then truncates the formatted String to the input limit.
public static  StringformatDescription(Object field, String layout, String domainClassWithPackage, String domainField, boolean toHtml, String beginMarker, String endMarker, int limit, String truncateIndicator)
     This method is invoked in cases where 'description' field is appended to a 'code' field. This method formats the input dexcriptionField based on the passed layout. The layout can be passed directly or can be determined from the parameters domainClassWithPackage and domainField, through the appropriate FieldMetaData object. It then truncates the formatted String to the input limit.
public static  StringgetDefaultDescriptionBeginMarker()
     Returns the default String used in the formatDescription() methods placed at the beginning.
public static  StringgetDefaultDescriptionEndMarker()
     Returns the default String used in the formatDescription() methods placed at the end.
public static  StringgetLower(String input)
    
public static  StringgetLower1(String input)
    
public static  StringgetSpace(String input)
    
public static  StringgetStatic(String input)
    
public static  StringgetString(Reader reader)
     This returns the contents of a Reader as a String.
Parameters:
  reader - the input source.
throws:
  IOException - if any error occurs in reading the contents of the input.
public static  StringBuffergetStringBuffer(Reader reader)
     This returns the contents of a Reader in a StringBuffer.
Parameters:
  reader - the input source.
throws:
  IOException - if any error occurs in reading the contents of the input.
public static  StringgetUpper(String input)
    
public static  StringgetUpper1(String input)
    
public static  StringlinePad(String text, int indent)
    
public static  StringlinePad(String text, int indent, String indentWith)
    
public static  StringlinePad(String text, int indent, String indentWith, boolean supressFirst)
    
public static  voidmain(String[] args)
    
public static  Stringpad(int number)
    
public static  Stringpad(int number, int length)
    
public static  Stringpad(int number, int len, String padVal)
    
public static  String[]parseString(String s)
    
public static  String[]parseString(String s, String delim)
    
public static  LinereadLine(PushbackReader reader)
     Reads a line from the input reader. It'll return an instance of StringHelper.Line object, which has the contents and EOL of the line. The EOL character can be '\r', '\n' or '\r\n'. This method is used instead of the readLine() method of the BufferedReader, since there is no other way of finding out if the last line in a file ends with an EOL. This also has the added benefit of knowing the exact EOL character. A null will be returned if the EOF is reached. a StringHelper.Line object containing the line contents and the EOL character.
public static  Stringreplace(String source, String find, String replace)
    
public static  Stringreplicate(String text, int count)
    



Method Detail
addCommentWithStamp
public static String addCommentWithStamp(String originalComment, String additionalComment, boolean lifo, String userId)(Code)
This is a helper for combining old and additional comments. A stamp containing the userId and current time will be inserted before the additional comment. The additional comment will be inserted before the old comment if 'lifo' is true, otherwise it'll be appended. If the input userId is null, then the userId will be obtained from the SecurityManager.
Parameters:
  originalComment - The original comment.
Parameters:
  additionalComment - The additional comment.
Parameters:
  lifo - This determines if the additional comment is inserted before or appended after the old comment.
Parameters:
  userId - The userId. The combination of the old comment and the additional comment.



addHTMLLineBreak
public static String addHTMLLineBreak(String s, int lineLimit)(Code)
This method will add HTML line breaks in the input String at the specified limits. This is useful for wrapping long lines of text.
Parameters:
  s - String to modify
Parameters:
  lineLimit - The interval at which the line breaks will be added.



convertFromHTML
public static String convertFromHTML(String s)(Code)
Convert a string that has XML (and HTML) entities in it, into a regular string It will convert the following... & to & < to < > to > ' to ' " to "
Parameters:
  s - String to convert converted string



convertToHTML
public static String convertToHTML(String s)(Code)
Convert a regular string into an XML (and HTML) based string It will convert the following... & to & < to < > to > ' to ' " to "
Parameters:
  s - String to convert converted string



convertToList
public static ArrayList convertToList(String commaList)(Code)
Converts a comma delimmitered string into an array of strings
Parameters:
  commaList - Source string List of strings



findEol
public static String findEol(String input)(Code)
Returns the EOL character for the input String, if any. The EOL character can be '\r', '\n' or '\r\n'. the EOL character for the input String. A null string will be returned in case no EOL charcater is found.



formatDescription
public static String formatDescription(Object field, String layout, String domainClassWithPackage, String domainField, boolean toHtml)(Code)
This method is invoked in cases where 'description' field is appended to a 'code' field. This method formats the input dexcriptionField based on the passed layout. The layout can be passed directly or can be determined from the parameters domainClassWithPackage and domainField, through the appropriate FieldMetaData object. It then truncates the formatted String to the input limit. If the String is truncated, then the truncateIndicator will be appended. Finally the String will be packaged between the beginMarker and endMarker. If the toHtml flag is true, then the result will made HTML safe. This method will use the default values beginMarker=' (', endMarker=')', limit=25, truncateIndicator='...'
Parameters:
  field - The description of the field.
Parameters:
  layout - The layout, if any to be used for formatting
Parameters:
  domainClassWithPackage - The domainClass to determine the FieldMetaData object, to get a handle on the layout.
Parameters:
  domainField - The domainField to determine the FieldMetaData object, to get a handle on the layout.
Parameters:
  toHtml - if true, then the output will be converted to HTML. the formatted string packed between the markers. An empty String will be returned, in case the input field is null.



formatDescription
public static String formatDescription(Object field, String layout, String domainClassWithPackage, String domainField, boolean toHtml, String beginMarker, String endMarker)(Code)
This method is invoked in cases where 'description' field is appended to a 'code' field. This method formats the input dexcriptionField based on the passed layout. The layout can be passed directly or can be determined from the parameters domainClassWithPackage and domainField, through the appropriate FieldMetaData object. It then truncates the formatted String to the input limit. If the String is truncated, then the truncateIndicator will be appended. Finally the String will be packaged between the beginMarker and endMarker. If the toHtml flag is true, then the result will made HTML safe. This method will use the default values limit=25, truncateIndicator='...'
Parameters:
  field - The description of the field.
Parameters:
  layout - The layout, if any to be used for formatting
Parameters:
  domainClassWithPackage - The domainClass to determine the FieldMetaData object, to get a handle on the layout.
Parameters:
  domainField - The domainField to determine the FieldMetaData object, to get a handle on the layout.
Parameters:
  toHtml - if true, then the output will be converted to HTML.
Parameters:
  beginMarker - The marker at the start of the output. Default is ' ('
Parameters:
  endMarker - The marker at the end of the output. Default is ')' the formatted string packed between the markers. An empty String will be returned, in case the input field is null.



formatDescription
public static String formatDescription(Object field, String layout, String domainClassWithPackage, String domainField, boolean toHtml, String beginMarker, String endMarker, int limit, String truncateIndicator)(Code)
This method is invoked in cases where 'description' field is appended to a 'code' field. This method formats the input dexcriptionField based on the passed layout. The layout can be passed directly or can be determined from the parameters domainClassWithPackage and domainField, through the appropriate FieldMetaData object. It then truncates the formatted String to the input limit. If the String is truncated, then the truncateIndicator will be appended. No truncation will be performed if the limit <= 0 Finally the String will be packaged between the beginMarker and endMarker. If the toHtml flag is true, then the result will made HTML safe.
Parameters:
  field - The description of the field.
Parameters:
  layout - The layout, if any to be used for formatting
Parameters:
  domainClassWithPackage - The domainClass to determine the FieldMetaData object, to get a handle on the layout.
Parameters:
  domainField - The domainField to determine the FieldMetaData object, to get a handle on the layout.
Parameters:
  toHtml - if true, then the output will be converted to HTML.
Parameters:
  beginMarker - The marker at the start of the output. Default is ' ('
Parameters:
  endMarker - The marker at the end of the output. Default is ')'
Parameters:
  limit - The limit for the formatted decription. Default is 25.
Parameters:
  truncateIndicator - The string to append tot he formatted description, if exceeds the limit and is truncated. the formatted string packed between the markers. An empty String will be returned, in case the input field is null.



getDefaultDescriptionBeginMarker
public static String getDefaultDescriptionBeginMarker()(Code)
Returns the default String used in the formatDescription() methods placed at the beginning. the default String used in the formatDescription() methods placed at the beginning.



getDefaultDescriptionEndMarker
public static String getDefaultDescriptionEndMarker()(Code)
Returns the default String used in the formatDescription() methods placed at the end. the default String used in the formatDescription() methods placed at the end.



getLower
public static String getLower(String input)(Code)
A convenience method to translate the input String to LowerCase
Parameters:
  input - the string to process the modified string



getLower1
public static String getLower1(String input)(Code)
A convenience method to translate the input String's 1st character to LowerCase, the rest of the string is left the same
Parameters:
  input - the string to process the modified string



getSpace
public static String getSpace(String input)(Code)
A convenience method to translate the input String to words separated by spaces For eg: "abcDef" would be translated to "abc Def"
Parameters:
  input - the string to process the modified string



getStatic
public static String getStatic(String input)(Code)
A convenience method to translate the input String to all UpperCase with underscores separating the words For eg: "abcDef" would be translated to "ABC_DEF"
Parameters:
  input - the string to process the modified string



getString
public static String getString(Reader reader) throws IOException(Code)
This returns the contents of a Reader as a String.
Parameters:
  reader - the input source.
throws:
  IOException - if any error occurs in reading the contents of the input. a String with the contents of the source. A null is returned if the input is null.



getStringBuffer
public static StringBuffer getStringBuffer(Reader reader) throws IOException(Code)
This returns the contents of a Reader in a StringBuffer.
Parameters:
  reader - the input source.
throws:
  IOException - if any error occurs in reading the contents of the input. a StringBuffer with the contents of the source. A null is returned if the input is null.



getUpper
public static String getUpper(String input)(Code)
A convenience method to translate the input String to UpperCase
Parameters:
  input - the string to process the modified string



getUpper1
public static String getUpper1(String input)(Code)
A convenience method to translate the input String's 1st character to UpperCase, the rest of the string is left the same
Parameters:
  input - the string to process the modified string



linePad
public static String linePad(String text, int indent)(Code)
Pad each new line of the supplied string with the specified number of spaces
Parameters:
  text - String to pad
Parameters:
  indent - number of spaces to indent by the indented string



linePad
public static String linePad(String text, int indent, String indentWith)(Code)
Pad each new line of the supplied string with the specified number of 'indent Strings'
Parameters:
  text - String to pad
Parameters:
  indent - number of spaces to indent by
Parameters:
  indentWith - String to use for indenting the indented string



linePad
public static String linePad(String text, int indent, String indentWith, boolean supressFirst)(Code)
Pad each new line of the supplied string with the specified number of the indent string, but allows the suppression of the first line from indentation
Parameters:
  text - String to pad
Parameters:
  indent - number of spaces to indent by
Parameters:
  indentWith - String to use for indenting
Parameters:
  supressFirst - true, if the first line should be skipped when indenting the indented string



main
public static void main(String[] args)(Code)
Test Routine
Parameters:
  args - no args required



pad
public static String pad(int number)(Code)
Pad a number to take up at least 2 characters
Parameters:
  number - the number to pad string representation of number padded to 2 characters



pad
public static String pad(int number, int length)(Code)
Pad a number to take up a specified length
Parameters:
  number - the number to pad
Parameters:
  length - length of resulting string string representation of number padded to specified length



pad
public static String pad(int number, int len, String padVal)(Code)
Pad a number to take up a specified length
Parameters:
  number - the number to pad
Parameters:
  len - length of resulting string
Parameters:
  padVal - Character to be used for Padding string representation of number padded to specified length



parseString
public static String[] parseString(String s)(Code)
Tokenize the Input String with the default tokenizer (whitespace)
Parameters:
  s - String to tokenize string[] representation tokenized String



parseString
public static String[] parseString(String s, String delim)(Code)
Tokenize the Input String with the given delim
Parameters:
  s - String to tokenize
Parameters:
  delim - Deliminator to use string[] representation tokenized String



readLine
public static Line readLine(PushbackReader reader) throws IOException(Code)
Reads a line from the input reader. It'll return an instance of StringHelper.Line object, which has the contents and EOL of the line. The EOL character can be '\r', '\n' or '\r\n'. This method is used instead of the readLine() method of the BufferedReader, since there is no other way of finding out if the last line in a file ends with an EOL. This also has the added benefit of knowing the exact EOL character. A null will be returned if the EOF is reached. a StringHelper.Line object containing the line contents and the EOL character. A null is returned if the end of file is reached.
throws:
  IOException - if any IO error occurs.



replace
public static String replace(String source, String find, String replace)(Code)
Basic find and replace on a string, it will replace ALL occurences of the string
Parameters:
  source - original string
Parameters:
  find - string to search for
Parameters:
  replace - string to replace found strings with resultant string from the replace



replicate
public static String replicate(String text, int count)(Code)
Produce a string by replicating the specific string the specified number of times
Parameters:
  text - String to replicate
Parameters:
  count - number of times to replicate string final replicated string



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.