Class JenaModelHelper
- java.lang.Object
-
- org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper
-
public final class JenaModelHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Model
createJenaModel(Object[] objects)
static <R extends IResource>
RfollowLink(Model m, Link l, Class<R> rClass)
Extracts a resource from the Jena model pointed to by a Link.static Object[]
fromJenaModel(Model model, Class<?> beanClass)
Deprecated.Useunmarshal(Model, Class)
instead.static Object
fromJenaResource(Resource resource, Class<?> beanClass)
Deprecated.Useunmarshal(Resource, Class)
orunmarshalSingle(Model, Class)
instead.protected static void
handleExtendedProperties(Class<?> resourceClass, Model model, Resource mainResource, IExtendedResource extendedResource, Map<String,Object> properties, Map<IExtendedResource,Resource> visitedResources)
static void
skolemize(Model m)
Skolemize all blank node by replacing them with equivalent resources with an ephemeral URI of form 'urn:skolem:%blankNodeId%''static void
skolemize(Model m, Function<BlankNodeId,String> skolemUriFunction)
Skolemize all blank node by replacing them with equivalent resources with a URI generated by the supplied lambda function.static <T> T[]
unmarshal(Model model, Class<T> clazz)
Wrapper aroundfromJenaModel(Model, Class)
to provide generics support and group exceptions.static <T> T
unmarshal(Resource resource, Class<T> clazz)
Wrapper aroundfromJenaResource(Resource, Class)
to provide generics support and group exceptions.static <T> T
unmarshalSingle(Model model, Class<T> clazz)
Wrapper aroundunmarshal(Model, Class)
to unmarshal a single resource instance.
-
-
-
Method Detail
-
createJenaModel
public static Model createJenaModel(Object[] objects) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, OslcCoreApplicationException
-
unmarshalSingle
public static <T> T unmarshalSingle(Model model, Class<T> clazz) throws IllegalArgumentException, LyoModelException
Wrapper aroundunmarshal(Model, Class)
to unmarshal a single resource instance.- Throws:
IllegalArgumentException
- if anything but 1 resource was unmarshaled exactly.LyoModelException
-
unmarshal
public static <T> T unmarshal(Resource resource, Class<T> clazz) throws LyoModelException
Wrapper aroundfromJenaResource(Resource, Class)
to provide generics support and group exceptions.- Type Parameters:
T
- Same resource class/interface to make the method generic- Parameters:
resource
- Jena resource to be unmarshalledclazz
- Lyo resource class/interface instance to assist reflection- Returns:
- an unmarshalled resource class instance
- Throws:
LyoModelException
- if the model cannot be unmarshalled into instances of the provided class
-
fromJenaResource
@Deprecated public static Object fromJenaResource(Resource resource, Class<?> beanClass) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InstantiationException, InvocationTargetException, OslcCoreApplicationException, URISyntaxException, SecurityException, NoSuchMethodException
Deprecated.Useunmarshal(Resource, Class)
orunmarshalSingle(Model, Class)
instead.
-
unmarshal
public static <T> T[] unmarshal(Model model, Class<T> clazz) throws LyoModelException
Wrapper aroundfromJenaModel(Model, Class)
to provide generics support and group exceptions.- Type Parameters:
T
- Same resource class to make the method generic- Parameters:
model
- Jena model with RDF resources to be unmarshalledclazz
- Lyo resource class instance to assist reflection- Returns:
- an array of unmarshalled resource class instances
- Throws:
LyoModelException
- if the model cannot be unmarshalled into instances of the provided class
-
fromJenaModel
@Deprecated public static Object[] fromJenaModel(Model model, Class<?> beanClass) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InstantiationException, InvocationTargetException, OslcCoreApplicationException, URISyntaxException, SecurityException, NoSuchMethodException
Deprecated.Useunmarshal(Model, Class)
instead.
-
followLink
public static <R extends IResource> R followLink(Model m, Link l, Class<R> rClass) throws IllegalArgumentException, LyoModelException
Extracts a resource from the Jena model pointed to by a Link.Useful in case of following links of a just unmarshaled resource using
unmarshal(Model, Class)
orunmarshalSingle(Model, Class)
.- Type Parameters:
R
- Same class argument to make method generic- Parameters:
m
- Jena modell
- Link that points to resouce inside the modelrClass
- Lyo resource class to unmarshall the OSLC resource into.- Returns:
- An instance of a resource class
- Throws:
IllegalArgumentException
- if the link does not point a resource in the model.LyoModelException
-
skolemize
public static void skolemize(Model m)
Skolemize all blank node by replacing them with equivalent resources with an ephemeral URI of form 'urn:skolem:%blankNodeId%''- Parameters:
m
- Jena model to skolemize
-
skolemize
public static void skolemize(Model m, Function<BlankNodeId,String> skolemUriFunction)
Skolemize all blank node by replacing them with equivalent resources with a URI generated by the supplied lambda function.See RDF 1.1 // Replacing Blank Nodes with IRIs for further guidance.
- Parameters:
m
- Jena model to skolemizeskolemUriFunction
- Lambda function that returns ("mints") a resource URI for a BNode.
-
handleExtendedProperties
protected static void handleExtendedProperties(Class<?> resourceClass, Model model, Resource mainResource, IExtendedResource extendedResource, Map<String,Object> properties, Map<IExtendedResource,Resource> visitedResources) throws DatatypeConfigurationException, IllegalAccessException, InvocationTargetException, OslcCoreApplicationException
-
-