Class JsonFile

java.lang.Object
org.japprove.files.JsonFile

public class JsonFile
extends java.lang.Object
JsonFile is a wrapper around TextFile that provides functionality to read and write data of JsonFiles.
  • Constructor Summary

    Constructors 
    Constructor Description
    JsonFile​(java.lang.String path)  
  • Method Summary

    Modifier and Type Method Description
    void create()
    Checks if the File already exists and creates a new one if not.
    boolean exists()
    Returns true if this file exists.
    java.lang.String getName()
    Returns the name of the corresponding TextFile.
    com.fasterxml.jackson.databind.JsonNode readData()
    Reads the data of the JsonFile and returns a JsonNode.
    void writeData​(com.fasterxml.jackson.databind.JsonNode data)
    Stores a JsonNode in the JsonFile.

    Methods inherited from class java.lang.Object

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

    • JsonFile

      public JsonFile​(java.lang.String path)
  • Method Details

    • writeData

      public void writeData​(com.fasterxml.jackson.databind.JsonNode data) throws java.io.FileNotFoundException, com.fasterxml.jackson.core.JsonProcessingException
      Stores a JsonNode in the JsonFile.
      Parameters:
      data - the JsonNode that should be stored
      Throws:
      java.io.FileNotFoundException - thrown if the file not exists
      com.fasterxml.jackson.core.JsonProcessingException - thrown if an error with the json object occurs
    • readData

      public com.fasterxml.jackson.databind.JsonNode readData()
      Reads the data of the JsonFile and returns a JsonNode.
      Returns:
      the content of the JsonFile in a JsonNode
    • create

      public void create() throws FileCreationFailedException
      Checks if the File already exists and creates a new one if not.
      Throws:
      FileCreationFailedException - thrown if the file cannot be created
    • getName

      public java.lang.String getName()
      Returns the name of the corresponding TextFile.
      Returns:
      the name of the corresponding TextFile.
    • exists

      public boolean exists()
      Returns true if this file exists.
      Returns:
      true if this file exists.