Package de.sfuhrm.sudoku.output
Class JsonArrayFormatter
java.lang.Object
de.sfuhrm.sudoku.output.JsonArrayFormatter
- All Implemented Interfaces:
GameMatrixFormatter
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFormats the document end part.Formats the document start part.format(de.sfuhrm.sudoku.GameMatrix matrix) Formats the input game matrix to a text representation.final StringGets the column separator String to use.final StringGets the row separator String to use.final StringGets the String to use for unknown/unset cells.final voidsetColumnSeparator(String newColumnSeparator) Sets the column separator String to use.voidsetIndent(boolean set) Whether to indent the output or not.final voidsetRowSeparator(String newRowSeparator) Sets the row separator String to use.final voidsetUnknownCellContentCharacter(String newUnknownCellContentCharacter) Sets the String to use for unknown/unset cells.
-
Constructor Details
-
JsonArrayFormatter
public JsonArrayFormatter()Constructs a new instance.
-
-
Method Details
-
format
Description copied from interface:GameMatrixFormatterFormats 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-trueif indention is desired.
-
documentStart
Description copied from interface:GameMatrixFormatterFormats the document start part.- Specified by:
documentStartin interfaceGameMatrixFormatter- Returns:
- a String representation of the document start.
-
documentEnd
Description copied from interface:GameMatrixFormatterFormats the document end part.- Specified by:
documentEndin interfaceGameMatrixFormatter- Returns:
- a String representation of the document end.
-
getUnknownCellContentCharacter
Gets the String to use for unknown/unset cells.- Returns:
- the unknown cell content String.
-
setUnknownCellContentCharacter
Sets the String to use for unknown/unset cells.- Parameters:
newUnknownCellContentCharacter- the new value for unknown cells.
-
getRowSeparator
Gets the row separator String to use.- Returns:
- the row separator String.
-
setRowSeparator
Sets the row separator String to use.- Parameters:
newRowSeparator- the new String to use as row separator.
-
getColumnSeparator
Gets the column separator String to use.- Returns:
- the column separator String.
-
setColumnSeparator
Sets the column separator String to use.- Parameters:
newColumnSeparator- the new String to use as column separator.
-