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.
| Modifier and Type | Field and Description |
|---|---|
static Properties.Mode |
mode |
| Constructor and Description |
|---|
Properties.Factory() |
| Modifier and Type | Method and Description |
|---|---|
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(InputStream in,
Charset charset) |
static Properties |
getInstance(Map map) |
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) |
public static Properties.Mode mode
public static Properties getInstance()
public static Properties getInstance(URL url)
public static Properties getInstance(Reader reader)
public static Properties getInstance(File file, Charset charset)
public static Properties getInstance(InputStream in)
public static Properties getInstance(InputStream in, Charset charset)
public static Properties getInstance(Properties legacy)
legacy - public static Properties getInstance(Map map)
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
baseName - locale - public static Properties getInstanceFromXML(File file, Charset charset)
file - RuntimeException - if it fails due to I/Opublic static Properties getInstanceFromXML(File file)
file - public static Properties sortedInstance(Properties props)
public static Properties sortedInstance(Properties props, Comparator<String> comp)
public static Properties getDotInstance(Reader reader)
public static Properties getDotInstance(InputStream in)
public static Properties loadReferences(List<PropertiesReference> refs)
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-2014 David R. Smith. All Rights Reserved.