Java Doc for Strings.java in  » Ajax » zk » org » zkoss » lang » 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 » Ajax » zk » org.zkoss.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.zkoss.lang.Strings

Strings
public class Strings (Code)
String utilties and constants
author:
   tomyeh

Inner Class :public static class Result



Method Summary
final public static  intanyOf(String src, String delimiters, int from)
     Returns the index that is one of delimiters, or the length if none of delimiter is found.
final public static  StringBufferappendEscape(StringBuffer sb, String s, String specials)
     Escapes (aka.
final public static  StringBufferencode(StringBuffer sb, int val)
     Returns an encoded string buffer, faster and shorter than Integer.toHexString.
final public static  StringBufferencode(StringBuffer sb, long val)
     Returns an encoded string buffer, faster and shorter than Long.toHexString.
final public static  Stringencode(int val)
     Returns an encoded string, faster and shorter than Long.toHexString.
final public static  Stringencode(long val)
     Returns an encoded string, faster and shorter than Long.toHexString.
final public static  Stringescape(String s, String specials)
     Escapes (aka, quote) the special characters with backslash. It prefix a backslash to any characters specfied in the specials argument.

Note: specials usually contains '\\'.

For example, org.zkoss.util.Maps.parse will un-quote backspace.

final public static  booleanisBlank(String s)
     Returns true if the string is null or empty or pure blank.
final public static  booleanisEmpty(String s)
     Returns true if the string is null or empty.
final public static  intlastAnyOf(String src, String delimiters, int from)
     The backward version of Strings.anyOf .
public static  intnextSeparator(String src, int from, char[] separators, boolean escBackslash, boolean escQuot, boolean quotAsSeparator)
     Returns the next seperator index in the src string.
Parameters:
  escQuot - whether to escape characters inside quotations('\'' or '"').
final public static  ResultnextToken(String src, int from, char[] separators)
     Returns the next token with unescape.
  • It trims whitespaces before and after the token.
  • It handles both '\'' and '"'.
final public static  ResultnextToken(String src, int from, char[] separators, boolean escBackslash, boolean quotAsToken)
     Returns the next token with unescape option.
final public static  intnextWhitespace(CharSequence src, int from)
     Returns the next whitespace.
final public static  intskipWhitespaces(CharSequence src, int from)
     Returns the next index after skipping whitespaces.
final public static  intskipWhitespacesBackward(CharSequence src, int from)
     The backward version of Strings.skipWhitespaces .
final public static  Resultsubstring(String src, int from, char until)
     Returns the substring from the from index up to the until character or end-of-string. Unlike String.subsring, it converts \f, \n, \t and \r.
final public static  Resultsubstring(String src, int from, char until, boolean escBackslash)
     Returns the substring from the from index up to the until character or end-of-string.
Parameters:
  escBackslash - whether to treat '\\' specially (as escape char)It doesn't handle u and x yet.
final public static  Stringunescape(String s)
     Un-escape the quoted string.



Method Detail
anyOf
final public static int anyOf(String src, String delimiters, int from)(Code)
Returns the index that is one of delimiters, or the length if none of delimiter is found.

Unlike String.indexOf(String, int), this method returns the first occurrence of any character in the delimiters.

This method is optimized to use String.indexOf(char, int) if it found the length of dilimiter is 1.
Parameters:
  src - the source string to search
Parameters:
  from - the index to start the search from
Parameters:
  delimiters - the set of characters to search for the index that is one of delimiters.If return >= src.length(), it means no such delimiters
See Also:   Strings.lastAnyOf




appendEscape
final public static StringBuffer appendEscape(StringBuffer sb, String s, String specials)(Code)
Escapes (aka. quote) the special characters with backslash and appends it the specified string buffer.



encode
final public static StringBuffer encode(StringBuffer sb, int val)(Code)
Returns an encoded string buffer, faster and shorter than Integer.toHexString. It uses numbers and lower-case leters only. Thus it is a valid variable name if prefix with an alphabet. At least one character is generated.

It works even in system that is case-insensitive, such as IE.

It is useful to generate a string to represent a number.




encode
final public static StringBuffer encode(StringBuffer sb, long val)(Code)
Returns an encoded string buffer, faster and shorter than Long.toHexString. It uses numbers and lower-case letters only. Thus it is a valid variable name if prefix with an alphabet. At least one character is generated.

It works even in system that is case-insensitive, such as IE.

It is useful to generate a string to represent a number.




encode
final public static String encode(int val)(Code)
Returns an encoded string, faster and shorter than Long.toHexString.



encode
final public static String encode(long val)(Code)
Returns an encoded string, faster and shorter than Long.toHexString.



escape
final public static String escape(String s, String specials)(Code)
Escapes (aka, quote) the special characters with backslash. It prefix a backslash to any characters specfied in the specials argument.

Note: specials usually contains '\\'.

For example, org.zkoss.util.Maps.parse will un-quote backspace. Thus, if you want to preserve backslash, you have invoke escape(s, "\\") before calling Maps.parse().
Parameters:
  s - the string to process. If null, null is returned.
Parameters:
  specials - a string of characters that shall be escaped/quoted
See Also:   Strings.unescape




isBlank
final public static boolean isBlank(String s)(Code)
Returns true if the string is null or empty or pure blank.



isEmpty
final public static boolean isEmpty(String s)(Code)
Returns true if the string is null or empty.



lastAnyOf
final public static int lastAnyOf(String src, String delimiters, int from)(Code)
The backward version of Strings.anyOf .

This method is optimized to use String.indexOf(char, int) if it found the length of dilimiter is 1. the previous index that is one of delimiter.If it is negative, it means no delimiter in front offrom
See Also:   Strings.anyOf




nextSeparator
public static int nextSeparator(String src, int from, char[] separators, boolean escBackslash, boolean escQuot, boolean quotAsSeparator)(Code)
Returns the next seperator index in the src string.
Parameters:
  escQuot - whether to escape characters inside quotations('\'' or '"'). In other words, ignore separators inside quotations
Parameters:
  quotAsSeparator - whether to consider quotations as one ofthe separators
since:
   2.4.0



nextToken
final public static Result nextToken(String src, int from, char[] separators) throws IllegalSyntaxException(Code)
Returns the next token with unescape.
  • It trims whitespaces before and after the token.
  • It handles both '\'' and '"'. All characters between them are considered as a token.
  • If nothing found before end-of-string, null is returned
If a separator is found, it is returned in Strings.Result.separator .
exception:
  IllegalSyntaxException - if the quoted string is unclosed.



nextToken
final public static Result nextToken(String src, int from, char[] separators, boolean escBackslash, boolean quotAsToken) throws IllegalSyntaxException(Code)
Returns the next token with unescape option.
  • It trims whitespaces before and after the token.
  • If quotAsToken is true, all characters between quotations ('\'' or '"') are considered as a token.
  • Consider '\\' as the escape char if escBackslash is true.
  • If nothing found before end-of-string, null is returned
If a separator is found, it is returned in Strings.Result.separator .
Parameters:
  escBackslash - whether to treat '\\' specially (as escape char)It doesn't handle u and x yet.
Parameters:
  quotAsToken - whether to treat characters inside '\'' or '"'as a token
exception:
  IllegalSyntaxException - if the quoted string is unclosed.



nextWhitespace
final public static int nextWhitespace(CharSequence src, int from)(Code)
Returns the next whitespace.



skipWhitespaces
final public static int skipWhitespaces(CharSequence src, int from)(Code)
Returns the next index after skipping whitespaces.



skipWhitespacesBackward
final public static int skipWhitespacesBackward(CharSequence src, int from)(Code)
The backward version of Strings.skipWhitespaces . the next index that is not a whitespace.If it is negative, it means no whitespace in front of it.



substring
final public static Result substring(String src, int from, char until)(Code)
Returns the substring from the from index up to the until character or end-of-string. Unlike String.subsring, it converts \f, \n, \t and \r. It doesn't handle u and x yet. the result (never null). Result.next is the position ofthe until character if found, ora number larger than length() if no such character.



substring
final public static Result substring(String src, int from, char until, boolean escBackslash)(Code)
Returns the substring from the from index up to the until character or end-of-string.
Parameters:
  escBackslash - whether to treat '\\' specially (as escape char)It doesn't handle u and x yet. the result (never null). Result.next is the position ofthe until character if found, ora number larger than length() if no such character.You can tell which case it is by examining Result.separator.



unescape
final public static String unescape(String s)(Code)
Un-escape the quoted string.
See Also:   Strings.escape
See Also:   Strings.appendEscape



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.