|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.java.rdf.sommer.Mapping
net.java.rdf.sommer.SesameMapper
public class SesameMapper
Nested Class Summary | |
---|---|
(package private) class |
SesameMapper.FilterFieldsSerialiser
filter for fields that have given annotations Note: this is used by findFromCifpConstructor (perhaps the class should be inernal to the method) also: this should be more subtle: if fields are private and in a superclass, then should we find a solution? |
(package private) class |
SesameMapper.IdFinderSerialiser
Tries to find the Identity of an object by looking for identiy or inverse functional properties. |
(package private) class |
SesameMapper.MappingSerialiser
take an unmapped object and add all its relations to the graph |
class |
SesameMapper.QueryByExampleSerialiser
|
static class |
SesameMapper.SesameInit
|
Nested classes/interfaces inherited from interface net.java.rdf.sommer.Mapper |
---|
Mapper.Init |
Field Summary | |
---|---|
(package private) org.openrdf.model.Resource[] |
graphs
|
private boolean |
inference
|
(package private) SesameMapper.SesameInit |
init
|
(package private) java.util.HashMap<java.lang.Class,JavaInstanceMapper> |
literalMap
|
(package private) static java.util.logging.Logger |
log
|
private java.util.WeakHashMap<java.lang.Object,org.openrdf.model.Resource> |
obj2Resource
A mapping from objects to resources is one to one. |
(package private) org.openrdf.repository.RepositoryConnection |
rep
|
private java.util.WeakHashMap<org.openrdf.model.Resource,java.util.List<java.lang.Object>> |
resource2Obj
A mapping from resources to objects is one to many. |
private static java.util.TimeZone |
TZ
|
(package private) java.util.Date |
updateTime
|
org.openrdf.model.ValueFactory |
vf
|
(package private) org.openrdf.model.Resource |
writeGrphs
|
(package private) static javax.xml.datatype.DatatypeFactory |
xmldf
|
Fields inherited from class net.java.rdf.sommer.Mapping |
---|
classmap |
Constructor Summary | |
---|---|
SesameMapper(SesameMapper.SesameInit init,
java.lang.String... urls)
Constructs a repository tied to a graph |
Method Summary | ||
---|---|---|
(package private) void |
addContext(java.lang.String context)
add a context to the list of 'read only contexts' |
|
(package private) void |
addJavaInstance(JavaInstanceMapper map)
|
|
|
addObject(T object)
Insert the object and all its dependent objects into the graph |
|
boolean |
addObjects(java.lang.Object... objects)
Insert all objects |
|
boolean |
addRelation(org.openrdf.model.Resource source,
org.openrdf.model.URI relation,
boolean inverse,
java.lang.Object obj)
|
|
private void |
addStatement(Statement s)
|
|
void |
addStatements(java.util.Collection<Statement> statements)
Add the following statements to the writeable graph. |
|
void |
cifpName(java.lang.Object thiz,
java.lang.Class clazz,
java.lang.Class[] argTypes,
java.lang.Object[] values)
Set the name for thiz to an existing one if one exists. |
|
|
cifpObject(java.lang.Class<T> clazz,
java.lang.Class[] argTypes,
java.lang.Object[] values)
Check to see if we don't allready have an object that corresponds to this cifp |
|
boolean |
clear()
note this clear here only clears what was written to the graph. |
|
java.lang.Object |
createLiteral(java.lang.String s)
|
|
java.lang.Object |
createLiteral(java.lang.String s,
java.lang.String lang)
|
|
java.lang.Object |
createLiteralType(java.lang.String s,
java.lang.String uriType)
|
|
|
createObjectWithId(java.lang.String uri,
java.lang.Class<T> clazz)
Create an object of type with a given uri |
|
java.lang.Object |
createResource(java.lang.String uri)
|
|
|
createVirtualCollection(java.lang.Object thiz,
rdf relation,
java.util.Collection<T> oldFieldValue,
java.lang.reflect.Type fieldType)
get the value of a virtual collection field. |
|
static java.lang.String |
dateToXsdString(java.util.Date date)
|
|
void |
enableInferencing(boolean on)
|
|
boolean |
equals(java.lang.Object mapped1,
java.lang.Object mapped2)
Equality of mapped objects. |
|
private org.openrdf.model.Resource |
findFromCifpConstructor(java.lang.reflect.Constructor con,
java.lang.Object obj)
|
|
(package private) org.openrdf.model.Value |
findKnownMappedValueFor(java.lang.Object obj)
Just find the Value of the object if it is known or a literal |
|
(package private) org.openrdf.model.Value |
findKnownMappedValueFor(java.lang.Object obj,
java.lang.String literalType)
Find a known mapped value of the object, whith the given type |
|
|
getAllObjectsOfType(java.lang.Class<T> clazz)
|
|
private org.openrdf.model.Resource |
getCIFPValue(java.lang.Class clazz,
java.lang.Class[] argTypes,
java.lang.Object[] values)
Find the object, if one exists that has the relations given by the rdf annotations on the arguments of the constructor clazz, to the values. |
|
java.util.List<java.lang.Class> |
getClassesOf(java.lang.String uri)
find the classes of the object with id uri |
|
|
getCollection(org.openrdf.model.Resource subj,
org.openrdf.model.URI relationUri,
boolean inverse,
java.lang.Class<E> clazz)
Get the collection starting with subj and the given relation, with contents of type clazz |
|
|
getCollectionField(java.lang.Object thiz,
rdf relation,
java.util.Collection<T> oldFieldValue,
java.lang.reflect.Type fieldType)
get the value of a collection field. |
|
java.lang.Object |
getField(java.lang.Class fieldClass,
java.lang.Object sourceObj,
rdf relation,
java.lang.Object fieldVal)
Get the value of a field |
|
|
getObjectById(java.lang.String uri,
java.lang.Class<T> clazz)
Fetch an object of type with a given uri. |
|
private java.util.ArrayList<java.lang.String> |
getTypesOf(org.openrdf.model.Resource res)
Get all the known types of resources res. |
|
(package private) org.openrdf.model.Resource |
getWriteGraphs()
|
|
java.lang.String |
graphId()
|
|
void |
importFrom(java.io.Reader r,
java.lang.String baseUri,
java.lang.String mimeType)
|
|
void |
importInto(java.io.Reader r,
java.lang.String baseUri,
java.lang.String mimeType,
java.lang.String context)
import graph serialisation into the given context. |
|
private void |
initInstanceMapper()
|
|
boolean |
isDirty(java.util.Date update)
|
|
boolean |
isInferencingEnabled()
|
|
boolean |
isMapped(java.lang.Object o)
note: We should be able to ask the object directly now that it implements SommerMapable except of course that we are adding this directly |
|
org.openrdf.model.Value |
map(java.lang.Object obj)
Map the java object to a RDF Value. |
|
org.openrdf.model.Value |
map(java.lang.Object obj,
java.lang.String literalType)
Map the java object to a RDF Value. |
|
private
|
map(org.openrdf.model.Value value,
java.lang.Class<T> sprClzz)
map the resource into an object of the given class |
|
void |
name(java.lang.Object obj,
org.openrdf.model.Resource id)
remember the name of the object |
|
void |
output(java.io.OutputStream out)
Output the contents of this graph todo: add type of output (N3,rdf/xml) |
|
void |
output(java.io.Writer out)
Output the contents of this graph todo: add type of output (N3,rdf/xml) |
|
|
queryByExample(java.lang.Object eg,
java.lang.Class<T> clazz)
Query the map by giving an example object, and return all objects that fit the example. |
|
boolean |
remove(java.lang.Object obj)
remove all statements concerning the resource this object is mapped to. |
|
void |
removeAll(org.openrdf.model.Resource source,
org.openrdf.model.URI relation,
boolean inverse)
|
|
boolean |
removeRelation(org.openrdf.model.Resource source,
org.openrdf.model.URI relation,
boolean inverse,
java.lang.Object obj)
|
|
private void |
removeStatement(Statement s)
|
|
void |
removeStatements(java.util.Collection<Statement> statements)
remove the following statements from the graphs. |
|
org.openrdf.repository.RepositoryConnection |
rep()
todo: It should be possible to set different repositories for different Maps. |
|
|
replaceVirtualCollection(java.lang.Object thiz,
rdf relation,
java.util.Collection<T> oldColl,
java.util.Collection<T> newColl,
java.lang.reflect.Type genType)
Replace the elements in the collection with the new elements. |
|
(package private)
|
resourceGet(org.openrdf.model.Resource name,
java.lang.Class<T> clazz)
look in our map for an object with rdf name and the most precise subclass |
|
(package private) void |
setChanged()
|
|
|
setCollectionField(java.lang.Object sourceObj,
rdf relation,
java.util.Collection<T> newColl,
java.lang.reflect.Type type)
Set a Collection on a given field. |
|
java.lang.Object |
setField(java.lang.Class fieldClass,
java.lang.Object obj,
rdf relation,
java.lang.Object value)
Set a given field |
|
long |
size()
The Size in triples of the graph, mapped to. |
|
void |
smush()
Smush this graph. |
|
boolean |
unmap(java.lang.Object obj)
This will remove the object from the map, but the relations will remain in the database. |
Methods inherited from class net.java.rdf.sommer.Mapping |
---|
cogitate, mostSpecificSubClass, preload |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static transient java.util.logging.Logger log
public transient org.openrdf.model.ValueFactory vf
transient org.openrdf.repository.RepositoryConnection rep
org.openrdf.model.Resource[] graphs
static javax.xml.datatype.DatatypeFactory xmldf
private static final java.util.TimeZone TZ
private boolean inference
SesameMapper.SesameInit init
org.openrdf.model.Resource writeGrphs
private java.util.WeakHashMap<java.lang.Object,org.openrdf.model.Resource> obj2Resource
private java.util.WeakHashMap<org.openrdf.model.Resource,java.util.List<java.lang.Object>> resource2Obj
java.util.Date updateTime
java.util.HashMap<java.lang.Class,JavaInstanceMapper> literalMap
Constructor Detail |
---|
SesameMapper(SesameMapper.SesameInit init, java.lang.String... urls)
init
- Initialisation behaviorurls
- the name of the graph or null for the default graphMethod Detail |
---|
org.openrdf.model.Resource getWriteGraphs()
void addContext(java.lang.String context)
context
- public boolean isDirty(java.util.Date update)
void setChanged()
public org.openrdf.repository.RepositoryConnection rep()
public void importFrom(java.io.Reader r, java.lang.String baseUri, java.lang.String mimeType) throws java.io.IOException, GraphUpdateException, ParseException
r
- a Reader on the rdfbaseUri
- the base to resolve relative uri frommimeType
- of the rdf serialisation: rdfxml, n3, turtle, ntriples, ...
java.io.IOException
GraphUpdateException
ParseException
public void importInto(java.io.Reader r, java.lang.String baseUri, java.lang.String mimeType, java.lang.String context) throws java.io.IOException, GraphUpdateException, ParseException
Mapper
r
- the reader containing the serialisation of the graphbaseUri
- the base uri to xxx relative urismimeType
- format of the serialisation ( currently the mime type)context
- the context to drop the information into
java.io.IOException
GraphUpdateException
ParseException
public boolean clear()
public <T> RDFCollection<T> replaceVirtualCollection(java.lang.Object thiz, rdf relation, java.util.Collection<T> oldColl, java.util.Collection<T> newColl, java.lang.reflect.Type genType)
RewriteMapper
thiz
- the object on which the field is attachedrelation
- the annotation on the fieldoldColl
- the old collection that the field was set tonewColl
- the new collection the it should be replaced bygenType
- the type of the objects in the collection
public <T> java.util.Collection<T> setCollectionField(java.lang.Object sourceObj, rdf relation, java.util.Collection<T> newColl, java.lang.reflect.Type type)
RewriteMapper
relation
- rdf annotation on the field
public <T> RDFCollection<T> createVirtualCollection(java.lang.Object thiz, rdf relation, java.util.Collection<T> oldFieldValue, java.lang.reflect.Type fieldType)
RewriteMapper
thiz
- the object on which the field is attachedrelation
- annotation on this fieldoldFieldValue
- the old value of the field - the one currently referred tofieldType
- Gernics type info of the Collection
public <T> java.util.Collection<T> getCollectionField(java.lang.Object thiz, rdf relation, java.util.Collection<T> oldFieldValue, java.lang.reflect.Type fieldType)
RewriteMapper
relation
- annotation on this fieldoldFieldValue
- the old value of the field - the one currently referred tofieldType
- the generic type of the collection
public java.lang.Object setField(java.lang.Class fieldClass, java.lang.Object obj, rdf relation, java.lang.Object value)
RewriteMapper
fieldClass
- The class of the field being setobj
- The object on which the field is attachedrelation
- The rdf annotation on the fieldvalue
- the value that the field should be set to
public java.lang.Object getField(java.lang.Class fieldClass, java.lang.Object sourceObj, rdf relation, java.lang.Object fieldVal)
RewriteMapper
fieldClass
- the class of the fieldsourceObj
- the object on which the field is locatedrelation
- the rdf annotation on the fieldfieldVal
- the current value of the field
public void name(java.lang.Object obj, org.openrdf.model.Resource id)
obj
- id
- public void cifpName(java.lang.Object thiz, java.lang.Class clazz, java.lang.Class[] argTypes, java.lang.Object[] values)
RewriteMapper
thiz
- the object to be namedclazz
- the class of the constructorargTypes
- the argument types identifying the particular constructorvalues
- the valuespublic <T> T cifpObject(java.lang.Class<T> clazz, java.lang.Class[] argTypes, java.lang.Object[] values)
RewriteMapper
clazz
- the class on which the constructor is being calledargTypes
- the types of the arguments of the constructor, to help find the constructor
private org.openrdf.model.Resource getCIFPValue(java.lang.Class clazz, java.lang.Class[] argTypes, java.lang.Object[] values)
clazz
- the class of the constructorargTypes
- the argument types identifying the particular constructorvalues
- the values that may have allready have a mapping in the rdf graph
void addJavaInstance(JavaInstanceMapper map)
private void initInstanceMapper()
org.openrdf.model.Value findKnownMappedValueFor(java.lang.Object obj)
obj
-
org.openrdf.model.Value findKnownMappedValueFor(java.lang.Object obj, java.lang.String literalType)
obj
- the object we are looking a mapping forliteralType
- the type of the literal
public static java.lang.String dateToXsdString(java.util.Date date)
public org.openrdf.model.Value map(java.lang.Object obj, java.lang.String literalType)
obj
- literalType
- the type the object should be mapped to, or "" if not a literal
public org.openrdf.model.Value map(java.lang.Object obj)
obj
-
private org.openrdf.model.Resource findFromCifpConstructor(java.lang.reflect.Constructor con, java.lang.Object obj)
public void smush()
private <T> T map(org.openrdf.model.Value value, java.lang.Class<T> sprClzz)
value
- sprClzz
- the class or super class of any object returned
private java.util.ArrayList<java.lang.String> getTypesOf(org.openrdf.model.Resource res)
res
-
<T> T resourceGet(org.openrdf.model.Resource name, java.lang.Class<T> clazz)
name
- the rdfclazz
- the supertype of the object to be returned
public boolean removeRelation(org.openrdf.model.Resource source, org.openrdf.model.URI relation, boolean inverse, java.lang.Object obj)
public boolean addRelation(org.openrdf.model.Resource source, org.openrdf.model.URI relation, boolean inverse, java.lang.Object obj)
source
- relation
- obj
- public void removeAll(org.openrdf.model.Resource source, org.openrdf.model.URI relation, boolean inverse)
public <E> java.util.ArrayList<E> getCollection(org.openrdf.model.Resource subj, org.openrdf.model.URI relationUri, boolean inverse, java.lang.Class<E> clazz)
subj
- the name of the object from which to gorelationUri
- the relation from subjinverse
- if the inverse of the relationURi is desiredclazz
- the class to return (could be a subclass if this is warranted by the database)
public boolean isMapped(java.lang.Object o)
Mapper
public <T> T getObjectById(java.lang.String uri, java.lang.Class<T> clazz)
Mapper
uri
- the id of the objectclazz
- the type of the object looked for
public <T> T createObjectWithId(java.lang.String uri, java.lang.Class<T> clazz)
Mapper
uri
- the id of the objectclazz
- the type of the object looked for
public <T> java.util.Collection<T> getAllObjectsOfType(java.lang.Class<T> clazz)
public <T> T addObject(T object)
Mapper
object
- the object whose relations should be added to the graph
public boolean addObjects(java.lang.Object... objects)
Mapper
public void addStatements(java.util.Collection<Statement> statements)
Mapper
private void addStatement(Statement s)
public void removeStatements(java.util.Collection<Statement> statements)
Mapper
private void removeStatement(Statement s)
public boolean remove(java.lang.Object obj)
Mapper
public boolean unmap(java.lang.Object obj)
Mapper
public void output(java.io.OutputStream out)
Mapper
public void output(java.io.Writer out)
Mapper
public java.lang.String graphId()
public boolean equals(java.lang.Object mapped1, java.lang.Object mapped2)
Mapper
mapped1
- a mapped objectmapped2
- another mapped objects
public <T> java.util.Collection<T> queryByExample(java.lang.Object eg, java.lang.Class<T> clazz)
Mapper
eg
- example object. Should not be a mapped object
or an object with a id specified by @rdf URI id since otherwise the only object returneable would be
the one given. The object can have fields that are set either to mapped or unmapped objects.clazz
- of objects to return (should this not just be the same as the class of o?
public java.lang.Object createLiteral(java.lang.String s)
public java.lang.Object createLiteral(java.lang.String s, java.lang.String lang)
public java.lang.Object createLiteralType(java.lang.String s, java.lang.String uriType)
public java.lang.Object createResource(java.lang.String uri)
public long size()
Mapper
public java.util.List<java.lang.Class> getClassesOf(java.lang.String uri)
Mapper
uri
- the id of the object looked for
public void enableInferencing(boolean on)
public boolean isInferencingEnabled()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |