Skip to content

Components

Oswaldo Baptista Vicente Junior edited this page Jul 5, 2024 · 28 revisions

Configuration

A Configuration is an object that consists of the combination of a data Source and a Mapper to load data from different media (e.g.: file, URL) and formats (e.g.: JSON, XML, YAML), and a set of auxiliary attributes that may modify its behavior or qualify its output.

Attribute Type Description Mandatory Default
source Source The source associated with this configuration Yes N/A
mapper Mapper The mapper associated with this configuration Yes DynamicMapper1
namespace String The namespace to be assigned to this configuration for identification in a container No {empty}
precedence int The level of importance of this configuration compared to other ones in the same namespace No 0
optional boolean Marks this configuration as optional, so no exception will be raised if the source can not be found No false
lazy boolean A flag determining that the source shall not be loaded until the data is needed No false

Source

A Source is an object that basically defines the input (e.g.: file, URL) and contains built-in logic for data access.

There are different implementations available for dedicated purposes, as enumerated in the following table:

Source Purpose
ClasspathFileSource Load a file resource from the Java classpath
DynamicSource Determine the actual source dynamically by checking the string prefix
FileSource Load a file from the file system
StringSource Load contents of a string
URLSource Load contents from a URL (local file or Web resource)

Mapper

A Mapper is an object that carries the business logic for parsing the input stream open by the Source and producing the final object, which can typically be an "object container" (such as HashMap or JSON object, for example), or even POJOs (user-defined beans), depending on the selected object.

There are several mappers available for different purposes, as enumerated in the following table:

Module Mapper Input format Output type Query language
confectory-core DynamicMapper1 ini
json
properties
txt
XML
Dynamic Dynamic
DocumentMapper2 xml org.w3c.dom.Document XPath
INIToJSONObjectMapper ini net.minidev.json.JSONObject JsonPath
INIToObjectMapper<T> ini T (user-defined) N/A
JSONObjectMapper json net.minidev.json.JSONObject JsonPath
PropertiesMapper properties java.util.Properties key/value
PropertiesToObjectMapper<T> properties T (user-defined) N/A
StringMapper txt java.util.String N/A
confectory-datamapper-json-org JsonOrgJSONObjectMapper json org.json.JSONObject JsonPath
JsonOrgPropertiesToJSONObjectMapper properties
JsonOrgXMLToJSONObjectMapper xml
confectory-datamapper-gson GsonJsonObjectMapper json com.google.gson.JsonObject JsonPath
GsonJsonToObjectMapper<T> json T (user-defined) N/A
confectory-datamapper-jackson2-json JacksonJsonNodeMapper json com.fasterxml.jackson.databind.JsonNode JsonPath
JacksonJsonToObjectMapper<T> json T (user-defined) N/A
confectory-datamapper-jackson2-toml JacksonTOMLToJsonNodeMapper toml com.fasterxml.jackson.databind.JsonNode JsonPath
JacksonTOMLToObjectMapper<T> toml T (user-defined) N/A
confectory-datamapper-jackson2-xml JacksonXMLToJsonNodeMapper xml com.fasterxml.jackson.databind.JsonNode JsonPath
JacksonXMLToObjectMapper<T> xml T (user-defined) N/A
confectory-datamapper-jackson2-yaml JacksonYAMLToJsonNodeMapper yaml com.fasterxml.jackson.databind.JsonNode JsonPath
JacksonYAMLToObjectMapper<T> yaml T (user-defined) N/A
confectory-datamapper-saxon12 SaxonXdmNodeMapper1 xml net.sf.saxon.s9api.XdmNode XPath
confectory-datamapper-snakeyaml YAMLToJSONObjectMapper yaml net.minidev.json.JSONObject JsonPath
YAMLToObjectMapper<T> yaml T (user-defined) N/A

1 Since 2.6.0
2 Since 2.4.0

Clone this wiki locally