Interface Backend.Meta
- Enclosing interface:
Backend
For callers familiar with the java.sql module, this type is analogous to JDBC's DatabaseMetaData. It
provides information about the backend implementation itself, such as its supported capabilities.
New methods may be added to this interface in the future, but they will always be default methods.
Implementors of Backend are encouraged to keep up-to-date with this interface by checking minor version
release notes.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the backend only recognizes string keys.booleanpreservesOrder(boolean reading) Whether this backend supports preservation of data entry order.booleansupportsComments(boolean documentLevel, boolean reading, @NonNull CommentLocation location) Whether comments are supported in the following context.booleanWhether the backend writesfloatvalues by casting them todouble.
-
Method Details
-
supportsComments
Whether comments are supported in the following context.The context is defined by whether the comments are placed on the document level or on specific entries, if the comments are being read or written, and where the comments are located with respect to entries. For example,
documentLevel = true, false, andABOVEspecifies the writability of the document-level header, anddocumentLevel = false, true, andINLINEspecify the capability to read inline comments on entries. The return value would then indicate whether comments are handled in this context.Implications
If comments are not supported in this context, this format backend is free to ignore them during
Backend.write(Document).If this method returns true for
reading = trueandreading = falsewith otherwise identicaldocumentLevelandlocation, that implies that comments in such context will be correctly read -- and identically reconstituted -- byreadprovided they were written bywrite.Ignored comments during reading
Note that some backends may expose comments in other places, not covered by this library. An example would be comments on list entries - because the API only supports comments on map entries. These comments are impossible to return from a call to
read, meaning they are necessarily produced by the end user. Such kind of comments should have no bearing on this method's results.- Parameters:
documentLevel- true for the document level, false for entry-level commentsreading- true for reading comments, false for writing themlocation- the location of the comments for whom support is queried- Returns:
- if the backend supports comments in this context
-
preservesOrder
boolean preservesOrder(boolean reading) Whether this backend supports preservation of data entry order.The
readingparameter defines where ordering happens. If ordering is preserved when reading, this method should return true whenreading = true, and if ordering is preserved when writing, it should return true whenwriting = true.Implications
If order is not preserved during reading, entries in a data tree may be read in any order. If not preserved during writing, the serialized format may be written in a different order.
If order is preserved in both contexts, then the backend should preserve a stable iteration order across multiple calls to
readandwriteusing the same data. Loading a data tree should produce an order which remains stable if that same tree is written and re-read at a later point.- Parameters:
reading- true for reading data, false for writing it- Returns:
- if order is preserved across the reading or writing operation
-
writesFloatAsDouble
boolean writesFloatAsDouble()Whether the backend writesfloatvalues by casting them todouble.Some backend formats do not inherently support floats, but the
Backendimplementation is required to write them if they appear.Implications
If this method returns true, the
Backendwill write float values by first casting them to doubles. Conversion operations may lead to a loss of precision in some cases.- Returns:
- if the backend writes float as doubles
-
allKeysAreStrings
boolean allKeysAreStrings()Whether the backend only recognizes string keys.Some backend formats do not support non-string keys, meaning that all keys (no matter what type they appear to be) will be loaded as strings.
Implications
If this method returns true, all keys in a loaded
DataTreewill be strings. During writing, if a non-string key is encountered, theBackendimplementation will convert the key to a string using itstoString()method.- Returns:
- if the backend loads all keys as strings, and writes them as strings likewise
-