public class LoadList extends Object
Container for list of references from which to load properties. The list can contain externalized files, internal files within the classpath (such as in a jar file) and even direct name value pairs.
The key idea is that if we load references in a given order, the properties values will be added and later additions will overwrite earlier ones. This means you can load a template file first (perhaps from the classpath) and then an override certain values from the file system afterwards.
| Modifier and Type | Field and Description |
|---|---|
(package private) List<PropertiesReference> |
list |
(package private) Properties |
props |
| Constructor and Description |
|---|
LoadList() |
LoadList(Properties props) |
| Modifier and Type | Method and Description |
|---|---|
LoadList |
addReference(File file)
This is understood as a shortcut for
PropertiesReference(ReferenceType.EXTERNAL, filepath);
|
LoadList |
addReference(PropertiesReference ref) |
LoadList |
addReference(ReferenceType type,
String data)
add a reference.
|
List<PropertiesReference> |
getList() |
Properties |
getProps() |
LoadList |
load() |
private void |
loadFromClasspath(PropertiesReference ref)
interpret ref.data as a class path such as /myprops.properties
|
private void |
loadFromDirect(PropertiesReference ref)
Interpret ref.data as a stream of properties such as myval.0=1\nmyval1=2
|
private void |
loadFromExternal(PropertiesReference ref)
Support data which is a directory path containing properties file(s)
or a else file path to a single properties file
|
private void |
loadFromSystemProps(String key) |
final List<PropertiesReference> list
final Properties props
public LoadList()
public LoadList(Properties props)
public LoadList addReference(File file)
public LoadList addReference(ReferenceType type, String data)
type - data - public LoadList addReference(PropertiesReference ref)
public LoadList load()
private void loadFromSystemProps(String key)
private void loadFromClasspath(PropertiesReference ref)
ref - private void loadFromDirect(PropertiesReference ref)
ref - private void loadFromExternal(PropertiesReference ref)
ref - public List<PropertiesReference> getList()
public Properties getProps()
Copyright © 2011–2016 David R. Smith. All rights reserved.