Java Doc for RefCapablePropertyResourceBundle.java in  » Database-DBMS » hsql » org » hsqldb » 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 » Database DBMS » hsql » org.hsqldb.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.hsqldb.util.RefCapablePropertyResourceBundle

RefCapablePropertyResourceBundle
public class RefCapablePropertyResourceBundle (Code)
Just like PropertyResourceBundle, except keys mapped to nothing in the properties file will load the final String value from a text file. The use case is where one wants to use a ResourceBundle for Strings, but some of the Strings are long-- too long to maintain in a Java .properties file. By using this class, you can put each such long String in its own separate file, yet all keys mapped to (non-empty) values in the .properties file will behave just like regular PropertyResourceBundle properties. In this documentation, I call these values read in atomically from other files referenced values, because the values are not directly in the .properties file, but are "referenced" in the .properties file by virtue of the empty value for the key. You use this class in the same way as you would traditionally use ResourceBundle:
 import org.hsqldb.util..RefCapablePropertyResourceBundle;
 ...
 RefCapablePropertyResourceBundle bundle =
 RefCapablePropertyResourceBundle.getBundle("subdir.xyz");
 System.out.println("Value for '1' = (" + bundle.getString("1") + ')');
 
Just like PropertyResourceBundle, the .properties file and the referenced files are read in from the classpath by a class loader, according to the normal ResourceBundle rules. To eliminate the need to prohibit the use of any strings in the .properties values, and to enforce consistency, you must use the following rules to when putting your referenced files into place.

REFERENCED FILE DIRECTORY is a directory named with the base name of the properties file, and in the same parent directory. So, the referenced file directory /a/b/c/greentea is used to hold all reference files for properties files /a/b/c/greentea_en_us.properties, /a/b/c/greentea_de.properties, /a/b/c/greentea.properties, etc. (BTW, according to ResourceBundle rules, this resource should be looked up with name "a.b.c.greentea", not "/a/b/c..." or "a/b/c"). REFERENCED FILES themselves all have the base name of the property key, with locale appendages exactly as the referring properties files has, plus the suffix .text.

So, if we have the following line in /a/b/c/greentea_de.properties:

 1: eins
 
then you must have a reference text file /a/b/c/greentea/1_de.properties:

In reference text files, sequences of "\r", "\n" and "\r\n" are all translated to the line delimiter for your platform (System property line.separator). If one of those sequences exists at the very end of the file, it will be eliminated (so, if you really want getString() to end with a line delimiter, end your file with two of them). (The file itself is never modified-- I'm talking about the value returned by getString(String). To prevent throwing at runtime due to unset variables, use a wrapper class like SqltoolRB (use SqltoolRB.java as a template). To prevent throwing at runtime due to unset System Properties, or insufficient parameters passed to getString(String, String[]), set the behavior values appropriately. Just like all Properties files, referenced files must use ISO-8859-1 encoding, with unicode escapes for characters outside of ISO-8859-1 character set. But, unlike Properties files, \ does not need to be escaped for normal usage. The getString() methods with more than one parameter substitute for "positional" parameters of the form "%{1}". The getExpandedString() methods substitute for System Property names of the form "${1}". In both cases, you can interpose :+ and a string between the variable name and the closing }. This works just like the Bourne shell ${x:+y} feature. If "x" is set, then "y" is returned, and "y" may contain references to the original variable without the curly braces. In this file, I refer to the y text as the "conditional string". One example of each type:

 Out val = (${condlSysProp:+Prop condlSysProp is set to $condlSysProp.})
 Out val = (%{2:+Pos Var #2 is set to %2.})
 OUTPUT if neither are set:
 Out val = ()
 Out val = ()
 OUTPUT if condlSysProp=alpha and condlPLvar=beta:
 Out val = (Prop condlSysProp is set to alpha.)
 Out val = (Pos Var #2 is set to beta.)
 
This feature has the following limitations.
  • The conditional string may only contain the primary variable.
  • Inner instances of the primary variable may not use curly braces, and therefore the variable name must end at a word boundary.
The conditional string may span newlines, and it is often very useful to do so.
See Also:   java.util.PropertyResourceBundle
See Also:   java.util.ResourceBundle
author:
   blaine.simpson@admc.com


Field Summary
final public static  intEMPTYSTRING_BEHAVIOR
    
public static  StringLS
    
final public static  intNOOP_BEHAVIOR
    
final public static  intTHROW_BEHAVIOR
    


Method Summary
public static  RefCapablePropertyResourceBundlegetBundle(String baseName, ClassLoader loader)
     Use like java.util.ResourceBundle.getBundle(String).
public static  RefCapablePropertyResourceBundlegetBundle(String baseName, Locale locale, ClassLoader loader)
     Use exactly like java.util.ResourceBundle.get(String, Locale, ClassLoader).
public  StringgetExpandedString(String key, int behavior)
     Same as getString(), but expands System Variables specified in property values like ${sysvarname}.
public  StringgetExpandedString(String key, String[] subs, int missingPropertyBehavior, int missingPosValueBehavior)
    
public  EnumerationgetKeys()
    
public  StringgetString(String key, String[] subs, int behavior)
    
public  StringgetString(String key)
     Returns value defined in this RefCapablePropertyResourceBundle's .properties file, unless that value is empty.
public static  Stringliteralize(String s)
     Escape \ and $ characters in replacement strings so that nothing funny happens.
public  StringposSubst(String s, String[] subs, int behavior)
     Replaces positional substitution patterns of the form %{\d} with corresponding element of the given subs array.
public  StringtoString()
     Just identifies this RefCapablePropertyResourceBundle instance.

Field Detail
EMPTYSTRING_BEHAVIOR
final public static int EMPTYSTRING_BEHAVIOR(Code)



LS
public static String LS(Code)



NOOP_BEHAVIOR
final public static int NOOP_BEHAVIOR(Code)



THROW_BEHAVIOR
final public static int THROW_BEHAVIOR(Code)





Method Detail
getBundle
public static RefCapablePropertyResourceBundle getBundle(String baseName, ClassLoader loader)(Code)
Use like java.util.ResourceBundle.getBundle(String). ClassLoader is required for our getBundles()s, since it is impossible to get the "caller's" ClassLoader without using JNI (i.e., with pure Java).
See Also:   ResourceBundle.getBundle(String)



getBundle
public static RefCapablePropertyResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader)(Code)
Use exactly like java.util.ResourceBundle.get(String, Locale, ClassLoader).
See Also:   ResourceBundle.getBundle(StringLocaleClassLoader)



getExpandedString
public String getExpandedString(String key, int behavior)(Code)
Same as getString(), but expands System Variables specified in property values like ${sysvarname}.



getExpandedString
public String getExpandedString(String key, String[] subs, int missingPropertyBehavior, int missingPosValueBehavior)(Code)



getKeys
public Enumeration getKeys()(Code)



getString
public String getString(String key, String[] subs, int behavior)(Code)



getString
public String getString(String key)(Code)
Returns value defined in this RefCapablePropertyResourceBundle's .properties file, unless that value is empty. If the value in the .properties file is empty, then this returns the entire contents of the referenced text file.
See Also:   ResourceBundle.get(String)



literalize
public static String literalize(String s)(Code)
Escape \ and $ characters in replacement strings so that nothing funny happens. Once we can use Java 1.5, wipe out this method and use java.util.regex.matcher.QuoteReplacement() instead.



posSubst
public String posSubst(String s, String[] subs, int behavior)(Code)
Replaces positional substitution patterns of the form %{\d} with corresponding element of the given subs array. Note that %{\d} numbers are 1-based, so we lok for subs[x-1].



toString
public String toString()(Code)
Just identifies this RefCapablePropertyResourceBundle instance.



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.