Interface UDTValue
-
- All Superinterfaces:
AutoCloseable,Closeable,Serializable
- All Known Implementing Classes:
ADEPT2UDTValue,FileUDTValue,JsonUdtValue,PlaceholderValue.PlaceholderUdtValue
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 aUDTValueneeds 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
ADEPT2UDTValueinstead!- See Also:
Blob
-
-
Field Summary
Fields Modifier and Type Field Description static longserialVersionUIDGenerated ID for serialisation.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default UDTValueclone()Clones thisUDTValuein case it isCloneable, otherwise aCloneNotSupportedExceptionwill be thrown (which is what this default implementation does).default voidclose()default byte[]getBytes()Gets the value as a byte array of this user-defined data type.default StringgetContentString()Gets the content of thisUDTValueas plain UTF-8-encoded string.default InputStreamgetInputStream()Gets the value as anInputStreamof this user-defined data type.default LonggetSize()Gets the size of this UDT value if it is known.default longgetSize(long def)Gets the size of this UDT value if it is known, the designated default value if it is unknown.StringgetUserDefinedType()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.InputStreamgetValueAsStream()Deprecated, for removal: This API element is subject to removal in a future version.Use and implementgetInputStream()instead.default BooleanisEmpty()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 anInputStreamof 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 anInputStreamof this user-defined data type.
You have to close the stream after usage. Usually you should notclose()thisUDTValuebefore all created input streams have been consumed. Implementations may deviate so that closing theUDTValuedoes 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, anIOExceptionwill 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 IOExceptionGets 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, anIOExceptionwill be thrown.
-
getContentString
default String getContentString() throws IOException
Gets the content of thisUDTValueas plain UTF-8-encoded string.- Returns:
- The content of this
UDTValueas plain UTF-8-encoded string. - Throws:
IOException- If there are problems creating or reading from the content input stream, anIOExceptionwill 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 andnullwill be returned.- Returns:
- Whether this UDT value has no content (and the content is known),
nullif 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 andnullwill be returned.- Returns:
- The size of the content of this UDT value,
nullif 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 thisUDTValuein case it isCloneable, otherwise aCloneNotSupportedExceptionwill 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
UDTValueinstance. - Throws:
CloneNotSupportedException- If the instance (is of a subclass that) is not cloneable, aCloneNotSupportedExceptionwill be thrown. This must not be thrown if (the subclass of) the instance is cloneable.
-
close
default void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-