edu.stanford.db.rdf.schema
Class RDFSchemaModel

java.lang.Object
  |
  +--edu.stanford.db.rdf.schema.RDFSchemaModel
All Implemented Interfaces:
Model, RDFNode, Resource, VirtualModel

public class RDFSchemaModel
extends java.lang.Object
implements VirtualModel

RDF schema model supports subclassing and validates RDF schemas.


Constructor Summary
RDFSchemaModel()
           
RDFSchemaModel(Model instances, Model closure)
          Creates a schema model, closure must contain transitive closures of subClassOf and subPropertyOf
RDFSchemaModel(NodeFactory f)
           
RDFSchemaModel(NodeFactory f, Model instances, Model closure)
           
 
Method Summary
 void add(Statement t)
          Adds a new triple to the model.
static Model computeClosure(Model src, Resource property)
          Compute a transitive closure, disallow loops.
static Model computeClosure(Model src, Resource property, boolean allowLoops)
          Computes a transitive closure on a given predicate.
static Model computeRDFSClosure(Model src)
           
 boolean contains(Statement t)
          Tests if the model contains the given triple.
 Model create()
          Creates empty model of the same Class
 Model duplicate()
          Clone the model.
 java.util.Enumeration elements()
          Enumerate triples
 Model find(Resource subject, Resource predicate, RDFNode object)
          General method to search for triples.
 Model getGroundModel()
           
 java.lang.String getLabel()
          The formal string label of the node.
 java.lang.String getLocalName()
          Returns the local name of the resource.
 java.lang.String getNamespace()
          Returns the namespace of the resource.
 NodeFactory getNodeFactory()
          Returns the node factory for this model
 java.lang.String getSourceURI()
          Returns current base URI setting.
 java.lang.String getURI()
          Returns the URI of the resource.
 boolean isEmpty()
          true if the model contains no triples
 boolean isMutable()
          True if the model supports add() and remove() methods.
static void main(java.lang.String[] args)
           
static void readModelsFromArgList(RDFFactory f, Model m, Model rawSchema, java.lang.String[] args)
           
 void remove(Statement t)
          Removes the triple from the model.
 void setSourceURI(java.lang.String uri)
          Set a base URI for the model.
 int size()
          Number of triples in the model
 java.lang.String toString()
           
static void validate(Model instances, Model schema)
          Validates the model.
static void validateRawSchema(Model rawInstances, Model rawSchema)
          Validates rawInstances model agains schema in rawSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RDFSchemaModel

public RDFSchemaModel()

RDFSchemaModel

public RDFSchemaModel(Model instances,
                      Model closure)
Creates a schema model, closure must contain transitive closures of subClassOf and subPropertyOf

RDFSchemaModel

public RDFSchemaModel(NodeFactory f)

RDFSchemaModel

public RDFSchemaModel(NodeFactory f,
                      Model instances,
                      Model closure)
Method Detail

getLabel

public java.lang.String getLabel()
                          throws ModelException
Description copied from interface: RDFNode
The formal string label of the node. URI in case of a resource, string in case of a literal.
Specified by:
getLabel in interface RDFNode

getURI

public java.lang.String getURI()
                        throws ModelException
Description copied from interface: Resource
Returns the URI of the resource. Triples and models must implement this method in a standard way.
Specified by:
getURI in interface Resource
Following copied from interface: org.w3c.rdf.model.Resource
Returns:
the URI of the resource
See Also:
Statement, Model

getLocalName

public java.lang.String getLocalName()
                              throws ModelException
Description copied from interface: Resource
Returns the local name of the resource. May not return null.
Specified by:
getLocalName in interface Resource
Following copied from interface: org.w3c.rdf.model.Resource
Returns:
the local name of the resource
See Also:
Statement, Model

getNamespace

public java.lang.String getNamespace()
                              throws ModelException
Description copied from interface: Resource
Returns the namespace of the resource. May return null.
Specified by:
getNamespace in interface Resource
Following copied from interface: org.w3c.rdf.model.Resource
Returns:
the namespace of the resource
See Also:
Statement, Model

getGroundModel

public Model getGroundModel()
                     throws ModelException
Specified by:
getGroundModel in interface VirtualModel
Returns:
model contains the fact basis of this model

setSourceURI

public void setSourceURI(java.lang.String uri)
                  throws ModelException
Set a base URI for the model. Affects creating of new resources and serialization syntax. Inherited method getURI returns the URI set in this method
Specified by:
setSourceURI in interface Model

getSourceURI

public java.lang.String getSourceURI()
                              throws ModelException
Returns current base URI setting.
Specified by:
getSourceURI in interface Model

size

public int size()
         throws ModelException
Number of triples in the model
Specified by:
size in interface Model
Returns:
number of triples, -1 if unknown

isEmpty

public boolean isEmpty()
                throws ModelException
true if the model contains no triples
Specified by:
isEmpty in interface Model

elements

public java.util.Enumeration elements()
                               throws ModelException
Enumerate triples
Specified by:
elements in interface Model

contains

public boolean contains(Statement t)
                 throws ModelException
Tests if the model contains the given triple.
Specified by:
contains in interface Model
Returns:
true if the triple belongs to the model; false otherwise.

add

public void add(Statement t)
         throws ModelException
Adds a new triple to the model.
Specified by:
add in interface Model

remove

public void remove(Statement t)
            throws ModelException
Removes the triple from the model.
Specified by:
remove in interface Model

find

public Model find(Resource subject,
                  Resource predicate,
                  RDFNode object)
           throws ModelException
General method to search for triples. null input for any parameter will match anything.

Example: Model result = m.find( null, RDF.type, new ResourceImpl("http://...#MyClass") )

finds all instances of the class MyClass

Specified by:
find in interface Model

duplicate

public Model duplicate()
                throws ModelException
Clone the model.
Specified by:
duplicate in interface Model

create

public Model create()
             throws ModelException
Creates empty model of the same Class
Specified by:
create in interface Model

isMutable

public boolean isMutable()
                  throws ModelException
Description copied from interface: Model
True if the model supports add() and remove() methods. A model may change behavior of this function over time.
Specified by:
isMutable in interface Model

getNodeFactory

public NodeFactory getNodeFactory()
                           throws ModelException
Returns the node factory for this model
Specified by:
getNodeFactory in interface Model

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

computeRDFSClosure

public static Model computeRDFSClosure(Model src)
                                throws ModelException

computeClosure

public static Model computeClosure(Model src,
                                   Resource property)
                            throws ModelException
Compute a transitive closure, disallow loops.

computeClosure

public static Model computeClosure(Model src,
                                   Resource property,
                                   boolean allowLoops)
                            throws ModelException
Computes a transitive closure on a given predicate. If allowLoops is set to false, an exception is thrown if a loop is encountered.

validateRawSchema

public static void validateRawSchema(Model rawInstances,
                                     Model rawSchema)
                              throws ModelException
Validates rawInstances model agains schema in rawSchema

validate

public static void validate(Model instances,
                            Model schema)
                     throws ModelException
Validates the model. schema should be RDFSchemaModel

readModelsFromArgList

public static void readModelsFromArgList(RDFFactory f,
                                         Model m,
                                         Model rawSchema,
                                         java.lang.String[] args)
                                  throws java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception