Java Doc for TextUtil.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » 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 » Wiki Engine » JSPWiki » com.ecyrd.jspwiki 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ecyrd.jspwiki.TextUtil

TextUtil
final public class TextUtil (Code)
Contains a number of static utility methods.


Field Summary
final static  StringHEX_DIGITS
    
final public static  intPASSWORD_LENGTH
     Length of password.


Method Summary
public static  StringbeautifyString(String s)
     Adds spaces in suitable locations of the input string.
public static  StringbeautifyString(String s, String space)
     Adds spaces in suitable locations of the input string.
public static  intcountSections(String pagedata)
     Counts the number of sections (separated with "----") from the page.
Parameters:
  pagedata - The WikiText to parse.
public static  PropertiescreateProperties(String[] values)
     Creates a Properties object based on an array which contains alternatively a key and a value.
public static  StringgenerateRandomPassword()
     Generate a random String suitable for use as a temporary password.
public static  booleangetBooleanProperty(Properties props, String key, boolean defval)
     Gets a boolean property from a standard Properties list. Returns the default value, in case the key has not been set.

The possible values for the property are "true"/"false", "yes"/"no", or "on"/"off".

public static  intgetIntegerProperty(Properties props, String key, int defVal)
     Gets an integer-valued property from a standard Properties list.
public static  StringgetSection(String pagedata, int section)
     Gets the given section (separated with "----") from the page text. Note that the first section is always #1.
public static  StringgetStringProperty(Properties props, String key, String defval)
     Fetches a String property from the set of Properties.
public static  booleanisNumber(String s)
     Returns true, if the argument contains a number, otherwise false. In a quick test this is roughly the same speed as Integer.parseInt() if the argument is a number, and roughly ten times the speed, if the argument is NOT a number.
since:
   2.4
Parameters:
  s - String to check True, if s represents a number.
public static  booleanisPositive(String val)
     Returns true, if the string "val" denotes a positive string.
public static  Stringnative2Ascii(String s)
     Converts a string from the Unicode representation into something that can be embedded in a java properties file.
public static  StringnormalizePostData(String postData)
     Makes sure that the POSTed data is conforms to certain rules.
public static  intparseIntParameter(String value, int defvalue)
     Parses an integer parameter, returning a default value if the value is null or a non-number.
public static  StringrepeatString(String what, int times)
     A simple routine which just repeates the arguments.
public static  StringreplaceEntities(String src)
     Replaces the relevant entities inside the String. All & >, <, and " are replaced by their respective names.
since:
   1.6.1
Parameters:
  src - The source string.
final public static  StringreplaceString(String orig, String src, String dest)
     Replaces a string with an other string.
Parameters:
  orig - Original string.
public static  StringreplaceString(String orig, int start, int end, String text)
     Replaces a part of a string with a new String.
Parameters:
  start - Where in the original string the replacing should start.
Parameters:
  end - Where the replacing should end.
Parameters:
  orig - Original string.
public static  StringtoHexString(byte[] bytes)
     Generates a hexadecimal string from an array of bytes.
protected static  StringurlDecode(byte[] bytes, String encoding)
     URL encoder does not handle all characters correctly.
public static  StringurlDecode(String data, String encoding)
     Provides decoded version of string depending on encoding.
public static  StringurlDecodeUTF8(String utf8)
     As java.net.URLDecoder class, but for UTF-8 strings.
protected static  StringurlEncode(byte[] rs)
     java.net.URLEncoder.encode() method in JDK < 1.4 is buggy.
public static  StringurlEncode(String data, String encoding)
     Provides encoded version of string depending on encoding.
public static  StringurlEncodeUTF8(String text)
     As java.net.URLEncoder class, but this does it in UTF8 character set.

Field Detail
HEX_DIGITS
final static String HEX_DIGITS(Code)



PASSWORD_LENGTH
final public static int PASSWORD_LENGTH(Code)
Length of password. @see #generateRandomPassword()





Method Detail
beautifyString
public static String beautifyString(String s)(Code)
Adds spaces in suitable locations of the input string. This is used to transform a WikiName into a more readable format.
Parameters:
  s - String to be beautified. A beautified string.



beautifyString
public static String beautifyString(String s, String space)(Code)
Adds spaces in suitable locations of the input string. This is used to transform a WikiName into a more readable format.
Parameters:
  s - String to be beautified.
Parameters:
  space - Use this string for the space character. A beautified string.
since:
   2.1.127



countSections
public static int countSections(String pagedata)(Code)
Counts the number of sections (separated with "----") from the page.
Parameters:
  pagedata - The WikiText to parse. int Number of counted sections.
since:
   2.1.86.



createProperties
public static Properties createProperties(String[] values) throws IllegalArgumentException(Code)
Creates a Properties object based on an array which contains alternatively a key and a value. It is useful for generating default mappings. For example:
 String[] properties = { "jspwiki.property1", "value1",
 "jspwiki.property2", "value2 };
 Properties props = TextUtil.createPropertes( values );
 System.out.println( props.getProperty("jspwiki.property1") );
 
would output "value1".
Parameters:
  values - Alternating key and value pairs. Property object
See Also:   java.util.Properties
throws:
  IllegalArgumentException - if the property array is missinga value for a key.
since:
   2.2.



generateRandomPassword
public static String generateRandomPassword()(Code)
Generate a random String suitable for use as a temporary password. String suitable for use as a temporary password
since:
   2.4



getBooleanProperty
public static boolean getBooleanProperty(Properties props, String key, boolean defval)(Code)
Gets a boolean property from a standard Properties list. Returns the default value, in case the key has not been set.

The possible values for the property are "true"/"false", "yes"/"no", or "on"/"off". Any value not recognized is always defined as "false".
Parameters:
  props - A list of properties to search.
Parameters:
  key - The property key.
Parameters:
  defval - The default value to return. True, if the property "key" was set to "true", "on", or "yes".
since:
   2.0.11




getIntegerProperty
public static int getIntegerProperty(Properties props, String key, int defVal)(Code)
Gets an integer-valued property from a standard Properties list. If the value does not exist, or is a non-integer, returns defVal.
since:
   2.1.48.
Parameters:
  props - The property set to look through
Parameters:
  key - The key to look for
Parameters:
  defVal - If the property is not found or is a non-integer, returns this value. The property value as an integer (or defVal).



getSection
public static String getSection(String pagedata, int section) throws IllegalArgumentException(Code)
Gets the given section (separated with "----") from the page text. Note that the first section is always #1. If a page has no section markers, them there is only a single section, #1.
Parameters:
  pagedata - WikiText to parse.
Parameters:
  section - Which section to get. String The section.
throws:
  IllegalArgumentException - If the page does not contain this many sections.
since:
   2.1.86.



getStringProperty
public static String getStringProperty(Properties props, String key, String defval)(Code)
Fetches a String property from the set of Properties. This differs from Properties.getProperty() in a couple of key respects: First, property value is trim()med (so no extra whitespace back and front), and well, that's it.
Parameters:
  props - The Properties to search through
Parameters:
  key - The property key
Parameters:
  defval - A default value to return, if the property does not exist. The property value.
since:
   2.1.151



isNumber
public static boolean isNumber(String s)(Code)
Returns true, if the argument contains a number, otherwise false. In a quick test this is roughly the same speed as Integer.parseInt() if the argument is a number, and roughly ten times the speed, if the argument is NOT a number.
since:
   2.4
Parameters:
  s - String to check True, if s represents a number. False otherwise.



isPositive
public static boolean isPositive(String val)(Code)
Returns true, if the string "val" denotes a positive string. Allowed values are "yes", "on", and "true". Comparison is case-insignificant. Null values are safe.
Parameters:
  val - Value to check. True, if val is "true", "on", or "yes"; otherwise false.
since:
   2.0.26



native2Ascii
public static String native2Ascii(String s)(Code)
Converts a string from the Unicode representation into something that can be embedded in a java properties file. All references outside the ASCII range are replaced with \\uXXXX.
Parameters:
  s - The string to convert the ASCII string



normalizePostData
public static String normalizePostData(String postData)(Code)
Makes sure that the POSTed data is conforms to certain rules. These rules are:
  • The data always ends with a newline (some browsers, such as NS4.x series, does not send a newline at the end, which makes the diffs a bit strange sometimes.
  • The CR/LF/CRLF mess is normalized to plain CRLF.
The reason why we're using CRLF is that most browser already return CRLF since that is the closest thing to a HTTP standard.
Parameters:
  postData - The data to normalize Normalized data



parseIntParameter
public static int parseIntParameter(String value, int defvalue)(Code)
Parses an integer parameter, returning a default value if the value is null or a non-number.
Parameters:
  value - The value to parse
Parameters:
  defvalue - A default value in case the value is not a number The parsed value (or defvalue).



repeatString
public static String repeatString(String what, int times)(Code)
A simple routine which just repeates the arguments. This is useful for creating something like a line or something.
Parameters:
  what - String to repeat
Parameters:
  times - How many times to repeat the string. Guess what?
since:
   2.1.98.



replaceEntities
public static String replaceEntities(String src)(Code)
Replaces the relevant entities inside the String. All & >, <, and " are replaced by their respective names.
since:
   1.6.1
Parameters:
  src - The source string. The encoded string.



replaceString
final public static String replaceString(String orig, String src, String dest)(Code)
Replaces a string with an other string.
Parameters:
  orig - Original string. Null is safe.
Parameters:
  src - The string to find.
Parameters:
  dest - The string to replace src with. A string with the replacement done.



replaceString
public static String replaceString(String orig, int start, int end, String text)(Code)
Replaces a part of a string with a new String.
Parameters:
  start - Where in the original string the replacing should start.
Parameters:
  end - Where the replacing should end.
Parameters:
  orig - Original string. Null is safe.
Parameters:
  text - The new text to insert into the string. The string with the orig replaced with text.



toHexString
public static String toHexString(byte[] bytes)(Code)
Generates a hexadecimal string from an array of bytes. For example, if the array contains { 0x01, 0x02, 0x3E }, the resulting string will be "01023E".
Parameters:
  bytes - A Byte array A String representation
since:
   2.3.87



urlDecode
protected static String urlDecode(byte[] bytes, String encoding) throws UnsupportedEncodingException, IllegalArgumentException(Code)
URL encoder does not handle all characters correctly. See Bug parade, bug #4257115 for more information.

Thanks to CJB for this fix.
Parameters:
  bytes - The byte array containing the bytes of the string
Parameters:
  encoding - The encoding in which the string should be interpreted A decoded String
throws:
  UnsupportedEncodingException - If the encoding is unknown.
throws:
  IllegalArgumentException - If the byte array is not a valid string.




urlDecode
public static String urlDecode(String data, String encoding) throws UnsupportedEncodingException, IllegalArgumentException(Code)
Provides decoded version of string depending on encoding. Encoding may be UTF-8 or ISO-8859-1 (default).

This implementation is the same as in FileSystemProvider.unmangleName().
Parameters:
  data - The URL-encoded string to decode
Parameters:
  encoding - The encoding to use A decoded string.
throws:
  UnsupportedEncodingException - If the encoding is unknown
throws:
  IllegalArgumentException - If the data cannot be decoded.




urlDecodeUTF8
public static String urlDecodeUTF8(String utf8)(Code)
As java.net.URLDecoder class, but for UTF-8 strings. null is a safe value and returns null.
Parameters:
  utf8 - The UTF-8 encoded string A plain, normal string.



urlEncode
protected static String urlEncode(byte[] rs)(Code)
java.net.URLEncoder.encode() method in JDK < 1.4 is buggy. This duplicates its functionality.
Parameters:
  rs - the string to encode the URL-encoded string



urlEncode
public static String urlEncode(String data, String encoding)(Code)
Provides encoded version of string depending on encoding. Encoding may be UTF-8 or ISO-8859-1 (default).

This implementation is the same as in FileSystemProvider.mangleName().
Parameters:
  data - A string to encode
Parameters:
  encoding - The encoding in which to encode An URL encoded string.




urlEncodeUTF8
public static String urlEncodeUTF8(String text)(Code)
As java.net.URLEncoder class, but this does it in UTF8 character set.
Parameters:
  text - The text to decode An URLEncoded 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.