public abstract class BaseKeyValuePairLoader extends BaseLoader implements ReadLoader
To implement a non-abstract class, override the
Loader.load(PropertyConfigurationInternal, LoaderEnvironment, ValidatedValuesWithContext)
method with a call to load(PropertyConfigurationInternal, List, String) and supply your
own list of key-value pair strings. For a simple example, see the
StdMainStringArgsLoader.
By default, this loader trims incoming values for String type properties and will
throw a RuntimeException if passed unrecognized properties. Both of these behaviours
can be changed by modifying the return values of isTrimmingRequiredForStringValues() and
isUnknownPropertyAProblem().
| Modifier and Type | Field and Description |
|---|---|
static String |
KVP_DELIMITER
The default delimiter between a key and a value.
|
protected boolean |
unknownPropertyAProblem |
| Constructor and Description |
|---|
BaseKeyValuePairLoader() |
| Modifier and Type | Method and Description |
|---|---|
String |
getLoaderDialect()
The type dialect of the loader.
|
String |
getLoaderType()
The type of the loader, such as JNDI, PropertyFile, SystemProperty,
etc..
|
String |
getSpecificLoadDescription()
For this particular load, where was info loaded from?
This may vary from run to run based on config params.
|
boolean |
isFlaggable()
Returns true if this loader supports
FlaggableType's. |
boolean |
isTrimmingRequiredForStringValues()
If true, values for string properties are trimmed by the Trimmer of
the property they are associated with.
|
boolean |
isUnknownPropertyAProblem()
If true, an unrecognized name is considered a problem that will stop
application startup.
|
LoaderValues |
load(PropertyConfigurationInternal runtimeDef,
List<String> keyValuePairs,
String delimiter)
Load from the passed list of keyValuePairs using the passed delimiter.
|
void |
setUnknownPropertyAProblem(boolean isAProblem)
If true, an unrecognized property name is considered a problem/error.
|
attemptToAdd, attemptToAdd, attemptToAdd, attemptToAddIfNotDuplicate, createValue, findDuplicateProperty, getClassConfig, getConfigSamplePrinter, getInstanceConfig, mapNametoProperty, releaseResourcesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClassConfig, getConfigSamplePrinter, getInstanceConfig, load, releaseResourcesprotected boolean unknownPropertyAProblem
public static final String KVP_DELIMITER
public LoaderValues load(PropertyConfigurationInternal runtimeDef, List<String> keyValuePairs, String delimiter)
runtimeDef - The definition of all known Properties and naming metadata.keyValuePairs - List of key-value pairs to load from. Each item in the list
is assumed to have a name and value separated by the delimiter.delimiter - The separator between the name and value in each key-value entry.public String getSpecificLoadDescription()
LoadergetSpecificLoadDescription in interface Loaderpublic boolean isTrimmingRequiredForStringValues()
LoaderisTrimmingRequiredForStringValues in interface Loaderpublic boolean isFlaggable()
LoaderFlaggableType's.
Loaders that support FlaggableType give special 'is present' meaning to a property being
present without a value, similar to a 'nix command line flag. If a Loader supports
flags, it should call FlaggableType.parseFlag(String) instead of
ValueType.parse(String) when a Property's ValueType is a FlaggableType.
See FlagProp for an example type.
Note: Returning true from this method is only potentially applicable to Loaders that parse strings. Loaders that directly load from rich values do not parse, so the loader logic would ignore the value here.
Examples:
Loading a non-null value from the properties file entry 'name = ' would be unexpected,
so a properties file Loader should return 'false' here.
However, a command line loader would be expected to support flags, so should return 'true'.
isFlaggable in interface Loaderpublic String getLoaderType()
LoadergetLoaderType in interface Loaderpublic String getLoaderDialect()
LoadergetLoaderDialect in interface Loaderpublic void setUnknownPropertyAProblem(boolean isAProblem)
ReadLoadersetUnknownPropertyAProblem in interface ReadLoaderpublic boolean isUnknownPropertyAProblem()
ReadLoaderisUnknownPropertyAProblem in interface ReadLoaderCopyright © 2022. All rights reserved.