asia.redact.bracket.properties
Class Properties.Factory

java.lang.Object
  extended by asia.redact.bracket.properties.Properties.Factory
Enclosing interface:
Properties

public static final class Properties.Factory
extends Object

 The default mode is the trivial memory mode, which is BasicToken.
 
 You can change the Mode of the factory globally by setting it to a different value like this:
 
 Properties.mode = Mode.Line;
 
 which changes the mode (and thus the parser/lexer) to Line. 
 
 

Author:
Dave

Field Summary
static Properties.Mode mode
           
 
Constructor Summary
Properties.Factory()
           
 
Method Summary
static Properties getDotInstance(InputStream in)
           
static Properties getDotInstance(Reader reader)
           
static Properties getInstance()
           
static Properties getInstance(File file, Charset charset)
           
static Properties getInstance(InputStream in)
           
static Properties getInstance(Properties legacy)
          Load from a legacy Properties file object
static Properties getInstance(Reader reader)
           
static Properties getInstance(String baseName, Locale locale)
           Similar to the behavior of a ResourceBundle.
static Properties getInstance(URL url)
           
static Properties getInstanceFromXML(File file)
          If Properties.Factory.mode == Mode.Compatibility, will expect ISO-8859-1.
static Properties getInstanceFromXML(File file, Charset charset)
          The input file must have been generated by OutputAdapter.writeAsXML(Writer) or meet the same requirements as regards form.
static Properties loadReferences(List<PropertiesReference> refs)
           
static Properties loadReferences(List<PropertiesReference> refs, Attributes attribs)
           Given a set of paths in the OS, load the files one by one into the Properties.
static Properties sortedInstance(Properties props)
           
static Properties sortedInstance(Properties props, Comparator<String> comp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mode

public static Properties.Mode mode
Constructor Detail

Properties.Factory

public Properties.Factory()
Method Detail

getInstance

public static Properties getInstance()

getInstance

public static Properties getInstance(URL url)

getInstance

public static Properties getInstance(Reader reader)

getInstance

public static Properties getInstance(File file,
                                     Charset charset)

getInstance

public static Properties getInstance(InputStream in)

getInstance

public static Properties getInstance(Properties legacy)
Load from a legacy Properties file object

Parameters:
legacy -
Returns:

getInstance

public static Properties getInstance(String baseName,
                                     Locale locale)
 Similar to the behavior of a ResourceBundle.
 
 baseName is something like a.b.c.MyProperty which with Locale.AU will be 
 a search path like /a.b.c.MyProperty_en_AU.properties
 
 

Parameters:
baseName -
locale -
Returns:

getInstanceFromXML

public static Properties getInstanceFromXML(File file,
                                            Charset charset)
The input file must have been generated by OutputAdapter.writeAsXML(Writer) or meet the same requirements as regards form. This is not yet documented but looking at the test case files you can figure it out.

Parameters:
file -
Returns:
Throws:
RuntimeException - if it fails due to I/O

getInstanceFromXML

public static Properties getInstanceFromXML(File file)
If Properties.Factory.mode == Mode.Compatibility, will expect ISO-8859-1. Otherwise, UTF-8 is used.

Parameters:
file -
Returns:

sortedInstance

public static Properties sortedInstance(Properties props)

sortedInstance

public static Properties sortedInstance(Properties props,
                                        Comparator<String> comp)

getDotInstance

public static Properties getDotInstance(Reader reader)

getDotInstance

public static Properties getDotInstance(InputStream in)

loadReferences

public static Properties loadReferences(List<PropertiesReference> refs)

loadReferences

public static Properties loadReferences(List<PropertiesReference> refs,
                                        Attributes attribs)
 Given a set of paths in the OS, load the files one by one into the Properties. This method
 relies on merge(), which overwrites if it finds a duplicate. So, suppose you have the following
 
 /WEB-INF/myapp.properties
 /.ext/passwords.properties
 
 Then you would do the following:
 
 List list = new List();
 list.add("C://MyStuff/tomcat/webapps/mywar/WEB-INF/myapp.properties");
 list.add("C://Users/dsmith/.ext/passwords.properties");
 Properties props = Properties.Factory.loadReferences(list,attribs);
 
 props will now have properties from myapp.properties and written on top of those will be 
 contents of passwords.properties
 
 The loadReferences methods support ResourceBundle style localization via attributes.locale. 
 Set this to the desired locale. Bracket goes beyond ResourceBundles by supporting 
 *externalized* localization.
 
 



Copyright © 2011-2013 David R. Smith. All Rights Reserved.