Class JsonDeserializer

java.lang.Object
cz.metacentrum.perun.rpclib.api.Deserializer
cz.metacentrum.perun.rpclib.impl.JsonDeserializer

public class JsonDeserializer extends Deserializer
Deserializer that reads values from JSON content.
Since:
0.1
Author:
Jan Klos <ddd@mail.muni.cz>
  • Constructor Details

    • JsonDeserializer

      public JsonDeserializer(InputStream in) throws IOException
      Parameters:
      in - InputStream to read JSON data from
      Throws:
      IOException - if an IO error occurs
      RpcException - if content of in is wrongly formatted
  • Method Details

    • contains

      public boolean contains(String name)
      Description copied from class: Deserializer
      Returns true if value with the specified name is supplied.
      Specified by:
      contains in class Deserializer
      Parameters:
      name - name of the value to check
      Returns:
      true if value with the specified name is supplied, false otherwise
    • read

      public <T> T read(String name, Class<T> valueType)
      Description copied from class: Deserializer
      Reads value with the specified name as valueType.
      Overrides:
      read in class Deserializer
      Parameters:
      name - name of the value to read
      valueType - type of the value to read
      Returns:
      the value as valueType
    • read

      public <T> T read(Class<T> valueType)
      Description copied from class: Deserializer
      Reads value as valueType.
      Overrides:
      read in class Deserializer
      Parameters:
      valueType - type of the value to read
      Returns:
      the value as valueType
    • readArrayOfInts

      public int[] readArrayOfInts(String name)
      Overrides:
      readArrayOfInts in class Deserializer
    • readArrayOfInts

      public int[] readArrayOfInts()
      Overrides:
      readArrayOfInts in class Deserializer
    • readInt

      public int readInt(String name)
      Description copied from class: Deserializer
      Reads value with the specified name as int.
      Specified by:
      readInt in class Deserializer
      Parameters:
      name - name of the value to read
      Returns:
      the value as int
    • readInt

      public int readInt()
      Description copied from class: Deserializer
      Reads value as int.
      Specified by:
      readInt in class Deserializer
      Returns:
      the value as int
    • readList

      public <T> List<T> readList(String name, Class<T> valueType)
      Description copied from class: Deserializer
      Reads array with the specified name as List<valueType>.
      Overrides:
      readList in class Deserializer
      Parameters:
      name - name of the array to read
      valueType - type of the value to read
      Returns:
      the value as List<valueType>
    • readList

      public <T> List<T> readList(Class<T> valueType)
      Description copied from class: Deserializer
      Reads an array List<valueType>.
      Overrides:
      readList in class Deserializer
      Parameters:
      valueType - type of the value to read
      Returns:
      the value as List<valueType>
    • readString

      public String readString(String name)
      Description copied from class: Deserializer
      Reads value with the specified name as String.
      Specified by:
      readString in class Deserializer
      Parameters:
      name - name of the value to read
      Returns:
      the value as String
    • readString

      public String readString()
      Description copied from class: Deserializer
      Reads value as String.
      Specified by:
      readString in class Deserializer
      Returns:
      the value as String