nesstar.rdf
Class RDFDB

java.lang.Object
  extended by nesstar.rdf.RDFDB
Direct Known Subclasses:
NetDB

public class RDFDB
extends Object

A repository for RDF objects. Objects can come from an RDF file or be created as Java objects and then loaded in the DB. They have: getType()= the mapped RDFClass getTypeID()=to the original RDF class or = null (if created as an object) Could they be mapped to an RDF class different from the original one? Possibly, if the mapping changes. Mappings: InstanceMapping: All instance of the RDF Class are mapped to instances of the Java Class - Reversible ClassMapping: All RDF classes equal to the RDFClass or subclasses of it are mapped to instances of the given Java Class ex: http://www.nesstar.org/Method -> javaClass=nesstar.rdf.NSMethod java -> RDF. Map them back to RDFS_CLASS DefaultMapping: All RDF entities not mapped otherwise are mapped to instances of the given Java Class. java -> RDF ?? Map back to the original class? The objects pointers (such as to their RDF class) cannot be resolved immediatly as the pointed objects might be declared after the current object. The class object could also not be explicitly declared (is it a problem?). It's probably acceptable that some references might be left dangling.

Created:
26 April 2002

Field Summary
static String FASTER_NS
          param
static String NESSTAR_NS
          param
static String NS_BOOLEAN
          param
static String NS_COMPLETE
          a flag to indicate that the object has been returned with all the properties known to the server
static String NS_DOMAIN
          param
static String NS_DOUBLE
          param
static String NS_FILE
          param
static String NS_FLOAT
          param
static String NS_IN
          param
static String NS_INTEGER
          param
static String NS_LABEL
          param
static String NS_METHOD
          param
static String NS_METHOD_OBJ
          param
static String NS_OBJECT
           
static String NS_OPTIONAL
          param
static String NS_OUT
          param
static String NS_PARAMETER
          param
static String NS_PATH
          param
static String NS_READONLY
          param
static String NS_STRING
          param
static String NS_VOID
          param
static String NS_ZIPPED_STRING
          param
static String RDF_BAG
          param
static String RDF_NS
          param
static String RDFS_CLASS
          param
static String RDFS_DOMAIN
          param
static String RDFS_NS
          param
static String RDFS_PROPERTY
          param
static String RDFS_RANGE
          param
static String RDFS_RESOURCE
          param
static String RDFS_SUBCLASS
          param
static String TRUE
          param
 
Constructor Summary
RDFDB()
          Constructor for the RDFDB object
 
Method Summary
 void addClassMapping(String rdfClassName, String javaClassName)
          Adds a feature to the ClassMapping attribute of the RDFDB object
 void addDefaultMapping(String javaClassName)
          Adds a feature to the DefaultMapping attribute of the RDFDB object
 void addMapping(String rdfClassName, String javaClassName)
          Adds a feature to the Mapping attribute of the RDFDB object
 void addRDFSClassMapping(String javaClassName)
          Adds a feature to the RDFSClassMapping attribute of the RDFDB object
static HashSet collectObjects(Object rootObject, Filter filter)
          returns a HashSet of Objects derived from the root object using the Filter object which describes how those objects should be derived
static String defaultWrap(String s)
          Method
 RDFDB getContext()
          Gets the context attribute of the RDFDB object
static String getLocalObjURL()
          Gets the localObjURL attribute of the RDFDB class
 URL getUniqueID()
           
 Iterator iterator()
          Returns a Vector containing all the known objects of a given class.
 Vector load(File file)
           
 Vector load(File file, String baseURI)
          Method
 void load(RDFObject obj)
          RDFObj can be created: - from an RDF entity - directly , ex: new RDFBag(db) This is called any time an RDFObject is created as part of its initialisation
 Vector load(Reader rdf)
          Method
 Vector load(String rdf)
          Method
 Vector load(String rdf, String baseURI)
          Method
 RDFObj lookup(String id)
          Resolve RDF URL to an object in this database or in the context DB
 RDFObj lookup(URL url)
          Both the IDs stored in the database and the ones being looked for can be either in numeric or symbolic form.
 void makeSureTypeIsSet(RDFObject obj)
          Method
 void markAllAsComplete()
          Mark all objects in the database as being 'complete'
static void markAllAsStale()
          Mark all objects in the all databases as being 'stale'
static void markAsStale(String serverIP)
          Mark all objects from the indicated server held in the database as being 'stale'
 String nestedToRDF(RDFObj obj)
          Method
 String nToRDF(Collection objs)
          Convert a Vector of objects to their RDF representation
 String nToRDF(Collection objs, RDFProperty prop)
          Method
 String nToRDF(Iterator objs)
          Method
 String nToRDF(Iterator objs, RDFProperty prop)
          Method
static Vector objsToStringIds(Vector objs)
          Method
 String printMappings()
          Method
 String printObjs()
          Description of the Method
 RDFObj recreate(URL url)
          Load from the net the object with the given url.
 RDFObj reload(String url)
          Load from the net the object with the given url.
 RDFObject reload(URL url)
          Load from the net the object with the given url.
 void remove(RDFObj obj)
          Remove obj from DB (if present)
 void remove(URL url)
          Remove obj from DB (if present)
 RDFObj retrieve(String url)
          If the required object is alread in the DB return it otherwise retrieve it from the network.
 RDFObj retrieve(URL url)
          If the required object is alread in the DB return it otherwise retrieve it from the network.
 RDFObj retrieveWithClassChain(URL url)
          If the required object is in the cache returns it otherwise retrieve it from the network.
 Vector search(Class cls)
           
 Vector search(Iterator objs, RDFProperty property, Object value)
           
 Vector search(RDFClass cls)
           
 Vector search(RDFClass cls, RDFProperty property, Object value)
           
 Vector search(RDFClass cls, RDFProperty property, Object value, RDFProperty select)
           
 Vector searchAllOfType(String type)
           
 Object searchOne(Class cls)
           
 RDFObject searchUniqueOfType(String type)
          Method
 void setContext(RDFDB context)
          Sets the context attribute of the RDFDB object
static void setLocalObjURL(String url)
          Sets the localObjURL attribute of the RDFDB class
 Vector stringIdsToObjs(String ids)
          Method
 Vector stringIdsToObjs(Vector ids)
          Method
 String toRDF()
          Convert full database to RDF
 String toRDF(RDFObj obj)
          Convert the object to its rdf representation
 String toRDF(RDFObj obj, RDFProperty prop, Object value)
          Convert an object and a given property to RDF
 String toRDF(RDFProperty prop, Object value)
          Method
 String toRDFCasted(RDFObj obj, RDFClass type)
          Method
 String toRDFNoWrap(RDFObj obj, RDFProperty prop, Object value)
          Convert an object and a given property to RDF
 String toRDFObj(RDFObj obj, Vector printed, boolean linked)
          Convert the object (and all its the linked objects if linked==true) to their rdf representation
 String toRDFObj(RDFObj obj, Vector printed, boolean linked, RDFClass rdftype)
          Method
 String toRDFWrapped(RDFObj obj)
          Method
 RDFObj unique(Vector r)
          Method
 String wrap(String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static final String TRUE
param

See Also:
Constant Field Values

RDF_NS

public static final String RDF_NS
param

See Also:
Constant Field Values

RDF_BAG

public static final String RDF_BAG
param

See Also:
Constant Field Values

RDFS_NS

public static final String RDFS_NS
param

See Also:
Constant Field Values

RDFS_CLASS

public static final String RDFS_CLASS
param

See Also:
Constant Field Values

RDFS_RESOURCE

public static final String RDFS_RESOURCE
param

See Also:
Constant Field Values

RDFS_PROPERTY

public static final String RDFS_PROPERTY
param

See Also:
Constant Field Values

RDFS_DOMAIN

public static final String RDFS_DOMAIN
param

See Also:
Constant Field Values

RDFS_RANGE

public static final String RDFS_RANGE
param

See Also:
Constant Field Values

RDFS_SUBCLASS

public static final String RDFS_SUBCLASS
param

See Also:
Constant Field Values

NESSTAR_NS

public static final String NESSTAR_NS
param

See Also:
Constant Field Values

FASTER_NS

public static final String FASTER_NS
param

See Also:
Constant Field Values

NS_OPTIONAL

public static final String NS_OPTIONAL
param

See Also:
Constant Field Values

NS_COMPLETE

public static final String NS_COMPLETE
a flag to indicate that the object has been returned with all the properties known to the server

See Also:
Constant Field Values

NS_READONLY

public static final String NS_READONLY
param

See Also:
Constant Field Values

NS_LABEL

public static final String NS_LABEL
param

See Also:
Constant Field Values

NS_PATH

public static final String NS_PATH
param

See Also:
Constant Field Values

NS_DOMAIN

public static final String NS_DOMAIN
param

See Also:
Constant Field Values

NS_IN

public static final String NS_IN
param

See Also:
Constant Field Values

NS_OUT

public static final String NS_OUT
param

See Also:
Constant Field Values

NS_METHOD

public static final String NS_METHOD
param

See Also:
Constant Field Values

NS_METHOD_OBJ

public static final String NS_METHOD_OBJ
param

See Also:
Constant Field Values

NS_PARAMETER

public static final String NS_PARAMETER
param

See Also:
Constant Field Values

NS_VOID

public static final String NS_VOID
param

See Also:
Constant Field Values

NS_OBJECT

public static final String NS_OBJECT
See Also:
Constant Field Values

NS_STRING

public static final String NS_STRING
param

See Also:
Constant Field Values

NS_INTEGER

public static final String NS_INTEGER
param

See Also:
Constant Field Values

NS_FLOAT

public static final String NS_FLOAT
param

See Also:
Constant Field Values

NS_DOUBLE

public static final String NS_DOUBLE
param

See Also:
Constant Field Values

NS_BOOLEAN

public static final String NS_BOOLEAN
param

See Also:
Constant Field Values

NS_ZIPPED_STRING

public static final String NS_ZIPPED_STRING
param

See Also:
Constant Field Values

NS_FILE

public static final String NS_FILE
param

See Also:
Constant Field Values
Constructor Detail

RDFDB

public RDFDB()
      throws Exception
Constructor for the RDFDB object

Throws:
Exception
Method Detail

setLocalObjURL

public static void setLocalObjURL(String url)
Sets the localObjURL attribute of the RDFDB class

Parameters:
url - The new localObjURL value

setContext

public void setContext(RDFDB context)
Sets the context attribute of the RDFDB object

Parameters:
context - The new context value

getLocalObjURL

public static String getLocalObjURL()
Gets the localObjURL attribute of the RDFDB class

Returns:
The localObjURL value

getUniqueID

public URL getUniqueID()
Returns:
a unique URL

getContext

public RDFDB getContext()
Gets the context attribute of the RDFDB object

Returns:
The context value

wrap

public String wrap(String s)
Parameters:
s -
Returns:
a full RDF document.

defaultWrap

public static String defaultWrap(String s)
Method

Parameters:
s -
Returns:

printObjs

public String printObjs()
Description of the Method


printMappings

public String printMappings()
Method

Returns:

addDefaultMapping

public void addDefaultMapping(String javaClassName)
                       throws ClassNotFoundException
Adds a feature to the DefaultMapping attribute of the RDFDB object

Parameters:
javaClassName - The feature to be added to the DefaultMapping attribute
Throws:
ClassNotFoundException

addMapping

public void addMapping(String rdfClassName,
                       String javaClassName)
                throws Exception
Adds a feature to the Mapping attribute of the RDFDB object

Parameters:
rdfClassName - The feature to be added to the Mapping attribute
javaClassName - The feature to be added to the Mapping attribute
Throws:
Exception

addRDFSClassMapping

public void addRDFSClassMapping(String javaClassName)
                         throws Exception
Adds a feature to the RDFSClassMapping attribute of the RDFDB object

Parameters:
javaClassName - The feature to be added to the RDFSClassMapping attribute
Throws:
Exception

addClassMapping

public void addClassMapping(String rdfClassName,
                            String javaClassName)
                     throws Exception
Adds a feature to the ClassMapping attribute of the RDFDB object

Parameters:
rdfClassName - The feature to be added to the ClassMapping attribute
javaClassName - The feature to be added to the ClassMapping attribute
Throws:
Exception

recreate

public RDFObj recreate(URL url)
                throws Exception
Load from the net the object with the given url. If an object with the same URL already exist in the database it's removed first.

Parameters:
url - the url of the object to recreate
Returns:
the object.
Throws:
Exception

reload

public RDFObject reload(URL url)
                 throws Exception
Load from the net the object with the given url. If the object already exist in the database it won't be recreated.

Parameters:
url - the url of the object to reload
Returns:
the object.
Throws:
Exception

reload

public RDFObj reload(String url)
              throws Exception
Load from the net the object with the given url.

Parameters:
url - the url of the object to reload
Returns:
the object.
Throws:
Exception

retrieve

public RDFObj retrieve(URL url)
                throws Exception
If the required object is alread in the DB return it otherwise retrieve it from the network.

Parameters:
url -
Returns:
Throws:
Exception

retrieve

public RDFObj retrieve(String url)
                throws Exception
If the required object is alread in the DB return it otherwise retrieve it from the network.

Parameters:
url -
Returns:
Throws:
Exception

retrieveWithClassChain

public RDFObj retrieveWithClassChain(URL url)
                              throws Exception
If the required object is in the cache returns it otherwise retrieve it from the network.
Retrieve also all the object that represents the class of the object and its methods and properties.

Parameters:
url - the url of the object to retrieve
Returns:
the retrieved object.
Throws:
Exception

load

public Vector load(Reader rdf)
            throws Exception
Method

Parameters:
rdf -
Returns:
Throws:
Exception

load

public Vector load(String rdf)
            throws Exception
Method

Parameters:
rdf -
Returns:
Throws:
Exception

load

public Vector load(String rdf,
                   String baseURI)
            throws Exception
Method

Parameters:
rdf -
baseURI -
Throws:
Exception

load

public Vector load(File file)
            throws Exception
Parameters:
file -
Throws:
Exception
Bug:
this seems to always use the default character encoding.

load

public Vector load(File file,
                   String baseURI)
            throws Exception
Method

Parameters:
file -
baseURI -
Throws:
Exception

remove

public void remove(RDFObj obj)
Remove obj from DB (if present)

Parameters:
obj - the obj to remove

remove

public void remove(URL url)
Remove obj from DB (if present)

Parameters:
url - the url of the obj to remove

load

public void load(RDFObject obj)
          throws Exception
RDFObj can be created: - from an RDF entity - directly , ex: new RDFBag(db) This is called any time an RDFObject is created as part of its initialisation

Parameters:
obj -
Throws:
Exception

makeSureTypeIsSet

public void makeSureTypeIsSet(RDFObject obj)
                       throws Exception
Method

Parameters:
obj -
Throws:
Exception

toRDFObj

public String toRDFObj(RDFObj obj,
                       Vector printed,
                       boolean linked)
                throws Exception
Convert the object (and all its the linked objects if linked==true) to their rdf representation

Parameters:
obj -
printed -
linked -
Returns:
Throws:
Exception

toRDFObj

public String toRDFObj(RDFObj obj,
                       Vector printed,
                       boolean linked,
                       RDFClass rdftype)
                throws Exception
Method

Parameters:
obj -
printed -
linked -
rdftype -
Returns:
Throws:
Exception

toRDF

public String toRDF(RDFProperty prop,
                    Object value)
             throws Exception
Method

Parameters:
prop -
value -
Returns:
Throws:
Exception

toRDF

public String toRDF(RDFObj obj,
                    RDFProperty prop,
                    Object value)
             throws Exception
Convert an object and a given property to RDF

Parameters:
obj -
prop -
value -
Returns:
Throws:
Exception

toRDF

public String toRDF(RDFObj obj)
             throws Exception
Convert the object to its rdf representation

Parameters:
obj -
Returns:
Throws:
Exception
Bug:
Hard properties are always mapped back to the default namespace

toRDFCasted

public String toRDFCasted(RDFObj obj,
                          RDFClass type)
                   throws Exception
Method

Parameters:
obj -
type -
Returns:
Throws:
Exception

toRDFWrapped

public String toRDFWrapped(RDFObj obj)
                    throws Exception
Method

Parameters:
obj -
Returns:
Throws:
Exception

nestedToRDF

public String nestedToRDF(RDFObj obj)
                   throws Exception
Method

Parameters:
obj -
Returns:
Throws:
Exception

nToRDF

public String nToRDF(Iterator objs)
              throws Exception
Method

Parameters:
objs -
Returns:
Throws:
Exception

toRDF

public String toRDF()
             throws Exception
Convert full database to RDF

Returns:
Throws:
Exception

nToRDF

public String nToRDF(Collection objs)
              throws Exception
Convert a Vector of objects to their RDF representation

Parameters:
objs -
Returns:
Throws:
Exception

nToRDF

public String nToRDF(Collection objs,
                     RDFProperty prop)
              throws Exception
Method

Parameters:
objs -
prop -
Returns:
Throws:
Exception

nToRDF

public String nToRDF(Iterator objs,
                     RDFProperty prop)
              throws Exception
Method

Parameters:
objs -
prop -
Returns:
Throws:
Exception

toRDFNoWrap

public String toRDFNoWrap(RDFObj obj,
                          RDFProperty prop,
                          Object value)
                   throws Exception
Convert an object and a given property to RDF

Parameters:
obj -
prop -
value -
Returns:
Throws:
Exception

lookup

public RDFObj lookup(String id)
              throws Exception
Resolve RDF URL to an object in this database or in the context DB

Parameters:
id -
Returns:
Throws:
Exception

lookup

public RDFObj lookup(URL url)
              throws Exception
Both the IDs stored in the database and the ones being looked for can be either in numeric or symbolic form. Assuming that the URL.equals() take care of equivalences among: every host has a single simbolic name (??) and possibly multiple IPs. The set of equivalent names can be derived as getHostName() + all getAllByName

Parameters:
url -
Returns:
Throws:
Exception

searchOne

public Object searchOne(Class cls)
                 throws Exception
Parameters:
cls -
Returns:
an object of class 'cls'
Throws:
Exception

search

public Vector search(Class cls)
              throws Exception
Parameters:
cls -
Returns:
all objects of class cls
Throws:
Exception

search

public Vector search(RDFClass cls)
              throws Exception
Parameters:
cls -
Returns:
all objects of RDFClass cls
Throws:
Exception

searchAllOfType

public Vector searchAllOfType(String type)
                       throws Exception
Parameters:
type -
Returns:
all objects of RDFClass cls
Throws:
Exception

searchUniqueOfType

public RDFObject searchUniqueOfType(String type)
                             throws Exception
Method

Parameters:
type -
Returns:
Throws:
Exception

search

public Vector search(RDFClass cls,
                     RDFProperty property,
                     Object value)
              throws Exception
Parameters:
cls -
property -
value -
Returns:
all objects of RDFClass cls and whose property property is equal to value
Throws:
Exception

search

public Vector search(Iterator objs,
                     RDFProperty property,
                     Object value)
              throws Exception
Parameters:
objs -
property -
value -
Returns:
all objects whose property property is equal to value
Throws:
Exception

unique

public RDFObj unique(Vector r)
              throws Exception
Method

Parameters:
r -
Returns:
Throws:
Exception

search

public Vector search(RDFClass cls,
                     RDFProperty property,
                     Object value,
                     RDFProperty select)
              throws Exception
Parameters:
cls -
property -
value -
select -
Returns:
all objects pointed by the select property of RDFClass cls and whose property property is equal to value
Throws:
Exception

objsToStringIds

public static Vector objsToStringIds(Vector objs)
Method

Parameters:
objs -
Returns:

stringIdsToObjs

public Vector stringIdsToObjs(Vector ids)
                       throws Exception
Method

Parameters:
ids -
Returns:
Throws:
Exception

stringIdsToObjs

public Vector stringIdsToObjs(String ids)
                       throws Exception
Method

Parameters:
ids -
Returns:
Throws:
Exception

iterator

public Iterator iterator()
Returns a Vector containing all the known objects of a given class.

Returns:
a Vector containing all the objects of the reqavailable Servers

markAllAsComplete

public void markAllAsComplete()
Mark all objects in the database as being 'complete'


markAllAsStale

public static void markAllAsStale()
Mark all objects in the all databases as being 'stale'


markAsStale

public static void markAsStale(String serverIP)
Mark all objects from the indicated server held in the database as being 'stale'

Parameters:
serverIP - the IP of the server for whom entries should be marked as stale, e.g. nesport4.essex.ac.uk
Bug:
this might mark as stale more stuff than intended (e.g. objects from other servers on the same machine)

collectObjects

public static HashSet collectObjects(Object rootObject,
                                     Filter filter)
                              throws Exception
returns a HashSet of Objects derived from the root object using the Filter object which describes how those objects should be derived

Parameters:
rootObject - the rootObject from which to derive the Set of objects
filter - the object describing how to derive sub-objects
Throws:
Exception

Nesstar SDK

Copyright©2003 NSD - All Rights Reserved