Class InstanceParser

java.lang.Object
com.github.perdia.queries.parsing.InstanceParser

public class InstanceParser extends Object
Class for parsing instance queries in JSON format from the database to Instance objects
  • Constructor Details

    • InstanceParser

      public InstanceParser(byte[] bytes)
      Constructor in which the byte array turns in to a JSON array which then gets processed further
      Parameters:
      bytes - Byte array containing the single characters of the JSON objects to be parsed encoded in UTF-8
  • Method Details

    • parseSingle

      public Instance parseSingle()
      Parses the first JSON object present in the JSON array to an Instance object
      Returns:
      The parsed Instance object
    • parseSingle

      public Instance parseSingle(int index)
      Parses the JSON object at the given index in the JSON array to an Instance object
      Parameters:
      index - The index of the JSON object to be parsed
      Returns:
      The parsed Instance object
    • parseMultiple

      public ArrayList<Instance> parseMultiple()
      Parses all the JSON objects in the JSON array to Instance objects in an ArrayList
      Returns:
      ArrayList containing all the parsed Instance objects
    • instanceAmount

      public int instanceAmount()
      Returns the amount of JSON objects in the JSON array
      Returns:
      Amount of JSON objects in the JSON array
    • toString

      public String toString()
      Returns the JSON array as a String (with indentation)
      Overrides:
      toString in class Object
      Returns:
      JSON array as a String