Package de.sfuhrm.sudoku.output
Class JsonArrayFormatter
- java.lang.Object
-
- de.sfuhrm.sudoku.output.JsonArrayFormatter
-
- All Implemented Interfaces:
GameMatrixFormatter
public final class JsonArrayFormatter extends java.lang.ObjectFormats 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 Constructor Description JsonArrayFormatter()Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringdocumentEnd()Formats the document end part.java.lang.StringdocumentStart()Formats the document start part.java.lang.Stringformat(GameMatrix matrix)Formats the input game matrix to a text representation.java.lang.StringgetLineSeparator()Gets the line separator String to use.java.lang.StringgetUnknownCellContentCharacter()Gets the String to use for unknown/unset cells.voidsetIndent(boolean set)Whether to indent the output or not.voidsetLineSeparator(java.lang.String newLineSeparator)Sets the line separator String to use.voidsetUnknownCellContentCharacter(java.lang.String newUnknownCellContentCharacter)Sets the String to use for unknown/unset cells.
-
-
-
Method Detail
-
format
public java.lang.String format(GameMatrix matrix)
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
public java.lang.String documentStart()
Description copied from interface:GameMatrixFormatterFormats the document start part.- Specified by:
documentStartin interfaceGameMatrixFormatter- Returns:
- a String representation of the document start.
-
documentEnd
public java.lang.String documentEnd()
Description copied from interface:GameMatrixFormatterFormats the document end part.- Specified by:
documentEndin interfaceGameMatrixFormatter- Returns:
- a String representation of the document end.
-
getUnknownCellContentCharacter
public final java.lang.String getUnknownCellContentCharacter()
Gets the String to use for unknown/unset cells.- Returns:
- the unknown cell content String.
-
setUnknownCellContentCharacter
public final void setUnknownCellContentCharacter(java.lang.String newUnknownCellContentCharacter)
Sets the String to use for unknown/unset cells.- Parameters:
newUnknownCellContentCharacter- the new value for unknown cells.
-
getLineSeparator
public final java.lang.String getLineSeparator()
Gets the line separator String to use.- Returns:
- the line separator String.
-
setLineSeparator
public final void setLineSeparator(java.lang.String newLineSeparator)
Sets the line separator String to use.- Parameters:
newLineSeparator- the new String to use as line separator.
-
-