Class TomlPositions
var document = Toml.parse(file);
var save = document.root().getTable("commands.save");
if (!save.entries().containsKey("command")) {
var position = document.positions().key(document.root().getTable("commands"), "save");
report(position.line(), position.column(), "[commands.save] names no command");
}
A position is looked up by the table or array that holds the key or the element, which must be the very instance
the parse returned: positions compare tables and arrays by identity, as equal tables can be written in several
places. A copy of a table, such as one built from it with TomlTable.toBuilder(), has no positions.
The key is a key of that table, never a dotted path: the position of port in [server] is
key(root.getTable("server"), "port").
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionReturns where an element of an array starts.Returns where a key of a table is written.Returns where the value of a key of a table starts.
-
Method Details
-
key
Returns where a key of a table is written.That is the key itself, or its own part of a dotted key: the position of
savein[commands.save]is that ofsave. A table that is defined in several places, as a table implicitly defined by[a.b]and then by[a], is at its header. An array of tables is at its first header.- Parameters:
table- a table of the documentkey- a key oftable- Returns:
- the position of
key - Throws:
IllegalArgumentException- iftableis not a table of the document, or has no keykeyNullPointerException- if an argument is null
-
value
Returns where the value of a key of a table starts.That is the first character of the value, which is the opening bracket or brace of an array or an inline table. For a table defined by a header, it is the header's opening bracket, and for an array of tables, its first header's. A table that only exists as the parent of others, as
afor[a.b]ora.b = 1, is at its key.- Parameters:
table- a table of the documentkey- a key oftable- Returns:
- the position of the value of
key - Throws:
IllegalArgumentException- iftableis not a table of the document, or has no keykeyNullPointerException- if an argument is null
-
element
Returns where an element of an array starts.That is the first character of the element, as for
value(TomlTable, String). The element of an array of tables is at the opening bracket of its header.- Parameters:
array- an array of the documentindex- the index of an element ofarray- Returns:
- the position of the element
- Throws:
IllegalArgumentException- ifarrayis not an array of the documentIndexOutOfBoundsException- ifindexis not an index ofarrayNullPointerException- ifarrayis null
-