Class YamlCommentFormatter
java.lang.Object
org.simpleyaml.configuration.comments.format.YamlCommentFormatter
- All Implemented Interfaces:
CommentFormatter
- Direct Known Subclasses:
BlankLineYamlCommentFormatter,PrettyYamlCommentFormatter
Comment formatter to parse and dump YAML comments (using the # prefix).
Default format is YamlCommentFormat.DEFAULT.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final YamlCommentFormatterConfigurationprotected final YamlSideCommentFormatterConfiguration -
Constructor Summary
ConstructorsConstructorDescriptionYamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter) YamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter, YamlSideCommentFormatterConfiguration sideFormatter) -
Method Summary
Modifier and TypeMethodDescriptiondump(String comment, CommentType type, KeyTree.Node node) Given a comment returns the raw-formatted string to be dumped somewhere like a file.booleaninthashCode()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 StringparseCommentLine(String line, String prefix, boolean strip) stripPrefix(boolean strip) Set if stripping the prefix is desired.toString()trim(boolean trim) Set if leading and trailing spaces and blank lines at the beginning and end of the comments should be stripped away.
-
Field Details
-
blockFormatter
-
sideFormatter
-
-
Constructor Details
-
YamlCommentFormatter
public YamlCommentFormatter(YamlCommentFormatterConfiguration blockFormatter, YamlSideCommentFormatterConfiguration sideFormatter) -
YamlCommentFormatter
-
YamlCommentFormatter
public YamlCommentFormatter()
-
-
Method Details
-
parse
Description copied from interface:CommentFormatterParse 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.- Specified by:
parsein interfaceCommentFormatter- Parameters:
raw- the comment to parse that may contain special format characters with leading and trailing spacetype- the comment typenode- the comment node- Returns:
- the comment in the expected format to be read by humans
- Throws:
IOException- if comment cannot be parsed
-
parseCommentLine
-
dump
Description copied from interface:CommentFormatterGiven a comment returns the raw-formatted string to be dumped somewhere like a file.- Specified by:
dumpin interfaceCommentFormatter- Parameters:
comment- the comment to be dumpedtype- the comment typenode- the comment node- Returns:
- the raw-formatted comment string to be dumped, for instance to a configuration file
-
blockFormatter
-
sideFormatter
-
formatterConfiguration
-
stripPrefix
Set if stripping the prefix is desired.If strip is true then the comment prefix will be stripped away.
Default is true.
- Parameters:
strip- if stripping the prefix is desired- Returns:
- this object, for chaining
-
trim
Set if leading and trailing spaces and blank lines at the beginning and end of the comments should be stripped away.This does not affect to every line of a multiline comment. Only to the beginning and end of the whole comment.
Default is true.
- Parameters:
trim- ifString.trim()should be applied to comments- Returns:
- this object, for chaining
-
equals
-
hashCode
public int hashCode() -
toString
-