Class ExtendedQALDJSONLoader

java.lang.Object
org.aksw.qa.commons.load.json.ExtendedQALDJSONLoader

public final class ExtendedQALDJSONLoader extends Object
Basic json load and store class using jackson.
  • Field Details

    • LOGGER

      private static org.slf4j.Logger LOGGER
  • Constructor Details

    • ExtendedQALDJSONLoader

      private ExtendedQALDJSONLoader()
      Make this class non instatiable.
  • Method Details

    • writeJson

      public static void writeJson(Object o, File f, boolean overwrite) throws IOException
      Loads and saves Settings into and from json files /** Writes the given Object as JSON to location specified in File. If File already exists and overwrite ==false, AttemptedOverwriteException will be thrown
      Parameters:
      o - The object you want to write.
      f - The File (-location) to save it in.
      overwrite - Set this true to overwrite existing file.
      Throws:
      IOException
    • writeJson

      public static byte[] writeJson(Object json) throws com.fasterxml.jackson.core.JsonProcessingException
      Writes the json to an byte array
      Parameters:
      json -
      Returns:
      the given json as byte representation
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • readJson

      public static Object readJson(byte[] inputJson, Class<?> type) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Parses Json file and returns an Object containing the results. You need to cast the return of this class to the class specified in type.
      Parameters:
      inputJson - the json to parse
      type - The class type you want to read.
      Returns:
      An Object you should cast.
      Throws:
      IOException
      com.fasterxml.jackson.databind.JsonMappingException
      com.fasterxml.jackson.core.JsonParseException
    • readJson

      public static Object readJson(InputStream in, Class<?> type) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Parses Json file and returns an Object containing the results. You need to cast the return of this class to the class specified in type.
      Parameters:
      f - The file location you want to read from.
      type - The class type you want to read.
      Returns:
      An Object you should cast.
      Throws:
      IOException
      com.fasterxml.jackson.databind.JsonMappingException
      com.fasterxml.jackson.core.JsonParseException
    • readJson

      public static Object readJson(InputStream in) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Throws:
      com.fasterxml.jackson.core.JsonParseException
      com.fasterxml.jackson.databind.JsonMappingException
      IOException
    • readJson

      public static Object readJson(File f) throws FileNotFoundException, IOException
      Throws:
      FileNotFoundException
      IOException
    • readJson

      public static Object readJson(File f, Class<?> type) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, FileNotFoundException, IOException
      Throws:
      com.fasterxml.jackson.core.JsonParseException
      com.fasterxml.jackson.databind.JsonMappingException
      FileNotFoundException
      IOException