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


java.lang.Object
   org.zkoss.util.Maps

Maps
public class Maps (Code)
Utilities for process Map.
author:
   tomyeh




Method Summary
final public static  voidload(Map map, InputStream sm, String charset, boolean caseInsensitive)
     Reads a property list (key and element pairs) from the input stream, by specifying the charset.

Like java.util.Properties, it translates \\u, \n, \r, \t and \f. However, it enhanced Properties as follows.

  • It accepts any charset, not just 8859-1.
  • It uses a different syntax to let value spread over multiple lines, descrubed below.
  • Whitespace is trimmed around '=' and at the beginning of the key and the ending of the value.
  • Illegal lines are ignored (Properties.load considers it as a key with an empty value).
  • Only '=' is accepted as the separator of key and value.
  • Only '#' is accepted as comment lines.

To spead a value over multiple lines, you could, unlike java.util.Properties.load, append '{' to the end of a line. Then, all the following lines are considerred as part of a value, unless encountering a line containing only one '}'.
Example:

abc = {
 line 1
 line 2
 }
 xyz = {
 line 1
 line 2
 }

Moreover, you could prefix a group of keys with certain prefix:

org.zkoss.some.
final public static  voidload(Map map, InputStream sm, String charset)
     Reads a property list (key and element pairs) from the input stream, by specifying the charset.
final public static  voidload(Map map, InputStream sm, boolean caseInsensitive)
     Reads a property list (key and element pairs) from the input stream, by detecting correct charset.
Parameters:
  caseInsensitive - whether the key used to access the mapis case-insensitive.
final public static  voidload(Map map, InputStream sm)
     Reads a property list (key and element pairs) from the input stream, by detecting correct charset.
final public static  Mapparse(Map map, String src, char separator, char quote)
     Parses a string into a map.

For example, if the following string is parsed:
a12=12,b3,c6=abc=125,x=y

Then, a map with the following content is returned:
("a12", "12"), ("b3", null), ("c6", "abc=125"), ("x", "y")

If = is omitted, it is considered as a key with the null value. If you want to consider it as the value, use Maps.parse(Map,String,char,char,boolean) instead. Actually, this is the same as parse(map, src, separator, quote, false);

Notice: only the first = after separator is meaningful, so you don't have to escape the following =.

Beside specifying the quote character, you could use back slash quote a single character (as Java does).
Parameters:
  map - the map to put parsed results to; null to create anew hash map
Parameters:
  src - the string to parse
Parameters:
  separator - the separator, e.g., ' ' or ','.
Parameters:
  quote - the quote character to surrounding value, e.g.,name = 'value'.

final public static  Mapparse(Map map, String src, char separator, char quote, boolean asValue)
     Parses a string into a map.

If = is omitted, whether it is considered as a key with the null value or a value with the null key depends on the asValue argument.

final public static  StringtoString(Map map, char quote, char separator)
     Converts a map to a string.
final public static  StringBuffertoStringBuffer(StringBuffer sb, Map map, char quote, char separator)
     Converts a map to string and append to a string buffer.



Method Detail
load
final public static void load(Map map, InputStream sm, String charset, boolean caseInsensitive) throws IOException(Code)
Reads a property list (key and element pairs) from the input stream, by specifying the charset.

Like java.util.Properties, it translates \\u, \n, \r, \t and \f. However, it enhanced Properties as follows.

  • It accepts any charset, not just 8859-1.
  • It uses a different syntax to let value spread over multiple lines, descrubed below.
  • Whitespace is trimmed around '=' and at the beginning of the key and the ending of the value.
  • Illegal lines are ignored (Properties.load considers it as a key with an empty value).
  • Only '=' is accepted as the separator of key and value.
  • Only '#' is accepted as comment lines.

To spead a value over multiple lines, you could, unlike java.util.Properties.load, append '{' to the end of a line. Then, all the following lines are considerred as part of a value, unless encountering a line containing only one '}'.
Example:

abc = {
 line 1
 line 2
 }
 xyz = {
 line 1
 line 2
 }

Moreover, you could prefix a group of keys with certain prefix:

org.zkoss.some. {
 a = aaa
 b = bbb
 }
It actually defines two keys: "org.zkoss.some.a" and "org.zkoss.some.b".

Note: (1) whitespace in the {...} block are all preserved.
(2) if only whitespaces is between '=' and '{', they are ignored.
Parameters:
  charset - the charset; if null, it detects UTF-16 BOM (0xfe 0xffor 0xff 0xfe). If no UTF-16 BOM, UTF-8 is always assumed.Note 1: UTF-8's BOM (0xef 0xbb 0xbf) is optional, so we don't count on it.Note 2: ISO-8859-1 is not used because we cannot tell its differencefrom UTF-8 (while some of our properties files are in UTF-8).
Parameters:
  caseInsensitive - whether the key used to access the mapis case-insensitive. If true, all keys are converted to lower cases.




load
final public static void load(Map map, InputStream sm, String charset) throws IOException(Code)
Reads a property list (key and element pairs) from the input stream, by specifying the charset.



load
final public static void load(Map map, InputStream sm, boolean caseInsensitive) throws IOException(Code)
Reads a property list (key and element pairs) from the input stream, by detecting correct charset.
Parameters:
  caseInsensitive - whether the key used to access the mapis case-insensitive. If true, all keys are converted to lower cases.



load
final public static void load(Map map, InputStream sm) throws IOException(Code)
Reads a property list (key and element pairs) from the input stream, by detecting correct charset.



parse
final public static Map parse(Map map, String src, char separator, char quote) throws IllegalSyntaxException(Code)
Parses a string into a map.

For example, if the following string is parsed:
a12=12,b3,c6=abc=125,x=y

Then, a map with the following content is returned:
("a12", "12"), ("b3", null), ("c6", "abc=125"), ("x", "y")

If = is omitted, it is considered as a key with the null value. If you want to consider it as the value, use Maps.parse(Map,String,char,char,boolean) instead. Actually, this is the same as parse(map, src, separator, quote, false);

Notice: only the first = after separator is meaningful, so you don't have to escape the following =.

Beside specifying the quote character, you could use back slash quote a single character (as Java does).
Parameters:
  map - the map to put parsed results to; null to create anew hash map
Parameters:
  src - the string to parse
Parameters:
  separator - the separator, e.g., ' ' or ','.
Parameters:
  quote - the quote character to surrounding value, e.g.,name = 'value'. If (char)0, no quotation is recognized.Notice: if value is an expression, it is better to specify (char)0because expression might contain strings. the map being generated
exception:
  IllegalSyntaxException - if syntax errors
See Also:   CollectionsX.parse
See Also:   Maps.toString(Map,char,char)




parse
final public static Map parse(Map map, String src, char separator, char quote, boolean asValue) throws IllegalSyntaxException(Code)
Parses a string into a map.

If = is omitted, whether it is considered as a key with the null value or a value with the null key depends on the asValue argument. If true, it is considered as a value with the null key.

For example, if the following string is parsed with asValue=false:
a12=12,b3,c6=abc=125,x=y

Then, a map with the following content is returned:
("a12", "12"), ("b3", null), ("c6", "abc=125"), ("x", "y")

Notice: only the first = after separator is meaningful, so you don't have to escape the following =.

Beside specifying the quote character, you could use back slash quote a single character (as Java does).
Parameters:
  map - the map to put parsed results to; null to create anew hash map
Parameters:
  src - the string to parse
Parameters:
  separator - the separator, e.g., ' ' or ','.
Parameters:
  quote - the quote character to surrounding value, e.g.,name = 'value'. If (char)0, no quotation is recognized.Notice: if value is an expression, it is better to specify (char)0because expression might contain strings.
Parameters:
  asValue - whether to consider the substring without = asa value (with the null key), or as a key (with the null value) the map being generated
exception:
  IllegalSyntaxException - if syntax errors
See Also:   CollectionsX.parse
See Also:   Maps.toString(Map,char,char)
since:
   2.4.0




toString
final public static String toString(Map map, char quote, char separator)(Code)
Converts a map to a string.
Parameters:
  map - the map to convert from
Parameters:
  quote - the quotation character; 0 means no quotation surrundingthe value
Parameters:
  separator - the separator between two name=value pairs
See Also:   Maps.parse(Map,String,char,char)



toStringBuffer
final public static StringBuffer toStringBuffer(StringBuffer sb, Map map, char quote, char separator)(Code)
Converts a map to string and append to a string buffer.
See Also:   Maps.toString



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.