Class JsonArrayFormatter

java.lang.Object
de.sfuhrm.sudoku.output.JsonArrayFormatter
All Implemented Interfaces:
GameMatrixFormatter

public final class JsonArrayFormatter extends Object
Formats the game matrices to a 3-dimensional JSON array. The outer dimension is the matrix itself. The next dimension is the row. The last dimension is the column containing numbers from 0 (for UNSET) over 1 to 9.
Author:
Stephan Fuhrmann
  • Constructor Details

    • JsonArrayFormatter

      public JsonArrayFormatter()
      Constructs a new instance.
  • Method Details

    • format

      public String format(de.sfuhrm.sudoku.GameMatrix matrix)
      Description copied from interface: GameMatrixFormatter
      Formats the input game matrix to a text representation.
      Parameters:
      matrix - the matrix to format to String format.
      Returns:
      a String representation of the game matrix.
    • setIndent

      public void setIndent(boolean set)
      Whether to indent the output or not.
      Parameters:
      set - true if indention is desired.
    • documentStart

      public String documentStart()
      Description copied from interface: GameMatrixFormatter
      Formats the document start part.
      Specified by:
      documentStart in interface GameMatrixFormatter
      Returns:
      a String representation of the document start.
    • documentEnd

      public String documentEnd()
      Description copied from interface: GameMatrixFormatter
      Formats the document end part.
      Specified by:
      documentEnd in interface GameMatrixFormatter
      Returns:
      a String representation of the document end.
    • getUnknownCellContentCharacter

      public final String getUnknownCellContentCharacter()
      Gets the String to use for unknown/unset cells.
      Returns:
      the unknown cell content String.
    • setUnknownCellContentCharacter

      public final void setUnknownCellContentCharacter(String newUnknownCellContentCharacter)
      Sets the String to use for unknown/unset cells.
      Parameters:
      newUnknownCellContentCharacter - the new value for unknown cells.
    • getRowSeparator

      public final String getRowSeparator()
      Gets the row separator String to use.
      Returns:
      the row separator String.
    • setRowSeparator

      public final void setRowSeparator(String newRowSeparator)
      Sets the row separator String to use.
      Parameters:
      newRowSeparator - the new String to use as row separator.
    • getColumnSeparator

      public final String getColumnSeparator()
      Gets the column separator String to use.
      Returns:
      the column separator String.
    • setColumnSeparator

      public final void setColumnSeparator(String newColumnSeparator)
      Sets the column separator String to use.
      Parameters:
      newColumnSeparator - the new String to use as column separator.