Package org.incenp.linkml.core
Interface IConverter
-
- All Known Implementing Classes:
BooleanConverter,ClassDefinitionConverter,CurieConverter,DateConverter,DatetimeConverter,DoubleConverter,EnumConverter,FloatConverter,IntegerConverter,ObjectConverter,ScalarConverterBase,StringConverter,TimeConverter,URIConverter
public interface IConverterAn object that can convert a “raw object” (as obtained from a JSON/YAML parser) into a LinkML object, and the other way round.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Objectconvert(Object raw, ConverterContext ctx)Converts a raw object into a LinkML object.voidconvertForSlot(Object raw, Object dest, Slot slot, ConverterContext ctx)Converts a raw object into a LinkML object and assigns the result to a slot of another object.Class<?>getType()Gets the type of object that this converter can convert a raw object into.Objectserialise(Object object, ConverterContext ctx)Converts a LinkML object into a raw object.ObjectserialiseForSlot(Object object, Slot slot, ConverterContext ctx)Converts a LinkML object into a raw object, when the object is the value of a specific LinkML slot.
-
-
-
Method Detail
-
getType
Class<?> getType()
Gets the type of object that this converter can convert a raw object into.
-
convert
Object convert(Object raw, ConverterContext ctx) throws LinkMLRuntimeException
Converts a raw object into a LinkML object.- Parameters:
raw- The raw object to convert.ctx- The global converter context.- Returns:
- The converted object.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value.
-
convertForSlot
void convertForSlot(Object raw, Object dest, Slot slot, ConverterContext ctx) throws LinkMLRuntimeException
Converts a raw object into a LinkML object and assigns the result to a slot of another object.- Parameters:
raw- The raw object to convert.dest- The object that should received the converted value.slot- The slot of thedestobject to which the converted value should be assigned.ctx- The global converter context.- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value, or cannot assign it to the target object/slot.
-
serialise
Object serialise(Object object, ConverterContext ctx) throws LinkMLRuntimeException
Converts a LinkML object into a raw object.- Parameters:
object- The LinkML object to convert.ctx- The global converter context.- Returns:
- The raw object that represents the original LinkML object.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given object.
-
serialiseForSlot
Object serialiseForSlot(Object object, Slot slot, ConverterContext ctx) throws LinkMLRuntimeException
Converts a LinkML object into a raw object, when the object is the value of a specific LinkML slot.We need such a method because the way to serialise a LinkML object into a raw object will sometimes depend on the slot to which the object belongs (the slot of which it is a value), especially with respect to inlining.
- Parameters:
object- The LinkML object to convert.slot- The slot that the given object is a value of.ctx- The global converter context.- Returns:
- The raw object that represents the original LinkML object.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given object.
-
-