Class ParentheticalStringBuilder

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ParentheticalStringBuilder
    extends PrependingStringBuilder
    implements java.lang.AutoCloseable
    IndentingStringBuilder that can be used to wrap appended material with an opening and closing String, but only if any material is written. The opening and closing Strings won't be written unless something else is written to this builder. Note that the closing String also won't be written if this builder is not close()d.
    • Constructor Detail

      • ParentheticalStringBuilder

        public ParentheticalStringBuilder​(IndentingStringBuilder sb,
                                          java.lang.String openString,
                                          java.lang.String closeString)
        Constructor.
        Parameters:
        sb - the IndentingStringBuilder to write to
        openString - the opening string
        closeString - the closing string
      • ParentheticalStringBuilder

        public ParentheticalStringBuilder​(IndentingStringBuilder sb)
        Constructor. This constructor provides "(" and ")" as the opening and closing Strings.
        Parameters:
        sb - the IndentingStringBuilder to write to
    • Method Detail

      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception