Class ResourceDescriptor
GetResourceDescriptor- Since:
- 3.3.0
-
Constructor Summary
ConstructorsConstructorDescriptionResourceDescriptor(com.sodius.oslc.core.rdf.Resource resource, ResourceShape shape, ConfigContext context) Constructs an instance specifying the resource, its shape and context. -
Method Summary
Modifier and TypeMethodDescriptionGets the configuration context used by the resource.Gets or creates the resource shape of described resource.getPropertyDefinition(String name) Convenient method to resolve a property definition, on this resource descriptor, given its name.getPropertyValues(URI resource, URI definition) Same asgetPropertyValues(URI, Optional), but will only return properties whose subject directly matches the given resource.getPropertyValues(URI definition, Optional<OslcClient> client) Retrieves all the values of a given property.com.sodius.oslc.core.rdf.ResourceGets the resource.static com.sodius.oslc.core.rdf.ResourcegetResource(URI uri, com.sodius.oslc.core.rdf.Model model) Convenient method to resolve aResourcewithin aModel.getShape()Gets the resource shape.Gets the properties having a value.
-
Constructor Details
-
ResourceDescriptor
public ResourceDescriptor(com.sodius.oslc.core.rdf.Resource resource, ResourceShape shape, ConfigContext context) Constructs an instance specifying the resource, its shape and context.- Parameters:
resource- the resource.shape- the resource shape.context- the configuration context.- Throws:
NullPointerException- ifresourceorcontextarenull.
-
-
Method Details
-
getResource
public static com.sodius.oslc.core.rdf.Resource getResource(URI uri, com.sodius.oslc.core.rdf.Model model) Convenient method to resolve aResourcewithin aModel.This method assumes that the
context, if any, is included already inuri.- Parameters:
uri- the resource URI.model- the containing model.- Returns:
- the corresponding resource.
-
getResource
public com.sodius.oslc.core.rdf.Resource getResource()Gets the resource.- Returns:
- the resource.
-
getShape
Gets the resource shape.- Returns:
- the resource shape.
-
getOrCreateShape
Gets or creates the resource shape of described resource.Unlike
getShape()this method creates a shape based on the property definitions, if nooslc:instanceShapeproperty was present.- Returns:
- the actual resource shape of the resource if the
oslc:instanceShapeproperty is present, a made-up shape otherwise.
-
getConfigContext
Gets the configuration context used by the resource.- Returns:
- the configuration context used by the resource.
-
getValuedProperties
Gets the properties having a value.- Returns:
- URI property definitions mapped to the corresponding Property.
-
getPropertyValues
Retrieves all the values of a given property.If a statement object is a
Literal, the methodLiteral.getValue()is used to extract the value in its Java-equivalent type; otherwise, if the statement object is aResource, the object is converted to aURIand that is what is returned unless the parameterclientis provided. If an OSLC client is provided, the object URI is fetched looking for thedcterms:titleorrdfs:labelproperties. If they are not present in the resulting resource, or any exception is thrown when trying to fetch it, the original object URI is used. This behavior is convenient when, for example, the object of a statement refers to a enumeration resource.- Parameters:
definition- the property definition.client- optional OSLC client to resolve, if present, the referenced resource of an statement object looking for thedcterms:titleorrdfs:labelproperties. Provide this client when some enumeration types (URIs) are expected in the statement objects.- Returns:
- all the values of the given property definition.
-
getPropertyValues
Same asgetPropertyValues(URI, Optional), but will only return properties whose subject directly matches the given resource.- Parameters:
resource- the resource to look for properties.definition- the property definition.- Returns:
- all the values of the given property definition
-
getPropertyDefinition
Convenient method to resolve a property definition, on this resource descriptor, given its name.- Parameters:
name- the given name.- Returns:
- an empty
Optionalif no such property definition exists; its contained reference otherwise.
-