Add sections to configuration API.


Some file formats such as INI naturally have the idea of "sections", e.g.:

Here a section is indicated by something special about the identifier: the brackets of [example].

But TURF files have something equivalent, indicated, not by the property, but the the fact that a property value is an object:

The two examples above could be seen as semantically equivalent. In addition TURF allows each "section" to have a type, e.g. the FooBar type:

Confound's Configuration needs to have the ability to send back a Configuration for any value, as well as convenience Configuration.get/findSection() methods. (Consider having a Section interface that is just a Configuration but that provides access to the Configuration for which it is a section.) There also needs to be a method of a Configuration that says, "retrieve all the sections" probably as an Iterable<Section>. Thsi would return all first-level sections. Lastly all configurations need the ability to indicate a "type", as the root configuration may have a type indicated in the underlying storage.




Garret Wilson
September 15, 2019, 2:48 PM

Another question is what type to return for Section.getSectionType(). Preferably we would want to return a String, but then for URF what would we return for types that don't have handles, e.g. types with the tag The obvious answer would be to return an URF handle when you can, but return the string form of the URI when there is no handle. But that seems a bit of a kludge, especially since a handle like FooBar could also be represented by

Maybe it's best, though, to assume that, although TURF can handle names in other namespaces, that most people using TURF for configurations will use names in the ad-hoc namespace or subnamespaces, such as foo-Bar. The URF implementation can return an IRI string for names in other namespaces, although we expect that this will seldom if ever occur for the moment.

Garret Wilson
September 15, 2019, 2:39 PM

One open question is what we we will call the type retrieval method. We could call it getSectionType(), but that would seem odd on the Configuration interface if there is also a Section interface. And we need the method on the root Configuration because e.g. a TURF file could have a root type, such as:

Perhaps the solution is to add the getSectionType() to the Section interface, but not all Configuration implementations are necessarily Section}}s. Thus if you wanted to get the root section type, you'd have to first make sure the {{Configuration implemented Section as well before asking.



Garret Wilson


Garret Wilson



Fix versions