Class JsonUdtValue

java.lang.Object
de.aristaflow.adept2.model.datamanagement.ADEPT2UDTValue
de.aristaflow.adept2.model.datamanagement.JsonUdtValue
All Implemented Interfaces:
UDTValue, TypedCloneable<ADEPT2UDTValue>, Closeable, Serializable, AutoCloseable, Cloneable

public class JsonUdtValue extends ADEPT2UDTValue
A User Defined Type for JSON data.
See Also:
  • Field Details

  • Constructor Details

    • JsonUdtValue

      @Deprecated(since="15.0.0", forRemoval=true) public JsonUdtValue(org.json.JSONObject json)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • JsonUdtValue

      public JsonUdtValue(org.json.JSONObject json, boolean... dummy) throws IOException
      Creates a new UDTValue for the designated JSONObject.
      Parameters:
      json - The JSONObject for which to create a UDTValue.
      dummy - Ignored, just distinguishes from the deprecated constructor.
      Throws:
      IOException - If there are problems creating the input stream or reading from it, an IOException will be thrown.
    • JsonUdtValue

      @Deprecated(since="15.0.0", forRemoval=true) public JsonUdtValue(byte[] value)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • JsonUdtValue

      public JsonUdtValue(String jsonString) throws IOException
      Creates a new UDTValue for the designated string. This should represent a valid JSONObject.
      Parameters:
      jsonString - The string representing a JSONObject for which to create a UDTValue.
      Throws:
      IOException - If there are problems creating the input stream or reading from it, an IOException will be thrown.
    • JsonUdtValue

      @Deprecated(since="15.0.0", forRemoval=true) public JsonUdtValue(InputStream stream, boolean eager)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • JsonUdtValue

      @Deprecated(since="15.0.0", forRemoval=true) public JsonUdtValue(InputStream stream, int length)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use JsonUdtValue(InputStream, boolean[]) with a BoundedInputStream instead.
    • JsonUdtValue

      @Deprecated(since="15.0.0", forRemoval=true) public JsonUdtValue(InputStream stream)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • JsonUdtValue

      public JsonUdtValue(InputStream stream, boolean... dummy) throws IOException
      Creates a new UDTValue for the designated input stream containing a UTF-8 encoded string representing a JSONObject.
      Parameters:
      stream - The input stream containing the UTF-8 encoded string representation of a JSONObject for which to create a UDTValue. The stream will be closed after the creation.
      dummy - Ignored, just distinguishes from the deprecated constructor.
      Throws:
      IOException - If there are problems creating the data structures for the content, an IOException will be thrown.
  • Method Details

    • toUtf8Bytes

      @Deprecated(since="15.0.0", forRemoval=true) public static byte[] toUtf8Bytes(org.json.JSONObject json)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts the given JSONObject to a UTF-8 encoded byte array.
      Parameters:
      json - The JSON object to be converted.
      Returns:
      The byte array.
    • toUtf8InputStream

      public static InputStream toUtf8InputStream(org.json.JSONObject json) throws IOException
      Gets an input stream containing the UTF-8 string representing the designated JSONObject.
      Parameters:
      json - The JSONObject for which to get an input stream.
      Returns:
      An input stream containing the UTF-8 string representing the designated JSONObject.
      Throws:
      IOException - If there are problems creating the input stream, an IOException will be thrown.
    • getValueAsJsonObject

      @Deprecated(since="15.0.0", forRemoval=true) public org.json.JSONObject getValueAsJsonObject()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getJsonObject() instead.
      Returns the current value as JSON object or null if there is no data.
      Returns:
      The UDT value as JSON object or null if there is no data.
    • getJsonObject

      public org.json.JSONObject getJsonObject() throws IOException
      Gets the current value as JSONObject or null if there is no data.
      Returns:
      The UDT value as JSONObject or null if there is no data.
      Throws:
      IOException - If there are problems reading the content of the designated UDTValue, an IOException will be thrown.
      See Also:
    • fromUDTValue

      @Deprecated(since="15.0.0", forRemoval=true) public static org.json.JSONObject fromUDTValue(UDTValue udt)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the JSON object from the given UDT or null if there is no data.
      Returns:
      The JSON object or null if there is no data.
    • fromUdtValue

      public static org.json.JSONObject fromUdtValue(UDTValue udt) throws IOException
      Gets the JSONObject from the designated UDT or null if there is no data. The designated UDTValue has to contain a valid JSON object (as UTF-8 encoded string).
      Parameters:
      udt - The UDTValue containing a UTF-8 encoded string representing a JSONObject. The caller is responsible for closing.
      Returns:
      The JSONObject or null if there is no data.
      Throws:
      IOException - If there are problems reading the content of the designated UDTValue, an IOException will be thrown.
      IllegalArgumentException - If the designated UDTValue has the wrong type, an IllegalArgumentException will be thrown.
    • fromByteArray

      public static org.json.JSONObject fromByteArray(byte[] bytes)
      Returns the JSON object from the given byte array or null if there is no data.
      Returns:
      The JSON object or null if there is no data.
    • rawTextFromUDTValue

      @Deprecated(since="15.0.0", forRemoval=true) public static String rawTextFromUDTValue(UDTValue udtValue)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Reads the JSON from the UDTValue as a raw string.
      Parameters:
      udtValue - the JSON UDT value
      Returns:
      the JSON as a raw string
    • getJsonString

      public static String getJsonString(UDTValue udtValue) throws IOException
      Gets the string content of the designated UDTValue.
      Parameters:
      udtValue - The UDTValue from which to get the content as string. The caller is responsible for closing.
      Returns:
      The string content of the designated UDTValue.
      Throws:
      IOException - If there are problems reading the content of the designated UDTValue, an IOException will be thrown.
      IllegalArgumentException - If the designated UDTValue has the wrong type, an IllegalArgumentException will be thrown.
    • udtValueFromRawText

      @Deprecated(since="15.0.0", forRemoval=true) public static UDTValue udtValueFromRawText(String jsonText)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns an UDTValue from the raw JSON string.
      Parameters:
      jsonText - the raw JSON text
      Returns:
      an UDTValue containing the JSON