public class BasePropertyFile extends Object implements BaseNonConfigIniFile, Serializable
Comments can be entered using standard XML comment syntax.
${<section>.<param>}
Forward and multi-level references are allowed, but circular are not.
Values may also contain references to system parameters.
<section name="sectionName">
<!-- Standard Parameter -->
<param name="paramName1"> paramValue </param>
<!-- Parameter Reference -->
<param name="paramName2"> ${sectionName.paramName1} </param>
<!-- Property Reference -->
<param name="paramName3"> #{user.property} </param>
</section>
| Modifier and Type | Class and Description |
|---|---|
static class |
BasePropertyFile.MetaDataInfo |
static interface |
BasePropertyFile.Parser
Interface used by PropertyFile and its subclasses to parse and load its
internal map data structure (eg.
|
static class |
BasePropertyFile.SubstitutionException |
| Modifier and Type | Field and Description |
|---|---|
protected PropertyFileData |
data |
protected long |
lastModified |
protected Map<String,Map<String,BasePropertyFile.MetaDataInfo>> |
metaData |
static String |
MISSING_LABEL |
| Modifier | Constructor and Description |
|---|---|
|
BasePropertyFile() |
|
BasePropertyFile(BasePropertyFile.Parser p) |
protected |
BasePropertyFile(BasePropertyFile.Parser p,
PropertyFileData data) |
|
BasePropertyFile(int initialCapacity) |
protected |
BasePropertyFile(int initialCapacity,
PropertyFileData data) |
protected |
BasePropertyFile(PropertyFileData data) |
| Modifier and Type | Method and Description |
|---|---|
void |
attachSharedKeyMap(SharedKeyMap<String,SharedKeyMap<String,Object>> seedKeyMap)
Allows for some implementations to save a great deal of memory by sharing
maps across various language versions of the "same" properties/labels.
|
boolean |
containsListParam(String section,
String baseParam)
Whether the section contains an enum list with the baseParam.
|
boolean |
containsParam(String section,
String param) |
boolean |
containsSection(String section) |
void |
doSubstitutions() |
void |
doSubstitutions(Object referenceConfig) |
Set<Map.Entry<String,Map<String,Object>>> |
entrySet() |
Object |
get(String section,
String param)
Get the value for a given SectName.ParamName pair.
|
Object |
get(String section,
String param,
boolean allowLabelException) |
Object |
get(String section,
String param,
Object ifNull)
Get the object stored in section/param in the IniFile.
|
boolean |
getBoolean(String section,
String param) |
boolean |
getBoolean(String section,
String param,
boolean ifNull)
Get the value stored in section/param in the IniFile as a boolean.
|
String |
getCensoredString(String section,
String param,
String ifNull)
Censors the value before returning it to the caller.
|
float |
getFloat(String section,
String param) |
float |
getFloat(String section,
String param,
float ifNull)
Gets the value stored in the section/param in the IniFile as a float
|
int |
getInt(String section,
String param) |
int |
getInt(String section,
String param,
int ifNull)
Get the value stored in section/param in the IniFile as an int.
|
long |
getLastModified() |
List<String> |
getList(String section,
String baseParam)
Gets all values of parameters that begin with baseParam_xx, where xx is a
number starting from 0.
|
List<String> |
getList(String section,
String baseParam,
List<String> ifNull)
Gets all values of parameters that begin with baseParam_xx, where xx is a
number starting from 0.
|
List<String> |
getListConfigValues(String section)
Gets all values of parameters that were in the section for a build config
file
|
int |
getNumListEntryParams(String section,
String baseParam)
Get the number of enumItems within an enum list param.
|
Set<String> |
getParams(String section) |
Set<String> |
getParams(String section,
Set<String> ifNull) |
protected PropertyFileData |
getPropertyFileData() |
Map<String,Object> |
getSection(String sectionName)
Returns an unmodifiable
Map of all the values for a
particular sectionName. |
String |
getString(String section,
String param) |
String |
getString(String section,
String param,
String ifNull)
Get the value stored in section/param in the IniFile as a string.
|
String |
getStringThrow(String section,
String param) |
protected Object |
inner_get(String section,
String param,
boolean throwSettingsSectionNotFoundException) |
boolean |
isProductionMode() |
static String |
makeListEntryParam(String baseParam,
int index) |
protected void |
outputValueXML(Object value,
OutputStreamWriter os) |
protected void |
outputValueXMLCensored(OutputStreamWriter os,
String sectionName,
String paramName,
Object value) |
void |
outputXML(OutputStream os)
Output XML data to a stream output is for set.dtd.
|
void |
outputXML(OutputStream os,
boolean doCensor)
Outputs XML data to a stream output, either censored or uncensored version depending on
doCensor's value.
|
Object |
put(String section,
String param,
Object value) |
void |
remove(String sectionName,
String paramName) |
void |
removeSection(String sectionName) |
Set<String> |
sectionNames() |
void |
setLastModified(long lastModified) |
static boolean |
stringToBoolean(String booleanValue)
Defaults to false if the string does not match one of the following
- 1
- true
- yes
- on
|
protected Object |
substitute(String sectionName,
String paramName,
Object val,
Object referenceConfig)
Allow child implementations to substitute values based on an external set of params
|
public static final String MISSING_LABEL
protected PropertyFileData data
protected final Map<String,Map<String,BasePropertyFile.MetaDataInfo>> metaData
protected long lastModified
public BasePropertyFile(int initialCapacity)
public BasePropertyFile()
protected BasePropertyFile(PropertyFileData data)
protected BasePropertyFile(int initialCapacity,
PropertyFileData data)
public BasePropertyFile(BasePropertyFile.Parser p) throws IOException
IOExceptionprotected BasePropertyFile(BasePropertyFile.Parser p, PropertyFileData data) throws IOException
IOExceptionpublic Set<Map.Entry<String,Map<String,Object>>> entrySet()
entrySet in interface BaseNonConfigIniFilepublic void removeSection(String sectionName)
public boolean containsSection(String section)
public boolean containsListParam(String section, String baseParam)
public List<String> getListConfigValues(String section) throws SettingsSectionNotFoundException
SettingsSectionNotFoundExceptionpublic List<String> getList(String section, String baseParam) throws SettingsSectionNotFoundException
SettingsSectionNotFoundExceptionpublic List<String> getList(String section, String baseParam, List<String> ifNull)
getList in interface BaseNonConfigIniFilesection - the section to look in.baseParam - the param name to look for.ifNull - the list to return if no list was found.public int getNumListEntryParams(String section, String baseParam)
public Set<String> getParams(String section) throws SettingsSectionNotFoundException
SettingsSectionNotFoundExceptionprotected Object inner_get(String section, String param, boolean throwSettingsSectionNotFoundException) throws SettingsSectionNotFoundException
SettingsSectionNotFoundExceptionpublic Set<String> getParams(String section, Set<String> ifNull)
public Object get(String section, String param, Object ifNull)
BaseNonConfigIniFileget in interface BaseNonConfigIniFilesection - the section to look in.param - the param name to look for.ifNull - the object to return if no value was found.public Object get(String section, String param, boolean allowLabelException) throws ParameterNotFoundException, SettingsSectionNotFoundException
public Object get(String section, String param) throws ParameterNotFoundException, SettingsSectionNotFoundException
section - the section name of the desired variableparam - the parameter name with the the given sectionParameterNotFoundExceptionSettingsSectionNotFoundExceptionpublic String getString(String section, String param) throws ParameterNotFoundException, SettingsSectionNotFoundException
public String getStringThrow(String section, String param) throws ParameterNotFoundException, SettingsSectionNotFoundException
public String getCensoredString(String section, String param, String ifNull)
getCensoredString in interface BaseNonConfigIniFilesection - the section for the labelparam - the key for the labelifNull - default value to return if null (not set).public String getString(String section, String param, String ifNull)
BaseNonConfigIniFilegetString in interface BaseNonConfigIniFilesection - the section to look in.param - the param name to look for.ifNull - the default value to use.public int getInt(String section, String param) throws ParameterNotFoundException, SettingsSectionNotFoundException
public int getInt(String section, String param, int ifNull)
BaseNonConfigIniFilegetInt in interface BaseNonConfigIniFilesection - the section to look in.param - the param name to look for.ifNull - the int to default to.public float getFloat(String section, String param) throws SettingsSectionNotFoundException, ParameterNotFoundException
public float getFloat(String section, String param, float ifNull)
BaseNonConfigIniFilegetFloat in interface BaseNonConfigIniFilesection - the section to look in.param - the param name to look for.ifNull - the float to default topublic boolean getBoolean(String section, String param) throws ParameterNotFoundException, SettingsSectionNotFoundException
public boolean getBoolean(String section, String param, boolean ifNull)
BaseNonConfigIniFilegetBoolean in interface BaseNonConfigIniFilesection - the section to look in.param - the param name to look for.ifNull - the boolean to default to.public Map<String,Object> getSection(String sectionName)
Map of all the values for a
particular sectionName. If, that section does not exist, will return
null.public void outputXML(OutputStream os) throws IOException
IOExceptionpublic void outputXML(OutputStream os, boolean doCensor) throws IOException
os - the output stream to write todoCensor - will censor values like password if set to trueIOExceptionprotected void outputValueXML(Object value, OutputStreamWriter os) throws IOException
IOExceptionprotected void outputValueXMLCensored(OutputStreamWriter os, String sectionName, String paramName, Object value) throws IOException
IOExceptionpublic final long getLastModified()
public final void setLastModified(long lastModified)
public void doSubstitutions()
throws ParameterNotFoundException,
IOException
public void doSubstitutions(Object referenceConfig) throws ParameterNotFoundException, IOException
protected Object substitute(String sectionName, String paramName, Object val, Object referenceConfig) throws IOException, BasePropertyFile.SubstitutionException
sectionName - the section of the param being replaceparamName - the key of the param being replaceval - the value being replacedreferenceConfig - an object being passed in to parsing forIOException - in case there are any IO ExceptionsBasePropertyFile.SubstitutionException - in case the val has a malformed section/paramprotected PropertyFileData getPropertyFileData()
public void attachSharedKeyMap(SharedKeyMap<String,SharedKeyMap<String,Object>> seedKeyMap)
public boolean isProductionMode()
public static boolean stringToBoolean(String booleanValue)
Copyright (c) 2016-2017, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE.txt file in the repository.