Interface RdfType
- All Known Implementing Classes:
RdfClass,RdfTypeBase,RdfTypeCollection,RdfTypeCollectionBase,RdfTypeComplexBase,RdfTypeIriStr,RdfTypeLiteralTyped,RdfTypeMap,RdfTypeNode,RdfTypePrimitiveBase,RdfTypeSeq
public interface RdfType
Base class for operations for mapping java objects of *a specific* class to and from sets of triples.
- fetch data from a remote store
- instanciate a corresponding java class (can be a proxy implementing appropriate interfaces)
- set properties on the instance
- a shape object that identifies the sub graph relevant for initializing properties
- a function that sets properties on an object from that sub graph
- a function that converts the state of an object to RDF in regard to this class
- Author:
- raven
-
Method Summary
Modifier and TypeMethodDescriptioncreateJavaObject(org.apache.jena.rdf.model.RDFNode r) Extract a Java (literal) object from a given node.voidexposeFragment(ResourceFragment out, org.apache.jena.rdf.model.Resource priorState, Object entity) voidClass<?>Return the Java class corresponding to this type (maybe it should be Type instead of Class)org.apache.jena.graph.NodegetRootNode(Object obj) Return the root node that corresponds to the given object in regard to this RdfType.booleanFlag to indicate whether entities created from this mapping have their own identity.booleanA simple type is a type that does not need to emit any triples, i.e.Populates an entity from a resource RDF graph that should match the exposed shape.
-
Method Details
-
getEntityClass
Class<?> getEntityClass()Return the Java class corresponding to this type (maybe it should be Type instead of Class)- Returns:
-
getRootNode
Return the root node that corresponds to the given object in regard to this RdfType. In the case of classes, this is an IRI node, whereas for literals this is either a plain or typed literal node. Note, that the following condition is expected to hold: getRootNode(createJavaObject(node)).equals(node) For types mapping to plain literals, this method should (must?) never return null. Note that certain Java types may not have capabilities assigned for returning a node for a given object. In this case, the result will be null.- Parameters:
obj-- Returns:
-
hasIdentity
boolean hasIdentity()Flag to indicate whether entities created from this mapping have their own identity. If not, ids are usually derived from the parent object- Returns:
-
createJavaObject
Extract a Java (literal) object from a given node. Note: Creating a *non-primitive* java object is not a concern of RdfType which only *MAPS* between a java object and its corresponding triples. The reason is, that via the RdfType's entity class the association to a newInstance method can be indirectly made on the outside, without RdfType having to be aware of it. Also, an RdfType reading a collection may be capable of reading and writing to any collection type, regardless of the concrete sub-type (list, set, etc). Create an empty java object (i.e. no properties set) based on the given node. In the case of primitive types (e.g. String, Long, etc), the object will already carry the correct value. In the case of classes, the result may either be a Java object regardless of the node argument, or a proxy to such java object that holds the node- Parameters:
node-- Returns:
-
isSimpleType
boolean isSimpleType()A simple type is a type that does not need to emit any triples, i.e. a simple type can de/serialize java objects to and from Node objects.- Returns:
-
exposeShape
-
exposeFragment
void exposeFragment(ResourceFragment out, org.apache.jena.rdf.model.Resource priorState, Object entity) - Parameters:
out-priorState-entity-
-
populate
Populates an entity from a resource RDF graph that should match the exposed shape.- Parameters:
inout-shape-entity-
-
resolve
-