Interface UDTValue
- All Superinterfaces:
AutoCloseable,Closeable,Serializable
- All Known Implementing Classes:
ADEPT2UDTValue,FileUDTValue,JsonUdtValue,PlaceholderValue.PlaceholderUdtValue
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longGenerated ID for serialisation. -
Method Summary
Modifier and TypeMethodDescriptiondefault 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 StringGets the content of thisUDTValueas plain UTF-8-encoded string.default InputStreamGets 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.Gets the name (a string) of the user-defined type of this value.byte[]Deprecated, for removal: This API element is subject to removal in a future version.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 Details
-
serialVersionUID
static final long serialVersionUIDGenerated ID for serialisation.- See Also:
-
-
Method Details
-
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, 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
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, 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
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, anIOExceptionwill be thrown.
-
getContentString
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
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
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:
-
clone
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
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getBytes()instead.