-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConverterCacheService.java
More file actions
105 lines (94 loc) · 3 KB
/
ConverterCacheService.java
File metadata and controls
105 lines (94 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package org.knime.scijava.commands.converter;
import java.util.Collection;
import java.util.Optional;
import org.knime.core.data.DataCell;
import org.knime.core.data.DataType;
import org.knime.core.data.DataValue;
import org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory;
import org.knime.core.data.convert.java.DataCellToJavaConverterFactory;
import org.knime.core.node.ExecutionContext;
import org.scijava.service.Service;
/**
* KNIME Converter Cache Service.
*
* Interface for services which are able to convert KNIME data cells into java
* types vice versa.
*
* @author Gabriel Einsdorf (University of Konstanz)
*/
// FIXME NAMING (KNIPConverterCache?!)
// FIXME CACHING (isn't implemented everywhere, yet)
// FIXME can we always delegate to Jonathans implementations?
public interface ConverterCacheService extends Service {
/**
* Convert a KNIME cell to the fitting java type.
*
* @param <O>
* the output Type
* @param cell
* the KNIME cell
* @param outputType
* the desired output type
* @return The converted object
* @throws Exception
* When the conversion fails
*/
<O> O convertToJava(DataCell cell, Class<O> outputType) throws Exception;
/**
* Convert a java object to the fitting KNIME cell.
*
* @param in
* The object to be converted
* @param inType
* the type of the object
* @return A DataCell with the converted value
* @throws Exception
* When the conversion fails
*/
DataCell convertToKnime(Object in, Class<?> inType, DataType type,
ExecutionContext es) throws Exception;
/**
* Flush all caches.
*/
void flushCaches();
/**
* Gets the converted type.
*
* @param type
* the type
* @return the converted type
*/
Optional<DataType> getConvertedType(Class<?> type);
/**
* Gets the matching input value class.
*
* @param type
* the type
* @return the matching input value class
*/
Optional<Class<DataValue>> getMatchingInputValueClass(Class<?> type);
/**
* Gets the matching java type for a given data value.
*
* @param dataType
* the preferred value class
* @return the matching java type
*/
Optional<Class<?>> getMatchingJavaType(DataType dataType);
/**
* Get all converter factories which are able to convert given
* {@link DataType} to a java type.
*
* @return Collection of converter factories
*/
Collection<DataCellToJavaConverterFactory<?, ?>> getMatchingJavaTypes(
ClassLoader loader, DataType dataType);
/**
* Get all converter factories which are able to convert given java type to
* a {@link DataType}.
*
* @return Collection of converter factories
*/
Collection<JavaToDataCellConverterFactory<?>> getMatchingFactories(
Class<?> javaType);
}