Class JsonArrayFormatter

  • All Implemented Interfaces:
    GameMatrixFormatter

    public final class JsonArrayFormatter
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      JsonArrayFormatter()
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String documentEnd()
      Formats the document end part.
      java.lang.String documentStart()
      Formats the document start part.
      java.lang.String format​(GameMatrix matrix)
      Formats the input game matrix to a text representation.
      java.lang.String getLineSeparator()
      Gets the line separator String to use.
      java.lang.String getUnknownCellContentCharacter()
      Gets the String to use for unknown/unset cells.
      void setIndent​(boolean set)
      Whether to indent the output or not.
      void setLineSeparator​(java.lang.String newLineSeparator)
      Sets the line separator String to use.
      void setUnknownCellContentCharacter​(java.lang.String newUnknownCellContentCharacter)
      Sets the String to use for unknown/unset cells.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonArrayFormatter

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

      • format

        public java.lang.String format​(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 java.lang.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 java.lang.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 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.