Package org.incenp.linkml.core
Class CurieConverter
- java.lang.Object
-
- org.incenp.linkml.core.ScalarConverterBase
-
- org.incenp.linkml.core.StringConverter
-
- org.incenp.linkml.core.CurieConverter
-
- All Implemented Interfaces:
IConverter
public class CurieConverter extends StringConverter
A converter for String-typed fields whose value is expected to be a CURIE.This is especially intended for slots of type
uriOrCurie. The converter will automatically expand the CURIE upon deserialising the data, so that after parsing we no longer need to worry about the presence of CURIEs anywhere – there will only be full-length IRIs. Conversely, when serialising the data the converter will take care of compacting the IRIs back into CURIE form.This is basically a generalisation of the approach previously used specifically for SSSOM-Java: expand CURIEs as soon as possible upon receiving data, contract them as late as possible upon writing data. In between, you only need to deal with full-length IRIs. This is the only sane way of working with CURIEs.
-
-
Constructor Summary
Constructors Constructor Description CurieConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectconvertImpl(Object raw, ConverterContext ctx)Performs the actual type conversion.Objectserialise(Object object, ConverterContext ctx)Converts a LinkML object into a raw object.-
Methods inherited from class org.incenp.linkml.core.StringConverter
getType
-
Methods inherited from class org.incenp.linkml.core.ScalarConverterBase
convert, convertForSlot, serialiseForSlot, toList
-
-
-
-
Method Detail
-
convertImpl
protected Object convertImpl(Object raw, ConverterContext ctx) throws LinkMLRuntimeException
Description copied from class:ScalarConverterBasePerforms the actual type conversion.- Overrides:
convertImplin classStringConverter- Parameters:
raw- The raw object to convert. This is guaranteed to be a non-null, non-list, non-dictionary object.- Returns:
- The converted value.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value.
-
serialise
public Object serialise(Object object, ConverterContext ctx) throws LinkMLRuntimeException
Description copied from interface:IConverterConverts a LinkML object into a raw object.- Specified by:
serialisein interfaceIConverter- Overrides:
serialisein classScalarConverterBase- 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.
-
-