Class SeparatorWriter

java.lang.Object
com.mapr.utils.SeparatorWriter

public class SeparatorWriter extends Object
Assistance for writing separators in strings. The user indicates if anything has been written and that a separator is necessary. Then, later, the user can make a request to write a separator to the string being built, and it will only be written if a previous request indicated that separator is necessary.
  • Constructor Details

    • SeparatorWriter

      public SeparatorWriter(StringBuilder sb, String separatorStr)
      Constructor.
      Parameters:
      sb - the StringBuilder being used to build the String
      separatorStr - the separator string to use
  • Method Details

    • needSeparator

      public void needSeparator()
      Indicate that a separator will be required the next time one is requested. If this is not called, then calls to writeSeparator() will do nothing.
    • writeSeparator

      public void writeSeparator()
      Request to write a separator if one is necessary. Necessity is determined by a previous call to needSeparator() that has not yet been fulfilled.