Package org.tomlj
Class TomlComment
java.lang.Object
org.tomlj.TomlComment
- All Implemented Interfaces:
TomlElement
A comment in a TOML document, either attached to an entry or unattached.
A comment attached to an entry is either the run of comment lines directly above it (TomlComment.Placement.ABOVE) or the
comment on its line (TomlComment.Placement.AFTER); every other comment is unattached, and belongs to the table or array
it was written in. An entry has at most one comment of each placement.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhere a comment sits relative to the entry it is attached to. -
Method Summary
Modifier and TypeMethodDescriptionlines()The text of each line, one entry per line of the run, in document order.Where this comment sits relative to the entry it is attached to.@Nullable TomlPositionposition()The position of the#opening the first line of this comment.text()The lines of this comment, joined with\n.toString()
-
Method Details
-
lines
The text of each line, one entry per line of the run, in document order.Each entry is the text after the
#, with one leading space removed if there is one, so# fooand#fooboth givefoo, while a line written with two spaces keeps its second. A bare#gives an empty string. No entry contains a newline.An attached
TomlComment.Placement.AFTERcomment has exactly one line.- Returns:
- The text of each line, in document order. Unmodifiable.
-
text
The lines of this comment, joined with\n.- Returns:
- The lines of this comment, joined with
\n.
-
position
The position of the#opening the first line of this comment.The lines of a run are contiguous, so line
iof the run is on lineposition().line() + i.- Specified by:
positionin interfaceTomlElement- Returns:
- The position of the
#opening the first line, ornullif this comment was not read from a document.
-
placement
Where this comment sits relative to the entry it is attached to.- Returns:
TomlComment.Placement.ABOVEorTomlComment.Placement.AFTERfor an attached comment, orTomlComment.Placement.UNATTACHEDfor an unattached one.
-
toString
-