public class YamlHeaderFormatter extends Object implements CommentFormatter
Modifier and Type | Field and Description |
---|---|
protected YamlCommentFormatterConfiguration |
configuration |
Modifier | Constructor and Description |
---|---|
|
YamlHeaderFormatter() |
|
YamlHeaderFormatter(String commentPrefix,
boolean strip) |
protected |
YamlHeaderFormatter(YamlCommentFormatterConfiguration configuration) |
Modifier and Type | Method and Description |
---|---|
String |
commentPrefix()
Gets the comment prefix to apply to every line of the header.
|
YamlHeaderFormatter |
commentPrefix(String commentPrefix)
Sets the comment prefix to apply to every line of the header.
|
YamlHeaderFormatter |
commentSuffix(String suffixMultiline)
Set the comment suffix to append to every line of the header.
|
String |
dump(String header,
CommentType type,
KeyTree.Node node)
Given the header (for instance the one returned by
parse(java.lang.String, org.simpleyaml.configuration.comments.CommentType, org.simpleyaml.configuration.comments.KeyTree.Node) ),
returns the final string formatted to be dumped somewhere like a file. |
boolean |
equals(Object o) |
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.
|
String |
parse(String raw,
CommentType type,
KeyTree.Node node)
Parse the header of a contents string, like a file contents.
|
YamlHeaderFormatter |
prefixFirst(String commentPrefixFirst)
Sets the comment prefix to apply to the beginning of the header.
|
boolean |
stripPrefix()
If strip is true then
String.trim() will be applied to every line of the header
and the commentPrefix() will be stripped away. |
YamlHeaderFormatter |
stripPrefix(boolean stripPrefix)
Set if stripping the prefix is desired.
|
YamlHeaderFormatter |
suffixLast(String suffixLast)
Set the suffix to append to the end of the header.
|
protected YamlCommentFormatterConfiguration configuration
protected YamlHeaderFormatter(YamlCommentFormatterConfiguration configuration)
public YamlHeaderFormatter(String commentPrefix, boolean strip)
public YamlHeaderFormatter()
public String parse(String raw, CommentType type, KeyTree.Node node) throws IOException
stripPrefix()
is true then String.trim()
will be applied to every line of the header
and the commentPrefix()
will be stripped away.parse
in interface CommentFormatter
raw
- the string to parsetype
- the comment typenode
- the comment nodeIOException
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 header, CommentType type, KeyTree.Node node)
parse(java.lang.String, org.simpleyaml.configuration.comments.CommentType, org.simpleyaml.configuration.comments.KeyTree.Node)
),
returns the final string formatted to be dumped somewhere like a file.
The header ends with a blank line and every line is prefixed with the commentPrefix()
.
If all header lines are already prefixed with a # then the commentPrefix()
is not applied.
dump
in interface CommentFormatter
header
- the header to dumptype
- the comment typenode
- the comment nodepublic boolean stripPrefix()
String.trim()
will be applied to every line of the header
and the commentPrefix()
will be stripped away.
Default is false.public YamlHeaderFormatter stripPrefix(boolean stripPrefix)
String.trim()
will be applied to every line of the header
and the commentPrefix()
will be stripped away.
Default is false.stripPrefix
- if stripping the prefix is desiredpublic String commentPrefix()
public YamlHeaderFormatter commentPrefix(String commentPrefix)
commentPrefix
- the comment prefixpublic YamlHeaderFormatter prefixFirst(String commentPrefixFirst)
commentPrefixFirst
- the comment prefix to apply to the beginning of the headerpublic YamlHeaderFormatter commentSuffix(String suffixMultiline)
suffixMultiline
- the suffix to append to every line of the headerpublic YamlHeaderFormatter suffixLast(String suffixLast)
suffixLast
- the suffix to append to the end of the headerCopyright © 2023. All rights reserved.