public class YamlHeaderFormatter extends Object implements org.simpleyaml.configuration.comments.format.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,
org.simpleyaml.configuration.comments.CommentType type,
org.simpleyaml.configuration.comments.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,
org.simpleyaml.configuration.comments.CommentType type,
org.simpleyaml.configuration.comments.KeyTree.Node node) |
String |
parse(String raw,
org.simpleyaml.configuration.comments.CommentType type,
org.simpleyaml.configuration.comments.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, org.simpleyaml.configuration.comments.CommentType type, org.simpleyaml.configuration.comments.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 org.simpleyaml.configuration.comments.format.CommentFormatter
raw
- the string to parseIOException
public String parse(Reader raw, org.simpleyaml.configuration.comments.CommentType type, org.simpleyaml.configuration.comments.KeyTree.Node node) throws IOException
parse
in interface org.simpleyaml.configuration.comments.format.CommentFormatter
IOException
public String dump(String header, org.simpleyaml.configuration.comments.CommentType type, org.simpleyaml.configuration.comments.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 org.simpleyaml.configuration.comments.format.CommentFormatter
header
- the header to dumppublic 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.