public interface DataType extends Serializable
The java type may be a Collection, in which case implementations should provide
additional information about the item type.
This also provides constants for some commonly used DataTypes.
| Modifier and Type | Field and Description |
|---|---|
static DataType |
ATOM_STRING |
static DataType |
BOOLEAN |
static DataType |
BYTE_ARRAY |
static DataType |
CURSOR_ITERATOR_PROVIDER |
static DataType |
CURSOR_STREAM_PROVIDER |
static DataType |
HTML_STRING |
static DataType |
INPUT_STREAM |
static DataType |
ITERATOR |
static DataType |
JSON_STRING |
static DataType |
MULE_MESSAGE |
static CollectionDataType |
MULE_MESSAGE_COLLECTION |
static CollectionDataType |
MULE_MESSAGE_LIST |
static MapDataType |
MULE_MESSAGE_MAP |
static DataType |
NUMBER |
static DataType |
OBJECT |
static DataType |
RSS_STRING |
static DataType |
STRING |
static DataType |
TEXT_STRING |
static DataType |
XML_STRING |
| Modifier and Type | Method and Description |
|---|---|
static DataTypeBuilder |
builder()
Provides a builder to create
DataType objects. |
static DataTypeBuilder |
builder(DataType dataType)
|
static DataType |
fromFunction(ExpressionFunction function)
Shortcut to create the
DataType from an ExpressionFunction instance. |
static DataType |
fromObject(Object value)
Shortcut to create the
DataType from an Object instance. |
static DataType |
fromType(Class<?> type)
Shortcut to create a
DataType using just a Java type. |
MediaType |
getMediaType()
The mime type of the the source object to transform.
|
Class<?> |
getType()
The object type of the source object to transform.
|
boolean |
isCompatibleWith(DataType dataType)
Used to determine if this data type is compatible with the data type passed in.
|
boolean |
isStreamType()
Used to determine if this DataType is a stream type.
|
static final DataType TEXT_STRING
static final DataType XML_STRING
static final DataType JSON_STRING
static final DataType HTML_STRING
static final DataType ATOM_STRING
static final DataType RSS_STRING
static final DataType STRING
static final DataType NUMBER
static final DataType BOOLEAN
static final DataType OBJECT
static final DataType BYTE_ARRAY
static final DataType INPUT_STREAM
static final DataType ITERATOR
static final DataType CURSOR_STREAM_PROVIDER
static final DataType CURSOR_ITERATOR_PROVIDER
static final DataType MULE_MESSAGE
static final CollectionDataType MULE_MESSAGE_COLLECTION
static final CollectionDataType MULE_MESSAGE_LIST
static final MapDataType MULE_MESSAGE_MAP
static DataTypeBuilder builder()
DataType objects.DataTypeBuilder.static DataTypeBuilder builder(DataType dataType)
dataType - existing DataType to use as a template to create a new DataTypeBuilder instance.DataTypeBuilder based on the template dataType provided.static DataType fromType(Class<?> type)
DataType using just a Java type. Default values will be used for mimeType
and encoding.type - the Java type to create DataType for.DataTypeBuilder for the given type.static DataType fromObject(Object value)
DataType from an Object instance.
This behaves in the same way as fromType(Class) creating a DataType based on
the value type with default values being used for mimeType and encoding if
the Object type has no mimeType or encoding. The DataTypeBuilder used by default may
introspect certain types that do contain type this meta-data such as
DataHandler and DataSource and populate
mimeType and encoding values based on this.
static DataType fromFunction(ExpressionFunction function)
DataType from an ExpressionFunction instance.
This behaves in the same way as fromObject(Object) but automatically populates the returnType and
parameters based on the function.
Class<?> getType()
MediaType getMediaType()
boolean isCompatibleWith(DataType dataType)
This method is NOT symmetric. That is, a.isCompatibleWith(b) and b.isCompatibleWith(a) may
yield different result.
dataType - the dataType object to compare withboolean isStreamType()
InputStream or Iterable, cannot be serialized without prior transformation or consumed twice and often their
size, depending on the specific type, is unknown until they have been fully consumed.true if the type is a stream type otherwise falseCopyright © 2017 MuleSoft, Inc.. All rights reserved.