I am working on a project that uses ontology to launch algorithm. In other words, the parameters/return value of an algorithm are retrieved from a semantic database so that they can be launched using SPARQL queries.
Let's say I want to get the result of such an algorithm after its execution, which has a specific type, but I have to store it in a very generic way. I would do Object result = myAlgorithm(param1, param2, ...);
. This does not allow me to store the type of the result for later casting though. I am thinking of a solution, but I am not sure how legitimate it is in Java:
public class Value {
Object o;
Class<?> type;
public Value(Object o, Class<?> type) {
this.o = o;
this.type = type;
}
Class<?> getType() { return type; }
Object getO() { return o; }
}
The return type of the algorithm is also stored in the database. I know this sounds a bit convoluted, but I hope you understand what I want to do.
Aucun commentaire:
Enregistrer un commentaire