public abstract class BaseLoader extends Object implements Loader
| Constructor and Description |
|---|
BaseLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
attemptToAdd(PropertyConfigurationInternal appConfigDef,
List<ValidatedValue> values,
ProblemList<Problem> loaderProblems,
Property prop,
Object value)
Util method to attempt to load an object of an unknown type to a property.
|
protected void |
attemptToAdd(PropertyConfigurationInternal appConfigDef,
List<ValidatedValue> values,
ProblemList<Problem> loaderProblems,
String key,
Object value)
Util method to load an Object value to a named Property.
|
protected void |
attemptToAdd(PropertyConfigurationInternal appConfigDef,
List<ValidatedValue> values,
ProblemList<Problem> loaderProblems,
String key,
String strValue)
Util method to load a String to a property by name.
|
protected void |
attemptToAddIfNotDuplicate(PropertyConfigurationInternal appConfigDef,
List<ValidatedValue> values,
ProblemList<Problem> loaderProblems,
ValidatedValue validatedValue)
Adds the ValidatedValue to the VV list if it is not a duplicate.
|
protected <T> ValidatedValue |
createValue(Property<T> prop,
String untrimmedString)
Central method for parsing Strings into a Property value.
|
protected ValidatedValue |
findDuplicateProperty(ValidatedValue current,
List<ValidatedValue> values) |
Class<?> |
getClassConfig()
Returns a PropertyGroup used to globally configure a class of Loader.
|
SamplePrinter |
getConfigSamplePrinter()
Returns a ConfigSamplePrinter, which can be used to print a configuration
sample for this Loader.
|
List<Property> |
getInstanceConfig()
A list of properties that the user has specified as being configuration
properties for this Loader.
|
protected Property |
mapNametoProperty(PropertyConfigurationInternal appConfigDef,
String name)
Maps the passed Property name or alias to a Property or null if it cannot be found.
|
void |
releaseResources()
Release any resources held by this loader.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLoaderDialect, getLoaderType, getSpecificLoadDescription, isFlaggable, isTrimmingRequiredForStringValues, loadpublic Class<?> getClassConfig()
LoadergetClassConfig in interface Loaderpublic List<Property> getInstanceConfig()
LoadergetInstanceConfig in interface Loaderpublic SamplePrinter getConfigSamplePrinter()
LoadergetConfigSamplePrinter in interface Loaderprotected void attemptToAdd(PropertyConfigurationInternal appConfigDef, List<ValidatedValue> values, ProblemList<Problem> loaderProblems, String key, String strValue)
Used for text based loaders.
appConfigDef - Used to look up the property name for find the actual propertyvalues - List of PropertyValues to add to, which should be only the value of this loader.loaderProblems - A list of Problems to add to if there is a loader related problemkey - The property namestrValue - The property valueprotected void attemptToAdd(PropertyConfigurationInternal appConfigDef, List<ValidatedValue> values, ProblemList<Problem> loaderProblems, String key, Object value)
Intended for code-based loaders where Property names are specified with Object based keys. This would happen with hardcoded / in-code loaders, likely during testing, where property values can be specified as real objects, but the Properties themselves may not all be visible, so names are used instead of Property references.
appConfigDef - Used to look up the property name for find the actual propertyvalues - List of PropertyValues to add to, which should be only the value of this loader.loaderProblems - A list of Problems to add to if there is a loader related problemkey - The property namevalue - The property value as an Object, already of the expected type for the Property.protected void attemptToAdd(PropertyConfigurationInternal appConfigDef, List<ValidatedValue> values, ProblemList<Problem> loaderProblems, Property prop, Object value)
Used for object based loaders where value are not in text form. This loader assumes the passed property is a valid property to load to, but it will check to make sure it is not null, which is not treated as an error.
appConfigDef - Used to look up the property name for find the actual propertyvalues - List of PropertyValues to add to, which should be only the value of this loader.loaderProblems - A list of LoaderProblems to add to if there is a loader related problemprop - The Property to load tovalue - The Object to be loaded to this property. If a String and that does
not match the Property type, parsing is attempted to convert it.protected void attemptToAddIfNotDuplicate(PropertyConfigurationInternal appConfigDef, List<ValidatedValue> values, ProblemList<Problem> loaderProblems, ValidatedValue validatedValue)
Loader subclasses should use the other attemptToAdd methods - this one is invoked by those.
appConfigDef - Used to look up the property name for find the actual propertyvalues - List of PropertyValues to add to, which should be only the value of this loader.loaderProblems - A list of Problems to add to if there is a loader related problemvalidatedValue - The validated value to load, which may be null which is a no-op.protected ValidatedValue findDuplicateProperty(ValidatedValue current, List<ValidatedValue> values)
protected <T> ValidatedValue createValue(Property<T> prop, String untrimmedString) throws ParsingException
This method throws a ParsingException if the value cannot be parsed into the destination
type. If that happens, the caller should consider it a LoaderProblem, not a
ValueProblem.
If a loader bypasses this method, it must replicate the trimming and (non) validation logic in this method to ensure String are trimmed appropriately. Specifically:
Loader.isTrimmingRequiredForStringValues() returns true.T - The destination type of the Property (i.e., an IntProp is Integer).prop - The Property the untrimmedString String holds the value foruntrimmedString - A String to be parsed into the destination type of the Property.ValidatedValue containing the Property and the resulting value. Validation
has not yet been applied to the ValidatedValue, so it won't have any Problems listed.ParsingException - If the String value cannot be parsed into the destination type.protected Property mapNametoProperty(PropertyConfigurationInternal appConfigDef, String name)
appConfigDef - The AppConfigname - The name, which will be trimmed and converted to an effective name.public void releaseResources()
LoaderreleaseResources in interface LoaderCopyright © 2022. All rights reserved.