Class YamlCommentFormatter

java.lang.Object
org.simpleyaml.configuration.comments.format.YamlCommentFormatter
All Implemented Interfaces:
org.simpleyaml.configuration.comments.format.CommentFormatter
Direct Known Subclasses:
BlankLineYamlCommentFormatter, PrettyYamlCommentFormatter

public class YamlCommentFormatter extends Object implements org.simpleyaml.configuration.comments.format.CommentFormatter
Comment formatter to parse and dump YAML comments (using the # prefix).

Default format is YamlCommentFormat.DEFAULT.

  • Field Details

  • Constructor Details

  • Method Details

    • parse

      public String parse(Reader raw, org.simpleyaml.configuration.comments.CommentType type, org.simpleyaml.configuration.comments.KeyTree.Node node) throws IOException
      Specified by:
      parse in interface org.simpleyaml.configuration.comments.format.CommentFormatter
      Throws:
      IOException
    • parseCommentLine

      protected String parseCommentLine(String line, String prefix, boolean strip)
    • dump

      public String dump(String comment, org.simpleyaml.configuration.comments.CommentType type, org.simpleyaml.configuration.comments.KeyTree.Node node)
      Specified by:
      dump in interface org.simpleyaml.configuration.comments.format.CommentFormatter
    • blockFormatter

      public final YamlCommentFormatterConfiguration blockFormatter()
    • sideFormatter

      public final YamlSideCommentFormatterConfiguration sideFormatter()
    • formatterConfiguration

      public final YamlCommentFormatterConfiguration formatterConfiguration(org.simpleyaml.configuration.comments.CommentType type)
    • stripPrefix

      public YamlCommentFormatter stripPrefix(boolean strip)
      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

      public 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.

      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 - if String.trim() should be applied to comments
      Returns:
      this object, for chaining
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object