public class YamlCommentFormatter extends Object implements CommentFormatter
Default format is YamlCommentFormat.DEFAULT
.
Modifier and Type | Field and Description |
---|---|
protected YamlCommentFormatterConfiguration |
blockFormatter |
protected YamlSideCommentFormatterConfiguration |
sideFormatter |
Constructor and Description |
---|
YamlCommentFormatter() |
YamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter) |
YamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter,
YamlSideCommentFormatterConfiguration sideFormatter) |
Modifier and Type | Method and Description |
---|---|
YamlCommentFormatterConfiguration |
blockFormatter() |
String |
dump(String comment,
CommentType type,
KeyTree.Node node)
Given a comment returns the raw-formatted string to be dumped somewhere like a file.
|
boolean |
equals(Object o) |
YamlCommentFormatterConfiguration |
formatterConfiguration(CommentType type) |
int |
hashCode() |
String |
parse(Reader raw,
CommentType type,
KeyTree.Node node)
Parse the comment from a reader that may contain a raw-formatted comment (for instance from a configuration file)
to a human-friendly contentful representation of that comment.
|
protected String |
parseCommentLine(String line,
String prefix,
boolean strip) |
YamlSideCommentFormatterConfiguration |
sideFormatter() |
YamlCommentFormatter |
stripPrefix(boolean strip)
Set if stripping the prefix is desired.
|
String |
toString() |
YamlCommentFormatter |
trim(boolean trim)
Set if leading and trailing spaces and blank lines at the beginning and end of the comments should be stripped away.
|
protected final YamlCommentFormatterConfiguration blockFormatter
protected final YamlSideCommentFormatterConfiguration sideFormatter
public YamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter, YamlSideCommentFormatterConfiguration sideFormatter)
public YamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter)
public YamlCommentFormatter()
public String parse(Reader raw, CommentType type, KeyTree.Node node) throws IOException
CommentFormatter
parse
in interface CommentFormatter
raw
- the comment to parse that may contain special format characters with leading and trailing spacetype
- the comment typenode
- the comment nodeIOException
- if comment cannot be parsedpublic String dump(String comment, CommentType type, KeyTree.Node node)
CommentFormatter
dump
in interface CommentFormatter
comment
- the comment to be dumpedtype
- the comment typenode
- the comment nodepublic final YamlCommentFormatterConfiguration blockFormatter()
public final YamlSideCommentFormatterConfiguration sideFormatter()
public final YamlCommentFormatterConfiguration formatterConfiguration(CommentType type)
public YamlCommentFormatter stripPrefix(boolean strip)
If strip is true then the comment prefix will be stripped away.
Default is true.
strip
- if stripping the prefix is desiredpublic YamlCommentFormatter trim(boolean trim)
This does not affect to every line of a multiline comment. Only to the beginning and end of the whole comment.
Default is true.
trim
- if String.trim()
should be applied to commentsCopyright © 2023. All rights reserved.