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 aUDTValue
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 Summary
Fields Modifier and Type Field Description static long
serialVersionUID
Generated ID for serialisation.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default UDTValue
clone()
Clones thisUDTValue
in case it isCloneable
, otherwise aCloneNotSupportedException
will be thrown (which is what this default implementation does).default void
close()
default byte[]
getBytes()
Gets the value as a byte array of this user-defined data type.default String
getContentString()
Gets the content of thisUDTValue
as plain UTF-8-encoded string.default InputStream
getInputStream()
Gets the value as anInputStream
of this user-defined data type.default Long
getSize()
Gets the size of this UDT value if it is known.default long
getSize(long def)
Gets the size of this UDT value if it is known, the designated default value if it is unknown.String
getUserDefinedType()
Gets the name (a string) of the user-defined type of this value.byte[]
getValueAsArray()
Deprecated, for removal: This API element is subject to removal in a future version.Use and implementgetBytes()
instead.InputStream
getValueAsStream()
Deprecated, for removal: This API element is subject to removal in a future version.Use and implementgetInputStream()
instead.default Boolean
isEmpty()
Gets whether this UDT value is empty (somewhat similar tonull
).
-
-
-
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 implementgetInputStream()
instead.Gets the value as anInputStream
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 anInputStream
of this user-defined data type.
You have to close the stream after usage. Usually you should notclose()
thisUDTValue
before all created input streams have been consumed. Implementations may deviate so that closing theUDTValue
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 correspondingInputStream
, anIOException
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 implementgetBytes()
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, anIOException
will be thrown.
-
getContentString
default String getContentString() throws IOException
Gets the content of thisUDTValue
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, anIOException
will be thrown.
-
isEmpty
default Boolean isEmpty()
Gets whether this UDT value is empty (somewhat similar tonull
). 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 andnull
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 andnull
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 thisUDTValue
in case it isCloneable
, otherwise aCloneNotSupportedException
will be thrown (which is what this default implementation does). Subclasses should provide a corresponding implementation and also extendCloneable
. 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, aCloneNotSupportedException
will be thrown. This must not be thrown if (the subclass of) the instance is cloneable.
-
close
default void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-