Interface UDTValue

  • All Superinterfaces:
    AutoCloseable, Closeable, Serializable
    All Known Implementing Classes:
    ADEPT2UDTValue, FileUDTValue, JsonUdtValue

    public interface UDTValue
    extends Serializable, Closeable
    This interface encapsulates the value of a user-defined data type (UDT). A UDT is not understood by ADEPT2. Instead, the application reading or writing a UDTValue needs to understand it. Besides, user-defined functions (UDFs) can be registered, that are able to interpret the data type and return data types understood by ADEPT2.

    Since UDTs are treated as black boxes, they are provided by InputStreams. This resembles BLOBs in database-management-systems.

    Closing allows all implementors to cleanup resources. Refer to the implementation on whether closing also affects the created input streams. To be sure try to defer closing until all input streams have been consumed appropriately before closing this UDTValue.

    To avoid serialisation problems do not implement this interface! Use ADEPT2UDTValue instead!

    See Also:
    Blob
    • Field Detail

      • serialVersionUID

        static final long serialVersionUID
        Generated ID for serialisation.
        See Also:
        Constant Field Values
    • Method Detail

      • getUserDefinedType

        String getUserDefinedType()
        Gets the name (a string) of the user-defined type of this value.
        Returns:
        The name of the user-defined data type of this value.
      • getValueAsStream

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        InputStream getValueAsStream()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use and implement getInputStream() instead.
        Gets the value as an InputStream of this user-defined data type.
        You have to close the stream after usage.
        Returns:
        The value of a (this) user-defined data type as an InputStream. The caller is responsible for closing.
      • getInputStream

        default InputStream getInputStream()
                                    throws IOException
        Gets the value as an InputStream of this user-defined data type.
        You have to close the stream after usage. Usually you should not close() this UDTValue before all created input streams have been consumed. Implementations may deviate so that closing the UDTValue does not affect the created input streams.
        Returns:
        The value of a (this) user-defined data type as an InputStream. The caller is responsible for closing.
        Throws:
        IOException - If there are problems creating a corresponding InputStream, an IOException will be thrown.
      • getValueAsArray

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        byte[] getValueAsArray()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use and implement getBytes() instead.
        Gets the value as a byte array of this user-defined data type.
        Returns:
        The value of a (this) user-defined data type as an array of bytes.
      • getBytes

        default byte[] getBytes()
                         throws IOException
        Gets the value as a byte array of this user-defined data type.
        Returns:
        The value of a (this) user-defined data type as an array of bytes.
        Throws:
        IOException - If there are problems retrieving the corresponding array, e. g the length of the data exceeds the maximum length of an array, an IOException will be thrown.
      • getContentString

        default String getContentString()
                                 throws IOException
        Gets the content of this UDTValue as plain UTF-8-encoded string.
        Returns:
        The content of this UDTValue as plain UTF-8-encoded string.
        Throws:
        IOException - If there are problems creating or reading from the content input stream, an IOException will be thrown.
      • isEmpty

        default Boolean isEmpty()
        Gets whether this UDT value is empty (somewhat similar to null). This depends on whether the content of the UDT is known or not. For instance, if the content stems from a stream and the stream is not read yet, the emptiness cannot be decided and null will be returned.
        Returns:
        Whether this UDT value has no content (and the content is known), null if the content is not known yet, for instance, it has not been read from the input stream yet.
      • getSize

        default Long getSize()
        Gets the size of this UDT value if it is known. For instance, if the content stems from a stream and the stream is not read yet, the size cannot be determined and null will be returned.
        Returns:
        The size of the content of this UDT value, null if the content is not known yet, for instance, it has not been read from the input stream yet.
      • getSize

        default long getSize​(long def)
        Gets the size of this UDT value if it is known, the designated default value if it is unknown.
        Parameters:
        def - The default value which to use in case the size of this UDT value is unknown (yet).
        Returns:
        The size of the content of this UDT value, the designated value if the content is not known yet, for instance, it has not been read from the input stream yet.
        See Also:
        getSize()
      • clone

        default UDTValue clone()
                        throws CloneNotSupportedException
        Clones this UDTValue in case it is Cloneable, otherwise a CloneNotSupportedException will be thrown (which is what this default implementation does). Subclasses should provide a corresponding implementation and also extend Cloneable. Those which do not, should forward to this default implementation.
        Returns:
        A clone of this UDTValue instance.
        Throws:
        CloneNotSupportedException - If the instance (is of a subclass that) is not cloneable, a CloneNotSupportedException will be thrown. This must not be thrown if (the subclass of) the instance is cloneable.