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 org.apache.jena.rdf.model.ModelcreateJenaModel(Object[] objects)static <R extends IResource>
RfollowLink(org.apache.jena.rdf.model.Model m, Link l, Class<R> rClass)Extracts a resource from the Jena model pointed to by a Link.static Object[]fromJenaModel(org.apache.jena.rdf.model.Model model, Class<?> beanClass)Deprecated.static ObjectfromJenaResource(org.apache.jena.rdf.model.Resource resource, Class<?> beanClass)Deprecated.protected static voidhandleExtendedProperties(Class<?> resourceClass, org.apache.jena.rdf.model.Model model, org.apache.jena.rdf.model.Resource mainResource, IExtendedResource extendedResource, Map<String,Object> properties, Map<IExtendedResource,org.apache.jena.rdf.model.Resource> visitedResources)static voidskolemize(org.apache.jena.rdf.model.Model m)Skolemize all blank node by replacing them with equivalent resources with an ephemeral URI of form 'urn:skolem:%blankNodeId%''static voidskolemize(org.apache.jena.rdf.model.Model m, Function<org.apache.jena.graph.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(org.apache.jena.rdf.model.Model model, Class<T> clazz)Wrapper aroundfromJenaModel(Model, Class)to provide generics support and group exceptions.static <T> Tunmarshal(org.apache.jena.rdf.model.Resource resource, Class<T> clazz)Wrapper aroundfromJenaResource(Resource, Class)to provide generics support and group exceptions.static <T> TunmarshalSingle(org.apache.jena.rdf.model.Model model, Class<T> clazz)Wrapper aroundunmarshal(Model, Class)to unmarshal a single resource instance.
-
-
-
Method Detail
-
createJenaModel
public static org.apache.jena.rdf.model.Model createJenaModel(Object[] objects) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, OslcCoreApplicationException
-
unmarshalSingle
public static <T> T unmarshalSingle(org.apache.jena.rdf.model.Model model, Class<T> clazz) throws IllegalArgumentException, LyoModelExceptionWrapper 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(org.apache.jena.rdf.model.Resource resource, Class<T> clazz) throws LyoModelExceptionWrapper 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(org.apache.jena.rdf.model.Resource resource, Class<?> beanClass) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InstantiationException, InvocationTargetException, OslcCoreApplicationException, URISyntaxException, SecurityException, NoSuchMethodException
Deprecated.
-
unmarshal
public static <T> T[] unmarshal(org.apache.jena.rdf.model.Model model, Class<T> clazz) throws LyoModelExceptionWrapper 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(org.apache.jena.rdf.model.Model model, Class<?> beanClass) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InstantiationException, InvocationTargetException, OslcCoreApplicationException, URISyntaxException, SecurityException, NoSuchMethodException
Deprecated.
-
followLink
public static <R extends IResource> R followLink(org.apache.jena.rdf.model.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(org.apache.jena.rdf.model.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(org.apache.jena.rdf.model.Model m, Function<org.apache.jena.graph.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, org.apache.jena.rdf.model.Model model, org.apache.jena.rdf.model.Resource mainResource, IExtendedResource extendedResource, Map<String,Object> properties, Map<IExtendedResource,org.apache.jena.rdf.model.Resource> visitedResources) throws DatatypeConfigurationException, IllegalAccessException, InvocationTargetException, OslcCoreApplicationException
-
-