Package edu.wisc.game.rest

## Class Files

- java.lang.Object
- - edu.wisc.game.rest.Files

-     public class Files
      extends Object

  Information about the data files the Rule Game web server reads and writes

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Files()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static File` | `boardsFile​(String playerId)` | The file into which the initial boards of all episodes played by a given player are written
    `static File` | `detailedTranscriptsFile​(String playerId)` |
    `static File` | `getImageFile​(String shape)` | Looks for an image file with an appropriate name in the shapes directory.
    `static File` | `getSvgFile​(Piece.Shape shape)` |
    `static File` | `getSvgFile​(String shape)` |
    `static File` | `guessesFile​(String playerId)` | The file into which guesses by a given player are written
    `static File` | `initialBoardFile​(String boardName)` |
    `static File` | `inputBoardSubdir​(String boardSubdirName)` | A subdirectory of the input boards directory, for use in a param set with initial boards
    `static String[]` | `listSAllExperimentPlans()` | List all existing experiment plans (based on the directory names in the appropriate tree)
    `static String` | `listSAllExperimentPlansHtml()` | Creates an HTML snippet (to be used inside a FORM) listing all currently existing experiment plans.
    `static boolean` | `rulesCanBeCached​(String ruleSetName)` | Can the game server cache this rule set? The convention is, names not starting with a slash refer to files in the tomcat directory, whose content is supposed to be stable; therefore, they can be cached in the web app.
    `static File` | `rulesFile​(String ruleSetName)` |
    `static void` | `setInputDir​(String path)` | Sets the path to the input directory, which is the root of the tree that contains the experiment control files.
    `static File` | `shapesDir()` |
    `static File` | `transcriptsFile​(String playerId)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Files

          public Files()

  - ### Method Detail

    - #### setInputDir

          public static void setInputDir​(String path)

      Sets the path to the input directory, which is the root of the tree that contains the experiment control files. You only need to use this method if you want trial list files, rule set files, etc. to be read from directories in a directory tree other than the default ("/opt/tomcat/game-data"). So, for example, the Captive Game Server may use this method. If you use it, do so early in your application.
      Parameters:
        `path` - E.g. "/opt/tomcat/game-data"

    - #### guessesFile

          public static File guessesFile​(String playerId)
                                  throws IOException

      The file into which guesses by a given player are written
      Throws:
        `IOException`

    - #### boardsFile

          public static File boardsFile​(String playerId)
                                 throws IOException

      The file into which the initial boards of all episodes played by a given player are written
      Throws:
        `IOException`

    - #### transcriptsFile

          public static File transcriptsFile​(String playerId)
                                      throws IOException

      Throws:
        `IOException`

    - #### detailedTranscriptsFile

          public static File detailedTranscriptsFile​(String playerId)
                                              throws IOException

      Throws:
        `IOException`

    - #### shapesDir

          public static File shapesDir()

    - #### rulesFile

          public static File rulesFile​(String ruleSetName)
                                throws IOException

      Parameters:
        `ruleSetName` - Either a complete absolute path name ("/home/vmenkov/foo.txt") starting with a slash, or just a file name without the extension ("foo"). In the later case, the file is assumed to be in the standard rules directory.
      Throws:
        `IOException`

    - #### rulesCanBeCached

          public static boolean rulesCanBeCached​(String ruleSetName)

      Can the game server cache this rule set? The convention is, names not starting with a slash refer to files in the tomcat directory, whose content is supposed to be stable; therefore, they can be cached in the web app. Names starting with a slash are interpreted as absolute paths of files, presumably belonging to developers and thus possibly not stable; so the game server does not cache those.

    - #### initialBoardFile

          public static File initialBoardFile​(String boardName)
                                       throws IOException

      Throws:
        `IOException`

    - #### inputBoardSubdir

          public static File inputBoardSubdir​(String boardSubdirName)
                                       throws IOException

      A subdirectory of the input boards directory, for use in a param set with initial boards
      Throws:
        `IOException`

    - #### getSvgFile

          public static File getSvgFile​(Piece.Shape shape)

    - #### getSvgFile

          public static File getSvgFile​(String shape)

      Parameters:
        `shape` - Case-insensitive shape name, e.g. "circle", or "arrows/up". To obtain the SVG file name, the shape name is converted to lower case, and ".svg" is added.

    - #### getImageFile

          public static File getImageFile​(String shape)

      Looks for an image file with an appropriate name in the shapes directory.
      Returns:
        A File object if a file has been found, or null otherwise

    - #### listSAllExperimentPlans

          public static String[] listSAllExperimentPlans()
                                                  throws IOException

      List all existing experiment plans (based on the directory names in the appropriate tree)
      Throws:
        `IOException`

    - #### listSAllExperimentPlansHtml

          public static String listSAllExperimentPlansHtml()
                                                    throws IOException

      Creates an HTML snippet (to be used inside a FORM) listing all currently existing experiment plans.
      Throws:
        `IOException`